package com.stylefeng.guns.modular.api; import com.alibaba.fastjson.JSONObject; import com.stylefeng.guns.core.common.constant.JwtConstants; import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.system.model.UserInfo; 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.*; import com.stylefeng.guns.modular.system.warpper.LoginWarpper; import com.stylefeng.guns.modular.system.warpper.UserInfoWarpper; import com.stylefeng.guns.modular.system.warpper.VerifiedWarpper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; 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.HttpServletResponse; import java.util.*; /** * 用户控制器 */ @Api @RestController @RequestMapping("") public class UserInfoController { @Autowired private IUserInfoService userInfoService; @Autowired private IVerifiedService verifiedService; @Autowired private ISmsrecordService smsrecordService; @Autowired private RedisUtil redisUtil; @Autowired private WeChatUtil weChatUtil; /** * 获取短信验证码 * @param phone * @return */ @ResponseBody @PostMapping("/base/queryCaptcha") @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 queryCaptcha(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(); } } /** * 手机验证码登录 * @param phone * @param code * @param registIp * @param registAreaCode * @return */ @ResponseBody @PostMapping("/base/user/captchaLogin") @ApiOperation(value = "手机验证码登录", tags = {"用户端-登录"}, notes = "") @ApiImplicitParams({ @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 = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"), @ApiImplicitParam(value = "当前定位区县行政编号", name = "registAreaCode", required = false, dataType = "String") }) public ResultUtil captchaLogin(String phone, String code, String registIp, String registAreaCode,String loginType){ try { return userInfoService.captchaLogin(phone, code, registIp, registAreaCode,loginType); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/base/user/oneClickLogin") @ApiOperation(value = "手机一键登录", tags = {"用户端-登录"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "app端SDK获取的登录token。", name = "accessToken", required = true, dataType = "String"), @ApiImplicitParam(value = "ip地址", name = "registIp", required = false, dataType = "String"), @ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"), @ApiImplicitParam(value = "当前定位区县行政编号", name = "registAreaCode", required = false, dataType = "String"), @ApiImplicitParam(value = "安卓或者苹果 安卓传android 苹果传ios", name = "androidOrIos", required = false, dataType = "String") }) public ResultUtil oneClickLogin(String accessToken, String registIp, String registAreaCode,String loginType,String androidOrIos){ try { return userInfoService.oneClickLogin(accessToken, registIp, registAreaCode,loginType,androidOrIos); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 手机验证码登录 * @param phone * @param code * @return */ @ResponseBody @PostMapping("/base/user/captchaLogin_") @ApiOperation(value = "手机验证码登录", tags = {"分享专用"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), @ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "String"), @ApiImplicitParam(value = "分享的用户id", name = "uid", required = true, dataType = "int"), @ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"), @ApiImplicitParam(value = "用户类型(1=用户,2=司机)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(value = "注册类型(1=司机注册,2=用户注册)", name = "userType", required = true, dataType = "int") }) public ResultUtil captchaLogin_(String phone, String code, Integer uid, Integer type, Integer userType,String loginType){ try { return userInfoService.captchaLogin(phone, code, uid, type, userType,loginType); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 账号密码登录 * @param phone * @param password * @return */ @ResponseBody @PostMapping("/base/user/userLogin") @ApiOperation(value = "账号密码登录", tags = {"用户端-登录"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), @ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"), @ApiImplicitParam(value = "登录密码", name = "password", required = true, dataType = "String") }) public ResultUtil userLogin(String phone, String password,String loginType){ if(ToolUtil.isNotEmpty(phone) && ToolUtil.isNotEmpty(password)){ try { return userInfoService.userLogin(phone, password,loginType); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } }else{ return ResultUtil.paranErr(); } } /** * 忘记密码 * @param phone * @param code * @param password * @return */ @ResponseBody @PostMapping("/base/user/forgetPassword") @ApiOperation(value = "忘记密码操作", tags = {"用户端-登录"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), @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){ if(ToolUtil.isNotEmpty(phone) && ToolUtil.isNotEmpty(code) && ToolUtil.isNotEmpty(password)){ try { return userInfoService.forgetPassword(phone, code, password); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } }else{ return ResultUtil.paranErr(); } } /** * 微信授权登录 * @param type 登录端口(1:APP登录,2:小程序) * @param openid 微信openid * @param unionid 微信unionid * @param jscode 小程序登录时的jscode临时凭证 * @param registIp ip地址 * @param registAreaCode 当前定位区县行政编号(6位) * @return */ @ResponseBody @PostMapping("/base/user/wxLogin") @ApiOperation(value = "微信授权登录", tags = {"用户端-登录"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "登录端口(1:APP,2:小程序)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(value = "微信openid(APP登录上传)", name = "openid", required = false, dataType = "String"), @ApiImplicitParam(value = "微信unionid(APP登录上传)", name = "unionid", required = false, dataType = "String"), @ApiImplicitParam(value = "微信jscode(小程序登录上传)", name = "jscode", required = false, dataType = "String"), @ApiImplicitParam(value = "ip地址", name = "registIp", required = false, dataType = "String"), @ApiImplicitParam(value = "当前定位区县行政编号", name = "registAreaCode", required = true, dataType = "String"), @ApiImplicitParam(value = "头像", name = "avatar", required = false, dataType = "String"), @ApiImplicitParam(value = "昵称", name = "nickName", required = false, dataType = "String"), @ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"), @ApiImplicitParam(value = "性别(1=男,2=女)", name = "sex", required = false, dataType = "int") }) public ResultUtil wxLogin(Integer type, String openid, String unionid, String jscode, String registIp, String registAreaCode, Integer sex, String nickName, String avatar,String loginType){ try { return userInfoService.wxLogin(type, openid, unionid, jscode, registIp, registAreaCode, sex, nickName, avatar,loginType); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 设置电话号码 * @param phone * @param code * @param request * @return */ @ResponseBody @PostMapping("/api/user/bindingPhone") @ApiOperation(value = "设置电话号码", tags = {"用户端-登录"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "String"), @ApiImplicitParam(value = "验证码", name = "code", required = false, dataType = "String"), @ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil bindingPhone(String phone, String code, HttpServletRequest request,String loginType){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return userInfoService.bindingPhone(uid, phone, code,loginType); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取用户个人信息 * @param request * @return */ @ResponseBody @PostMapping("/api/user/queryUserInfo") @ApiOperation(value = "获取用户详情", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryUserInfo(HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } Map map = userInfoService.queryUserInfo(uid); return ResultUtil.success(UserInfoWarpper.getUserInfoWarpper(map)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 手机号码获取用户 * @param phone * @return */ @ResponseBody @PostMapping("/api/user/queryUser") @ApiOperation(value = "手机号码获取用户", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @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 queryUser(String phone){ try { Map map = userInfoService.queryUser(phone); if(null != map){ return ResultUtil.success(UserInfoWarpper.getUserInfoWarpper(map)); } return ResultUtil.success(new JSONObject()); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 实名认证操作 * @param verifiedWarpper * @param request * @return */ @ResponseBody @PostMapping("/api/user/verified") @ApiOperation(value = "实名认证操作", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil verified(VerifiedWarpper verifiedWarpper, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return verifiedService.verified(VerifiedWarpper.getVerified(verifiedWarpper), uid); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 设置紧急联系人 * @param name * @param phone * @param request * @return */ @ResponseBody @PostMapping("/api/user/setUrgentUser") @ApiOperation(value = "设置紧急联系人", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "姓名,没有传空字符串", name = "name", required = true, dataType = "String"), @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 setUrgentUser(String name, String phone, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } userInfoService.setUrgentUser(name, phone, uid); return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 用户充值余额 * @param payType * @param money * @param request * @return */ @ResponseBody @PostMapping("/api/user/depositBalance") @ApiOperation(value = "余额充值", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "支付方式(1=微信,2=支付宝)", 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){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return userInfoService.depositBalance(payType, money, uid, type); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 修改手机号码 * @param code * @param phone * @param request * @return */ @ResponseBody @PostMapping("/api/user/updatePhone") @ApiOperation(value = "修改手机号码", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "验证码", name = "code", required = true, dataType = "string"), @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){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return userInfoService.updatePhone(code, phone, uid); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/api/user/checkCaptcha") @ApiOperation(value = "验证短信验证码", tags = {"用户端-个人中心"}, notes = "1=正确,0=错误") @ApiImplicitParams({ @ApiImplicitParam(value = "电话号码", name = "phone", 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 checkCaptcha(String phone, String code, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } UserInfo userInfo = userInfoService.selectById(uid); smsrecordService.saveData(4, userInfo.getPhone(), code, "短信验证码【" + code + "】已发到您的手机,验证码将在5分钟后失效,请及时登录!"); boolean b = userInfoService.checkCaptcha(phone, code); Map map = new HashMap<>(); map.put("ok", b ? 1 : 0); return ResultUtil.success(map); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 修改登录密码 * @param password * @param request * @return */ @ResponseBody @PostMapping("/api/user/updatePassword") @ApiOperation(value = "修改登录密码", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @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){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return userInfoService.updatePass(password, uid); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 修改个人信息 * @param avatar * @param nickname * @param sex * @param birthday * @param request * @return */ @ResponseBody @PostMapping("/api/user/updateInfo") @ApiOperation(value = "修改个人信息", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "头像", name = "avatar", required = false, dataType = "string"), @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(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){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } userInfoService.updateInfo(avatar, nickname, sex, birthday, uid); return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/api/user/queryRealName") @ApiOperation(value = "获取实名认证的数据", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryRealName(HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } Map map = userInfoService.queryRealName(uid); return ResultUtil.success(null != map ? map : new HashMap<>()); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 后台调用禁用用户 * @param uid * @return */ @ResponseBody @PostMapping("/base/user/freeze") public ResultUtil freeze(Integer uid){ try { UserInfo userInfo = userInfoService.selectById(uid); String value = redisUtil.getValue(userInfo.getPhone()); redisUtil.remove(value); redisUtil.remove(userInfo.getPhone()); return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 仿socket接口(单点登录) * @param request * @return */ @ResponseBody @PostMapping("/api/user/comparisonToken") @ApiOperation(value = "单点登录", tags = {"用户端-仿socket接口"}, notes = "match=1(匹配),match=2(不匹配)") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil comparisonToken(HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } String requestHeader = request.getHeader(JwtConstants.AUTH_HEADER); requestHeader = requestHeader.substring(requestHeader.indexOf(" ") + 1); String value = redisUtil.getValue("USER_" + uid); Map map = new HashMap<>(); map.put("match", requestHeader.equals(value) ? 1 : 2); return ResultUtil.success(map); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 注销账号 * @param request * @return */ @ResponseBody @PostMapping("/api/user/cancellation") @ApiOperation(value = "注销账号", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil cancellation(HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } UserInfo userInfo = userInfoService.selectById(uid); userInfo.setState(2); userInfoService.updateById(userInfo); //开始验证当前账号是否在别处登录 String value = redisUtil.getValue("USER_" + uid); if(ToolUtil.isNotEmpty(value)){//将另外设备上的强迫下线 //开始清除redis中无效的数据 String key = redisUtil.getValue("USER_" + userInfo.getPhone()); redisUtil.remove(key);//删除个人信息数据 redisUtil.remove("USER_" + userInfo.getPhone());//删除后台冻结相关缓存 redisUtil.remove("USER_" + uid);//清除存储的token } return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/base/user/dxlcLogin") @ApiOperation(value = "道行龙城登录", tags = {"用户端-道行龙城"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "道行龙城获取的授权", name = "authCode", required = true, dataType = "String"), @ApiImplicitParam(value = "登录端口-小程序和H5传Applets", name = "loginType", required = false, dataType = "String"), @ApiImplicitParam(value = "当前定位区县行政编号", name = "registAreaCode", required = false, dataType = "String") }) public ResultUtil dxlcLogin(String authCode, String registAreaCode,String loginType){ try { return userInfoService.dxlcLogin(authCode, registAreaCode, loginType); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/base/user/getSignatureConfig") @ApiOperation(value = "获取微信JS-SDK", tags = {"用户端-道行龙城"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "授权地址", name = "url", required = true, dataType = "String"), }) public ResultUtil getSignatureConfig(String url){ try { Map signatureConfig = weChatUtil.getSignatureConfig(url); return ResultUtil.success(signatureConfig); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 手机号码获取用户 * @return */ @ResponseBody @PostMapping("/api/user/phoneLoginBindingWeChat") @ApiOperation(value = "微信小程序手机号登录后调用此接口保存微信openid", tags = {"用户端-登录"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "微信登录临时凭证", name = "jscode", required = true, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil phoneLoginBindingWeChat(String jscode, HttpServletRequest request){ try { Integer userId = userInfoService.getUserIdFormRedis(request); if(null == userId){ return ResultUtil.tokenErr(); } return userInfoService.phoneLoginBindingWeChat(userId, jscode); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/base/uploadImg") @ApiOperation(value = "上传图片接口", tags = {"公共接口"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "图片文件", name = "file", required = true, dataType = "file"), }) public ResultUtil uploadImg(MultipartFile file, HttpServletRequest request, HttpServletResponse response){ try { String name = file.getOriginalFilename(); String type = name.substring(name.lastIndexOf(".") + 1).toLowerCase(); List types = Arrays.asList("jpg", "jpeg", "png"); if(!types.contains(type)){ return ResultUtil.error("请上传图片文件(jpg/jpeg/png)"); } String s = ObsUploadUtil.obsUpload(request, file); // String s = OssUploadUtil.ossUpload(request, file); return ResultUtil.success(s); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 注销账号 * @param request * @return */ @ResponseBody @PostMapping("/api/user/cancelAccount") @ApiOperation(value = "注销账号", tags = {"用户端-登录"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil cancelAccount(HttpServletRequest request){ try { Integer userId = userInfoService.getUserIdFormRedis(request); if(null == userId){ return ResultUtil.tokenErr(); } UserInfo userInfo = userInfoService.selectById(userId); userInfo.setFlag(3); userInfoService.updateById(userInfo); return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } }