Commit 6fa8615f 6fa8615f314f5b4ca90b55e003fa398f1b1f5684 by xianghan

1.完成通过旧密码修改app密码

2.完成通过验证码修改app密码
3.完成app账号信息的修改
1 parent 5c07b99a
......@@ -24,8 +24,8 @@ public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpec
Integer updateLastActiveTime(String username);
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `password` = ?2 WHERE `id` = ?1", nativeQuery = true)
Integer updatePasswordById(Long id, String password);
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `password` = ?2 WHERE `username` = ?1", nativeQuery = true)
Integer updatePasswordByUsername(String username, String password);
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `nickname` = :#{#resources.nickname}, " +
......@@ -33,4 +33,9 @@ public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpec
" `gender` = :#{#resources.gender}, `birthday` = :#{#resources.birthday}, `tags` = :#{#resources.tags}, `description` = :#{#resources.description}" +
" WHERE `id` = :#{#resources.id}", nativeQuery = true)
Integer updateAppInfo(@Param("resources") UserApp resources);
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `password` = ?2 WHERE `id` = ?1", nativeQuery = true)
Integer updatePasswordById(Long id, String password);
}
......
......@@ -36,10 +36,10 @@ public class UserAppController {
private UserAppBindService userAppBindService;
@Log
@PostMapping(value = "/updatePasswordById")
@PostMapping(value = "/updateAppPasswordByUsername")
@ApiOperation("修改app账号密码")
@AnonymousAccess
public ResultInfo updatePasswordById(@Validated @RequestBody UserApp resources) {
public ResultInfo updateAppPasswordByUsername(@Validated @RequestBody UserApp resources) {
log.info("修改app账号密码,参数 ==>> [updatePassword#{}]", resources);
String username = resources.getUsername();
if (StringUtils.isBlank(username)) {
......@@ -56,10 +56,10 @@ public class UserAppController {
boolean passwordRegexResult = RegexUtil.appPasswordRegex(password);
if (!passwordRegexResult) {
log.error("修改app账号密码失败,参数错误,密码格式不正确,[updatePassword#{}]", resources);
return ResultInfo.failure("密码必须包含大小写字母和数字的组合,不能使用特殊字符,长度在 8-10 之间");
return ResultInfo.failure("密码必须包含大小写字母和数字的组合,不能使用特殊字符,长度在 8-25 之间");
}
boolean result = this.userAppService.updatePasswordById(resources);
boolean result = this.userAppService.updatePasswordByUsername(resources);
return ResultInfo.success(result);
}
......
......@@ -56,6 +56,13 @@ public interface UserAppService {
* @param resources
* @return
*/
boolean updatePasswordByUsername(UserApp resources);
/**
*
* @param resources
* @return
*/
boolean updatePasswordById(UserApp resources);
/**
......@@ -64,4 +71,7 @@ public interface UserAppService {
* @return
*/
UserAppSimpleDTO updateAppInfo(UserApp resources);
}
......
......@@ -96,8 +96,8 @@ public class UserAppServiceImpl implements UserAppService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updatePasswordById(UserApp resources) {
return this.userAppRepository.updatePasswordById(resources.getId(), resources.getPassword()) > 0;
public boolean updatePasswordByUsername(UserApp resources) {
return this.userAppRepository.updatePasswordByUsername(resources.getUsername(), resources.getPassword()) > 0;
}
@Override
......@@ -122,5 +122,11 @@ public class UserAppServiceImpl implements UserAppService {
return null;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updatePasswordById(UserApp resources) {
return this.userAppRepository.updatePasswordById(resources.getId(), resources.getPassword()) > 0;
}
}
......
......@@ -24,7 +24,7 @@ public class RegexUtil {
}
public static boolean appPasswordRegex(String password) {
String pattern = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,10}$";
String pattern = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,25}$";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(password);
return m.find();
......
......@@ -64,7 +64,7 @@
<!--监控sql日志输出 -->
<logger name="jdbc.sqlonly" level="INFO" additivity="false">
<logger name="jdbc.sqlonly" level="OFF" additivity="false">
<appender-ref ref="console" />
<appender-ref ref="info" />
</logger>
......