初始版本
This commit is contained in:
636
src/main/java/com/vverp/entity/Admin.java
Normal file
636
src/main/java/com/vverp/entity/Admin.java
Normal file
@@ -0,0 +1,636 @@
|
||||
/*
|
||||
* Copyright 2013-2017 vverp.com. All rights reserved.
|
||||
* Support: http://www.vverp.com
|
||||
* License: http://www.vverp.com/license
|
||||
*/
|
||||
package com.vverp.entity;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
|
||||
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
|
||||
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.vverp.annotation.Module;
|
||||
import com.vverp.enums.Education;
|
||||
import com.vverp.enums.NationalityType;
|
||||
import com.vverp.enums.Reservoir;
|
||||
import com.vverp.enums.WorkingState;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* Entity - 管理员
|
||||
*
|
||||
* @author
|
||||
* @version 1.0
|
||||
*/
|
||||
@Entity
|
||||
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "seq_admin")
|
||||
@ExcelTarget("admin")
|
||||
@Module(name = "管理员", generate = false)
|
||||
public class Admin extends BaseEntity<Long> implements java.io.Serializable {
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
public enum Sex {
|
||||
|
||||
/**
|
||||
* 未知
|
||||
*/
|
||||
unknown("未知"),
|
||||
|
||||
/**
|
||||
* 男
|
||||
*/
|
||||
Male("男"),
|
||||
|
||||
/**
|
||||
* 女
|
||||
*/
|
||||
female("女");
|
||||
|
||||
private String message;
|
||||
|
||||
Sex(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Type{
|
||||
supplier,
|
||||
admin
|
||||
}
|
||||
|
||||
/**账号类型*/
|
||||
private Type type = Type.admin;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
@Excel(name = "账号", orderNum = "1", needMerge = true)
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@Excel(name = "姓名", orderNum = "2", needMerge = true)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Excel(name = "手机号", orderNum = "3", needMerge = true)
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@Excel(name = "性别", orderNum = "4", needMerge = true, replace = {"未知_unknown", "男_Male", "女_female"})
|
||||
private Sex sex;
|
||||
|
||||
/**
|
||||
* 是否可用
|
||||
*/
|
||||
@Excel(name = "是否可用", orderNum = "5", needMerge = true, replace = {"是_true", "是_false"})
|
||||
private Boolean isEnabled;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
@ExcelCollection(name = "角色", orderNum = "6")
|
||||
private Set<Role> roles = new HashSet<>();
|
||||
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
@ExcelEntity
|
||||
private Department department;
|
||||
|
||||
/**
|
||||
* 公司
|
||||
*/
|
||||
private Company company;
|
||||
|
||||
/**
|
||||
* 员工编号
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 民族
|
||||
*/
|
||||
private NationalityType nationalityType;
|
||||
|
||||
/**
|
||||
* 学历
|
||||
*/
|
||||
private Education education;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idCard;
|
||||
|
||||
/**
|
||||
* 在职状态
|
||||
*/
|
||||
private WorkingState workingState;
|
||||
|
||||
/**
|
||||
* 户籍地址
|
||||
*/
|
||||
private String censusRegister;
|
||||
|
||||
/**
|
||||
* 现在所居地
|
||||
*/
|
||||
private String presentAddress;
|
||||
|
||||
/**
|
||||
* 入职时间
|
||||
*/
|
||||
private Date hireDate;
|
||||
|
||||
/**
|
||||
* 离职时间
|
||||
*/
|
||||
private Date departureDate;
|
||||
|
||||
/**
|
||||
* 是否为临时工
|
||||
*/
|
||||
private Boolean casualWorker;
|
||||
|
||||
/**
|
||||
* Token
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 消息通知列表
|
||||
*/
|
||||
private List<NoticeEntity> noticeEntityList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 管理的部门列表
|
||||
*/
|
||||
private List<Department> departmentList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 总经办
|
||||
*/
|
||||
private Boolean generalManagerFlag = Boolean.FALSE;
|
||||
|
||||
/**
|
||||
* 公众号openid
|
||||
*/
|
||||
private String mpOpenid;
|
||||
|
||||
/**
|
||||
* 公众号绑定码
|
||||
*/
|
||||
@Excel(name = "公众号绑定码", orderNum = "7", needMerge = true)
|
||||
private String mpBindingCode;
|
||||
|
||||
/**
|
||||
* 库区
|
||||
*/
|
||||
private Reservoir reservoir;
|
||||
|
||||
/**
|
||||
* 可见公司id
|
||||
* -1: 全可见
|
||||
*/
|
||||
private String visibleCompanyIdsStr;
|
||||
|
||||
/**
|
||||
* 可见部门id
|
||||
* -1: 全可见
|
||||
*/
|
||||
private String visibleDepartmentIdsStr;
|
||||
|
||||
/**
|
||||
* 是否只能看到自己所创建的内容
|
||||
*/
|
||||
private Boolean onlySeeSelfFlag = Boolean.FALSE;
|
||||
|
||||
/**
|
||||
* 邮箱密码
|
||||
*/
|
||||
private String emailPassword;
|
||||
|
||||
/**
|
||||
* 设备clientId, 个推推送用
|
||||
*/
|
||||
private String cid;
|
||||
|
||||
/**
|
||||
* 是否需要考勤
|
||||
*/
|
||||
private Boolean attendanceFlag;
|
||||
|
||||
/**当前使用的项目*/
|
||||
private Long nowProgress;
|
||||
|
||||
private List<Supplier> supplierList = new ArrayList<>();
|
||||
|
||||
/**邮箱*/
|
||||
private String email;
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
// private List<Long> productTypeIds = new ArrayList<>();
|
||||
|
||||
private List<AdminPurchase> adminPurchaseList = new ArrayList<>();
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY,cascade = CascadeType.REMOVE,mappedBy = "admin")
|
||||
@JsonIgnore
|
||||
public List<AdminPurchase> getAdminPurchaseList() {
|
||||
return adminPurchaseList;
|
||||
}
|
||||
|
||||
public void setAdminPurchaseList(List<AdminPurchase> adminPurchaseList) {
|
||||
this.adminPurchaseList = adminPurchaseList;
|
||||
}
|
||||
|
||||
// @NotEmpty
|
||||
// @Column(nullable = false, length = 4000)
|
||||
// @Convert(converter = CommonBulkApply.AttachFileConverter.class)
|
||||
// public List<Long> getProductTypeIds() {
|
||||
// return productTypeIds;
|
||||
// }
|
||||
//
|
||||
// public void setProductTypeIds(List<Long> productTypeIds) {
|
||||
// this.productTypeIds = productTypeIds;
|
||||
// }
|
||||
|
||||
|
||||
public Long getNowProgress() {
|
||||
return nowProgress;
|
||||
}
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY,cascade = CascadeType.REMOVE,mappedBy = "admin")
|
||||
@JsonIgnore
|
||||
public List<Supplier> getSupplierList() {
|
||||
return supplierList;
|
||||
}
|
||||
|
||||
public void setSupplierList(List<Supplier> supplierList) {
|
||||
this.supplierList = supplierList;
|
||||
}
|
||||
|
||||
public void setNowProgress(Long nowProgress) {
|
||||
this.nowProgress = nowProgress;
|
||||
}
|
||||
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public Sex getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(Sex sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public Boolean getIsEnabled() {
|
||||
return isEnabled != null ? isEnabled : true;
|
||||
}
|
||||
|
||||
public void setIsEnabled(Boolean isEnabled) {
|
||||
this.isEnabled = isEnabled;
|
||||
}
|
||||
|
||||
@NotEmpty
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "t_admin_role")
|
||||
@JsonIgnore
|
||||
public Set<Role> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(Set<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
public Department getDepartment() {
|
||||
return department;
|
||||
}
|
||||
|
||||
public void setDepartment(Department department) {
|
||||
this.department = department;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
public Company getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
public void setCompany(Company company) {
|
||||
this.company = company;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public NationalityType getNationalityType() {
|
||||
return nationalityType;
|
||||
}
|
||||
|
||||
public void setNationalityType(NationalityType nationalityType) {
|
||||
this.nationalityType = nationalityType;
|
||||
}
|
||||
|
||||
public Education getEducation() {
|
||||
return education;
|
||||
}
|
||||
|
||||
public void setEducation(Education education) {
|
||||
this.education = education;
|
||||
}
|
||||
|
||||
public String getIdCard() {
|
||||
return idCard;
|
||||
}
|
||||
|
||||
public void setIdCard(String idCard) {
|
||||
this.idCard = idCard;
|
||||
}
|
||||
|
||||
public WorkingState getWorkingState() {
|
||||
return workingState;
|
||||
}
|
||||
|
||||
public void setWorkingState(WorkingState workingState) {
|
||||
this.workingState = workingState;
|
||||
}
|
||||
|
||||
public String getCensusRegister() {
|
||||
return censusRegister;
|
||||
}
|
||||
|
||||
public void setCensusRegister(String censusRegister) {
|
||||
this.censusRegister = censusRegister;
|
||||
}
|
||||
|
||||
public String getPresentAddress() {
|
||||
return presentAddress;
|
||||
}
|
||||
|
||||
public void setPresentAddress(String presentAddress) {
|
||||
this.presentAddress = presentAddress;
|
||||
}
|
||||
|
||||
public Date getHireDate() {
|
||||
return hireDate;
|
||||
}
|
||||
|
||||
public void setHireDate(Date hireDate) {
|
||||
this.hireDate = hireDate;
|
||||
}
|
||||
|
||||
public Date getDepartureDate() {
|
||||
return departureDate;
|
||||
}
|
||||
|
||||
public void setDepartureDate(Date departureDate) {
|
||||
this.departureDate = departureDate;
|
||||
}
|
||||
|
||||
@Column(name = "is_casual_worker")
|
||||
public Boolean getCasualWorker() {
|
||||
return casualWorker != null ? casualWorker : false;
|
||||
}
|
||||
|
||||
public void setCasualWorker(Boolean casualWorker) {
|
||||
this.casualWorker = casualWorker;
|
||||
}
|
||||
|
||||
@Column(unique = true, nullable = false, length = 32)
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@OneToMany(mappedBy = "admin", cascade = CascadeType.REMOVE)
|
||||
public List<NoticeEntity> getNoticeEntityList() {
|
||||
return noticeEntityList;
|
||||
}
|
||||
|
||||
public void setNoticeEntityList(List<NoticeEntity> noticeEntityList) {
|
||||
this.noticeEntityList = noticeEntityList;
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
@OneToMany(mappedBy = "directorEntity")
|
||||
public List<Department> getDepartmentList() {
|
||||
return departmentList;
|
||||
}
|
||||
|
||||
public void setDepartmentList(List<Department> departmentList) {
|
||||
this.departmentList = departmentList;
|
||||
}
|
||||
|
||||
public Boolean getGeneralManagerFlag() {
|
||||
return generalManagerFlag != null ? generalManagerFlag : false;
|
||||
}
|
||||
|
||||
public void setGeneralManagerFlag(Boolean generalManagerFlag) {
|
||||
this.generalManagerFlag = generalManagerFlag;
|
||||
}
|
||||
|
||||
public String getMpOpenid() {
|
||||
return mpOpenid;
|
||||
}
|
||||
|
||||
public void setMpOpenid(String mpOpenid) {
|
||||
this.mpOpenid = mpOpenid;
|
||||
}
|
||||
|
||||
public String getMpBindingCode() {
|
||||
return mpBindingCode;
|
||||
}
|
||||
|
||||
public void setMpBindingCode(String mpBindingCode) {
|
||||
this.mpBindingCode = mpBindingCode;
|
||||
}
|
||||
|
||||
@PreRemove
|
||||
public void preRemove() {
|
||||
for (Department department : getDepartmentList()) {
|
||||
if (department != null) {
|
||||
department.setDirectorEntity(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Reservoir getReservoir() {
|
||||
return reservoir;
|
||||
}
|
||||
|
||||
public void setReservoir(Reservoir reservoir) {
|
||||
this.reservoir = reservoir;
|
||||
}
|
||||
|
||||
public String getVisibleCompanyIdsStr() {
|
||||
return visibleCompanyIdsStr != null ? visibleCompanyIdsStr : "-1";
|
||||
}
|
||||
|
||||
public void setVisibleCompanyIdsStr(String visibleCompanyIdsStr) {
|
||||
this.visibleCompanyIdsStr = visibleCompanyIdsStr;
|
||||
}
|
||||
|
||||
public String getVisibleDepartmentIdsStr() {
|
||||
return visibleDepartmentIdsStr != null ? visibleDepartmentIdsStr : "-1";
|
||||
}
|
||||
|
||||
public void setVisibleDepartmentIdsStr(String visibleDepartmentIdsStr) {
|
||||
this.visibleDepartmentIdsStr = visibleDepartmentIdsStr;
|
||||
}
|
||||
|
||||
public Boolean getOnlySeeSelfFlag() {
|
||||
return onlySeeSelfFlag != null ? onlySeeSelfFlag : Boolean.FALSE;
|
||||
}
|
||||
|
||||
public void setOnlySeeSelfFlag(Boolean onlySeeSelfFlag) {
|
||||
this.onlySeeSelfFlag = onlySeeSelfFlag;
|
||||
}
|
||||
|
||||
public String getEmailPassword() {
|
||||
return emailPassword;
|
||||
}
|
||||
|
||||
public void setEmailPassword(String emailPassword) {
|
||||
this.emailPassword = emailPassword;
|
||||
}
|
||||
|
||||
public String getCid() {
|
||||
return cid;
|
||||
}
|
||||
|
||||
public void setCid(String cid) {
|
||||
this.cid = cid;
|
||||
}
|
||||
|
||||
public Boolean getAttendanceFlag() {
|
||||
return attendanceFlag != null ? attendanceFlag : true;
|
||||
}
|
||||
|
||||
public void setAttendanceFlag(Boolean attendanceFlag) {
|
||||
this.attendanceFlag = attendanceFlag;
|
||||
}
|
||||
|
||||
public void setVisibleCompanyIdsStrByArr(Long[] visibleCompanyId) {
|
||||
if (visibleCompanyId == null || visibleCompanyId.length == 0) {
|
||||
setVisibleCompanyIdsStr("-1");
|
||||
} else {
|
||||
if (ArrayUtil.contains(visibleCompanyId, -1L)) {
|
||||
setVisibleCompanyIdsStr("-1");
|
||||
} else {
|
||||
setVisibleCompanyIdsStr(ArrayUtil.join(visibleCompanyId, ","));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisibleDepartmentIdsStrByArr(Long[] visibleDepartmentId) {
|
||||
if (visibleDepartmentId == null || visibleDepartmentId.length == 0) {
|
||||
setVisibleDepartmentIdsStr("-1");
|
||||
} else {
|
||||
if (ArrayUtil.contains(visibleDepartmentId, -1L)) {
|
||||
setVisibleDepartmentIdsStr("-1");
|
||||
} else {
|
||||
setVisibleDepartmentIdsStr(ArrayUtil.join(visibleDepartmentId, ","));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transient
|
||||
public boolean containsRole(String name) {
|
||||
for (Role role : getRoles()) {
|
||||
if (role.getChineseName().equals(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public String getEwoEmail() {
|
||||
return getUsername() + "@runyimail.vverp.com";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user