partner_info.go
2.2 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
package domain
import "time"
type PartnerInfoRepository interface {
Save(dm *PartnerInfo) (*PartnerInfo, error)
Remove(dm *PartnerInfo) (*PartnerInfo, error)
FindOne(queryOptions map[string]interface{}) (*PartnerInfo, error)
Find(queryOptions map[string]interface{}) (int64, []*PartnerInfo, error)
}
type PartnerInfo struct {
// 合伙人ID
Id int64 `json:"id"`
// 合伙人姓名
PartnerName string `json:"partnerName"`
// 登录账号
Account string `json:"account"`
// 登录密码
Password string `json:"password"`
// 状态(1:启用或者0:禁用)
Status int `json:"status"`
// 合伙类别 (1.事业合伙人 2.业务合伙人 3.研发合伙人)
PartnerCategory int `json:"partnerCategory"`
//所属区域信息
RegionInfo *RegionInfo `json:"regionId"`
//合作时间
CooperateTime time.Time `json:"cooperateTime"`
//创建时间
CreateAt time.Time `json:"createAt"`
//更新时间
UpdateAt time.Time `json:"updateAt"`
//关联业务员
Salesman []*Salesman `json:"salesman"`
}
func (m *PartnerInfo) Identify() interface{} {
if m.Id == 0 {
return nil
}
return m.Id
}
func (m *PartnerInfo) Update(data map[string]interface{}) error {
if partnerName, ok := data["partnerName"]; ok && partnerName != "" {
m.PartnerName = partnerName.(string)
}
if account, ok := data["account"]; ok && account != "" {
m.Account = account.(string)
}
if password, ok := data["password"]; ok && password != "" {
m.Password = password.(string)
}
if status, ok := data["status"]; ok && status != 0 {
m.Status = status.(int)
}
if partnerCategory, ok := data["partnerCategory"]; ok && partnerCategory != 0 {
m.PartnerCategory = partnerCategory.(int)
}
if salesman, ok := data["salesman"]; ok {
m.Salesman = salesman.([]*Salesman)
}
m.UpdateAt = time.Now()
return nil
}
func (m *PartnerInfo) PartnerCategoryInfo() *PartnerCategoryInfo {
var name string
switch m.PartnerCategory {
case 1:
name = "事业合伙人"
break
case 2:
name = "业务合伙人"
break
case 3:
name = "研发合伙人"
break
default:
name = "事业合伙人"
break
}
return &PartnerCategoryInfo{
Id: m.PartnerCategory,
Name: name,
}
}
type PartnerCategoryInfo struct {
Id int `json:"id"`
Name string `json:"name"`
}