attendance_controller.go
4.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/attendance/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/attendance/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/attendance/service"
)
type AttendanceController struct {
beego.BaseController
}
func (controller *AttendanceController) CreateAttendance() {
attendanceService := service.NewAttendanceService(nil)
createAttendanceCommand := &command.CreateAttendanceCommand{}
controller.Unmarshal(createAttendanceCommand)
data, err := attendanceService.CreateAttendance(ParseOperateInfo(controller.BaseController), createAttendanceCommand)
controller.Response(data, err)
}
func (controller *AttendanceController) UpdateAttendance() {
attendanceService := service.NewAttendanceService(nil)
updateAttendanceCommand := &command.UpdateAttendanceCommand{}
controller.Unmarshal(updateAttendanceCommand)
productAttendanceId, _ := controller.GetInt(":productAttendanceId")
updateAttendanceCommand.ProductAttendanceId = productAttendanceId
data, err := attendanceService.UpdateAttendance(updateAttendanceCommand)
controller.Response(data, err)
}
func (controller *AttendanceController) GetAttendance() {
attendanceService := service.NewAttendanceService(nil)
getAttendanceQuery := &query.GetAttendanceQuery{}
productAttendanceId, _ := controller.GetInt(":productAttendanceId")
getAttendanceQuery.ProductAttendanceId = productAttendanceId
data, err := attendanceService.GetAttendance(getAttendanceQuery)
controller.Response(data, err)
}
func (controller *AttendanceController) RemoveAttendance() {
attendanceService := service.NewAttendanceService(nil)
removeAttendanceCommand := &command.RemoveAttendanceCommand{}
controller.Unmarshal(removeAttendanceCommand)
productAttendanceId, _ := controller.GetInt(":productAttendanceId")
removeAttendanceCommand.ProductAttendanceId = productAttendanceId
data, err := attendanceService.RemoveAttendance(removeAttendanceCommand)
controller.Response(data, err)
}
func (controller *AttendanceController) ListAttendance() {
attendanceService := service.NewAttendanceService(nil)
listAttendanceQuery := &query.ListAttendanceQuery{}
offset, _ := controller.GetInt("offset")
listAttendanceQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listAttendanceQuery.Limit = limit
data, err := attendanceService.ListAttendance(listAttendanceQuery)
controller.Response(data, err)
}
func (controller *AttendanceController) ApproveAttendance() {
attendanceService := service.NewAttendanceService(nil)
approveAttendanceCommand := &command.ApproveAttendanceCommand{}
controller.Unmarshal(approveAttendanceCommand)
if approveAttendanceCommand.ApproveUserId == 0 {
operateInfo := ParseOperateInfo(controller.BaseController)
approveAttendanceCommand.ApproveUserId = operateInfo.UserId
}
data, err := attendanceService.ApproveAttendance(approveAttendanceCommand)
controller.Response(data, err)
}
func (controller *AttendanceController) SearchAttendance() {
attendanceService := service.NewAttendanceService(nil)
cmd := &query.SearchAttendanceQuery{}
controller.Unmarshal(cmd)
operateInfo := ParseOperateInfo(controller.BaseController)
//cmd.OrgId = operateInfo.OrgId
cmd.CompanyId = operateInfo.CompanyId
cmd.InOrgIds = operateInfo.OrgIds
total, data, err := attendanceService.SearchAttendance(operateInfo, cmd)
ResponseGrid(controller.BaseController, total, data, err)
}
func (controller *AttendanceController) SearchEmployeeAttendanceStatics() {
attendanceService := service.NewAttendanceService(nil)
cmd := &query.SearchEmployeeAttendanceQuery{}
controller.Unmarshal(cmd)
operateInfo := ParseOperateInfo(controller.BaseController)
//cmd.OrgId = operateInfo.OrgId
cmd.CompanyId = operateInfo.CompanyId
cmd.InOrgIds = operateInfo.OrgIds
total, data, err := attendanceService.SearchEmployeeAttendanceStatics(operateInfo, cmd)
ResponseGrid(controller.BaseController, total, data, err)
}
func (controller *AttendanceController) SearchWorkshopWorkTimeStatics() {
attendanceService := service.NewAttendanceService(nil)
cmd := &query.SearchEmployeeAttendanceQuery{}
controller.Unmarshal(cmd)
operateInfo := ParseOperateInfo(controller.BaseController)
//cmd.OrgId = operateInfo.OrgId
cmd.CompanyId = operateInfo.CompanyId
cmd.InOrgIds = operateInfo.OrgIds
total, data, err := attendanceService.SearchWorkshopWorkTimeStatics(operateInfo, cmd)
ResponseGrid(controller.BaseController, total, data, err)
}