employee.go
1.4 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
package domain
// 员工
type Employee struct {
// 员工ID
EmployeeId int64 `json:"employeeId"`
// 公司ID
CompanyId int64 `json:"companyId"`
// 员工信息
EmployeeInfo *EmployeeInfo `json:"employeeInfo"`
// 当前素币
SuMoney float64 `json:"suMoney"`
// 员工状态(启用或者禁用)
Status int `json:"status"`
}
type EmployeeRepository interface {
Save(employee *Employee) (*Employee, error)
Remove(employee *Employee) (*Employee, error)
FindOne(queryOptions map[string]interface{}) (*Employee, error)
Find(queryOptions map[string]interface{}) (int64, []*Employee, error)
}
func (employee *Employee) Identify() interface{} {
if employee.EmployeeId == 0 {
return nil
}
return employee.EmployeeId
}
func (employee *Employee) Update(data map[string]interface{}) error {
if employeeName, ok := data["employeeName"]; ok {
employee.EmployeeInfo.EmployeeName = employeeName.(string)
}
if employeeAccount, ok := data["employeeAccount"]; ok {
employee.EmployeeInfo.EmployeeAccount = employeeAccount.(string)
}
if status, ok := data["status"]; ok {
employee.Status = status.(int)
}
return nil
}
func (employee *Employee) TransferSuMoney(suMoney float64) error {
employee.SuMoney = employee.SuMoney + suMoney
return nil
}
func (employee *Employee) TransitionSuMoney(suMoney float64) error {
employee.SuMoney = employee.SuMoney + suMoney
return nil
}