org.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package domain
import "time"
// 组织 organization
type Org struct {
// 组织ID
OrgId int64 `json:"orgId,omitempty"`
// 企业id
CompanyId int64 `json:"companyId,omitempty"`
// 创建时间
CreatedAt time.Time `json:"createdAt,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt,omitempty"`
// 删除时间
DeletedAt time.Time `json:"deletedAt,omitempty"`
// 组织编码
OrgCode string `json:"orgCode,omitempty"`
// 组织名称
OrgName string `json:"orgName,omitempty"`
// 扩展数据
Ext *Ext `json:"ext,omitempty"`
// 是否是组织标识 1:是 2:不是
IsOrg int `json:"isOrg,omitempty"`
// 组织状态 1:启用 2:禁用 3.删除
OrgStatus int `json:"orgStatus,omitempty"`
// 父级ID
ParentId int64 `json:"parentId,omitempty"`
// 父级节点路径("0,11,12,")
ParentPath string `json:"parentPath,omitempty"`
}
type OrgRepository interface {
Save(org *Org) (*Org, error)
Remove(org *Org) (*Org, error)
FindOne(queryOptions map[string]interface{}) (*Org, error)
Find(queryOptions map[string]interface{}) (int64, []*Org, error)
}
func (org *Org) Identify() interface{} {
if org.OrgId == 0 {
return nil
}
return org.OrgId
}
func (org *Org) Update(data map[string]interface{}) error {
if createdAt, ok := data["createdAt"]; ok {
org.CreatedAt = createdAt.(time.Time)
}
if updatedAt, ok := data["updatedAt"]; ok {
org.UpdatedAt = updatedAt.(time.Time)
}
if deletedAt, ok := data["deletedAt"]; ok {
org.DeletedAt = deletedAt.(time.Time)
}
if orgCode, ok := data["orgCode"]; ok {
org.OrgCode = orgCode.(string)
}
if orgName, ok := data["orgName"]; ok {
org.OrgName = orgName.(string)
}
if userName, ok := data["userName"]; ok {
org.Ext.UserName = userName.(string)
}
if orgName, ok := data["orgName"]; ok {
org.Ext.OrgName = orgName.(string)
}
if phone, ok := data["phone"]; ok {
org.Ext.Phone = phone.(string)
}
if depName, ok := data["depName"]; ok {
org.Ext.DepName = depName.(string)
}
if parentDepName, ok := data["parentDepName"]; ok {
org.Ext.ParentDepName = parentDepName.(string)
}
if isOrg, ok := data["isOrg"]; ok {
org.IsOrg = isOrg.(int)
}
if parentId, ok := data["parentId"]; ok {
org.ParentId = parentId.(int64)
}
if parentPath, ok := data["parentPath"]; ok {
org.ParentPath = parentPath.(string)
}
return nil
}
// 部门
type Department struct {
// 部门ID
DepartmentId int64 `json:"departmentId"`
// 部门名称
DepartmentName string `json:"departmentName"`
// 部门编号
DepartmentNumber string `json:"departmentNumber"`
}
// 通过组织获取当前部门信息
func (org *Org) ConvDep() *Department {
return &Department{
DepartmentId: org.OrgId,
DepartmentName: org.OrgName,
DepartmentNumber: org.OrgCode,
}
}