mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-09 20:57:21 +08:00
chore: 优化个人中心部分参数命名
This commit is contained in:
@@ -88,15 +88,15 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
tableList.removeIf(table -> !StrUtil.containsAny(table.getTableName(), tableName));
|
||||
}
|
||||
tableList.removeIf(table -> StrUtil.equalsAnyIgnoreCase(table.getTableName(), generatorProperties
|
||||
.getExcludeTables()));
|
||||
.getExcludeTables()));
|
||||
CollUtil.sort(tableList, Comparator.comparing(Table::getCreateTime)
|
||||
.thenComparing(table -> Optional.ofNullable(table.getUpdateTime()).orElse(table.getCreateTime()))
|
||||
.reversed());
|
||||
.thenComparing(table -> Optional.ofNullable(table.getUpdateTime()).orElse(table.getCreateTime()))
|
||||
.reversed());
|
||||
List<TableResp> tableRespList = BeanUtil.copyToList(tableList, TableResp.class);
|
||||
PageResp<TableResp> pageResp = PageResp.build(pageQuery.getPage(), pageQuery.getSize(), tableRespList);
|
||||
for (TableResp tableResp : pageResp.getList()) {
|
||||
long count = genConfigMapper.selectCount(Wrappers.lambdaQuery(GenConfigDO.class)
|
||||
.eq(GenConfigDO::getTableName, tableResp.getTableName()));
|
||||
.eq(GenConfigDO::getTableName, tableResp.getTableName()));
|
||||
tableResp.setIsConfiged(count > 0);
|
||||
}
|
||||
return pageResp;
|
||||
@@ -118,8 +118,8 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
}
|
||||
// 默认作者名称(上次保存使用的作者名称)
|
||||
GenConfigDO lastGenConfig = genConfigMapper.selectOne(Wrappers.lambdaQuery(GenConfigDO.class)
|
||||
.orderByDesc(GenConfigDO::getCreateTime)
|
||||
.last("LIMIT 1"));
|
||||
.orderByDesc(GenConfigDO::getCreateTime)
|
||||
.last("LIMIT 1"));
|
||||
if (null != lastGenConfig) {
|
||||
genConfig.setAuthor(lastGenConfig.getAuthor());
|
||||
}
|
||||
@@ -148,11 +148,11 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
Set<Map.Entry<String, List<String>>> typeMappingEntrySet = typeMappingMap.entrySet();
|
||||
// 新增或更新字段配置
|
||||
Map<String, FieldConfigDO> fieldConfigMap = fieldConfigList.stream()
|
||||
.collect(Collectors.toMap(FieldConfigDO::getColumnName, Function.identity(), (key1, key2) -> key2));
|
||||
.collect(Collectors.toMap(FieldConfigDO::getColumnName, Function.identity(), (key1, key2) -> key2));
|
||||
int i = 1;
|
||||
for (Column column : columnList) {
|
||||
FieldConfigDO fieldConfig = Optional.ofNullable(fieldConfigMap.get(column.getName()))
|
||||
.orElseGet(() -> new FieldConfigDO(column));
|
||||
.orElseGet(() -> new FieldConfigDO(column));
|
||||
// 更新已有字段配置
|
||||
if (null != fieldConfig.getCreateTime()) {
|
||||
String columnType = StrUtil.splitToArray(column.getTypeName(), StringConstants.SPACE)[0].toLowerCase();
|
||||
@@ -160,10 +160,10 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
fieldConfig.setColumnSize(Convert.toStr(column.getSize()));
|
||||
}
|
||||
String fieldType = typeMappingEntrySet.stream()
|
||||
.filter(entry -> entry.getValue().contains(fieldConfig.getColumnType()))
|
||||
.map(Map.Entry::getKey)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
.filter(entry -> entry.getValue().contains(fieldConfig.getColumnType()))
|
||||
.map(Map.Entry::getKey)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
fieldConfig.setFieldType(fieldType);
|
||||
fieldConfig.setFieldSort(i++);
|
||||
latestFieldConfigList.add(fieldConfig);
|
||||
@@ -193,7 +193,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
}
|
||||
// 既不在表单也不在查询中显示,不需要设置表单类型
|
||||
if (Boolean.FALSE.equals(fieldConfig.getShowInForm()) && Boolean.FALSE.equals(fieldConfig
|
||||
.getShowInQuery())) {
|
||||
.getShowInQuery())) {
|
||||
fieldConfig.setFormType(null);
|
||||
}
|
||||
fieldConfig.setTableName(tableName);
|
||||
@@ -222,7 +222,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
genConfigMap.put("date", DateUtil.date().toString("yyyy/MM/dd HH:mm"));
|
||||
String packageName = genConfig.getPackageName();
|
||||
String apiModuleName = StrUtil.subSuf(packageName, StrUtil
|
||||
.lastIndexOfIgnoreCase(packageName, StringConstants.DOT) + 1);
|
||||
.lastIndexOfIgnoreCase(packageName, StringConstants.DOT) + 1);
|
||||
genConfigMap.put("apiModuleName", apiModuleName);
|
||||
genConfigMap.put("apiName", StrUtil.lowerFirst(genConfig.getClassNamePrefix()));
|
||||
// 渲染代码
|
||||
@@ -243,8 +243,8 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
generatePreview.setContent(TemplateUtils.render(templateConfig.getTemplatePath(), genConfigMap));
|
||||
} else {
|
||||
generatePreview.setFileName(".vue".equals(extension) && "index".equals(templateConfigEntry.getKey())
|
||||
? "index.vue"
|
||||
: this.getFrontendFileName(classNamePrefix, className, extension));
|
||||
? "index.vue"
|
||||
: this.getFrontendFileName(classNamePrefix, className, extension));
|
||||
genConfigMap.put("fieldConfigs", fieldConfigList);
|
||||
generatePreview.setContent(TemplateUtils.render(templateConfig.getTemplatePath(), genConfigMap));
|
||||
}
|
||||
@@ -253,26 +253,29 @@ 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);
|
||||
.lastIndexOfIgnoreCase(packageName, StringConstants.DOT) + 1);
|
||||
String packagePath;
|
||||
if (generatePreview.isBackend()) {
|
||||
// 例如:continew-admin/continew-system/src/main/java/top/continew/admin/system/service/impl
|
||||
packagePath = String.join(File.separator, backendBasicPackagePath, templateConfig.getPackageName()
|
||||
.replace(StringConstants.DOT, File.separator));
|
||||
.replace(StringConstants.DOT, File.separator));
|
||||
} else {
|
||||
// 例如:continew-admin/continew-admin-ui/src/views/system
|
||||
packagePath = String.join(File.separator, frontendBasicPackagePath, templateConfig.getPackageName()
|
||||
.replace(StringConstants.SLASH, File.separator), moduleName);
|
||||
.replace(StringConstants.SLASH, File.separator), moduleName);
|
||||
// 例如:continew-admin/continew-admin-ui/src/views/system/user
|
||||
packagePath = ".vue".equals(templateConfig.getExtension())
|
||||
? packagePath + File.separator + StrUtil.lowerFirst(genConfig.getClassNamePrefix())
|
||||
: packagePath;
|
||||
? packagePath + File.separator + StrUtil.lowerFirst(genConfig.getClassNamePrefix())
|
||||
: packagePath;
|
||||
}
|
||||
generatePreview.setPath(packagePath);
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -357,8 +360,8 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
GeneratorProperties.TemplateConfig templateConfig = templateConfigEntry.getValue();
|
||||
// 移除需要忽略的字段
|
||||
List<FieldConfigDO> fieldConfigList = originFieldConfigList.stream()
|
||||
.filter(fieldConfig -> !StrUtil.equalsAny(fieldConfig.getFieldName(), templateConfig.getExcludeFields()))
|
||||
.toList();
|
||||
.filter(fieldConfig -> !StrUtil.equalsAny(fieldConfig.getFieldName(), templateConfig.getExcludeFields()))
|
||||
.toList();
|
||||
genConfigMap.put("fieldConfigs", fieldConfigList);
|
||||
// 统计部分特殊字段特征
|
||||
genConfigMap.put("hasLocalDateTime", false);
|
||||
@@ -378,7 +381,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
}
|
||||
QueryTypeEnum queryType = fieldConfig.getQueryType();
|
||||
if (null != queryType && StrUtil.equalsAny(queryType.name(), QueryTypeEnum.IN.name(), QueryTypeEnum.NOT_IN
|
||||
.name(), QueryTypeEnum.BETWEEN.name())) {
|
||||
.name(), QueryTypeEnum.BETWEEN.name())) {
|
||||
genConfigMap.put("hasListQueryField", true);
|
||||
}
|
||||
}
|
||||
|
@@ -102,7 +102,7 @@ public class UserInfoResp implements Serializable {
|
||||
* 密码是否已过期
|
||||
*/
|
||||
@Schema(description = "密码是否已过期", example = "true")
|
||||
private Boolean passwordExpired;
|
||||
private Boolean pwdExpired;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -76,20 +76,20 @@ public interface UserService extends BaseService<UserResp, UserDetailResp, UserQ
|
||||
/**
|
||||
* 修改手机号
|
||||
*
|
||||
* @param newPhone 新手机号
|
||||
* @param currentPassword 当前密码
|
||||
* @param id ID
|
||||
* @param newPhone 新手机号
|
||||
* @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 id ID
|
||||
* @param newEmail 新邮箱
|
||||
* @param oldPassword 当前密码
|
||||
* @param id ID
|
||||
*/
|
||||
void updateEmail(String newEmail, String currentPassword, Long id);
|
||||
void updateEmail(String newEmail, String oldPassword, Long id);
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
|
@@ -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(), "新邮箱不能与当前邮箱相同");
|
||||
// 更新邮箱
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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("修改成功");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user