审查视图

pkg/port/beego/controllers/task_controller.go 12.3 KB
tangxvhui authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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
}
tangxvhui authored
15
// 获取任务
tangxvhui authored
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
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)
}
tangxvhui authored
31 32 33 34 35 36 37 38 39 40 41

// 更新任务
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
	}
tangxvhui authored
42 43
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.CompanyId = int(userReq.CompanyId)
郑周 authored
44
	data, err := srv.UpdateTask(paramReq, userReq)
tangxvhui authored
45 46 47
	c.Response(data, err)
}
tangxvhui authored
48 49 50 51 52 53 54 55 56 57
// 更新任务
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
	}
tangxvhui authored
58 59
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.CompanyId = int(userReq.CompanyId)
郑周 authored
60
	resp, err := srv.CreateTask(paramReq, userReq)
tangxvhui authored
61
	c.Response(resp, err)
tangxvhui authored
62 63
}
tangxvhui authored
64 65 66 67 68 69 70 71 72 73
// 启动任务
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
	}
tangxvhui authored
74 75
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.CompanyId = int(userReq.CompanyId)
tangxvhui authored
76 77 78 79 80 81 82 83 84 85 86 87 88 89
	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
	}
tangxvhui authored
90 91
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.CompanyId = int(userReq.CompanyId)
tangxvhui authored
92 93 94 95 96 97 98 99 100 101 102 103 104 105
	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
	}
tangxvhui authored
106 107
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.CompanyId = int(userReq.CompanyId)
tangxvhui authored
108 109 110
	data, err := srv.ListTask(paramReq)
	c.Response(data, err)
}
tangxvhui authored
111
112
// CancelAttention 员工绩效-任务管理列表-取消关注的任务
tangxvhui authored
113 114 115 116 117 118 119 120 121 122
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)
tangxvhui authored
123
	paramReq.UserId = int(userReq.UserId)
tangxvhui authored
124 125 126 127
	paramReq.CompanyId = int(userReq.CompanyId)
	err = srv.CancelAttention(paramReq)
	c.Response(nil, err)
}
128 129 130 131 132 133 134 135 136 137 138 139 140 141

// 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)
tangxvhui authored
142
	result, err := srv.ListTask3(paramReq)
143 144
	c.Response(result, err)
}
tangxvhui authored
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 175 176

// 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)
}
tangxvhui authored
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193

// SelectCondition 员工绩效-任务管理-任务列表-筛选条件
func (c *TaskController) SelectCondition() {
	srv := service.NewTaskService()
	paramReq := &command.GetSelcetCommand{}
	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)
	data, err := srv.ConditionForListTask2(paramReq)
	c.Response(data, err)
}
tangxvhui authored
194
tangxvhui authored
195
// 优先级
tangxvhui authored
196 197 198 199 200 201 202
func (c *TaskController) LevelList() {
	srv := service.NewTaskService()
	userReq := middlewares.GetUser(c.Ctx)
	companyId := int(userReq.CompanyId)
	data, err := srv.ListTaskLevel(companyId)
	c.Response(data, err)
}
tangxvhui authored
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218

// 新建任务优先级
func (c *TaskController) SaveTaskLevel() {
	srv := service.NewTaskService()
	paramReq := &command.CreateTaskLevelCommand{}
	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)
	err = srv.SaveTaskLevel(paramReq)
	c.Response(nil, err)
}
tangxvhui authored
219 220 221 222 223 224 225 226 227 228 229 230

// 取消关注的任务列表
func (c *TaskController) ListTaskIgnore() {
	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)
tangxvhui authored
231
	paramReq.UserId = int(userReq.UserId)
tangxvhui authored
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
	paramReq.CompanyId = int(userReq.CompanyId)
	result, err := srv.ListTaskIgnore(paramReq)
	c.Response(result, err)
}

// 从取消关注的任务列表中移除
func (c *TaskController) CancelIgnore() {
	srv := service.NewTaskService()
	paramReq := &command.CancelIgnoreCommand{}
	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)
tangxvhui authored
249
	paramReq.UserId = int(userReq.UserId)
tangxvhui authored
250 251 252 253
	_, err = srv.CancleTaskIgnore(paramReq)
	c.Response(nil, err)

}
tangxvhui authored
254
tangxvhui authored
255
// 我负责的任务,异常列表
tangxvhui authored
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
func (c *TaskController) TaskAnomalyList1() {
	srv := service.NewTaskService()
	paramReq := &command.ListTaskAnomalyCommand{}
	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)
	resp, err := srv.ListTaskAnomaly1(paramReq)
	c.Response(resp, err)
}
tangxvhui authored
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301

// 我负责的任务,异常列表
func (c *TaskController) TaskAnomalyList3() {
	srv := service.NewTaskService()
	paramReq := &command.ListTaskAnomalyCommand{}
	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)
	resp, err := srv.ListTaskAnomaly3(paramReq)
	c.Response(resp, err)
}

// 我的下级负责任务,异常列表
func (c *TaskController) TaskAnomalyList2() {
	srv := service.NewTaskService()
	paramReq := &command.ListTaskAnomalyCommand{}
	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)
tangxvhui authored
302
	resp, err := srv.ListTaskAnomaly2(paramReq)
tangxvhui authored
303 304
	c.Response(resp, err)
}
tangxvhui authored
305
tangxvhui authored
306
// UserSelect 人员下拉选择
tangxvhui authored
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
func (c *TaskController) UserSelect() {
	srv := service.NewTaskService()
	paramReq := &command.UserSelectCommand{}
	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)
	resp := srv.UserSelect(paramReq)
	c.Response(resp, nil)
}

// 点击操作
func (c *TaskController) TaskAnomalyMark() {
	srv := service.NewTaskService()
	paramReq := &command.MarkTaskAnomalyCommand{}
	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)
	resp, err := srv.MarkTaskAnomaly(paramReq)
	c.Response(resp, err)

}
tangxvhui authored
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372

// 我的下级负责任务,异常列表,结构变体
func (c *TaskController) TaskAnomalyList2Tree() {
	srv := service.NewTaskService()
	paramReq := &command.ListTaskAnomalyCommand{}
	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)
	resp, err := srv.ListTreeTaskAnomaly2(paramReq)
	c.Response(resp, err)
}

// 我相关的负责任务,异常列表,结构变体
func (c *TaskController) TaskAnomalyList3Tree() {
	srv := service.NewTaskService()
	paramReq := &command.ListTaskAnomalyCommand{}
	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)
	resp, err := srv.ListTreeTaskAnomaly2(paramReq)
	c.Response(resp, err)
}
tangxvhui authored
373 374 375 376 377 378 379 380 381 382 383 384 385

// TaskAnomalyInfo 任务异常记录详情
func (c *TaskController) TaskAnomalyInfo() {
	srv := service.NewTaskService()
	paramReq := &command.GetTaskAnomalyCommand{}
	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)
386
	userReq.UserId = userReq.UserId
tangxvhui authored
387 388 389
	resp, err := srv.TaskAnomalyInfo(paramReq)
	c.Response(resp, err)
}
390 391 392 393 394 395 396 397 398 399 400 401 402

// 任务管理列表,对异常点击操作
func (c *TaskController) TaskAnomalyMarkByTask() {
	srv := service.NewTaskService()
	paramReq := &command.MarkTaskAnomalyCommand{}
	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)
403
	paramReq.UserId = int(userReq.UserId)
404 405 406 407
	resp, err := srv.MarkTaskAnomalyByTask(paramReq)
	c.Response(resp, err)

}
tangxvhui authored
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423

func (c *TaskController) SearchTaskAnomaly() {
	srv := service.NewTaskService()
	paramReq := &command.ListTaskAnomalyCommand{}
	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)
	resp, err := srv.ListTaskAnomaly4(paramReq)
	c.Response(resp, err)
}