提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.controller.admin.user.vo.user; |
H |
2 |
|
|
3 |
import cn.hutool.core.util.ObjectUtil; |
|
4 |
import com.iailab.framework.common.validation.Mobile; |
|
5 |
import com.iailab.module.system.framework.operatelog.core.DeptParseFunction; |
|
6 |
import com.iailab.module.system.framework.operatelog.core.PostParseFunction; |
|
7 |
import com.iailab.module.system.framework.operatelog.core.SexParseFunction; |
|
8 |
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
9 |
import com.mzt.logapi.starter.annotation.DiffLogField; |
|
10 |
import io.swagger.v3.oas.annotations.media.Schema; |
|
11 |
import lombok.Data; |
|
12 |
import org.hibernate.validator.constraints.Length; |
|
13 |
|
|
14 |
import javax.validation.constraints.*; |
|
15 |
import java.util.Set; |
|
16 |
|
|
17 |
@Schema(description = "管理后台 - 用户创建/修改 Request VO") |
|
18 |
@Data |
|
19 |
public class UserSaveReqVO { |
|
20 |
|
|
21 |
@Schema(description = "用户编号", example = "1024") |
|
22 |
private Long id; |
|
23 |
|
|
24 |
@Schema(description = "用户账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "iailab") |
|
25 |
@NotBlank(message = "用户账号不能为空") |
|
26 |
@Pattern(regexp = "^[a-zA-Z0-9]{4,30}$", message = "用户账号由 数字、字母 组成") |
|
27 |
@Size(min = 4, max = 30, message = "用户账号长度为 4-30 个字符") |
|
28 |
@DiffLogField(name = "用户账号") |
|
29 |
private String username; |
|
30 |
|
|
31 |
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "iailab") |
|
32 |
@Size(max = 30, message = "用户昵称长度不能超过30个字符") |
|
33 |
@DiffLogField(name = "用户昵称") |
|
34 |
private String nickname; |
|
35 |
|
|
36 |
@Schema(description = "备注", example = "我是一个用户") |
|
37 |
@DiffLogField(name = "备注") |
|
38 |
private String remark; |
|
39 |
|
|
40 |
@Schema(description = "部门编号", example = "我是一个用户") |
|
41 |
@DiffLogField(name = "部门", function = DeptParseFunction.NAME) |
|
42 |
private Long deptId; |
|
43 |
|
|
44 |
@Schema(description = "岗位编号数组", example = "1") |
|
45 |
@DiffLogField(name = "岗位", function = PostParseFunction.NAME) |
|
46 |
private Set<Long> postIds; |
|
47 |
|
|
48 |
@Schema(description = "用户邮箱", example = "iailab@iocoder.cn") |
|
49 |
@Email(message = "邮箱格式不正确") |
|
50 |
@Size(max = 50, message = "邮箱长度不能超过 50 个字符") |
|
51 |
@DiffLogField(name = "用户邮箱") |
|
52 |
private String email; |
|
53 |
|
|
54 |
@Schema(description = "手机号码", example = "15601691300") |
|
55 |
@Mobile |
|
56 |
@DiffLogField(name = "手机号码") |
|
57 |
private String mobile; |
|
58 |
|
|
59 |
@Schema(description = "用户性别,参见 SexEnum 枚举类", example = "1") |
|
60 |
@DiffLogField(name = "用户性别", function = SexParseFunction.NAME) |
|
61 |
private Integer sex; |
|
62 |
|
|
63 |
@Schema(description = "用户头像", example = "https://www.baidu.com/xxx.png") |
|
64 |
@DiffLogField(name = "用户头像") |
|
65 |
private String avatar; |
|
66 |
|
|
67 |
// ========== 仅【创建】时,需要传递的字段 ========== |
|
68 |
|
|
69 |
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") |
|
70 |
@Length(min = 4, max = 16, message = "密码长度为 4-16 位") |
|
71 |
private String password; |
|
72 |
|
|
73 |
@AssertTrue(message = "密码不能为空") |
|
74 |
@JsonIgnore |
|
75 |
public boolean isPasswordValid() { |
|
76 |
return id != null // 修改时,不需要传递 |
|
77 |
|| (ObjectUtil.isAllNotEmpty(password)); // 新增时,必须都传递 password |
|
78 |
} |
|
79 |
|
|
80 |
} |