首次提交
This commit is contained in:
commit
1101681331
131 changed files with 7017 additions and 0 deletions
103
src/main/java/com/xjhs/findmemerchant/entity/Employee.java
Normal file
103
src/main/java/com/xjhs/findmemerchant/entity/Employee.java
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
package com.xjhs.findmemerchant.entity;
|
||||
|
||||
import com.xjhs.findmemerchant.common.jpa.AbstractBaseEntity;
|
||||
import com.xjhs.findmemerchant.types.CommonStatus;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
/**
|
||||
* 员工实体
|
||||
* 对应表:employees
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(
|
||||
name = "employees",
|
||||
indexes = {
|
||||
@Index(name = "idx_employees_merchant_id", columnList = "merchant_id"),
|
||||
@Index(name = "idx_employees_store_id", columnList = "store_id"),
|
||||
@Index(name = "idx_employees_role_id", columnList = "role_id"),
|
||||
@Index(name = "idx_employees_phone", columnList = "phone")
|
||||
}
|
||||
)
|
||||
public class Employee extends AbstractBaseEntity {
|
||||
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Column(name = "phone", nullable = false, length = 11)
|
||||
@Comment("手机号")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 员工姓名
|
||||
*/
|
||||
@Column(name = "name", nullable = false, length = 50)
|
||||
@Comment("员工姓名")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 状态:0-禁用 1-启用
|
||||
*/
|
||||
@Column(name = "status",columnDefinition = "VARCHAR(15)",length = 15, nullable = false)
|
||||
@Comment("状态:0禁用 1启用")
|
||||
private CommonStatus status = CommonStatus.ENABLED;
|
||||
|
||||
|
||||
|
||||
// ===== 关联关系 =====
|
||||
|
||||
/**
|
||||
* 商户
|
||||
*/
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "merchant_id", insertable = false, updatable = false)
|
||||
private Merchant merchant;
|
||||
|
||||
/**
|
||||
* 门店
|
||||
*/
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "store_id", insertable = false, updatable = false)
|
||||
private Store store;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "role_id", insertable = false, updatable = false)
|
||||
private Role role;
|
||||
|
||||
// ===== 业务方法 =====
|
||||
|
||||
/**
|
||||
* 是否为启用状态
|
||||
*/
|
||||
public boolean isActive() {
|
||||
return this.status == CommonStatus.ENABLED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 状态文案
|
||||
*/
|
||||
public String getStatusText() {
|
||||
CommonStatus e = this.status;
|
||||
return e != null ? e.getDesc() : "未知";
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回脱敏手机号,例如:138****1234
|
||||
*/
|
||||
public String maskPhone() {
|
||||
if (phone == null || phone.length() != 11) {
|
||||
return phone;
|
||||
}
|
||||
return phone.substring(0, 3) + "****" + phone.substring(7);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue