User.java
4.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
package com.huaheng.pc.system.user.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.huaheng.framework.aspectj.lang.annotation.Excel;
import com.huaheng.pc.system.dept.domain.Dept;
import lombok.Data;
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 用户对象 sys_user
*
* @author huaheng
*/
@Data
@TableName(value = "sys_user")
public class User implements Serializable
{
private static final long serialVersionUID = 3875676767702L;
/** 用户ID */
@Excel(name = "用户序号")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/** 部门ID */
@TableField(value = "deptId")
private Integer deptId;
/** 部门父ID */
@TableField(value = "parentId")
private Integer parentId;
/** 登录名称 */
@Excel(name = "登录名称")
@TableField(value = "loginName")
private String loginName;
/** 用户名称 */
@Excel(name = "用户名称")
@TableField(value = "userName")
private String userName;
/** 用户邮箱 */
@Excel(name = "用户邮箱")
@TableField(value = "email")
private String email;
/** 手机号码 */
@Excel(name = "手机号码")
@TableField(value = "phoneNumber")
private String phoneNumber;
/** 用户性别 */
@Excel(name = "用户性别")
@TableField(value = "sex")
private String sex;
/** 用户头像 */
@TableField(value = "avatar")
private String avatar;
/** 密码 */
@TableField(value = "password")
private String password;
/** 盐加密 */
@TableField(value = "salt")
private String salt;
/** 启用状态 */
@Excel(name = "启用状态")
@TableField(value = "enable")
private Boolean enable;
/** 删除状态 */
@Excel(name = "删除状态")
@TableField(value = "deleted")
private Boolean deleted;
/** 最后登陆IP */
@Excel(name = "最后登陆IP")
@TableField(value = "loginIp")
private String loginIp;
/** 最后登陆时间 */
@Excel(name = "最后登陆时间")
@TableField(value = "loginDate")
private Date loginDate;
/** 部门对象 */
private Dept dept;
/** 仓库ID */
private Integer warehouseId;
/** 仓库编码 */
private String warehouseCode;
/** 角色列表 */
private List<Integer> roleIds;
/** 货主id列表 */
private List<Integer> companyIdList;
/** 货主编码列表 */
private List<String> companyCodeList;
/** 仓库编码列表 */
private List<String> warehouseCodeList;
/** 搜索值 */
private String searchValue;
/** 创建者 */
@TableField(value = "createBy")
private String createBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "createTime")
private Date createTime;
/** 更新者 */
@TableField(value = "updateBy")
private String updateBy;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "updateTime")
private Date updateTime;
/** 备注 */
@TableField(value = "remark")
private String remark;
@TableField(exist = false)
private Boolean admin;
/** 请求参数 */
private Map<String, Object> params;
private List<Integer> supplierIds;
/**
* 生成随机盐
*/
public void randomSalt()
{
// 一个Byte占两个字节,此处生成的3字节,字符串长度为6
SecureRandomNumberGenerator secureRandom = new SecureRandomNumberGenerator();
String hex = secureRandom.nextBytes(3).toHex();
setSalt(hex);
}
public boolean unAdmin()
{
return unAdmin(this.id);
}
public static boolean unAdmin(Integer id)
{
return id != null && 1L == id;
}
public static boolean unAdmin(String loginName)
{
return "superAdmin".equals(loginName);
}
@Override
public String toString()
{
return "User [id=" + id + ", deptId=" + deptId + ", parentId=" + parentId + ", loginName=" + loginName
+ ", userName=" + userName + ", email=" + email + ", phoneNumber=" + phoneNumber + ", sex=" + sex
+ ", avatar=" + avatar + ", password=" + password + ", salt=" + salt + ", enable=" + enable
+ ", deleted=" + deleted + ", loginIp=" + loginIp + ", loginDate=" + loginDate + ", dept=" + dept + "]";
// + ", roleIds=" + String.join(",", roleIds) + ", companyIds=" + Arrays.toString(companyIds.toArray()) + "]";
}
}