sys_employee.go
2.7 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
package models
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain"
"gorm.io/gorm"
"gorm.io/plugin/soft_delete"
"time"
)
type SysEmployee struct {
Id int64 // 唯一标识
UserId int64 // 用户表ID
CompanyId int64 // 公司表ID
Code string `gorm:"type:varchar(128)"` // 自定义编码(成员的唯一标识、员工编号、工号等)
//Departments []int64 `gorm:"type:jsonb;serializer:json"` // 归属部门列表
//Name string `gorm:"type:varchar(64)"` // 姓名
//Avatar string `gorm:"type:varchar(1024)"` // 头像
//Phone string `gorm:"type:varchar(64)"` // 手机号码
Position string `gorm:"type:varchar(128)"` // 职务
AccountStatus int // 账号状态 0.未激活 1.正常 2.已暂停 4.未加入 5.主动退出
EmployeeType string `gorm:"type:varchar(64)"` // 雇员类型 正式、实习、外包、劳务、顾问
BaseInfo domain.EmployeeBaseInfo `gorm:"type:jsonb;serializer:json"` // 基本信息
WorkInfo domain.EmployeeWorkInfo `gorm:"type:jsonb;serializer:json"` // 工作信息
CreatedAt int64
UpdatedAt int64
DeletedAt int64
Version int
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
}
func (m *SysEmployee) TableName() string {
return "sys.employee"
}
func (m *SysEmployee) BeforeCreate(tx *gorm.DB) (err error) {
m.CreatedAt = time.Now().Unix()
m.UpdatedAt = time.Now().Unix()
return
}
func (m *SysEmployee) BeforeUpdate(tx *gorm.DB) (err error) {
// m.UpdatedAt = time.Now().Unix()
return
}
func (m *SysEmployee) CacheKeyFunc() string {
if m.Id == 0 {
return ""
}
return fmt.Sprintf("%v:cache:%v:id:%v", domain.ProjectName, m.TableName(), m.Id)
}
func (m *SysEmployee) CacheKeyFuncByObject(obj interface{}) string {
if v, ok := obj.(*SysEmployee); ok {
return v.CacheKeyFunc()
}
return ""
}
func (m *SysEmployee) CachePrimaryKeyFunc() string {
if len("") == 0 {
return ""
}
return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key")
}
func (m *SysEmployee) CachePrimaryKeyCompanyPhoneFunc() string {
//if m.CompanyId == 0 || m.Phone == "" {
// return ""
//}
//return fmt.Sprintf("%v:cache:%v:primarykey:%v:%v", domain.ProjectName, m.TableName(), m.CompanyId, m.Phone)
return ""
}
func (m *SysEmployee) CachePrimaryKeyCompanyUserFunc() string {
if m.CompanyId == 0 || m.UserId == 0 {
return ""
}
return fmt.Sprintf("%v:cache:%v:primarykey:%v:%v", domain.ProjectName, m.TableName(), m.CompanyId, m.UserId)
}