-
Notifications
You must be signed in to change notification settings - Fork 3
/
employee.go
98 lines (84 loc) · 3.9 KB
/
employee.go
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
96
97
98
package controller
import (
"context"
"github.com/SupenBysz/gf-admin-community/api_v1"
"github.com/SupenBysz/gf-admin-company-modules/api/co_v1"
"github.com/SupenBysz/gf-admin-company-modules/co_controller"
"github.com/SupenBysz/gf-admin-company-modules/co_interface"
"github.com/SupenBysz/gf-admin-company-modules/co_interface/i_controller"
"github.com/SupenBysz/gf-admin-company-modules/co_model"
"github.com/kysion/base-library/utility/kconv"
)
type EmployeeController[TIRes co_model.IEmployeeRes] struct {
i_controller.IEmployee[TIRes]
}
func Employee[
ITCompanyRes co_model.ICompanyRes,
TIRes co_model.IEmployeeRes,
ITTeamRes co_model.ITeamRes,
ITFdAccountRes co_model.IFdAccountRes,
ITFdAccountBillRes co_model.IFdAccountBillRes,
ITFdBankCardRes co_model.IFdBankCardRes,
ITFdCurrencyRes co_model.IFdCurrencyRes,
ITFdInvoiceRes co_model.IFdInvoiceRes,
ITFdInvoiceDetailRes co_model.IFdInvoiceDetailRes,
](modules co_interface.IModules[
ITCompanyRes,
TIRes,
ITTeamRes,
ITFdAccountRes,
ITFdAccountBillRes,
ITFdBankCardRes,
ITFdCurrencyRes,
ITFdInvoiceRes,
ITFdInvoiceDetailRes,
]) *EmployeeController[TIRes] {
return &EmployeeController[TIRes]{
IEmployee: co_controller.Employee(modules),
}
}
func (c *EmployeeController[TIRes]) GetEmployeeById(ctx context.Context, req *co_v1.GetEmployeeByIdReq) (TIRes, error) {
return c.IEmployee.GetEmployeeById(ctx, &req.GetEmployeeByIdReq)
}
// GetEmployeeDetailById 获取员工详情信息
func (c *EmployeeController[TIRes]) GetEmployeeDetailById(ctx context.Context, req *co_v1.GetEmployeeDetailByIdReq) (TIRes, error) {
return c.IEmployee.GetEmployeeDetailById(ctx, &req.GetEmployeeDetailByIdReq)
}
// HasEmployeeByName 员工名称是否存在
func (c *EmployeeController[TIRes]) HasEmployeeByName(ctx context.Context, req *co_v1.HasEmployeeByNameReq) (api_v1.BoolRes, error) {
return c.IEmployee.HasEmployeeByName(ctx, &req.HasEmployeeByNameReq)
}
// HasEmployeeByNo 员工工号是否存在
func (c *EmployeeController[TIRes]) HasEmployeeByNo(ctx context.Context, req *co_v1.HasEmployeeByNoReq) (api_v1.BoolRes, error) {
return c.IEmployee.HasEmployeeByNo(ctx, &req.HasEmployeeByNoReq)
}
// QueryEmployeeList 查询员工列表
func (c *EmployeeController[TIRes]) QueryEmployeeList(ctx context.Context, req *co_v1.QueryEmployeeListReq) (*co_model.EmployeeListRes, error) {
ret, err := c.IEmployee.QueryEmployeeList(ctx, &req.QueryEmployeeListReq)
return kconv.Struct(ret, &co_model.EmployeeListRes{}), err
}
// CreateEmployee 创建员工信息
func (c *EmployeeController[TIRes]) CreateEmployee(ctx context.Context, req *co_v1.CreateEmployeeReq) (TIRes, error) {
return c.IEmployee.CreateEmployee(ctx, &req.CreateEmployeeReq)
}
// UpdateEmployee 更新员工信息
func (c *EmployeeController[TIRes]) UpdateEmployee(ctx context.Context, req *co_v1.UpdateEmployeeReq) (TIRes, error) {
return c.IEmployee.UpdateEmployee(ctx, &req.UpdateEmployeeReq)
}
// DeleteEmployee 删除员工信息
func (c *EmployeeController[TIRes]) DeleteEmployee(ctx context.Context, req *co_v1.DeleteEmployeeReq) (api_v1.BoolRes, error) {
return c.IEmployee.DeleteEmployee(ctx, &req.DeleteEmployeeReq)
}
func (c *EmployeeController[TIRes]) GetEmployeeListByRoleId(ctx context.Context, req *co_v1.GetEmployeeListByRoleIdReq) (*co_model.EmployeeListRes, error) {
ret, err := c.IEmployee.GetEmployeeListByRoleId(ctx, &req.GetEmployeeListByRoleIdReq)
return kconv.Struct(ret, &co_model.EmployeeListRes{}), err
}
// SetEmployeeRoles 设置员工角色
func (c *EmployeeController[TIRes]) SetEmployeeRoles(ctx context.Context, req *co_v1.SetEmployeeRolesReq) (api_v1.BoolRes, error) {
return c.IEmployee.SetEmployeeRoles(ctx, &req.SetEmployeeRolesReq)
}
// SetEmployeeState 设置员工状态
func (c *EmployeeController[TIRes]) SetEmployeeState(ctx context.Context, req *co_v1.SetEmployeeStateReq) (api_v1.BoolRes, error) {
ret, err := c.IEmployee.SetEmployeeState(ctx, &req.SetEmployeeStateReq)
return ret == true, err
}