company.go
2.1 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
package domain
import "time"
// 公司信息
type Company struct {
// 公司Id
CompanyId int64 `json:"companyId"`
// 公司信息
CompanyInfo *CompanyInfo `json:"companyInfo"`
// 创建时间
CreateAt time.Time `json:"createAt"`
// 更新时间
UpdateAt time.Time `json:"updateAt"`
// 删除时间
DeleteAt time.Time `json:"deleteAt"`
}
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 companyId, ok := data["companyId"]; ok {
company.CompanyId = companyId.(int64)
}
if name, ok := data["name"]; ok {
company.CompanyInfo.Name = name.(string)
}
if abbreviation, ok := data["abbreviation"]; ok {
company.CompanyInfo.Abbreviation = abbreviation.(string)
}
if logo, ok := data["logo"]; ok {
company.CompanyInfo.Logo = logo.(string)
}
if phone, ok := data["phone"]; ok {
company.CompanyInfo.Phone = phone.(string)
}
if status, ok := data["status"]; ok {
company.CompanyInfo.Status = status.(int64)
}
if remarks, ok := data["remarks"]; ok {
company.CompanyInfo.Remarks = remarks.(string)
}
if enable, ok := data["enable"]; ok {
company.CompanyInfo.Enable = enable.(int64)
}
if userAccount, ok := data["userAccount"]; ok {
company.CompanyInfo.Admin.UserAccount = userAccount.(string)
}
if userName, ok := data["userName"]; ok {
company.CompanyInfo.Admin.UserName = userName.(string)
}
if createAt, ok := data["createAt"]; ok {
company.CreateAt = createAt.(time.Time)
}
if updateAt, ok := data["updateAt"]; ok {
company.UpdateAt = updateAt.(time.Time)
}
if deleteAt, ok := data["deleteAt"]; ok {
company.DeleteAt = deleteAt.(time.Time)
}
return nil
}
// 更改公司管理员信息
func (company *Company) SetCompanyAdmin(admin *CompanyAdmin) error {
company.CompanyInfo.Admin = admin
return nil
}