chore: 优化个人中心部分参数命名

This commit is contained in:
2024-05-09 22:34:43 +08:00
parent 1de2a8f2dc
commit 61dd3a4c3a
8 changed files with 61 additions and 58 deletions

View File

@@ -253,10 +253,13 @@ public class GeneratorServiceImpl implements GeneratorService {
return generatePreviewList;
}
private void setPreviewPath(GeneratePreviewResp generatePreview, GenConfigDO genConfig, GeneratorProperties.TemplateConfig templateConfig) {
private void setPreviewPath(GeneratePreviewResp generatePreview,
GenConfigDO genConfig,
GeneratorProperties.TemplateConfig templateConfig) {
// 获取前后端基础路径
String backendBasicPackagePath = this.buildBackendBasicPackagePath(genConfig);
String frontendBasicPackagePath = String.join(File.separator, projectProperties.getAppName(), projectProperties.getAppName() + "-ui");
String frontendBasicPackagePath = String.join(File.separator, projectProperties.getAppName(), projectProperties
.getAppName() + "-ui");
String packageName = genConfig.getPackageName();
String moduleName = StrUtil.subSuf(packageName, StrUtil
.lastIndexOfIgnoreCase(packageName, StringConstants.DOT) + 1);
@@ -310,7 +313,8 @@ public class GeneratorServiceImpl implements GeneratorService {
for (GeneratePreviewResp generatePreview : generatePreviewList) {
// 后端continew-admin/continew-system/src/main/java/top/continew/admin/system/service/impl/XxxServiceImpl.java
// 前端continew-admin/continew-admin-ui/src/views/system/user/index.vue
File file = new File(SystemUtil.getUserInfo().getTempDir() + generatePreview.getPath(), generatePreview.getFileName());
File file = new File(SystemUtil.getUserInfo().getTempDir() + generatePreview.getPath(), generatePreview
.getFileName());
// 如果已经存在,且不允许覆盖,则跳过
if (!file.exists() || Boolean.TRUE.equals(genConfig.getIsOverride())) {
FileUtil.writeUtf8String(generatePreview.getContent(), file);
@@ -326,9 +330,8 @@ public class GeneratorServiceImpl implements GeneratorService {
*/
private String buildBackendBasicPackagePath(GenConfigDO genConfig) {
// 例如continew-admin/continew-system/src/main/java/top/continew/admin/system
return String.join(File.separator, projectProperties
.getAppName(), projectProperties.getAppName(), genConfig.getModuleName(), "src", "main", "java", genConfig
.getPackageName()
return String.join(File.separator, projectProperties.getAppName(), projectProperties.getAppName(), genConfig
.getModuleName(), "src", "main", "java", genConfig.getPackageName()
.replace(StringConstants.DOT, File.separator));
}

View File

@@ -102,7 +102,7 @@ public class UserInfoResp implements Serializable {
* 密码是否已过期
*/
@Schema(description = "密码是否已过期", example = "true")
private Boolean passwordExpired;
private Boolean pwdExpired;
/**
* 创建时间

View File

@@ -45,7 +45,7 @@ public class UserEmailUpdateRequest implements Serializable {
@Schema(description = "新邮箱", example = "123456789@qq.com")
@NotBlank(message = "新邮箱不能为空")
@Pattern(regexp = RegexPool.EMAIL, message = "邮箱格式错误")
private String newEmail;
private String email;
/**
* 验证码
@@ -60,5 +60,5 @@ public class UserEmailUpdateRequest implements Serializable {
*/
@Schema(description = "当前密码(加密)", example = "SYRLSszQGcMv4kP2Yolou9zf28B9GDakR9u91khxmR7V++i5A384kwnNZxqgvT6bjT4zqpIDuMFLWSt92hQJJA==")
@NotBlank(message = "当前密码不能为空")
private String currentPassword;
private String oldPassword;
}

View File

@@ -45,7 +45,7 @@ public class UserPhoneUpdateReq implements Serializable {
@Schema(description = "新手机号", example = "13811111111")
@NotBlank(message = "新手机号不能为空")
@Pattern(regexp = RegexPool.MOBILE, message = "手机号格式错误")
private String newPhone;
private String phone;
/**
* 验证码
@@ -60,5 +60,5 @@ public class UserPhoneUpdateReq implements Serializable {
*/
@Schema(description = "当前密码(加密)", example = "SYRLSszQGcMv4kP2Yolou9zf28B9GDakR9u91khxmR7V++i5A384kwnNZxqgvT6bjT4zqpIDuMFLWSt92hQJJA==")
@NotBlank(message = "当前密码不能为空")
private String currentPassword;
private String oldPassword;
}

View File

@@ -77,19 +77,19 @@ public interface UserService extends BaseService<UserResp, UserDetailResp, UserQ
* 修改手机号
*
* @param newPhone 新手机号
* @param currentPassword 当前密码
* @param oldPassword 当前密码
* @param id ID
*/
void updatePhone(String newPhone, String currentPassword, Long id);
void updatePhone(String newPhone, String oldPassword, Long id);
/**
* 修改邮箱
*
* @param newEmail 新邮箱
* @param currentPassword 当前密码
* @param oldPassword 当前密码
* @param id ID
*/
void updateEmail(String newEmail, String currentPassword, Long id);
void updateEmail(String newEmail, String oldPassword, Long id);
/**
* 重置密码

View File

@@ -262,9 +262,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
}
@Override
public void updatePhone(String newPhone, String currentPassword, Long id) {
public void updatePhone(String newPhone, String oldPassword, Long id) {
UserDO user = super.getById(id);
CheckUtils.throwIf(!passwordEncoder.matches(currentPassword, user.getPassword()), "当前密码错误");
CheckUtils.throwIf(!passwordEncoder.matches(oldPassword, user.getPassword()), "当前密码错误");
CheckUtils.throwIf(this.isPhoneExists(newPhone, id), "手机号已绑定其他账号,请更换其他手机号");
CheckUtils.throwIfEqual(newPhone, user.getPhone(), "新手机号不能与当前手机号相同");
// 更新手机号
@@ -272,9 +272,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
}
@Override
public void updateEmail(String newEmail, String currentPassword, Long id) {
public void updateEmail(String newEmail, String oldPassword, Long id) {
UserDO user = super.getById(id);
CheckUtils.throwIf(!passwordEncoder.matches(currentPassword, user.getPassword()), "当前密码错误");
CheckUtils.throwIf(!passwordEncoder.matches(oldPassword, user.getPassword()), "当前密码错误");
CheckUtils.throwIf(this.isEmailExists(newEmail, id), "邮箱已绑定其他账号,请更换其他邮箱");
CheckUtils.throwIfEqual(newEmail, user.getEmail(), "新邮箱不能与当前邮箱相同");
// 更新邮箱

View File

@@ -127,7 +127,7 @@ public class AuthController {
UserInfoResp userInfoResp = BeanUtil.copyProperties(userDetailResp, UserInfoResp.class);
userInfoResp.setPermissions(loginUser.getPermissions());
userInfoResp.setRoles(loginUser.getRoleCodes());
userInfoResp.setPasswordExpired(userService.isPasswordExpired(userDetailResp.getPwdResetTime()));
userInfoResp.setPwdExpired(userService.isPasswordExpired(userDetailResp.getPwdResetTime()));
return R.ok(userInfoResp);
}

View File

@@ -100,30 +100,30 @@ public class UserCenterController {
@Operation(summary = "修改手机号", description = "修改手机号")
@PatchMapping("/phone")
public R<Void> updatePhone(@Validated @RequestBody UserPhoneUpdateReq updateReq) {
String rawCurrentPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(updateReq
.getCurrentPassword()));
ValidationUtils.throwIfBlank(rawCurrentPassword, DECRYPT_FAILED);
String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + updateReq.getNewPhone();
String rawOldPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(updateReq
.getOldPassword()));
ValidationUtils.throwIfBlank(rawOldPassword, DECRYPT_FAILED);
String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + updateReq.getPhone();
String captcha = RedisUtils.get(captchaKey);
ValidationUtils.throwIfBlank(captcha, CAPTCHA_EXPIRED);
ValidationUtils.throwIfNotEqualIgnoreCase(updateReq.getCaptcha(), captcha, "验证码错误");
RedisUtils.delete(captchaKey);
userService.updatePhone(updateReq.getNewPhone(), rawCurrentPassword, LoginHelper.getUserId());
userService.updatePhone(updateReq.getPhone(), rawOldPassword, LoginHelper.getUserId());
return R.ok("修改成功");
}
@Operation(summary = "修改邮箱", description = "修改用户邮箱")
@PatchMapping("/email")
public R<Void> updateEmail(@Validated @RequestBody UserEmailUpdateRequest updateReq) {
String rawCurrentPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(updateReq
.getCurrentPassword()));
ValidationUtils.throwIfBlank(rawCurrentPassword, DECRYPT_FAILED);
String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + updateReq.getNewEmail();
String rawOldPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(updateReq
.getOldPassword()));
ValidationUtils.throwIfBlank(rawOldPassword, DECRYPT_FAILED);
String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + updateReq.getEmail();
String captcha = RedisUtils.get(captchaKey);
ValidationUtils.throwIfBlank(captcha, CAPTCHA_EXPIRED);
ValidationUtils.throwIfNotEqualIgnoreCase(updateReq.getCaptcha(), captcha, "验证码错误");
RedisUtils.delete(captchaKey);
userService.updateEmail(updateReq.getNewEmail(), rawCurrentPassword, LoginHelper.getUserId());
userService.updateEmail(updateReq.getEmail(), rawOldPassword, LoginHelper.getUserId());
return R.ok("修改成功");
}