company.go
1.9 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
package domain
import (
"fmt"
"time"
)
// 公司的状态 1正常 2禁用
const (
companyStatusUsable int8 = 1
companyStatusUnusable int8 = 2
)
//是否开启机会模块,是否有效【1:有效】【2:无效】
const (
CompanyEnableYes int8 = 1
CompanyEnableNo int8 = 2
)
// 公司信息
type Company struct {
// 唯一标识
Id int64 `json:"id"`
// 名称
Name string `json:"name"`
//简称
Abbreviation string `json:"abbreviation"`
// 手机号码
Phone string `json:"phone"`
// 公司logo
Logo string `json:"logo"`
// 备注
Remarks string `json:"remarks"`
// 总后台的公司id
AdminCompanyId int `json:"adminCompanyId"`
//是否有效【1:有效】【2:无效】
Enable int8 `json:"enable"`
// 创建时间
CreateAt time.Time `json:"createAt"`
// 更新时间
UpdateAt time.Time `json:"updateAt"`
// 删除时间
DeleteAt time.Time `json:"deleteAt"`
}
// func (c Company) StatusIsOk() bool {
// return c.Status == companyStatusUsable
// }
func (c Company) EnableIsOk() bool {
return c.Enable == CompanyEnableYes
}
func (c *Company) Update(m map[string]interface{}) error {
if v, ok := m["Name"]; ok {
c.Name = fmt.Sprint(v)
}
if v, ok := m["Phone"]; ok {
c.Phone = fmt.Sprint(v)
}
if v, ok := m["Logo"]; ok {
c.Logo = fmt.Sprint(v)
}
if v, ok := m["Remarks"]; ok {
c.Remarks = fmt.Sprint(v)
}
if v, ok := m["AdminCompanyId"]; ok {
c.AdminCompanyId = v.(int)
}
if v, ok := m["Remarks"]; ok {
c.Remarks = fmt.Sprint(v)
}
if v, ok := m["Enable"]; ok {
c.Enable = v.(int8)
}
if v, ok := m["Abbreviation"]; ok {
c.Abbreviation = v.(string)
}
return nil
}
type CompanyFindOneOptions struct {
Id int64
AdminCompanyId int64
}
type CompanyFindOptions struct {
}
type CompanyRepository interface {
Add(*Company) error
Edit(*Company) error
FindOne(queryOptions CompanyFindOneOptions) (Company, error)
Find(queryOptions CompanyFindOptions) (int64, []Company, error)
}