首次提交

This commit is contained in:
guotao 2026-01-09 12:20:24 +08:00
commit 1101681331
131 changed files with 7017 additions and 0 deletions

View 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);
}
}