diff --git a/luoo_common/src/main/java/util/JwtUtil.java b/luoo_common/src/main/java/util/JwtUtil.java index fa7e3c8..fb7931d 100644 --- a/luoo_common/src/main/java/util/JwtUtil.java +++ b/luoo_common/src/main/java/util/JwtUtil.java @@ -74,7 +74,7 @@ public class JwtUtil { return null; } UserLoginDto userLoginDto=new UserLoginDto(); - Claims claims = this.parseJWT(token); + Claims claims = parseJWT(token); userLoginDto.setUserId(claims.getId()); userLoginDto.setNickName(claims.getSubject()); userLoginDto.setRoles((String) claims.get("roles")); diff --git a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java index 4881923..5e6dd59 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java @@ -1,17 +1,22 @@ package com.luoo.user.controller; +import java.io.File; +import java.io.IOException; import java.util.List; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; import com.luoo.user.annotation.GlobalInterceptor; +import com.luoo.user.constants.Constants; import com.luoo.user.dto.response.UserRespDTO; import com.luoo.user.pojo.User; import com.luoo.user.service.UserService; @@ -22,6 +27,7 @@ import dto.UserLoginDto; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import util.JwtUtil; +import util.StringTools; @RestController @CrossOrigin @@ -33,6 +39,10 @@ public class MyController { @Autowired private UserService userService; + /* + * @Value("${project.folder:}") private String projectFolder="./"; + */ + @ApiOperation(value = "1.获取个人信息") @PostMapping("/getUserInfo") @GlobalInterceptor @@ -44,7 +54,52 @@ public class MyController { User user = userService.findById(userLoginDto.getUserId()); UserRespDTO userRespDTO = new UserRespDTO(); BeanUtils.copyProperties(user, userRespDTO); - userRespDTO.setToken(token); return Result.success(userRespDTO); } + + /* + * @ApiOperation(value = "2.上传个人头像") + * + * @RequestMapping("/uploadAvatar") + * + * @GlobalInterceptor(checkLogin = true) public Result + * uploadAvatar(@RequestHeader(value = "token", required = false) String token, + * MultipartFile file) throws IOException { UserLoginDto userLoginDto = + * jwtUtil.getUserLoginDto(token); String folderName = projectFolder + + * Constants.FOLDER_AVATAR; File folder = new File(folderName); if + * (!folder.exists()) { folder.exists(); } + * + * String avatarName = userLoginDto.getUserId() + + * StringTools.getFileSuffix(file.getOriginalFilename()); File avatarFileName = + * new File(folder.getPath() + "/" + avatarName); + * + * file.transferTo(avatarFileName); + * + * ScaleFilter.createThumbnail(avatarFileName, Constants.LENGTH_70, + * Constants.LENGTH_70, avatarFileName); + * + * AppUserInfo appUserInfo = new AppUserInfo(); + * appUserInfo.setAvatar(Constants.FOLDER_AVATAR + avatarName); + * appUserInfoService.updateAppUserInfoByUserId(appUserInfo, + * userLoginDto.getUserId()); return getSuccessResponseVO(null); } + * + * @ApiOperation(value = "1.获取个人信息") + * + * @RequestMapping("/updateUserInfo") + * + * @GlobalInterceptor(checkLogin = true) public ResponseVO + * updateUserInfo(@RequestHeader(value = "token", required = false) String + * token, + * + * @VerifyParam(required = true) Integer sex, + * + * @VerifyParam(regex = VerifyRegexEnum.PASSWORD) String passwrd) { + * AppUserLoginDto userLoginDto = getAppUserLoginfoFromToken(token); + * + * AppUserInfo updateInfo = new AppUserInfo(); updateInfo.setSex(sex); if + * (!StringTools.isEmpty(passwrd)) { + * updateInfo.setPassword(StringTools.encodeByMD5(passwrd)); } + * appUserInfoService.updateAppUserInfoByUserId(updateInfo, + * userLoginDto.getUserId()); return getSuccessResponseVO(null); } + */ } diff --git a/luoo_user/src/main/java/com/luoo/user/controller/UserController.java b/luoo_user/src/main/java/com/luoo/user/controller/UserController.java index 99ffa2c..7ed7692 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/UserController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/UserController.java @@ -126,9 +126,9 @@ public class UserController { /** * 发送短信验证码 */ - @ApiOperation(value = "1.发送短信验证码", notes = "有效期15分钟,一个手机号一分钟内只能请求1次") + @ApiOperation(value = "1.发送短信验证码", notes = "有效期15分钟,一个手机号一天内最多发送50个请求") @PostMapping("/sendsms/{mobile}") - @GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.MINUTE, requestFrequencyThreshold = 1) + @GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.DAY, requestFrequencyThreshold = 50) public Result sendSms(@PathVariable @VerifyParam(required=true,regex=VerifyRegexEnum.MOBILE)String mobile) { userService.sendSms(mobile); return Result.success(); diff --git a/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java b/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java index 3dbac49..d35414b 100644 --- a/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java +++ b/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java @@ -14,6 +14,4 @@ public class UserRespDTO { private String avatar;//头像 @ApiModelProperty(value = "个性签名,首次注册登录,默认为“无签名”") private String personality;//个性 - @ApiModelProperty(value = "TOKEN") - private String token; }