release- 用户修改密码

release-2024-08-08
pikaqiudeshujia 6 months ago
parent bd7b8bf9f0
commit 7135ebeca4

@ -1,45 +1,40 @@
package com.luoo.user.controller; package com.luoo.user.controller;
import java.io.ByteArrayOutputStream; import annotation.GlobalInterceptor;
import java.io.IOException; import annotation.VerifyParam;
import java.util.*; import api.Result;
import java.util.concurrent.TimeUnit; import api.StatusCode;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.luoo.user.dto.UserNameLoginDto;
import com.luoo.user.dto.request.*; import com.luoo.user.dto.request.*;
import com.luoo.user.service.WeChatAouth2Service;
import com.luoo.user.util.IOSTokenUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import constants.Constants;
import controller.BaseController;
import com.luoo.user.dto.response.CountryCodeDTO; import com.luoo.user.dto.response.CountryCodeDTO;
import com.luoo.user.dto.response.CreateImageCode; import com.luoo.user.dto.response.CreateImageCode;
import com.luoo.user.pojo.UserInfo; import com.luoo.user.pojo.UserInfo;
import com.luoo.user.service.UserInfoService; import com.luoo.user.service.UserInfoService;
import com.luoo.user.util.NickNameUtil; import com.luoo.user.service.WeChatAouth2Service;
import com.luoo.user.util.IOSTokenUtils;
import annotation.GlobalInterceptor; import constants.Constants;
import annotation.VerifyParam; import controller.BaseController;
import api.Result;
import api.StatusCode;
import enums.RequestFrequencyTypeEnum; import enums.RequestFrequencyTypeEnum;
import enums.VerifyRegexEnum;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import util.IdWorker; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import util.JwtUtil; import util.JwtUtil;
import util.StringTools; import util.StringTools;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;
/** /**
* *
* *
@ -364,13 +359,13 @@ public class LoginController extends BaseController {
/** /**
* / * /
* *
* @param userName
* @param password
* @return * @return
*/ */
@ApiOperation(value = "通过用户名/密码登录") @ApiOperation(value = "通过用户名/密码登录")
@PostMapping("/login/{userName}/{password}") @PostMapping("/login/username")
public Result loginByUserName(@PathVariable String userName, @PathVariable String password) { public Result loginByUserName(@Validated @RequestBody UserNameLoginDto userNameLoginDto) {
String userName = userNameLoginDto.getUserName();
String password = userNameLoginDto.getPassword();
UserInfo userInfo = userInfoService.findByUserNameAndPassword(userName, password); UserInfo userInfo = userInfoService.findByUserNameAndPassword(userName, password);
if (userInfo !=null) { if (userInfo !=null) {
//生成token //生成token
@ -385,4 +380,11 @@ public class LoginController extends BaseController {
} }
} }
@ApiOperation(value = "修改密码")
@PostMapping("/changePassword")
public Result<Void> changePassword(@Validated @RequestBody UserNameLoginDto changePasswordDto) {
userInfoService.changePassword(changePasswordDto.getUserName(), changePasswordDto.getPassword());
return Result.success();
}
} }

@ -0,0 +1,26 @@
package com.luoo.user.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author: yawei.huang
* @Package: com.luoo.user.dto
* @Project: luoo_parent
* @Date: 2024/5/29 8:55
* @Filename: UserNameLoginDto
* @Describe:
*/
@Data
public class UserNameLoginDto implements Serializable {
@ApiModelProperty("用户名")
@NotBlank(message = "用户名不能为空")
private String userName;
@ApiModelProperty("密码")
@NotBlank(message = "密码不能为空")
private String password;
}

@ -697,4 +697,16 @@ public class UserInfoService {
return new PageResult<>(totalElements, content); return new PageResult<>(totalElements, content);
} }
/**
*
*
* @param userName
* @param password
*/
@Transactional(rollbackFor = Exception.class)
public void changePassword(String userName, String password) {
UserInfo userInfoByUserName = userInfoDao.findUserInfoByUserName(userName);
userInfoByUserName.setPassword(encoder.encode(password));
userInfoDao.save(userInfoByUserName);
}
} }

Loading…
Cancel
Save