From bec5cb722440d35c2e28d81b26c0cf4e39dfdd49 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期一, 13 三月 2023 09:22:16 +0800 Subject: [PATCH] 修改bug --- UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java | 262 +++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 228 insertions(+), 34 deletions(-) diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java index 529c540..d114fa1 100644 --- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java +++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java @@ -7,12 +7,11 @@ import com.stylefeng.guns.core.support.HttpKit; import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.system.model.UserInfo; +import com.stylefeng.guns.modular.system.service.IReportLossService; import com.stylefeng.guns.modular.system.service.ISmsrecordService; import com.stylefeng.guns.modular.system.service.IUserInfoService; import com.stylefeng.guns.modular.system.service.IVerifiedService; -import com.stylefeng.guns.modular.system.util.ALiApiUtil; -import com.stylefeng.guns.modular.system.util.RedisUtil; -import com.stylefeng.guns.modular.system.util.ResultUtil; +import com.stylefeng.guns.modular.system.util.*; import com.stylefeng.guns.modular.system.warpper.LoginWarpper; import com.stylefeng.guns.modular.system.warpper.UserInfoWarpper; import com.stylefeng.guns.modular.system.warpper.UserInviteInfoWarpper; @@ -21,15 +20,17 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.io.File; +import java.util.*; /** * 用户控制器 @@ -53,7 +54,13 @@ private RedisUtil redisUtil; @Autowired - private ALiApiUtil aLiApiUtil; + private IReportLossService reportLossService; + + @Value("${spring.mail.template-path}") + private String templatePath; + + + @ResponseBody @PostMapping("/base/isEnterEmergencyContact") @@ -111,7 +118,7 @@ @ApiImplicitParam(value = "图片验证码", name = "kaptcha", required = true, dataType = "String"), @ApiImplicitParam(value = "场景类型(1=身份验证,2=登录确认,3=用户注册,4=修改密码)", name = "type", required = true, dataType = "String") }) - public ResultUtil queryCaptcha(HttpServletRequest request,String phone, Integer type,String kaptcha){ + public ResultUtil queryCaptcha(HttpServletRequest request,String phone, Integer type,String kaptcha, Integer language){ if(ToolUtil.isNotEmpty(phone)){ try { /* HttpSession session = request.getSession(); @@ -119,7 +126,7 @@ String code = redisUtil.getValue(phone+"_Code"); System.out.println("缓存中验证码为:"+code); if (ToolUtil.isEmpty(kaptcha) || !kaptcha.equalsIgnoreCase(code)) { - return ResultUtil.error("图形验证码错误"); + return ResultUtil.error(language == 1 ? "图形验证码错误" : language == 2 ? "The graphic verification code is incorrect" : "Code de vérification graphique incorrect"); } return userInfoService.queryCaptcha(phone, type); }catch (Exception e){ @@ -132,12 +139,102 @@ } + + @ResponseBody + @PostMapping("/base/queryCaptcha1") + @ApiOperation(value = "获取短信验证码", tags = {"用户端-登录"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), + @ApiImplicitParam(value = "场景类型(1=身份验证,2=登录确认,3=用户注册,4=修改密码)", name = "type", required = true, dataType = "String") + }) + public ResultUtil queryCaptcha1(String phone, Integer type){ + if(ToolUtil.isNotEmpty(phone)){ + try { + return userInfoService.queryCaptcha(phone, type); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + }else{ + return ResultUtil.paranErr(); + } + } + + + + + + @ResponseBody + @PostMapping("/base/sedEmail") + @ApiOperation(value = "获取邮箱验证码【1.0】", tags = {"用户端-登录"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "邮箱地址", name = "email", required = true, dataType = "String") + }) + public ResultUtil sedEmail(String email, Integer language, HttpServletRequest request){ + try { + Integer uid = userInfoService.getUserIdFormRedis(request); + if(ToolUtil.isEmpty(email)){ + return ResultUtil.error(language == 1 ? "邮箱不能为空" : language == 2 ? "The mailbox cannot be empty" : "L’email ne peut pas être vide"); + } + Random random = new Random(); + StringBuffer sb = new StringBuffer(); + for(int i = 0; i < 4; i++){ + sb.append((int) (random.nextDouble() * 10)); + } + String authCode = sb.toString(); + redisUtil.setStrValue(email, authCode, 5 * 60); + + UserInfo userInfo = userInfoService.selectById(uid); + String nickName = ""; + if(null != userInfo){ + nickName = userInfo.getNickName(); + } + + if(ToolUtil.isNotEmpty(email)){ + String path = templatePath + "user/mainbox.html"; + Document document = Jsoup.parse(new File(path), "UTF-8"); + if(1 == language){ + document.getElementById("english").attr("style", "display: none;"); + document.getElementById("french").attr("style", "display: none;"); + Element user_chinese = document.getElementById("user_chinese"); + user_chinese.text("您好 " + nickName + ","); + Element content_chinese = document.getElementById("content_chinese"); + content_chinese.text(authCode); + } + if(2 == language){ + document.getElementById("chinese").attr("style", "display: none;"); + document.getElementById("french").attr("style", "display: none;"); + Element user_chinese = document.getElementById("user_english"); + user_chinese.text("Hello " + nickName + ","); + Element content_chinese = document.getElementById("content_english"); + content_chinese.text(authCode); + } + if(3 == language){ + document.getElementById("chinese").attr("style", "display: none;"); + document.getElementById("english").attr("style", "display: none;"); + Element user_french = document.getElementById("user_french"); + user_french.text("Bonjour " + nickName + ","); + Element content_french = document.getElementById("content_french"); + content_french.text(authCode); + } + + EmailUtil.send(email, language == 1 ? "验证码" : language == 2 ? "Verification code" : "Code de vérification", document.html()); + } + return ResultUtil.success(); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + + + + /** * 手机验证码登录 * @param phone * @param code * @param registIp - * @param registAreaCode * @return */ @ResponseBody @@ -147,11 +244,12 @@ @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), @ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "String"), @ApiImplicitParam(value = "ip地址", name = "registIp", required = false, dataType = "String"), - @ApiImplicitParam(value = "当前定位区县行政编号", name = "registAreaCode", required = false, dataType = "String") + @ApiImplicitParam(value = "纬度", name = "lat", required = false, dataType = "double"), + @ApiImplicitParam(value = "经度", name = "lng", required = false, dataType = "double") }) - public ResultUtil<LoginWarpper> captchaLogin(String phone, String code, String registIp, String registAreaCode){ + public ResultUtil<LoginWarpper> captchaLogin(String phone, String code, String registIp, Double lat, Double lng, Integer language){ try { - return userInfoService.captchaLogin(phone, code, registIp, registAreaCode,null,null,null); + return userInfoService.captchaLogin(phone, code, registIp, lat, lng,null,null,null,language); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); @@ -176,9 +274,9 @@ @ApiImplicitParam(value = "用户类型(1=用户,2=司机)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(value = "注册类型(1=司机注册,2=用户注册)", name = "userType", required = true, dataType = "int") }) - public ResultUtil<LoginWarpper> captchaLogin_(String phone, String code, Integer uid, Integer type, Integer userType){ + public ResultUtil<LoginWarpper> captchaLogin_(String phone, String code, Integer uid, Integer type, Integer userType, Integer language){ try { - return userInfoService.captchaLogin(phone, code, uid, type, userType); + return userInfoService.captchaLogin(phone, code, uid, type, userType, language); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); @@ -202,10 +300,10 @@ @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), @ApiImplicitParam(value = "登录密码", name = "password", required = true, dataType = "String") }) - public ResultUtil<LoginWarpper> userLogin(String phone, String password){ + public ResultUtil<LoginWarpper> userLogin(String phone, String password, Integer language){ if(ToolUtil.isNotEmpty(phone) && ToolUtil.isNotEmpty(password)){ try { - return userInfoService.userLogin(phone, password); + return userInfoService.userLogin(phone, password, language); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); @@ -231,10 +329,10 @@ @ApiImplicitParam(value = "验证码", name = "code", required = true, dataType = "String"), @ApiImplicitParam(value = "新密码", name = "password", required = true, dataType = "String") }) - public ResultUtil forgetPassword(String phone, String code, String password){ + public ResultUtil forgetPassword(String phone, String code, String password, Integer language){ if(ToolUtil.isNotEmpty(phone) && ToolUtil.isNotEmpty(code) && ToolUtil.isNotEmpty(password)){ try { - return userInfoService.forgetPassword(phone, code, password); + return userInfoService.forgetPassword(phone, code, password, language); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); @@ -273,9 +371,10 @@ @ApiImplicitParam(value = "分享的用户id", name = "uid", required = false, dataType = "int"), @ApiImplicitParam(value = "性别(1=男,2=女)", name = "sex", required = false, dataType = "int") }) - public ResultUtil<LoginWarpper> wxLogin(Integer uid,String encryptedData, String iv,Integer type, String openid, String unionid, String jscode, String registIp, String registAreaCode, Integer sex, String nickName, String avatar,String loginType){ + public ResultUtil<LoginWarpper> wxLogin(Integer uid,String encryptedData, String iv,Integer type, String openid, String unionid, String jscode, String registIp, + String registAreaCode, Integer sex, String nickName, String avatar,String loginType, Integer language){ try { - return userInfoService.wxLogin(type, openid, unionid, jscode, registIp, registAreaCode, sex, nickName, avatar,loginType,encryptedData,iv,uid); + return userInfoService.wxLogin(type, openid, unionid, jscode, registIp, registAreaCode, sex, nickName, avatar,loginType,encryptedData,iv,uid,language); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); @@ -298,6 +397,31 @@ } + @ResponseBody + @PostMapping("/base/user/facebookLogin") + @ApiOperation(value = "FaceBook授权登录【1.0】", tags = {"用户端-登录"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "FaceBook用户id", name = "id", required = true, dataType = "String"), + @ApiImplicitParam(value = "FaceBook用户名称", name = "name", required = true, dataType = "String"), + @ApiImplicitParam(value = "FaceBook绑定的email", name = "email", required = false, dataType = "String"), + @ApiImplicitParam(value = "头像", name = "avatar", required = false, dataType = "String"), + @ApiImplicitParam(value = "性别(1=男,2=女)", name = "sex", required = false, dataType = "int"), + @ApiImplicitParam(value = "纬度", name = "lat", required = false, dataType = "double"), + @ApiImplicitParam(value = "经度", name = "lng", required = false, dataType = "double"), + @ApiImplicitParam(value = "分享的用户id", name = "uid", required = false, dataType = "int"), + }) + public ResultUtil facebookLogin(String id, String name, String email, Double lat, Double lng, Integer uid, Integer language){ + try { + return userInfoService.facebookLogin(id, name, email, lat, lng, uid, language); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + + + + /** * 设置电话号码 * @param phone @@ -313,13 +437,36 @@ @ApiImplicitParam(value = "验证码", name = "code", required = false, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) - public ResultUtil<LoginWarpper> bindingPhone(String phone, String code, HttpServletRequest request){ + public ResultUtil<LoginWarpper> bindingPhone(String phone, String code, Integer language, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } - return userInfoService.bindingPhone(uid, phone, code); + return userInfoService.bindingPhone(uid, phone, code, language); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + + + @ResponseBody + @PostMapping("/api/user/bindingEmail") + @ApiOperation(value = "设置邮箱地址【1.0】", tags = {"用户端-登录"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "绑定类型(1=注册账号绑定,2=个人中心绑定)", name = "type", required = true, dataType = "int"), + @ApiImplicitParam(value = "邮箱地址", name = "email", required = true, dataType = "String"), + @ApiImplicitParam(value = "验证码", name = "code", required = true, dataType = "String"), + @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResultUtil<LoginWarpper> bindingEmail(Integer type, String email, String code, Integer language, HttpServletRequest request){ + try { + Integer uid = userInfoService.getUserIdFormRedis(request); + if(null == uid){ + return ResultUtil.tokenErr(); + } + return userInfoService.bindingEmail(uid, type, email, code, language); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); @@ -334,7 +481,7 @@ */ @ResponseBody @PostMapping("/api/user/queryUserInfo") - @ApiOperation(value = "获取用户详情", tags = {"用户端-个人中心"}, notes = "") + @ApiOperation(value = "获取用户详情【1.0】", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) @@ -446,18 +593,18 @@ @PostMapping("/api/user/depositBalance") @ApiOperation(value = "余额充值", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ - @ApiImplicitParam(value = "支付方式(1=微信,2=支付宝)", name = "payType", required = true, dataType = "int"), + @ApiImplicitParam(value = "支付方式(1=线上支付)", name = "payType", required = true, dataType = "int"), @ApiImplicitParam(value = "充值金额", name = "money", required = true, dataType = "double"), @ApiImplicitParam(value = "支付端(1=用户APP端,2=司机APP端,3=用户小程序端)", name = "type", required = false, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) - public ResultUtil depositBalance(Integer payType, Double money, Integer type, HttpServletRequest request){ + public ResultUtil depositBalance(Integer payType, Double money, Integer type, Integer language, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } - return userInfoService.depositBalance(payType, money, uid, type); + return userInfoService.depositBalance(payType, "user_" + uid, money, uid, type, language); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); @@ -480,13 +627,13 @@ @ApiImplicitParam(value = "新手机号", name = "phone", required = true, dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) - public ResultUtil updatePhone(String code, String phone, HttpServletRequest request){ + public ResultUtil updatePhone(String code, String phone, Integer language, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } - return userInfoService.updatePhone(code, phone, uid); + return userInfoService.updatePhone(code, phone, uid, language); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); @@ -534,13 +681,13 @@ @ApiImplicitParam(value = "新密码", name = "password", required = true, dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) - public ResultUtil updatePassword(String password, HttpServletRequest request){ + public ResultUtil updatePassword(String password, Integer language, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } - return userInfoService.updatePass(password, uid); + return userInfoService.updatePass(password, uid, language); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); @@ -565,15 +712,18 @@ @ApiImplicitParam(value = "昵称", name = "nickname", required = false, dataType = "string"), @ApiImplicitParam(value = "性别(1=男,2=女)", name = "sex", required = false, dataType = "int"), @ApiImplicitParam(value = "生日(2020-06-15)", name = "birthday", required = false, dataType = "string"), + @ApiImplicitParam(value = "邮箱", name = "email", required = false, dataType = "string"), + @ApiImplicitParam(value = "姓氏", name = "lastName", required = false, dataType = "string"), + @ApiImplicitParam(value = "名字", name = "firstName", required = false, dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) - public ResultUtil updateInfo(String avatar, String nickname, Integer sex, Date birthday, HttpServletRequest request){ + public ResultUtil updateInfo(String avatar, String nickname, Integer sex, Date birthday, String email, String lastName, String firstName, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } - userInfoService.updateInfo(avatar, nickname, sex, birthday, uid); + userInfoService.updateInfo(avatar, nickname, sex, birthday, email, lastName, firstName, uid); return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); @@ -712,4 +862,48 @@ } } + + + @ResponseBody + @PostMapping("/api/user/editLanguage") + @ApiOperation(value = "修改多语言配置", tags = {"用户端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "1=中文,2=英文,3=法语", name = "language", required = true, dataType = "int"), + @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResultUtil editLanguage(Integer language, HttpServletRequest request){ + try { + Integer uid = userInfoService.getUserIdFormRedis(request); + if(null == uid){ + return ResultUtil.tokenErr(); + } + UserInfo userInfo = userInfoService.selectById(uid); + userInfo.setLanguage(language); + userInfoService.updateById(userInfo); + return ResultUtil.success(); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + + + @ResponseBody + @PostMapping("/base/user/addReportLoss") + @ApiOperation(value = "提交报失", tags = {"用户端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城出行,4=同城小件物流,5=跨城小件物流)", name = "orderType", required = true, dataType = "int"), + @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), + @ApiImplicitParam(value = "提交内容", name = "remark", required = true, dataType = "int"), + @ApiImplicitParam(value = "提交图片", name = "image", required = true, dataType = "int"), + }) + public ResultUtil addReportLoss(Integer orderType, Integer orderId, String remark, String image){ + try { + reportLossService.addReportLoss(orderType, orderId, remark, image); + return ResultUtil.success(); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } } -- Gitblit v1.7.1