mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:59:19 +08:00
refactor(account): 账户管理表单和后端DTO全面同步
前端: - 部门和职位改为必填 - 密码改为6-20位(无复杂校验) - 登录账号、手机号、头像等字段已移除 后端: - CreateAccountDTO/UpdateAccountDTO 移除 loginCode、avatarImageId - 密码校验改为6-20位 - 移除密码复杂度和部门/岗位的非空校验(由前端控制)
This commit is contained in:
+4
-16
@@ -2,8 +2,7 @@ package top.xyquan.ecomdmbbackend.modules.org.account.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -13,18 +12,12 @@ import lombok.Data;
|
||||
@Schema(description = "创建账户请求")
|
||||
public class CreateAccountDTO {
|
||||
|
||||
@NotBlank(message = "登录账号不能为空")
|
||||
@Pattern(regexp = "^[a-zA-Z0-9_]{4,20}$", message = "登录账号只能包含字母、数字、下划线,长度4-20位")
|
||||
@Schema(description = "登录账号", example = "admin001")
|
||||
private String loginCode;
|
||||
|
||||
@NotBlank(message = "密码不能为空")
|
||||
@Pattern(regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d@$!%*?&]{8,}$",
|
||||
message = "密码必须包含大小写字母、数字,长度至少8位")
|
||||
@Schema(description = "登录密码", example = "Password123")
|
||||
@Size(min = 6, max = 20, message = "密码长度为6-20个字符")
|
||||
@Schema(description = "登录密码", example = "123456")
|
||||
private String password;
|
||||
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码格式不正确")
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
@Schema(description = "手机号码", example = "13800138000")
|
||||
private String phone;
|
||||
|
||||
@@ -32,14 +25,9 @@ public class CreateAccountDTO {
|
||||
@Schema(description = "用户姓名", example = "张三")
|
||||
private String realName;
|
||||
|
||||
@Schema(description = "头像图片ID", example = "1")
|
||||
private Long avatarImageId;
|
||||
|
||||
@NotNull(message = "部门ID不能为空")
|
||||
@Schema(description = "部门ID", example = "1")
|
||||
private Long departmentId;
|
||||
|
||||
@NotNull(message = "岗位ID不能为空")
|
||||
@Schema(description = "岗位ID", example = "1")
|
||||
private Long positionId;
|
||||
|
||||
|
||||
-7
@@ -11,10 +11,6 @@ import lombok.Data;
|
||||
@Schema(description = "更新账户请求")
|
||||
public class UpdateAccountDTO {
|
||||
|
||||
@Pattern(regexp = "^[a-zA-Z0-9_]{4,20}$", message = "登录账号只能包含字母、数字、下划线,长度4-20位")
|
||||
@Schema(description = "登录账号", example = "admin001")
|
||||
private String loginCode;
|
||||
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码格式不正确")
|
||||
@Schema(description = "手机号码", example = "13800138000")
|
||||
private String phone;
|
||||
@@ -22,9 +18,6 @@ public class UpdateAccountDTO {
|
||||
@Schema(description = "用户姓名", example = "张三")
|
||||
private String realName;
|
||||
|
||||
@Schema(description = "头像图片ID", example = "1")
|
||||
private Long avatarImageId;
|
||||
|
||||
@Schema(description = "部门ID", example = "1")
|
||||
private Long departmentId;
|
||||
|
||||
|
||||
-26
@@ -79,15 +79,6 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
||||
throw new BusinessException("无法获取公司信息");
|
||||
}
|
||||
|
||||
// 验证登录账号是否已存在
|
||||
if (StringUtils.hasText(createAccountDTO.getLoginCode())) {
|
||||
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserPO::getLoginCode, createAccountDTO.getLoginCode());
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("登录账号已存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 验证手机号码是否已存在
|
||||
if (StringUtils.hasText(createAccountDTO.getPhone())) {
|
||||
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
||||
@@ -137,17 +128,6 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
||||
throw new BusinessException("账户不存在");
|
||||
}
|
||||
|
||||
// 检查登录账号是否被其他用户使用
|
||||
if (StringUtils.hasText(updateAccountDTO.getLoginCode()) &&
|
||||
!updateAccountDTO.getLoginCode().equals(user.getLoginCode())) {
|
||||
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserPO::getLoginCode, updateAccountDTO.getLoginCode());
|
||||
wrapper.ne(UserPO::getId, accountId);
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("登录账号已被其他用户使用");
|
||||
}
|
||||
}
|
||||
|
||||
// 检查手机号码是否被其他用户使用
|
||||
if (StringUtils.hasText(updateAccountDTO.getPhone()) &&
|
||||
!updateAccountDTO.getPhone().equals(user.getPhone())) {
|
||||
@@ -160,18 +140,12 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
||||
}
|
||||
|
||||
// 更新账户信息
|
||||
if (StringUtils.hasText(updateAccountDTO.getLoginCode())) {
|
||||
user.setLoginCode(updateAccountDTO.getLoginCode());
|
||||
}
|
||||
if (StringUtils.hasText(updateAccountDTO.getPhone())) {
|
||||
user.setPhone(updateAccountDTO.getPhone());
|
||||
}
|
||||
if (StringUtils.hasText(updateAccountDTO.getRealName())) {
|
||||
user.setRealName(updateAccountDTO.getRealName());
|
||||
}
|
||||
if (updateAccountDTO.getAvatarImageId() != null) {
|
||||
user.setAvatarImageId(updateAccountDTO.getAvatarImageId());
|
||||
}
|
||||
if (StringUtils.hasText(updateAccountDTO.getRemark())) {
|
||||
user.setRemark(updateAccountDTO.getRemark());
|
||||
}
|
||||
|
||||
+7
-3
@@ -338,6 +338,7 @@ defineExpose({
|
||||
<Form.Item
|
||||
label="所属部门"
|
||||
name="departmentId"
|
||||
:rules="[{ required: true, message: '请选择所属部门' }]"
|
||||
>
|
||||
<Cascader
|
||||
:value="departmentPath"
|
||||
@@ -351,14 +352,17 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="职位" name="positionId">
|
||||
<Form.Item
|
||||
label="职位"
|
||||
name="positionId"
|
||||
:rules="[{ required: true, message: '请选择职位' }]"
|
||||
>
|
||||
<Select
|
||||
v-model:value="formData.positionId"
|
||||
:loading="positionOptionsLoading"
|
||||
:options="positionOptions"
|
||||
placeholder="请选择职位(可选)"
|
||||
placeholder="请选择职位"
|
||||
:disabled="positionOptionsLoading"
|
||||
allow-clear
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user