| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- /*
- * Copyright 2019-2020 Zheng Jie
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package me.zhengjie.dao.mybatis.entity;
- import com.baomidou.mybatisplus.annotation.TableField;
- import io.swagger.annotations.ApiModelProperty;
- import lombok.Getter;
- import lombok.Setter;
- import me.zhengjie.base.BaseEntity;
- import javax.persistence.*;
- import javax.validation.constraints.Email;
- import javax.validation.constraints.NotBlank;
- import javax.validation.constraints.NotNull;
- import org.apache.commons.lang3.StringUtils;
- import java.io.Serializable;
- import java.util.Date;
- import java.util.Objects;
- import java.util.Set;
- /**
- * @author Zheng Jie
- * @date 2018-11-22
- */
- @Entity
- @Getter
- @Setter
- @Table(name = "sys_user")
- public class User extends BaseEntity implements Serializable {
- @Id
- @Column(name = "user_id")
- @NotNull(groups = Update.class)
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @ApiModelProperty(value = "ID", hidden = true)
- private Long id;
- @ManyToMany(fetch = FetchType.EAGER)
- @ApiModelProperty(value = "用户角色")
- @JoinTable(name = "sys_users_roles", joinColumns = {
- @JoinColumn(name = "user_id", referencedColumnName = "user_id") }, inverseJoinColumns = {
- @JoinColumn(name = "role_id", referencedColumnName = "role_id") })
- private Set<Role> roles;
- @ManyToMany(fetch = FetchType.EAGER)
- @ApiModelProperty(value = "用户岗位")
- @JoinTable(name = "sys_users_jobs", joinColumns = {
- @JoinColumn(name = "user_id", referencedColumnName = "user_id") }, inverseJoinColumns = {
- @JoinColumn(name = "job_id", referencedColumnName = "job_id") })
- private Set<Job> jobs;
- @OneToOne
- @JoinColumn(name = "dept_id")
- @ApiModelProperty(value = "用户部门")
- private Dept dept;
- @NotBlank
- @Column(unique = true)
- @ApiModelProperty(value = "用户名称")
- private String username;
- @NotBlank
- @ApiModelProperty(value = "用户昵称")
- private String nickName;
- @Email
- // @NotBlank
- @ApiModelProperty(value = "邮箱")
- private String email;
- @NotBlank
- @ApiModelProperty(value = "电话号码")
- private String phone;
- @ApiModelProperty(value = "用户性别")
- private String gender;
- @ApiModelProperty(value = "头像真实名称", hidden = true)
- private String avatarName;
- @ApiModelProperty(value = "头像存储的路径", hidden = true)
- private String avatarPath;
- @ApiModelProperty(value = "密码")
- private String password;
- @NotNull
- @ApiModelProperty(value = "是否启用")
- private Boolean enabled;
- @ApiModelProperty(value = "是否为admin账号", hidden = true)
- private Boolean isAdmin = false;
- @Column(name = "pwd_reset_time")
- @ApiModelProperty(value = "最后修改密码的时间", hidden = true)
- private Date pwdResetTime;
- @Column(name = "org_id")
- @ApiModelProperty(value = "机构的id") // 银行或者公证处
- private String orgId;
- @Column(name = "id_card")
- @ApiModelProperty(value = "身份证") // 用户身份证
- private String idCard;
- @Column(name = "sign_img_id")
- @ApiModelProperty(value = "签名图片id")
- private String signImgId;
- @Column(name = "axq_user_id")
- @ApiModelProperty(value = "安心签用户ID")
- private String axqUserId;
- @Column(name = "axq_seal_id")
- @ApiModelProperty(value = "安心签签名图片ID")
- private String axqSealId;
- @Column(name = "axq_is_auth")
- @ApiModelProperty(value = "安心签签名授权标记")
- private String axqIsAuth;
- @Transient
- @TableField(exist = false)
- @ApiModelProperty(value = "安心签签名授权验证码")
- private String checkCode;
- @Transient
- @TableField(exist = false)
- @ApiModelProperty(value = "图片的id的值")
- private String imageId;
- /**
- * 获取用户类型
- *
- * @return
- */
- public String getUserType() {
- if (StringUtils.isNotBlank(orgId) && orgId.contains(",")) {
- return orgId.split("_")[0];
- }
- return "";
- }
- /**
- * 获取公司ID
- *
- * @return
- */
- public String getComId() {
- // 增加非空判断
- if (StringUtils.isNotBlank(orgId) && orgId.contains(",")) {
- return orgId.split("_")[1];
- }
- return "";
- }
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- User user = (User) o;
- return Objects.equals(id, user.id) && Objects.equals(username, user.username);
- }
- @Override
- public int hashCode() {
- return Objects.hash(id, username);
- }
- }
|