From efd9ac5b88dfdb3c4d2e4bcc5e7a5258aa55542c Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期一, 21 四月 2025 20:29:15 +0800 Subject: [PATCH] 更换缓存连接方式 --- UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java | 68 +++++++++++++++++++++++++++++++-- 1 files changed, 63 insertions(+), 5 deletions(-) diff --git a/UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java b/UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java index 529c540..474f3bb 100644 --- a/UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java +++ b/UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java @@ -13,6 +13,7 @@ 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.qiniuyun.KodoUtil; import com.stylefeng.guns.modular.system.warpper.LoginWarpper; import com.stylefeng.guns.modular.system.warpper.UserInfoWarpper; import com.stylefeng.guns.modular.system.warpper.UserInviteInfoWarpper; @@ -23,6 +24,7 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -116,11 +118,11 @@ try { /* HttpSession session = request.getSession(); String code = (String)session.getAttribute(Constants.KAPTCHA_SESSION_KEY);*/ - String code = redisUtil.getValue(phone+"_Code"); - System.out.println("缓存中验证码为:"+code); - if (ToolUtil.isEmpty(kaptcha) || !kaptcha.equalsIgnoreCase(code)) { - return ResultUtil.error("图形验证码错误"); - } +// String code = redisUtil.getValue(phone+"_Code"); +// System.out.println("缓存中验证码为:"+code); +// if (ToolUtil.isEmpty(kaptcha) || !kaptcha.equalsIgnoreCase(code)) { +// return ResultUtil.error("图形验证码错误"); +// } return userInfoService.queryCaptcha(phone, type); }catch (Exception e){ e.printStackTrace(); @@ -130,6 +132,42 @@ return ResultUtil.paranErr(); } } + + + + /** + * 获取短信验证码 + * @param phone + * @return + */ + @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 { + /* HttpSession session = request.getSession(); + String code = (String)session.getAttribute(Constants.KAPTCHA_SESSION_KEY);*/ +// String code = redisUtil.getValue(phone+"_Code"); +// System.out.println("缓存中验证码为:"+code); +// if (ToolUtil.isEmpty(kaptcha) || !kaptcha.equalsIgnoreCase(code)) { +// return ResultUtil.error("图形验证码错误"); +// } + return userInfoService.queryCaptcha(phone, type); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + }else{ + return ResultUtil.paranErr(); + } + } + + /** @@ -178,6 +216,10 @@ }) public ResultUtil<LoginWarpper> captchaLogin_(String phone, String code, Integer uid, Integer type, Integer userType){ try { + UserInfo userInfo = userInfoService.queryByPhone(phone); + if(null != userInfo){ + return ResultUtil.error("手机号已注册"); + } return userInfoService.captchaLogin(phone, code, uid, type, userType); }catch (Exception e){ e.printStackTrace(); @@ -712,4 +754,20 @@ } } + + @ResponseBody + @PostMapping("/base/user/uploadImg") + @ApiOperation(value = "上传图片", tags = {"用户端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "文件", name = "file", required = true, dataType = "file"), + }) + public ResultUtil uploadImg(MultipartFile file){ + try { + String upload = KodoUtil.upload(file); + return ResultUtil.success(upload); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } } -- Gitblit v1.7.1