company.go
2.5 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
package domain
import "time"
// 公司状态状态 1:已注册 2:待认证 3:已认证
const (
CompanyRegistered = iota + 1
CompanyUnauthenticated
CompanyAuthenticated
)
// 企业信息 (base)
type Company struct {
// 企业id
CompanyId int64 `json:"companyId"`
// 企业配置信息
CompanyConfig *CompanyConfig `json:"companyConfig"`
// 企业基本信息
CompanyInfo *CompanyInfo `json:"companyInfo"`
// 公司状态 1:已注册 2:待认证 3:已认证
Status int `json:"status"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt"`
}
type CompanyRepository interface {
Save(company *Company) (*Company, error)
Remove(company *Company) (*Company, error)
FindOne(queryOptions map[string]interface{}) (*Company, error)
Find(queryOptions map[string]interface{}) (int64, []*Company, error)
}
func (company *Company) Identify() interface{} {
if company.CompanyId == 0 {
return nil
}
return company.CompanyId
}
func (company *Company) Update(data map[string]interface{}) error {
if systemName, ok := data["systemName"]; ok {
company.CompanyConfig.SystemName = systemName.(string)
}
if theme, ok := data["theme"]; ok {
company.CompanyConfig.Theme = theme.(string)
}
if companyName, ok := data["companyName"]; ok {
company.CompanyInfo.CompanyName = companyName.(string)
}
if scale, ok := data["scale"]; ok {
company.CompanyInfo.Scale = scale.(string)
}
if logo, ok := data["logo"]; ok {
company.CompanyInfo.Logo = logo.(string)
}
if address, ok := data["address"]; ok {
company.CompanyInfo.Address = address.(string)
}
if industryCategory, ok := data["industryCategory"]; ok {
company.CompanyInfo.IndustryCategory = industryCategory.(string)
}
//if contacts, ok := data["contacts"]; ok {
// company.CompanyInfo.Contacts = contacts.(string)
//}
if registTime, ok := data["registTime"]; ok {
company.CompanyInfo.RegisteredTime = registTime.(time.Time)
}
//if registStatus, ok := data["registStatus"]; ok {
// company.CompanyInfo.Status = registStatus.(int)
//}
if status, ok := data["status"]; ok {
company.Status = status.(int)
}
if createdAt, ok := data["createdAt"]; ok {
company.CreatedAt = createdAt.(time.Time)
}
if updatedAt, ok := data["updatedAt"]; ok {
company.UpdatedAt = updatedAt.(time.Time)
}
return nil
}
func (company *Company) CloneSample() *Company {
return &Company{
CompanyId: company.CompanyId,
Status: company.Status,
CompanyInfo: company.CompanyInfo,
}
}