1.修正短信调用频次为1天50次

main
Gary 1 year ago
parent 4e70d7819f
commit 7e832125bc

@ -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"));

@ -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); }
*/
}

@ -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<Void> sendSms(@PathVariable @VerifyParam(required=true,regex=VerifyRegexEnum.MOBILE)String mobile) {
userService.sendSms(mobile);
return Result.success();

@ -14,6 +14,4 @@ public class UserRespDTO {
private String avatar;//头像
@ApiModelProperty(value = "个性签名,首次注册登录,默认为“无签名”")
private String personality;//个性
@ApiModelProperty(value = "TOKEN")
private String token;
}

Loading…
Cancel
Save