task_controller.go
4.8 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package controllers
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/task/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/task/service"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
)
type TaskController struct {
beego.BaseController
}
// 获取任务
func (c *TaskController) GetTaskInfo() {
srv := service.NewTaskService()
paramReq := &command.GetTaskCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.GetTaskInfo(paramReq)
c.Response(data, err)
}
// 更新任务
func (c *TaskController) UpdateTask() {
srv := service.NewTaskService()
paramReq := &command.UpdateTaskCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
data, err := srv.UpdateTask(paramReq)
c.Response(data, err)
}
// 更新任务
func (c *TaskController) CreateTask() {
srv := service.NewTaskService()
paramReq := &command.CreateTaskCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
err = srv.CreateTaskTest(paramReq)
c.Response(nil, err)
}
// 启动任务
func (c *TaskController) RunTask() {
srv := service.NewTaskService()
paramReq := &command.RunTaskCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.RunTask(paramReq)
c.Response(data, err)
}
// 启动任务
func (c *TaskController) StopTask() {
srv := service.NewTaskService()
paramReq := &command.StopTaskCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.StopTask(paramReq)
c.Response(data, err)
}
// 任务列表
func (c *TaskController) ListTask() {
srv := service.NewTaskService()
paramReq := &command.ListTaskCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.ListTask(paramReq)
c.Response(data, err)
}
// CancelAttention 员工绩效-任务管理列表-取消关注的任务
func (c *TaskController) CancelAttention() {
srv := service.NewTaskService()
paramReq := &command.CancelAttentionCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.UserId = int(userReq.UserId)
paramReq.CompanyId = int(userReq.CompanyId)
err = srv.CancelAttention(paramReq)
c.Response(nil, err)
}
// ListTask2 员工绩效-任务管理列表
func (c *TaskController) ListTask2() {
srv := service.NewTaskService()
paramReq := &command.SearchTaskCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.UserId = int(userReq.UserId)
result, err := srv.ListTask2(paramReq)
c.Response(result, err)
}
// ListTaskRecord 员工绩效-获取任务反馈列表
func (c *TaskController) ListTaskRecord() {
srv := service.NewTaskService()
paramReq := &command.ListTaskRecordCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
result, err := srv.ListTaskRecord(paramReq)
c.Response(result, err)
}
// DeleteTask 删除任务
func (c *TaskController) DeleteTask() {
srv := service.NewTaskService()
paramReq := &command.GetTaskCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.DeleteTaskInfo(paramReq)
c.Response(data, err)
}