Merge branch 'dev-tangxvhui' into test
正在显示
11 个修改的文件
包含
430 行增加
和
61 行删除
@@ -459,6 +459,12 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess) | @@ -459,6 +459,12 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess) | ||
459 | if len(taskList) == 0 { | 459 | if len(taskList) == 0 { |
460 | continue | 460 | continue |
461 | } | 461 | } |
462 | + if taskList[0].UseEndTime == 1 { | ||
463 | + if staffAssess.BeginTime.Unix() > taskList[0].EndTime { | ||
464 | + continue | ||
465 | + } | ||
466 | + | ||
467 | + } | ||
462 | //获取里程碑数据 | 468 | //获取里程碑数据 |
463 | _, taskStageList, err := taskStageRepo.Find(map[string]interface{}{ | 469 | _, taskStageList, err := taskStageRepo.Find(map[string]interface{}{ |
464 | "taskId": taskList[0].Id, | 470 | "taskId": taskList[0].Id, |
@@ -493,7 +499,9 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess) | @@ -493,7 +499,9 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess) | ||
493 | } | 499 | } |
494 | } | 500 | } |
495 | } | 501 | } |
496 | - taskRecordList = append(taskRecordList, &newTaskRecord) | 502 | + if newTaskRecord.TaskStageCheck.Id > 0 { |
503 | + taskRecordList = append(taskRecordList, &newTaskRecord) | ||
504 | + } | ||
497 | } | 505 | } |
498 | 506 | ||
499 | if err := transactionContext.CommitTransaction(); err != nil { | 507 | if err := transactionContext.CommitTransaction(); err != nil { |
1 | package adapter | 1 | package adapter |
2 | 2 | ||
3 | type TaskInfoAdapter struct { | 3 | type TaskInfoAdapter struct { |
4 | - Id int `json:"id,string"` | ||
5 | - Name string `json:"name"` // 任务名称 | ||
6 | - Alias string `json:"alias"` // 任务别名 | ||
7 | - LeaderId int64 `json:"leaderId,string"` // | ||
8 | - Leader UserData `json:"leader"` // 任务负责人 | ||
9 | - Status int `json:"status"` // 任务的状态 | ||
10 | - StatusDescription string `json:"statusDescription"` // | ||
11 | - Level int `json:"level"` // 优先级,值越小优先级越高 | ||
12 | - LevelName string `json:"levelName"` // 优先级名称 | ||
13 | - RelatedUserId []string `json:"relatedUserId"` // 相关的员工id | ||
14 | - RelatedUser []UserData `json:"relatedUser"` // 相关的员工id | ||
15 | - StageList []TaskStage `json:"stageList"` | 4 | + Id int `json:"id,string"` |
5 | + Name string `json:"name"` // 任务名称 | ||
6 | + Alias string `json:"alias"` // 任务别名 | ||
7 | + LeaderId int64 `json:"leaderId,string"` // | ||
8 | + Leader UserData `json:"leader"` // 任务负责人 | ||
9 | + Status int `json:"status"` // 任务的状态 | ||
10 | + StatusDescription string `json:"statusDescription"` // | ||
11 | + // Level int `json:"level"` // 优先级,值越小优先级越高 | ||
12 | + LevelName string `json:"levelName"` // 任务类别名称 | ||
13 | + SortBy int `json:"sortBy"` // 优先级排序;值越小优先级越高 | ||
14 | + EndTime int64 `json:"endTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间 | ||
15 | + UseEndtime int `json:"useEndTime"` // 是否应用任务截止的时间;默认值0:不应用,1:应用 | ||
16 | + RelatedUserId []string `json:"relatedUserId"` // 相关的员工id | ||
17 | + RelatedUser []UserData `json:"relatedUser"` // 相关的员工id | ||
18 | + StageList []TaskStage `json:"stageList"` | ||
16 | } | 19 | } |
17 | 20 | ||
18 | type UserData struct { | 21 | type UserData struct { |
@@ -8,6 +8,6 @@ type SearchTaskCommand struct { | @@ -8,6 +8,6 @@ type SearchTaskCommand struct { | ||
8 | OnlyMy bool `json:"onlyMy"` //只查看我负责的任务 | 8 | OnlyMy bool `json:"onlyMy"` //只查看我负责的任务 |
9 | SearchWord string `json:"searchWord"` | 9 | SearchWord string `json:"searchWord"` |
10 | // TaskName string `json:"taskName"` //任务名称 | 10 | // TaskName string `json:"taskName"` //任务名称 |
11 | - // LevelName string `json:"levelName"` //优先级 | 11 | + LevelName string `json:"levelName"` //任务类型 |
12 | // LeaderName string `json:"leaderId"` //任务负责人id | 12 | // LeaderName string `json:"leaderId"` //任务负责人id |
13 | } | 13 | } |
@@ -73,7 +73,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont | @@ -73,7 +73,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont | ||
73 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询任务失败:"+err.Error()) | 73 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询任务失败:"+err.Error()) |
74 | } | 74 | } |
75 | if cnt > 0 { | 75 | if cnt > 0 { |
76 | - //TODO | 76 | + |
77 | //任务已存在 | 77 | //任务已存在 |
78 | return nil | 78 | return nil |
79 | } | 79 | } |
@@ -172,11 +172,11 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | @@ -172,11 +172,11 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | ||
172 | defer func() { | 172 | defer func() { |
173 | _ = transactionContext.RollbackTransaction() | 173 | _ = transactionContext.RollbackTransaction() |
174 | }() | 174 | }() |
175 | - if len(param.StageList) < 3 { | ||
176 | - return map[string]interface{}{ | ||
177 | - "id": param.Id, | ||
178 | - }, application.ThrowError(application.INTERNAL_SERVER_ERROR, "里程碑数量至少3个") | ||
179 | - } | 175 | + // if len(param.StageList) < 3 { |
176 | + // return map[string]interface{}{ | ||
177 | + // "id": param.Id, | ||
178 | + // }, application.ThrowError(application.INTERNAL_SERVER_ERROR, "里程碑数量至少3个") | ||
179 | + // } | ||
180 | if len(param.StageList) > 5 { | 180 | if len(param.StageList) > 5 { |
181 | return map[string]interface{}{ | 181 | return map[string]interface{}{ |
182 | "id": param.Id, | 182 | "id": param.Id, |
@@ -212,31 +212,15 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | @@ -212,31 +212,15 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | ||
212 | var relatedUser []*domain.User | 212 | var relatedUser []*domain.User |
213 | if len(relatedUserIds) > 0 { | 213 | if len(relatedUserIds) > 0 { |
214 | _, relatedUser, err = userRepo.Find(map[string]interface{}{ | 214 | _, relatedUser, err = userRepo.Find(map[string]interface{}{ |
215 | - "ids": relatedUserIds, | 215 | + "ids": relatedUserIds, |
216 | + "companyId": param.CompanyId, | ||
216 | }) | 217 | }) |
217 | if err != nil { | 218 | if err != nil { |
218 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务的相关人员"+err.Error()) | 219 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务的相关人员"+err.Error()) |
219 | } | 220 | } |
220 | } | 221 | } |
221 | - _, leaderList, err := userRepo.Find(map[string]interface{}{ | ||
222 | - "id": taskData.Leader.Id, | ||
223 | - }) | ||
224 | - if err != nil { | ||
225 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询人员失败:"+err.Error()) | ||
226 | - } | ||
227 | - if len(leaderList) == 0 { | ||
228 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有查询到人员") | ||
229 | - } | ||
230 | - leaderData := leaderList[0] | ||
231 | - //更新相关人员 | ||
232 | - taskData.RelatedUser = []int{int(leaderData.Id)} | ||
233 | - if leaderData.ParentId != 0 { | ||
234 | - taskData.RelatedUser = append(taskData.RelatedUser, int(leaderData.ParentId)) | ||
235 | - } | 222 | + taskData.RelatedUser = []int{} |
236 | for _, val := range relatedUser { | 223 | for _, val := range relatedUser { |
237 | - if val.Id == leaderData.Id || val.Id == leaderData.ParentId { | ||
238 | - continue | ||
239 | - } | ||
240 | taskData.RelatedUser = append(taskData.RelatedUser, int(val.Id)) | 224 | taskData.RelatedUser = append(taskData.RelatedUser, int(val.Id)) |
241 | } | 225 | } |
242 | //更新任务名称 | 226 | //更新任务名称 |
@@ -314,7 +298,8 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | @@ -314,7 +298,8 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | ||
314 | } | 298 | } |
315 | taskData.SetCurrentStage(stageList) | 299 | taskData.SetCurrentStage(stageList) |
316 | taskData.SetSortBy(param.SortBy) | 300 | taskData.SetSortBy(param.SortBy) |
317 | - taskData.EndTime = param.EndTime | 301 | + //处理endTime |
302 | + taskData.EndTime = dayEndTime(time.Unix(param.EndTime, 10)).Unix() | ||
318 | taskData.UseEndTime = param.UseEndtime | 303 | taskData.UseEndTime = param.UseEndtime |
319 | err = taskRepo.Save(taskData) | 304 | err = taskRepo.Save(taskData) |
320 | if err != nil { | 305 | if err != nil { |
@@ -323,7 +308,7 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | @@ -323,7 +308,7 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | ||
323 | messageRepo := factory.CreateMessagePersonalRepository(map[string]interface{}{ | 308 | messageRepo := factory.CreateMessagePersonalRepository(map[string]interface{}{ |
324 | "transactionContext": transactionContext, | 309 | "transactionContext": transactionContext, |
325 | }) | 310 | }) |
326 | - //更具markStage 记录的里程碑数据生成通知 | 311 | + //根据markStage 记录的里程碑数据生成通知 |
327 | for _, val := range markStage { | 312 | for _, val := range markStage { |
328 | for _, val2 := range taskData.RelatedUser { | 313 | for _, val2 := range taskData.RelatedUser { |
329 | t1 := time.Unix(val.PlanCompletedAt, 0).Format("2006-01-02") | 314 | t1 := time.Unix(val.PlanCompletedAt, 0).Format("2006-01-02") |
@@ -486,11 +471,14 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | @@ -486,11 +471,14 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | ||
486 | }, | 471 | }, |
487 | Status: int(taskData.Status), | 472 | Status: int(taskData.Status), |
488 | StatusDescription: taskData.StatusDescription(), | 473 | StatusDescription: taskData.StatusDescription(), |
489 | - Level: taskData.Level, | ||
490 | - LevelName: taskData.LevelName, | ||
491 | - RelatedUserId: []string{}, | ||
492 | - RelatedUser: []adapter.UserData{}, | ||
493 | - StageList: []adapter.TaskStage{}, | 474 | + // Level: taskData.Level, |
475 | + LevelName: taskData.LevelName, | ||
476 | + SortBy: int(taskData.SortBy), | ||
477 | + EndTime: taskData.EndTime, | ||
478 | + UseEndtime: taskData.UseEndTime, | ||
479 | + RelatedUserId: []string{}, | ||
480 | + RelatedUser: []adapter.UserData{}, | ||
481 | + StageList: []adapter.TaskStage{}, | ||
494 | } | 482 | } |
495 | for _, val := range relatedUserList { | 483 | for _, val := range relatedUserList { |
496 | idStr := strconv.Itoa(int(val.Id)) | 484 | idStr := strconv.Itoa(int(val.Id)) |
@@ -910,6 +898,22 @@ func (srv TaskService) DeleteTaskInfo(param *command.GetTaskCommand) (*adapter.T | @@ -910,6 +898,22 @@ func (srv TaskService) DeleteTaskInfo(param *command.GetTaskCommand) (*adapter.T | ||
910 | if err != nil { | 898 | if err != nil { |
911 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "xx"+err.Error()) | 899 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "xx"+err.Error()) |
912 | } | 900 | } |
901 | + | ||
902 | + taskIgnoreRepo := factory.CreateTaskIgnoreRepository(map[string]interface{}{ | ||
903 | + "transactionContext": transactionContext, | ||
904 | + }) | ||
905 | + _, taskIgnoreList, err := taskIgnoreRepo.Find(map[string]interface{}{ | ||
906 | + "taskId": param.TaskId, | ||
907 | + }) | ||
908 | + if err != nil { | ||
909 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "xx"+err.Error()) | ||
910 | + } | ||
911 | + for _, v := range taskIgnoreList { | ||
912 | + err = taskIgnoreRepo.Remove(v.Id) | ||
913 | + if err != nil { | ||
914 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
915 | + } | ||
916 | + } | ||
913 | if err := transactionContext.CommitTransaction(); err != nil { | 917 | if err := transactionContext.CommitTransaction(); err != nil { |
914 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 918 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
915 | } | 919 | } |
@@ -1026,6 +1030,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i | @@ -1026,6 +1030,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i | ||
1026 | CompanyId: param.CompanyId, | 1030 | CompanyId: param.CompanyId, |
1027 | OnlyMy: param.OnlyMy, | 1031 | OnlyMy: param.OnlyMy, |
1028 | SearchWord: param.SearchWord, | 1032 | SearchWord: param.SearchWord, |
1033 | + LevelName: param.LevelName, | ||
1029 | } | 1034 | } |
1030 | 1035 | ||
1031 | taskDao := dao.NewTaskDao(map[string]interface{}{ | 1036 | taskDao := dao.NewTaskDao(map[string]interface{}{ |
@@ -1041,7 +1046,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i | @@ -1041,7 +1046,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i | ||
1041 | if err != nil { | 1046 | if err != nil { |
1042 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error()) | 1047 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error()) |
1043 | } | 1048 | } |
1044 | - //里程碑异常s | 1049 | + //里程碑异常 |
1045 | taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyNotHrbp(condition) | 1050 | taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyNotHrbp(condition) |
1046 | if err != nil { | 1051 | if err != nil { |
1047 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计异常的任务里程碑总数"+err.Error()) | 1052 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计异常的任务里程碑总数"+err.Error()) |
@@ -1172,6 +1177,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s | @@ -1172,6 +1177,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s | ||
1172 | CompanyId: param.CompanyId, | 1177 | CompanyId: param.CompanyId, |
1173 | OnlyMy: param.OnlyMy, | 1178 | OnlyMy: param.OnlyMy, |
1174 | SearchWord: param.SearchWord, | 1179 | SearchWord: param.SearchWord, |
1180 | + LevelName: param.LevelName, | ||
1175 | } | 1181 | } |
1176 | 1182 | ||
1177 | taskDao := dao.NewTaskDao(map[string]interface{}{ | 1183 | taskDao := dao.NewTaskDao(map[string]interface{}{ |
@@ -1321,3 +1327,174 @@ func (srv TaskService) ListTaskLevel(companyId int) (map[string]interface{}, err | @@ -1321,3 +1327,174 @@ func (srv TaskService) ListTaskLevel(companyId int) (map[string]interface{}, err | ||
1321 | } | 1327 | } |
1322 | return result, nil | 1328 | return result, nil |
1323 | } | 1329 | } |
1330 | + | ||
1331 | +// 取消关注的任务列表 | ||
1332 | +func (srv *TaskService) ListTaskIgnore(param *command.SearchTaskCommand) (result map[string]interface{}, err error) { | ||
1333 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
1334 | + if err != nil { | ||
1335 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1336 | + } | ||
1337 | + if err := transactionContext.StartTransaction(); err != nil { | ||
1338 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1339 | + } | ||
1340 | + defer func() { | ||
1341 | + _ = transactionContext.RollbackTransaction() | ||
1342 | + }() | ||
1343 | + var limit = 20 | ||
1344 | + var offset = 0 | ||
1345 | + if param.PageSize > 0 { | ||
1346 | + limit = param.PageSize | ||
1347 | + if param.PageNumber > 0 { | ||
1348 | + offset = (param.PageNumber - 1) * param.PageSize | ||
1349 | + } | ||
1350 | + } | ||
1351 | + param.SearchWord = strings.TrimSpace(param.SearchWord) | ||
1352 | + if len(param.SearchWord) > 0 { | ||
1353 | + param.SearchWord = "%" + param.SearchWord + "%" | ||
1354 | + } | ||
1355 | + condition := dao.ListTaskCondition{ | ||
1356 | + Limit: limit, | ||
1357 | + Offset: offset, | ||
1358 | + UserId: param.UserId, | ||
1359 | + CompanyId: param.CompanyId, | ||
1360 | + OnlyMy: param.OnlyMy, | ||
1361 | + SearchWord: param.SearchWord, | ||
1362 | + LevelName: param.LevelName, | ||
1363 | + } | ||
1364 | + | ||
1365 | + taskDao := dao.NewTaskDao(map[string]interface{}{ | ||
1366 | + "transactionContext": transactionContext, | ||
1367 | + }) | ||
1368 | + //任务列表数据 | ||
1369 | + taskListData, err := taskDao.ListTaskIgnore(condition) | ||
1370 | + if err != nil { | ||
1371 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error()) | ||
1372 | + } | ||
1373 | + //查到的任务数据总数 | ||
1374 | + taskCount, err := taskDao.CountTaskIgnore(condition) | ||
1375 | + if err != nil { | ||
1376 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error()) | ||
1377 | + } | ||
1378 | + | ||
1379 | + taskResult := []*adapter.TaskItem{} | ||
1380 | + taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{ | ||
1381 | + "transactionContext": transactionContext, | ||
1382 | + }) | ||
1383 | + nowTime := time.Now().Unix() | ||
1384 | + for _, val := range taskListData { | ||
1385 | + tk := adapter.TaskItem{ | ||
1386 | + Id: val.TaskId, | ||
1387 | + Name: "", | ||
1388 | + Alias: val.Alias, | ||
1389 | + Leader: val.LeaderName, | ||
1390 | + Status: val.Status, | ||
1391 | + Level: val.Level, | ||
1392 | + LevelName: val.LevelName, | ||
1393 | + UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"), | ||
1394 | + Anomaly: val.Anomaly, | ||
1395 | + WarnFlag: 0, | ||
1396 | + LastStage: adapter.TaskStage{ | ||
1397 | + Id: val.LastStage.Id, | ||
1398 | + Name: val.LastStage.Name, | ||
1399 | + StatusDescription: val.LastStage.StatusDescription(), | ||
1400 | + SortBy: val.LastStage.SortBy, | ||
1401 | + PlanCompletedAt: time.Unix(int64(val.LastStage.PlanCompletedAt), 0).Local().Format("2006-01-02"), | ||
1402 | + RealCompletedAt: "", | ||
1403 | + IsRef: false, | ||
1404 | + }, | ||
1405 | + CurrentStage: adapter.TaskStage{ | ||
1406 | + Id: val.CurrentStage.Id, | ||
1407 | + Name: val.CurrentStage.Name, | ||
1408 | + StatusDescription: val.CurrentStage.StatusDescription(), | ||
1409 | + SortBy: val.CurrentStage.SortBy, | ||
1410 | + PlanCompletedAt: time.Unix(int64(val.CurrentStage.PlanCompletedAt), 0).Local().Format("2006-01-02"), | ||
1411 | + RealCompletedAt: "", | ||
1412 | + IsRef: false, | ||
1413 | + }, | ||
1414 | + } | ||
1415 | + if val.LastStage.RealCompletedAt > 0 { | ||
1416 | + tk.LastStage.RealCompletedAt = time.Unix(int64(val.LastStage.RealCompletedAt), 0).Local().Format("2006-01-02") | ||
1417 | + } | ||
1418 | + if val.CurrentStage.RealCompletedAt > 0 { | ||
1419 | + tk.CurrentStage.RealCompletedAt = time.Unix(int64(val.CurrentStage.RealCompletedAt), 0).Local().Format("2006-01-02") | ||
1420 | + } | ||
1421 | + if val.LastStage.Id > 0 && val.LastStage.PlanCompletedAt < val.LastStage.RealCompletedAt { | ||
1422 | + tk.WarnFlag = int(domain.TaskWarn) | ||
1423 | + } | ||
1424 | + if val.CurrentStage.Id > 0 && val.CurrentStage.PlanCompletedAt < nowTime { | ||
1425 | + tk.WarnFlag = int(domain.TaskWarn) | ||
1426 | + } | ||
1427 | + _, stageList, err := taskStageRepo.Find(map[string]interface{}{ | ||
1428 | + "taskId": val.TaskId, | ||
1429 | + }) | ||
1430 | + if err != nil { | ||
1431 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务里程碑"+err.Error()) | ||
1432 | + } | ||
1433 | + | ||
1434 | + for _, val2 := range stageList { | ||
1435 | + stage := adapter.TaskStage{ | ||
1436 | + Id: val2.Id, | ||
1437 | + Name: val2.Name, | ||
1438 | + SortBy: val2.SortBy, | ||
1439 | + PlanCompletedAt: time.Unix(int64(val2.PlanCompletedAt), 0).Local().Format("2006-01-02"), | ||
1440 | + RealCompletedAt: "", | ||
1441 | + } | ||
1442 | + if val2.RealCompletedAt > 0 { | ||
1443 | + stage.RealCompletedAt = time.Unix(int64(val2.RealCompletedAt), 0).Local().Format("2006-01-02") | ||
1444 | + } | ||
1445 | + switch val2.SortBy { | ||
1446 | + case 1: | ||
1447 | + tk.StageA = stage | ||
1448 | + case 2: | ||
1449 | + tk.StageB = stage | ||
1450 | + case 3: | ||
1451 | + tk.StageC = stage | ||
1452 | + case 4: | ||
1453 | + tk.StageD = stage | ||
1454 | + case 5: | ||
1455 | + tk.StageE = stage | ||
1456 | + } | ||
1457 | + } | ||
1458 | + taskResult = append(taskResult, &tk) | ||
1459 | + } | ||
1460 | + | ||
1461 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
1462 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1463 | + } | ||
1464 | + result = tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult) | ||
1465 | + return | ||
1466 | +} | ||
1467 | + | ||
1468 | +// 从取消关注的列表中移除数据 | ||
1469 | +func (srv *TaskService) CancleTaskIgnore(param *command.CancelIgnoreCommand) (result map[string]interface{}, err error) { | ||
1470 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
1471 | + if err != nil { | ||
1472 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1473 | + } | ||
1474 | + if err := transactionContext.StartTransaction(); err != nil { | ||
1475 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1476 | + } | ||
1477 | + defer func() { | ||
1478 | + _ = transactionContext.RollbackTransaction() | ||
1479 | + }() | ||
1480 | + | ||
1481 | + taskIgnoreRepo := factory.CreateTaskIgnoreRepository(map[string]interface{}{ | ||
1482 | + "transactionContext": transactionContext, | ||
1483 | + }) | ||
1484 | + _, taskIgnoreList, err := taskIgnoreRepo.Find(map[string]interface{}{ | ||
1485 | + "userId": param.UserId, | ||
1486 | + "taskId": param.TaskId, | ||
1487 | + }) | ||
1488 | + if len(taskIgnoreList) == 0 { | ||
1489 | + return | ||
1490 | + } | ||
1491 | + | ||
1492 | + err = taskIgnoreRepo.Remove(taskIgnoreList[0].Id) | ||
1493 | + if err != nil { | ||
1494 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1495 | + } | ||
1496 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
1497 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1498 | + } | ||
1499 | + return nil, nil | ||
1500 | +} |
@@ -63,11 +63,12 @@ func (d *TaskDao) catchTaskIdByPermission(userId int) string { | @@ -63,11 +63,12 @@ func (d *TaskDao) catchTaskIdByPermission(userId int) string { | ||
63 | } | 63 | } |
64 | 64 | ||
65 | type ListTaskCondition struct { | 65 | type ListTaskCondition struct { |
66 | - Limit int //分页 | ||
67 | - Offset int //分页 | ||
68 | - CompanyId int //公司id | ||
69 | - UserId int //谁要查看任务数据 | ||
70 | - OnlyMy bool //只查看我负责的任务 | 66 | + Limit int //分页 |
67 | + Offset int //分页 | ||
68 | + CompanyId int //公司id | ||
69 | + UserId int //谁要查看任务数据 | ||
70 | + OnlyMy bool //只查看我负责的任务 | ||
71 | + LevelName string //任务类型名称 | ||
71 | SearchWord string | 72 | SearchWord string |
72 | } | 73 | } |
73 | 74 | ||
@@ -108,7 +109,10 @@ func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) { | @@ -108,7 +109,10 @@ func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) { | ||
108 | condition = append(condition, param.SearchWord, param.SearchWord) | 109 | condition = append(condition, param.SearchWord, param.SearchWord) |
109 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` | 110 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` |
110 | } | 111 | } |
111 | - | 112 | + if len(param.LevelName) > 0 { |
113 | + condition = append(condition, param.LevelName) | ||
114 | + whereSql += ` and task.level_name = ? ` | ||
115 | + } | ||
112 | sqlStr := withSql + whereSql | 116 | sqlStr := withSql + whereSql |
113 | tx := d.transactionContext.PgTx | 117 | tx := d.transactionContext.PgTx |
114 | var cnt int | 118 | var cnt int |
@@ -135,6 +139,10 @@ func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) { | @@ -135,6 +139,10 @@ func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) { | ||
135 | condition = append(condition, param.SearchWord, param.SearchWord) | 139 | condition = append(condition, param.SearchWord, param.SearchWord) |
136 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` | 140 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` |
137 | } | 141 | } |
142 | + if len(param.LevelName) > 0 { | ||
143 | + condition = append(condition, param.LevelName) | ||
144 | + whereSql += ` and task.level_name = ? ` | ||
145 | + } | ||
138 | sqlStr := withSql + whereSql | 146 | sqlStr := withSql + whereSql |
139 | tx := d.transactionContext.PgTx | 147 | tx := d.transactionContext.PgTx |
140 | var cnt int | 148 | var cnt int |
@@ -167,6 +175,10 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er | @@ -167,6 +175,10 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er | ||
167 | condition = append(condition, param.SearchWord, param.SearchWord) | 175 | condition = append(condition, param.SearchWord, param.SearchWord) |
168 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` | 176 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` |
169 | } | 177 | } |
178 | + if len(param.LevelName) > 0 { | ||
179 | + condition = append(condition, param.LevelName) | ||
180 | + whereSql += ` and task.level_name = ? ` | ||
181 | + } | ||
170 | sqlStr := withSql + whereSql | 182 | sqlStr := withSql + whereSql |
171 | tx := d.transactionContext.PgTx | 183 | tx := d.transactionContext.PgTx |
172 | var cnt int | 184 | var cnt int |
@@ -201,6 +213,10 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err | @@ -201,6 +213,10 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err | ||
201 | condition = append(condition, param.SearchWord, param.SearchWord) | 213 | condition = append(condition, param.SearchWord, param.SearchWord) |
202 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` | 214 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` |
203 | } | 215 | } |
216 | + if len(param.LevelName) > 0 { | ||
217 | + condition = append(condition, param.LevelName) | ||
218 | + whereSql += ` and task.level_name = ? ` | ||
219 | + } | ||
204 | 220 | ||
205 | sqlStr := withSql + whereSql | 221 | sqlStr := withSql + whereSql |
206 | tx := d.transactionContext.PgTx | 222 | tx := d.transactionContext.PgTx |
@@ -302,6 +318,10 @@ func (d *TaskDao) CountTaskAnomalyNotHrbp(param ListTaskCondition) (int, error) | @@ -302,6 +318,10 @@ func (d *TaskDao) CountTaskAnomalyNotHrbp(param ListTaskCondition) (int, error) | ||
302 | condition = append(condition, param.SearchWord, param.SearchWord) | 318 | condition = append(condition, param.SearchWord, param.SearchWord) |
303 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` | 319 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` |
304 | } | 320 | } |
321 | + if len(param.LevelName) > 0 { | ||
322 | + condition = append(condition, param.LevelName) | ||
323 | + whereSql += ` and task.level_name = ? ` | ||
324 | + } | ||
305 | sqlStr := withSql + whereSql | 325 | sqlStr := withSql + whereSql |
306 | tx := d.transactionContext.PgTx | 326 | tx := d.transactionContext.PgTx |
307 | var cnt int | 327 | var cnt int |
@@ -326,7 +346,11 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) { | @@ -326,7 +346,11 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) { | ||
326 | } | 346 | } |
327 | if param.SearchWord != "" { | 347 | if param.SearchWord != "" { |
328 | condition = append(condition, param.SearchWord, param.SearchWord) | 348 | condition = append(condition, param.SearchWord, param.SearchWord) |
329 | - whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` | 349 | + whereSql += ` and (task.leader->>'name' like ? or task.alias like ?) ` |
350 | + } | ||
351 | + if len(param.LevelName) > 0 { | ||
352 | + condition = append(condition, param.LevelName) | ||
353 | + whereSql += ` and task.level_name = ? ` | ||
330 | } | 354 | } |
331 | sqlStr := withSql + whereSql | 355 | sqlStr := withSql + whereSql |
332 | tx := d.transactionContext.PgTx | 356 | tx := d.transactionContext.PgTx |
@@ -453,6 +477,8 @@ type ListTask struct { | @@ -453,6 +477,8 @@ type ListTask struct { | ||
453 | CreatedAt time.Time `pg:"created_at"` | 477 | CreatedAt time.Time `pg:"created_at"` |
454 | CurrentStage domain.TaskStage `pg:"current_stage"` // 当前执行的里程碑 | 478 | CurrentStage domain.TaskStage `pg:"current_stage"` // 当前执行的里程碑 |
455 | LastStage domain.TaskStage `pg:"last_stage"` // 上一个完成的里程碑 | 479 | LastStage domain.TaskStage `pg:"last_stage"` // 上一个完成的里程碑 |
480 | + SortBy int `pg:"sort_by"` | ||
481 | + EndTime int `pg:"end_time"` | ||
456 | } | 482 | } |
457 | 483 | ||
458 | // (新)获取任务,用于页面展示; 无过滤查看权限 | 484 | // (新)获取任务,用于页面展示; 无过滤查看权限 |
@@ -481,6 +507,8 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) | @@ -481,6 +507,8 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) | ||
481 | task.updated_at, | 507 | task.updated_at, |
482 | task.current_stage, | 508 | task.current_stage, |
483 | task.last_stage, | 509 | task.last_stage, |
510 | + task.sort_by, | ||
511 | + task.end_time, | ||
484 | task.created_at | 512 | task.created_at |
485 | from task | 513 | from task |
486 | left join t_task_ignore on t_task_ignore.task_id=task.id | 514 | left join t_task_ignore on t_task_ignore.task_id=task.id |
@@ -511,14 +539,16 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) | @@ -511,14 +539,16 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) | ||
511 | t_task.updated_at , | 539 | t_task.updated_at , |
512 | t_task.current_stage, | 540 | t_task.current_stage, |
513 | t_task.last_stage, | 541 | t_task.last_stage, |
542 | + t_task.sort_by, | ||
543 | + t_task.end_time, | ||
514 | t_task.created_at | 544 | t_task.created_at |
515 | from t_task | 545 | from t_task |
516 | where 1=1 | 546 | where 1=1 |
517 | )select * | 547 | )select * |
518 | from t_task_1 | 548 | from t_task_1 |
519 | - order by t_task_1.sort_by_1, | 549 | + order by t_task_1.status, t_task_1.sort_by_1, |
520 | t_task_1.sort_by_2,t_task_1.anomaly desc, | 550 | t_task_1.sort_by_2,t_task_1.anomaly desc, |
521 | - t_task_1."level",t_task_1."created_at" | 551 | + t_task_1.sort_by,t_task_1."created_at" |
522 | limit ? offset ? | 552 | limit ? offset ? |
523 | ` | 553 | ` |
524 | condition := []interface{}{param.UserId, param.CompanyId} | 554 | condition := []interface{}{param.UserId, param.CompanyId} |
@@ -531,6 +561,10 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) | @@ -531,6 +561,10 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) | ||
531 | condition = append(condition, param.SearchWord, param.SearchWord) | 561 | condition = append(condition, param.SearchWord, param.SearchWord) |
532 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` | 562 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` |
533 | } | 563 | } |
564 | + if len(param.LevelName) > 0 { | ||
565 | + condition = append(condition, param.LevelName) | ||
566 | + whereSql += ` and task.level_name = ? ` | ||
567 | + } | ||
534 | strSql2 := fmt.Sprintf(sqlStr, whereSql) | 568 | strSql2 := fmt.Sprintf(sqlStr, whereSql) |
535 | condition = append(condition, param.Limit, param.Offset) | 569 | condition = append(condition, param.Limit, param.Offset) |
536 | result := []ListTask{} | 570 | result := []ListTask{} |
@@ -558,6 +592,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) | @@ -558,6 +592,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) | ||
558 | task.last_stage, | 592 | task.last_stage, |
559 | task.status , | 593 | task.status , |
560 | task.updated_at, | 594 | task.updated_at, |
595 | + task.sort_by, | ||
596 | + task.end_time, | ||
561 | task.created_at | 597 | task.created_at |
562 | from task | 598 | from task |
563 | join t_task_1 on t_task_1.id=task.id | 599 | join t_task_1 on t_task_1.id=task.id |
@@ -587,14 +623,16 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) | @@ -587,14 +623,16 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) | ||
587 | t_task.last_stage, | 623 | t_task.last_stage, |
588 | t_task.status , | 624 | t_task.status , |
589 | t_task.updated_at , | 625 | t_task.updated_at , |
626 | + t_task.sort_by, | ||
627 | + t_task.end_time, | ||
590 | t_task.created_at | 628 | t_task.created_at |
591 | from t_task | 629 | from t_task |
592 | where 1=1 | 630 | where 1=1 |
593 | )select * | 631 | )select * |
594 | from tt_task_1 | 632 | from tt_task_1 |
595 | - order by tt_task_1.sort_by_1, | 633 | + order by tt_task_1.status,tt_task_1.sort_by_1, |
596 | tt_task_1.sort_by_2,tt_task_1.anomaly desc, | 634 | tt_task_1.sort_by_2,tt_task_1.anomaly desc, |
597 | - tt_task_1."level",tt_task_1."created_at" | 635 | + tt_task_1.sort_by,tt_task_1."created_at" |
598 | limit ? offset ? | 636 | limit ? offset ? |
599 | ` | 637 | ` |
600 | condition := []interface{}{param.CompanyId} | 638 | condition := []interface{}{param.CompanyId} |
@@ -607,6 +645,10 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) | @@ -607,6 +645,10 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) | ||
607 | condition = append(condition, param.SearchWord, param.SearchWord) | 645 | condition = append(condition, param.SearchWord, param.SearchWord) |
608 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` | 646 | whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` |
609 | } | 647 | } |
648 | + if len(param.LevelName) > 0 { | ||
649 | + condition = append(condition, param.LevelName) | ||
650 | + whereSql += ` and task.level_name = ? ` | ||
651 | + } | ||
610 | strSql2 := fmt.Sprintf(strSql, whereSql) | 652 | strSql2 := fmt.Sprintf(strSql, whereSql) |
611 | condition = append(condition, param.Limit, param.Offset) | 653 | condition = append(condition, param.Limit, param.Offset) |
612 | result := []ListTask{} | 654 | result := []ListTask{} |
@@ -614,3 +656,84 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) | @@ -614,3 +656,84 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) | ||
614 | _, err := tx.Query(&result, strSql2, condition...) | 656 | _, err := tx.Query(&result, strSql2, condition...) |
615 | return result, err | 657 | return result, err |
616 | } | 658 | } |
659 | + | ||
660 | +// 获取已取消关注的任务列表 | ||
661 | +func (d *TaskDao) ListTaskIgnore(param ListTaskCondition) ([]ListTask, error) { | ||
662 | + sqlStr := `with | ||
663 | + t_task_ignore as( | ||
664 | + select task_ignore.task_id | ||
665 | + from task_ignore | ||
666 | + where user_id =3252522494124032 | ||
667 | + )select | ||
668 | + task.id as task_id , | ||
669 | + task.alias , | ||
670 | + task.leader ->>'name' as leader_name, | ||
671 | + task."level" , | ||
672 | + task.level_name , | ||
673 | + task.anomaly , | ||
674 | + task.status , | ||
675 | + task.updated_at , | ||
676 | + task.created_at , | ||
677 | + task.current_stage , | ||
678 | + task.last_stage , | ||
679 | + task.sort_by , | ||
680 | + task.end_time | ||
681 | + from task | ||
682 | + join t_task_ignore on t_task_ignore.task_id=task.id | ||
683 | + where 1=1 and task.company_id=? and task.deleted_at isnull ` | ||
684 | + condition := []interface{}{param.CompanyId} | ||
685 | + whereSql := `` | ||
686 | + if param.OnlyMy { | ||
687 | + condition = append(condition, param.UserId) | ||
688 | + whereSql += ` and task.leader ->>'id' = '?' ` | ||
689 | + } | ||
690 | + if param.SearchWord != "" { | ||
691 | + condition = append(condition, param.SearchWord, param.SearchWord) | ||
692 | + whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` | ||
693 | + } | ||
694 | + if len(param.LevelName) > 0 { | ||
695 | + condition = append(condition, param.LevelName) | ||
696 | + whereSql += ` and task.level_name = ? ` | ||
697 | + } | ||
698 | + condition = append(condition, param.Limit, param.Offset) | ||
699 | + sqlStr = sqlStr + whereSql + ` limit ? offset ? ` | ||
700 | + | ||
701 | + result := []ListTask{} | ||
702 | + tx := d.transactionContext.PgTx | ||
703 | + _, err := tx.Query(&result, sqlStr, condition...) | ||
704 | + return result, err | ||
705 | +} | ||
706 | + | ||
707 | +func (d *TaskDao) CountTaskIgnore(param ListTaskCondition) (int, error) { | ||
708 | + sqlStr := `with | ||
709 | + t_task_ignore as( | ||
710 | + select task_ignore.task_id | ||
711 | + from task_ignore | ||
712 | + where user_id =3252522494124032 | ||
713 | + )select | ||
714 | + count(*) as cnt | ||
715 | + from task | ||
716 | + join t_task_ignore on t_task_ignore.task_id=task.id | ||
717 | + where 1=1 and task.company_id=? and task.deleted_at isnull ` | ||
718 | + condition := []interface{}{param.CompanyId} | ||
719 | + whereSql := `` | ||
720 | + if param.OnlyMy { | ||
721 | + condition = append(condition, param.UserId) | ||
722 | + whereSql += ` and task.leader ->>'id' = '?' ` | ||
723 | + } | ||
724 | + if param.SearchWord != "" { | ||
725 | + condition = append(condition, param.SearchWord, param.SearchWord) | ||
726 | + whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` | ||
727 | + } | ||
728 | + if len(param.LevelName) > 0 { | ||
729 | + condition = append(condition, param.LevelName) | ||
730 | + whereSql += ` and task.level_name = ? ` | ||
731 | + } | ||
732 | + condition = append(condition, param.Limit, param.Offset) | ||
733 | + sqlStr = sqlStr + whereSql + ` limit ? offset ? ` | ||
734 | + | ||
735 | + result := 0 | ||
736 | + tx := d.transactionContext.PgTx | ||
737 | + _, err := tx.Query(pg.Scan(&result), sqlStr, condition...) | ||
738 | + return result, err | ||
739 | +} |
@@ -27,7 +27,7 @@ type Task struct { | @@ -27,7 +27,7 @@ type Task struct { | ||
27 | Anomaly int `pg:"anomaly,use_zero"` // 异常反馈的数量 | 27 | Anomaly int `pg:"anomaly,use_zero"` // 异常反馈的数量 |
28 | WarnFlag int `pg:"warn_flag,use_zero"` // 里程碑异常标记 | 28 | WarnFlag int `pg:"warn_flag,use_zero"` // 里程碑异常标记 |
29 | CurrentStage domain.TaskStage `pg:"current_stage,type:jsonb"` // 添加type:jsonb 防止orm(可能是特性)生成sql时字段丢失 | 29 | CurrentStage domain.TaskStage `pg:"current_stage,type:jsonb"` // 添加type:jsonb 防止orm(可能是特性)生成sql时字段丢失 |
30 | - SortBy int `pg:"sort_by"` // 优先级排序;值越小优先级越高 | ||
31 | - EndTime int64 `pg:"end_time"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间 | ||
32 | - UseEndTime int `pg:"use_end_time"` // 是否应用任务截止的时间;默认值0:不应用,1:应用 | 30 | + SortBy int `pg:"sort_by,use_zero"` // 优先级排序;值越小优先级越高 |
31 | + EndTime int64 `pg:"end_time,use_zero"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间 | ||
32 | + UseEndTime int `pg:"use_end_time,use_zero"` // 是否应用任务截止的时间;默认值0:不应用,1:应用 | ||
33 | } | 33 | } |
@@ -88,6 +88,12 @@ func (repo *TaskIgnoreRepository) Find(queryOptions map[string]interface{}) (int | @@ -88,6 +88,12 @@ func (repo *TaskIgnoreRepository) Find(queryOptions map[string]interface{}) (int | ||
88 | tx := repo.transactionContext.PgTx | 88 | tx := repo.transactionContext.PgTx |
89 | var m []*models.TaskIgnore | 89 | var m []*models.TaskIgnore |
90 | query := tx.Model(&m) | 90 | query := tx.Model(&m) |
91 | + if v, ok := queryOptions["userId"]; ok { | ||
92 | + query.Where(" user_id=? ", v) | ||
93 | + } | ||
94 | + if v, ok := queryOptions["taskId"]; ok { | ||
95 | + query.Where(" task_id=? ", v) | ||
96 | + } | ||
91 | query.Order("id desc") | 97 | query.Order("id desc") |
92 | count, err := query.SelectAndCount() | 98 | count, err := query.SelectAndCount() |
93 | if err != nil { | 99 | if err != nil { |
@@ -215,3 +215,36 @@ func (c *TaskController) SaveTaskLevel() { | @@ -215,3 +215,36 @@ func (c *TaskController) SaveTaskLevel() { | ||
215 | err = srv.SaveTaskLevel(paramReq) | 215 | err = srv.SaveTaskLevel(paramReq) |
216 | c.Response(nil, err) | 216 | c.Response(nil, err) |
217 | } | 217 | } |
218 | + | ||
219 | +// 取消关注的任务列表 | ||
220 | +func (c *TaskController) ListTaskIgnore() { | ||
221 | + srv := service.NewTaskService() | ||
222 | + paramReq := &command.SearchTaskCommand{} | ||
223 | + err := c.BindJSON(paramReq) | ||
224 | + if err != nil { | ||
225 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
226 | + c.Response(nil, e) | ||
227 | + return | ||
228 | + } | ||
229 | + userReq := middlewares.GetUser(c.Ctx) | ||
230 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
231 | + result, err := srv.ListTaskIgnore(paramReq) | ||
232 | + c.Response(result, err) | ||
233 | +} | ||
234 | + | ||
235 | +// 从取消关注的任务列表中移除 | ||
236 | +func (c *TaskController) CancelIgnore() { | ||
237 | + srv := service.NewTaskService() | ||
238 | + paramReq := &command.CancelIgnoreCommand{} | ||
239 | + err := c.BindJSON(paramReq) | ||
240 | + if err != nil { | ||
241 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
242 | + c.Response(nil, e) | ||
243 | + return | ||
244 | + } | ||
245 | + userReq := middlewares.GetUser(c.Ctx) | ||
246 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
247 | + _, err = srv.CancleTaskIgnore(paramReq) | ||
248 | + c.Response(nil, err) | ||
249 | + | ||
250 | +} |
@@ -29,6 +29,8 @@ func init() { | @@ -29,6 +29,8 @@ func init() { | ||
29 | web.NSCtrlPost("/list/select", (*controllers.TaskController).SelectCondition), | 29 | web.NSCtrlPost("/list/select", (*controllers.TaskController).SelectCondition), |
30 | web.NSCtrlPost("/task_record/list", (*controllers.TaskController).ListTaskRecord), | 30 | web.NSCtrlPost("/task_record/list", (*controllers.TaskController).ListTaskRecord), |
31 | web.NSCtrlPost("/info", (*controllers.TaskController).GetTaskInfo), | 31 | web.NSCtrlPost("/info", (*controllers.TaskController).GetTaskInfo), |
32 | + web.NSCtrlPost("/ignore/list", (*controllers.TaskController).ListTaskIgnore), | ||
33 | + web.NSCtrlPost("/ignore/cancle", (*controllers.TaskController).CancelIgnore), | ||
32 | ) | 34 | ) |
33 | web.AddNamespace(taskFontNS) | 35 | web.AddNamespace(taskFontNS) |
34 | t := web.NewNamespace("/test/task", | 36 | t := web.NewNamespace("/test/task", |
-
请 注册 或 登录 后发表评论