Merge branch 'dev-tangxvhui' into test
正在显示
14 个修改的文件
包含
342 行增加
和
196 行删除
@@ -655,7 +655,7 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | @@ -655,7 +655,7 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | ||
655 | if principalId == 0 { | 655 | if principalId == 0 { |
656 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "请选择任务负责人") | 656 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "请选择任务负责人") |
657 | } | 657 | } |
658 | - err := projectTaskService.CreateTask(transactionContext, &taskCommand.CreateTaskCommand{ | 658 | + err := projectTaskService.CreateTaskByProject(transactionContext, &taskCommand.CreateTaskByProjectCommand{ |
659 | Name: content.Name, | 659 | Name: content.Name, |
660 | LeaderId: principalId, | 660 | LeaderId: principalId, |
661 | }) | 661 | }) |
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 | - 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"` | 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 | + LevelName string `json:"levelName"` // 任务类别名称 | ||
12 | + SortBy int `json:"sortBy"` // 优先级排序;值越小优先级越高 | ||
13 | + EndTime int64 `json:"endTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间 | ||
14 | + UseEndtime int `json:"useEndTime"` // 是否应用任务截止的时间;默认值0:不应用,1:应用 | ||
15 | + AssistFlagMax int `json:"assist_flag_max"` // 辅导异常标记最大值 | ||
16 | + RelatedUserId []string `json:"relatedUserId"` // 相关的员工id | ||
17 | + RelatedUser []UserData `json:"relatedUser"` // 相关的员工id | ||
18 | + StageList []TaskStage `json:"stageList"` | ||
19 | } | 19 | } |
20 | 20 | ||
21 | type UserData struct { | 21 | type UserData struct { |
1 | package command | 1 | package command |
2 | 2 | ||
3 | -type CreateTaskCommand struct { | 3 | +type CreateTaskByProjectCommand struct { |
4 | Name string `json:"name"` //任务名称 | 4 | Name string `json:"name"` //任务名称 |
5 | LeaderId int `json:"leaderId,string"` //赋值人id | 5 | LeaderId int `json:"leaderId,string"` //赋值人id |
6 | } | 6 | } |
7 | + | ||
8 | +type CreateTaskCommand struct { | ||
9 | + CompanyId int `json:"-"` | ||
10 | + LeaderId int `json:"leaderId,string"` | ||
11 | + Alias string `json:"alias"` //任务名称 | ||
12 | + LevelName string `json:"levelName"` //优先级 | ||
13 | + RelatedUserId []string `json:"relatedUserId"` //相关人员id | ||
14 | + SortBy int `json:"sortBy"` // 优先级排序;值越小优先级越高 | ||
15 | + EndTime int64 `json:"endTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间 | ||
16 | +} |
@@ -14,4 +14,5 @@ type UpdateTaskCommand struct { | @@ -14,4 +14,5 @@ type UpdateTaskCommand struct { | ||
14 | Name string `json:"name"` //里程碑名称 | 14 | Name string `json:"name"` //里程碑名称 |
15 | PlanCompletedAt string `json:"planCompletedAt"` //计划完成时间, 例:2006-01-02 | 15 | PlanCompletedAt string `json:"planCompletedAt"` //计划完成时间, 例:2006-01-02 |
16 | } `json:"stageList"` | 16 | } `json:"stageList"` |
17 | + AssistFlagMax int `json:"assistFlagMax"` // 辅导异常标记最大值 | ||
17 | } | 18 | } |
1 | -package command |
1 | package service | 1 | package service |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | - "encoding/json" | ||
5 | "fmt" | 4 | "fmt" |
6 | "strconv" | 5 | "strconv" |
7 | "strings" | 6 | "strings" |
@@ -36,28 +35,29 @@ func dayEndTime(t time.Time) time.Time { | @@ -36,28 +35,29 @@ func dayEndTime(t time.Time) time.Time { | ||
36 | // return t2 | 35 | // return t2 |
37 | // } | 36 | // } |
38 | 37 | ||
39 | -func (srv TaskService) CreateTaskTest(param *command.CreateTaskCommand) error { | ||
40 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
41 | - if err != nil { | ||
42 | - return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
43 | - } | ||
44 | - if err := transactionContext.StartTransaction(); err != nil { | ||
45 | - return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
46 | - } | ||
47 | - defer func() { | ||
48 | - _ = transactionContext.RollbackTransaction() | ||
49 | - }() | ||
50 | - err = srv.CreateTask(transactionContext, param) | ||
51 | - if err != nil { | ||
52 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error()) | ||
53 | - } | ||
54 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
55 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
56 | - } | ||
57 | - return nil | ||
58 | -} | 38 | +// func (srv TaskService) CreateTaskTest(param *command.CreateTaskCommand) error { |
39 | +// transactionContext, err := factory.CreateTransactionContext(nil) | ||
40 | +// if err != nil { | ||
41 | +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
42 | +// } | ||
43 | +// if err := transactionContext.StartTransaction(); err != nil { | ||
44 | +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
45 | +// } | ||
46 | +// defer func() { | ||
47 | +// _ = transactionContext.RollbackTransaction() | ||
48 | +// }() | ||
49 | +// err = srv.CreateTask(transactionContext, param) | ||
50 | +// if err != nil { | ||
51 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error()) | ||
52 | +// } | ||
53 | +// if err := transactionContext.CommitTransaction(); err != nil { | ||
54 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
55 | +// } | ||
56 | +// return nil | ||
57 | +// } | ||
59 | 58 | ||
60 | -func (srv TaskService) CreateTask(transactionContext application.TransactionContext, param *command.CreateTaskCommand) error { | 59 | +// CreateTask 重评估模板中创建 |
60 | +func (srv TaskService) CreateTaskByProject(transactionContext application.TransactionContext, param *command.CreateTaskByProjectCommand) error { | ||
61 | taskRepo := factory.CreateTaskRepository(map[string]interface{}{ | 61 | taskRepo := factory.CreateTaskRepository(map[string]interface{}{ |
62 | "transactionContext": transactionContext, | 62 | "transactionContext": transactionContext, |
63 | }) | 63 | }) |
@@ -65,9 +65,10 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont | @@ -65,9 +65,10 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont | ||
65 | "transactionContext": transactionContext, | 65 | "transactionContext": transactionContext, |
66 | }) | 66 | }) |
67 | cnt, _, err := taskRepo.Find(map[string]interface{}{ | 67 | cnt, _, err := taskRepo.Find(map[string]interface{}{ |
68 | - "name": param.Name, | ||
69 | - "leaderId": strconv.Itoa(param.LeaderId), | ||
70 | - "limit": 1, | 68 | + "name": param.Name, |
69 | + "leaderId": strconv.Itoa(param.LeaderId), | ||
70 | + "createdBy": 0, | ||
71 | + "limit": 1, | ||
71 | }) | 72 | }) |
72 | if err != nil { | 73 | if err != nil { |
73 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询任务失败:"+err.Error()) | 74 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询任务失败:"+err.Error()) |
@@ -112,6 +113,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont | @@ -112,6 +113,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont | ||
112 | RunAt: nowTime.Unix(), | 113 | RunAt: nowTime.Unix(), |
113 | StopAt: 0, | 114 | StopAt: 0, |
114 | SortBy: domain.TaskSortNull, | 115 | SortBy: domain.TaskSortNull, |
116 | + CreatedBy: 0, | ||
115 | } | 117 | } |
116 | if int(leaderData.ParentId) != 0 { | 118 | if int(leaderData.ParentId) != 0 { |
117 | newTask.RelatedUser = append(newTask.RelatedUser, int(leaderData.ParentId)) | 119 | newTask.RelatedUser = append(newTask.RelatedUser, int(leaderData.ParentId)) |
@@ -160,6 +162,113 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont | @@ -160,6 +162,113 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont | ||
160 | return nil | 162 | return nil |
161 | } | 163 | } |
162 | 164 | ||
165 | +// 创建任务 | ||
166 | +func (srv TaskService) CreateTask(param *command.CreateTaskCommand) (map[string]interface{}, error) { | ||
167 | + sortNamed := domain.TaskSortBy(param.SortBy) | ||
168 | + if sortNamed.Named() == "" { | ||
169 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "优先级设置错误") | ||
170 | + } | ||
171 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
172 | + if err != nil { | ||
173 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
174 | + } | ||
175 | + if err := transactionContext.StartTransaction(); err != nil { | ||
176 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
177 | + } | ||
178 | + defer func() { | ||
179 | + _ = transactionContext.RollbackTransaction() | ||
180 | + }() | ||
181 | + taskRepo := factory.CreateTaskRepository(map[string]interface{}{ | ||
182 | + "transactionContext": transactionContext, | ||
183 | + }) | ||
184 | + cnt, _, err := taskRepo.Find(map[string]interface{}{ | ||
185 | + "name": param.Alias, | ||
186 | + "leaderId": strconv.Itoa(param.LeaderId), | ||
187 | + "createdBy": 1, | ||
188 | + "limit": 1, | ||
189 | + }) | ||
190 | + if err != nil { | ||
191 | + return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error()) | ||
192 | + } | ||
193 | + if cnt > 0 { | ||
194 | + return map[string]interface{}{}, application.ThrowError(application.BUSINESS_ERROR, "已经存在相同的任务") | ||
195 | + } | ||
196 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
197 | + "transactionContext": transactionContext, | ||
198 | + }) | ||
199 | + | ||
200 | + _, leaderList, err := userRepo.Find(map[string]interface{}{ | ||
201 | + "id": param.LeaderId, | ||
202 | + "companyId": param.CompanyId, | ||
203 | + }) | ||
204 | + if err != nil { | ||
205 | + return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询人员失败:"+err.Error()) | ||
206 | + } | ||
207 | + if len(leaderList) == 0 { | ||
208 | + return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有查询到人员") | ||
209 | + } | ||
210 | + relatedUserIds := []int{} | ||
211 | + for _, val := range param.RelatedUserId { | ||
212 | + id, _ := strconv.Atoi(val) | ||
213 | + relatedUserIds = append(relatedUserIds, id) | ||
214 | + } | ||
215 | + var relatedUser []*domain.User | ||
216 | + if len(relatedUserIds) > 0 { | ||
217 | + _, relatedUser, err = userRepo.Find(map[string]interface{}{ | ||
218 | + "ids": relatedUserIds, | ||
219 | + "companyId": param.CompanyId, | ||
220 | + }) | ||
221 | + if err != nil { | ||
222 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务的相关人员"+err.Error()) | ||
223 | + } | ||
224 | + } | ||
225 | + leaderData := leaderList[0] | ||
226 | + nowTime := time.Now() | ||
227 | + newTask := domain.Task{ | ||
228 | + Id: 0, | ||
229 | + CreatedAt: time.Time{}, | ||
230 | + UpdatedAt: time.Time{}, | ||
231 | + DeletedAt: nil, | ||
232 | + CompanyId: int(leaderData.CompanyId), | ||
233 | + Name: param.Alias, | ||
234 | + Alias: param.Alias, | ||
235 | + Leader: domain.TaskLeader{ | ||
236 | + Id: leaderData.Id, | ||
237 | + Account: leaderData.Account, | ||
238 | + Name: leaderData.Name, | ||
239 | + }, | ||
240 | + Status: domain.TaskRunning, | ||
241 | + Level: 0, | ||
242 | + LevelName: "", | ||
243 | + RelatedUser: []int{int(leaderData.Id)}, | ||
244 | + RunAt: nowTime.Unix(), | ||
245 | + StopAt: 0, | ||
246 | + SortBy: domain.TaskSortBy(param.SortBy), | ||
247 | + CreatedBy: 1, | ||
248 | + AssistFlagMax: 0, | ||
249 | + } | ||
250 | + //处理endTime | ||
251 | + if param.EndTime == 0 { | ||
252 | + newTask.EndTime = 0 | ||
253 | + } else { | ||
254 | + newTask.EndTime = dayEndTime(time.Unix(param.EndTime, 10)).Unix() | ||
255 | + } | ||
256 | + newTask.ApplyLevelName(param.LevelName) | ||
257 | + newTask.RelatedUser = []int{} | ||
258 | + for _, val := range relatedUser { | ||
259 | + newTask.RelatedUser = append(newTask.RelatedUser, int(val.Id)) | ||
260 | + } | ||
261 | + | ||
262 | + err = taskRepo.Save(&newTask) | ||
263 | + if err != nil { | ||
264 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
265 | + } | ||
266 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
267 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
268 | + } | ||
269 | + return map[string]interface{}{"id": newTask.Id}, nil | ||
270 | +} | ||
271 | + | ||
163 | // 更新任务 | 272 | // 更新任务 |
164 | func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]interface{}, error) { | 273 | func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]interface{}, error) { |
165 | transactionContext, err := factory.CreateTransactionContext(nil) | 274 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -198,7 +307,7 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | @@ -198,7 +307,7 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | ||
198 | if err != nil { | 307 | if err != nil { |
199 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 308 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
200 | } | 309 | } |
201 | - //任务的相关人员 | 310 | + //更新任务的相关人员 |
202 | relatedUserIds := []int{} | 311 | relatedUserIds := []int{} |
203 | for _, val := range param.RelatedUserId { | 312 | for _, val := range param.RelatedUserId { |
204 | id, _ := strconv.Atoi(val) | 313 | id, _ := strconv.Atoi(val) |
@@ -218,10 +327,12 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | @@ -218,10 +327,12 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | ||
218 | for _, val := range relatedUser { | 327 | for _, val := range relatedUser { |
219 | taskData.RelatedUser = append(taskData.RelatedUser, int(val.Id)) | 328 | taskData.RelatedUser = append(taskData.RelatedUser, int(val.Id)) |
220 | } | 329 | } |
221 | - //更新任务名称 | 330 | + //更新任务名称,任务分类 |
222 | taskData.Alias = param.Alias | 331 | taskData.Alias = param.Alias |
223 | taskData.ApplyLevelName(param.LevelName) | 332 | taskData.ApplyLevelName(param.LevelName) |
333 | + | ||
224 | nowTime := time.Now() | 334 | nowTime := time.Now() |
335 | + //更新里程碑数据 | ||
225 | stageMap := map[int]*domain.TaskStage{} | 336 | stageMap := map[int]*domain.TaskStage{} |
226 | for _, val := range stageList { | 337 | for _, val := range stageList { |
227 | val.DeletedAt = &nowTime | 338 | val.DeletedAt = &nowTime |
@@ -229,8 +340,8 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | @@ -229,8 +340,8 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | ||
229 | } | 340 | } |
230 | lastPlanCompletedAt := time.Time{} | 341 | lastPlanCompletedAt := time.Time{} |
231 | newStageList := []*domain.TaskStage{} | 342 | newStageList := []*domain.TaskStage{} |
232 | - //标记完成时间变更的里程碑 | ||
233 | - markStage := []domain.TaskStage{} | 343 | + //标记 变更完成时间的 里程碑 |
344 | + //markStage := []domain.TaskStage{} | ||
234 | for i, val2 := range param.StageList { | 345 | for i, val2 := range param.StageList { |
235 | t, err := time.ParseInLocation("2006-01-02", val2.PlanCompletedAt, time.Local) | 346 | t, err := time.ParseInLocation("2006-01-02", val2.PlanCompletedAt, time.Local) |
236 | if err != nil { | 347 | if err != nil { |
@@ -262,9 +373,10 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | @@ -262,9 +373,10 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | ||
262 | oldStage.DeletedAt = nil | 373 | oldStage.DeletedAt = nil |
263 | oldStage.SortBy = i + 1 | 374 | oldStage.SortBy = i + 1 |
264 | oldStage.Name = val2.Name | 375 | oldStage.Name = val2.Name |
265 | - if ok := oldStage.SetPlanCompleted(t); ok { | ||
266 | - markStage = append(markStage, *oldStage) | ||
267 | - } | 376 | + oldStage.SetPlanCompleted(t) |
377 | + //if ok := oldStage.SetPlanCompleted(t); ok { | ||
378 | + //markStage = append(markStage, *oldStage) | ||
379 | + // } | ||
268 | } | 380 | } |
269 | 381 | ||
270 | stageList = append(stageList, newStageList...) | 382 | stageList = append(stageList, newStageList...) |
@@ -303,39 +415,40 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | @@ -303,39 +415,40 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | ||
303 | } | 415 | } |
304 | 416 | ||
305 | taskData.UseEndTime = param.UseEndtime | 417 | taskData.UseEndTime = param.UseEndtime |
418 | + taskData.AssistFlagMax = param.AssistFlagMax | ||
306 | err = taskRepo.Save(taskData) | 419 | err = taskRepo.Save(taskData) |
307 | if err != nil { | 420 | if err != nil { |
308 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 421 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
309 | } | 422 | } |
310 | - messageRepo := factory.CreateMessagePersonalRepository(map[string]interface{}{ | ||
311 | - "transactionContext": transactionContext, | ||
312 | - }) | 423 | + // messageRepo := factory.CreateMessagePersonalRepository(map[string]interface{}{ |
424 | + // "transactionContext": transactionContext, | ||
425 | + // }) | ||
313 | //根据markStage 记录的里程碑数据生成通知 | 426 | //根据markStage 记录的里程碑数据生成通知 |
314 | - for _, val := range markStage { | ||
315 | - for _, val2 := range taskData.RelatedUser { | ||
316 | - t1 := time.Unix(val.PlanCompletedAt, 0).Format("2006-01-02") | ||
317 | - s := fmt.Sprintf(`%s 负责的任务 %s 的里程碑 %s 计划完成时间变更为 %s,请知晓!`, taskData.Leader.Name, taskData.Alias, val.Name, t1) | ||
318 | - payload := map[string]string{ | ||
319 | - "id": strconv.Itoa(val.Id), | ||
320 | - "taskName": taskData.Name, | ||
321 | - "taskStageName": val.Name, | ||
322 | - } | ||
323 | - payloadStr, _ := json.Marshal(payload) | ||
324 | - newMessage := domain.MessagePersonal{ | ||
325 | - Id: 0, | ||
326 | - Types: domain.MessageTypesTaskModify, | ||
327 | - TargetUserId: val2, | ||
328 | - ReadFlag: domain.MessageUnread, | ||
329 | - Title: s, | ||
330 | - Content: s, | ||
331 | - Payload: string(payloadStr), | ||
332 | - } | ||
333 | - err = messageRepo.Save(&newMessage) | ||
334 | - if err != nil { | ||
335 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
336 | - } | ||
337 | - } | ||
338 | - } | 427 | + // for _, val := range markStage { |
428 | + // for _, val2 := range taskData.RelatedUser { | ||
429 | + // t1 := time.Unix(val.PlanCompletedAt, 0).Format("2006-01-02") | ||
430 | + // s := fmt.Sprintf(`%s 负责的任务 %s 的里程碑 %s 计划完成时间变更为 %s,请知晓!`, taskData.Leader.Name, taskData.Alias, val.Name, t1) | ||
431 | + // payload := map[string]string{ | ||
432 | + // "id": strconv.Itoa(val.Id), | ||
433 | + // "taskName": taskData.Name, | ||
434 | + // "taskStageName": val.Name, | ||
435 | + // } | ||
436 | + // payloadStr, _ := json.Marshal(payload) | ||
437 | + // newMessage := domain.MessagePersonal{ | ||
438 | + // Id: 0, | ||
439 | + // Types: domain.MessageTypesTaskModify, | ||
440 | + // TargetUserId: val2, | ||
441 | + // ReadFlag: domain.MessageUnread, | ||
442 | + // Title: s, | ||
443 | + // Content: s, | ||
444 | + // Payload: string(payloadStr), | ||
445 | + // } | ||
446 | + // err = messageRepo.Save(&newMessage) | ||
447 | + // if err != nil { | ||
448 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
449 | + // } | ||
450 | + // } | ||
451 | + // } | ||
339 | if err := transactionContext.CommitTransaction(); err != nil { | 452 | if err := transactionContext.CommitTransaction(); err != nil { |
340 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 453 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
341 | } | 454 | } |
@@ -449,13 +562,6 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | @@ -449,13 +562,6 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | ||
449 | taskRecordRepo := factory.CreateTaskRecordRepository(map[string]interface{}{ | 562 | taskRecordRepo := factory.CreateTaskRecordRepository(map[string]interface{}{ |
450 | "transactionContext": transactionContext, | 563 | "transactionContext": transactionContext, |
451 | }) | 564 | }) |
452 | - // cnt, _, err := taskRecordRepo.Find(map[string]interface{}{ | ||
453 | - // "taskId": param.TaskId, | ||
454 | - // "limit": 1, | ||
455 | - // }) | ||
456 | - // if err != nil { | ||
457 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "相关联的任务反馈信息"+err.Error()) | ||
458 | - // } | ||
459 | result := adapter.TaskInfoAdapter{ | 565 | result := adapter.TaskInfoAdapter{ |
460 | Id: taskData.Id, | 566 | Id: taskData.Id, |
461 | Name: taskData.Name, | 567 | Name: taskData.Name, |
@@ -477,6 +583,7 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | @@ -477,6 +583,7 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | ||
477 | RelatedUserId: []string{}, | 583 | RelatedUserId: []string{}, |
478 | RelatedUser: []adapter.UserData{}, | 584 | RelatedUser: []adapter.UserData{}, |
479 | StageList: []adapter.TaskStage{}, | 585 | StageList: []adapter.TaskStage{}, |
586 | + AssistFlagMax: taskData.AssistFlagMax, | ||
480 | } | 587 | } |
481 | for _, val := range relatedUserList { | 588 | for _, val := range relatedUserList { |
482 | idStr := strconv.Itoa(int(val.Id)) | 589 | idStr := strconv.Itoa(int(val.Id)) |
@@ -487,6 +594,7 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | @@ -487,6 +594,7 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | ||
487 | Name: val.Name, | 594 | Name: val.Name, |
488 | ParentId: val.ParentId, | 595 | ParentId: val.ParentId, |
489 | }) | 596 | }) |
597 | + | ||
490 | } | 598 | } |
491 | 599 | ||
492 | for _, val := range stageList { | 600 | for _, val := range stageList { |
@@ -43,38 +43,45 @@ const ( | @@ -43,38 +43,45 @@ const ( | ||
43 | ) | 43 | ) |
44 | 44 | ||
45 | func (t TaskSortBy) Named() string { | 45 | func (t TaskSortBy) Named() string { |
46 | - nameMap := map[TaskSortBy]string{ | ||
47 | - TaskSortHight: "高", | ||
48 | - TaskSortMiddle: "中", | ||
49 | - TaskSortLow: "低", | ||
50 | - TaskSortNull: "无", | 46 | + switch t { |
47 | + case TaskSortHight: | ||
48 | + return "高" | ||
49 | + case TaskSortMiddle: | ||
50 | + return "中" | ||
51 | + case TaskSortLow: | ||
52 | + return "低" | ||
53 | + case TaskSortNull: | ||
54 | + return "无" | ||
51 | } | 55 | } |
52 | - return nameMap[t] | 56 | + return "" |
53 | } | 57 | } |
54 | 58 | ||
55 | // 任务 | 59 | // 任务 |
56 | type Task struct { | 60 | type Task struct { |
57 | - Id int `json:"id"` | ||
58 | - CreatedAt time.Time `json:"createdAt"` | ||
59 | - UpdatedAt time.Time `json:"updatedAt"` | ||
60 | - DeletedAt *time.Time `json:"deletedAt"` | ||
61 | - CompanyId int `json:"companyId,string"` | ||
62 | - Name string `json:"name"` // 任务名称 | ||
63 | - Alias string `json:"alias"` // 任务别名 | ||
64 | - Leader TaskLeader `json:"leader"` // 任务负责人 | ||
65 | - Status TaskState `json:"status"` // 任务的状态 | ||
66 | - Level int `json:"level"` // 优先级 (优先级字段表示的意义变更,不再需要这个字段,仅数据保留) | ||
67 | - LevelName string `json:"levelName"` // 字段表示的意义变更; 原来 (“优先级名称“)=> 现在 (“任务类型“) | ||
68 | - SortBy TaskSortBy `json:"sortBy"` // 优先级排序;值越小优先级越高 | ||
69 | - EndTime int64 `json:"endTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间 | ||
70 | - UseEndTime int `json:"useEndTime"` // 是否应用任务截止的时间;默认值0:不应用,1:应用 | ||
71 | - RelatedUser []int `json:"relatedUser"` // 相关的员工id | ||
72 | - RunAt int64 `json:"runAt"` // 启动的时间戳,单位:秒 | ||
73 | - StopAt int64 `json:"stopAt"` // 停止的时间戳,单位:秒 | ||
74 | - Anomaly int `json:"anomaly"` // 异常反馈的次数 | ||
75 | - WarnFlag TaskWarnFlag `json:"warnFlag"` // 里程碑异常标记 | ||
76 | - CurrentStage TaskStage `json:"currentStage"` // 当前执行的里程碑 | ||
77 | - LastStage TaskStage `json:"lastStage"` // 上一个完成的里程碑 | 61 | + Id int `json:"id"` |
62 | + CreatedAt time.Time `json:"createdAt"` | ||
63 | + UpdatedAt time.Time `json:"updatedAt"` | ||
64 | + DeletedAt *time.Time `json:"deletedAt"` | ||
65 | + CompanyId int `json:"companyId,string"` | ||
66 | + Name string `json:"name"` // 任务名称 | ||
67 | + Alias string `json:"alias"` // 任务别名 | ||
68 | + Leader TaskLeader `json:"leader"` // 任务负责人 | ||
69 | + Status TaskState `json:"status"` // 任务的状态 | ||
70 | + Level int `json:"level"` // 优先级 (优先级字段表示的意义变更,不再需要这个字段,仅数据保留) | ||
71 | + LevelName string `json:"levelName"` // 字段表示的意义变更; 原来 (“优先级名称“)=> 现在 (“任务类型“) | ||
72 | + SortBy TaskSortBy `json:"sortBy"` // 优先级排序;值越小优先级越高 | ||
73 | + EndTime int64 `json:"endTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间 | ||
74 | + UseEndTime int `json:"useEndTime"` // 是否应用任务截止的时间;默认值0:不应用,1:应用 | ||
75 | + RelatedUser []int `json:"relatedUser"` // 相关的员工id | ||
76 | + RunAt int64 `json:"runAt"` // 启动的时间戳,单位:秒 | ||
77 | + StopAt int64 `json:"stopAt"` // 停止的时间戳,单位:秒 | ||
78 | + Anomaly int `json:"anomaly"` // 异常反馈的次数 | ||
79 | + WarnFlag TaskWarnFlag `json:"warnFlag"` // 里程碑异常标记 | ||
80 | + AssistFlag int `json:"assistFlag"` // 辅导异常标记 | ||
81 | + AssistFlagMax int `json:"assistFlagMax"` // 辅导异常标记最大值 | ||
82 | + CurrentStage TaskStage `json:"currentStage"` // 当前执行的里程碑 | ||
83 | + LastStage TaskStage `json:"lastStage"` // 上一个完成的里程碑 | ||
84 | + CreatedBy int `json:"createdBy"` // 任务的创建方式 0: 根据模板中的任务创建,1:页面主动直接创建 | ||
78 | } | 85 | } |
79 | 86 | ||
80 | type TaskLeader struct { | 87 | type TaskLeader struct { |
pkg/domain/task_anomaly.go
0 → 100644
@@ -19,23 +19,23 @@ const ( | @@ -19,23 +19,23 @@ const ( | ||
19 | 19 | ||
20 | // TaskRecord 任务反馈情况记录 | 20 | // TaskRecord 任务反馈情况记录 |
21 | type TaskRecord struct { | 21 | type TaskRecord struct { |
22 | - Id int `json:"id,string" comment:"记录ID"` | ||
23 | - CompanyId int `json:"companyId,string" comment:"公司ID"` | ||
24 | - StaffAssessId int `json:"staffAssessId,string" comment:"每日评估的ID"` | ||
25 | - TaskId int `json:"taskId,string" comment:"任务ID"` | ||
26 | - TaskCategory string `json:"taskCategory" comment:"任务类别"` | ||
27 | - TaskName string `json:"taskName" comment:"任务名称"` | ||
28 | - TaskAlias string `json:"taskAlias" comment:"任务别名"` | ||
29 | - TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"` | ||
30 | - AssistLevel int `json:"assistLevel" comment:"上级辅导情况"` | ||
31 | - AssistContent string `json:"assistContent" comment:"上级辅导内容"` | ||
32 | - RemarkContent []RemarkText `json:"remarkContent" comment:"填写反馈"` | ||
33 | - AnomalyState int `json:"anomalyState" comment:"异常是否反馈状态(-1初始状态、0异常、1正常)"` | ||
34 | - TaskStages []TaskStage `json:"taskStages" comment:"里程碑列表"` | ||
35 | - TaskStageCheck TaskStage `json:"taskStageCheck" comment:"提交的里程碑"` | ||
36 | - CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | ||
37 | - UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | ||
38 | - DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | 22 | + Id int `json:"id,string" comment:"记录ID"` |
23 | + CompanyId int `json:"companyId,string" comment:"公司ID"` | ||
24 | + StaffAssessId int `json:"staffAssessId,string" comment:"每日评估的ID"` | ||
25 | + TaskId int `json:"taskId,string" comment:"任务ID"` | ||
26 | + TaskCategory string `json:"taskCategory" comment:"任务类别"` | ||
27 | + TaskName string `json:"taskName" comment:"任务名称"` | ||
28 | + TaskAlias string `json:"taskAlias" comment:"任务别名"` | ||
29 | + TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"` | ||
30 | + AssistLevel int `json:"assistLevel" comment:"上级辅导情况"` | ||
31 | + AssistContent string `json:"assistContent" comment:"上级辅导内容"` | ||
32 | + AnomalyState int `json:"anomalyState" comment:"异常是否反馈状态(-1初始状态、0异常、1正常)"` | ||
33 | + TaskStages []TaskStage `json:"taskStages" comment:"里程碑列表"` | ||
34 | + TaskStageCheck TaskStage `json:"taskStageCheck" comment:"提交的里程碑"` | ||
35 | + CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | ||
36 | + UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | ||
37 | + DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | ||
38 | + TaskCreatedBy int `json:"taskCreatedBy" comment:"任务的创建方式"` // 任务的创建方式 0: 根据模板中的任务创建,1:页面主动直接创建 | ||
39 | } | 39 | } |
40 | 40 | ||
41 | type TaskRecordRepository interface { | 41 | type TaskRecordRepository interface { |
@@ -8,26 +8,29 @@ import ( | @@ -8,26 +8,29 @@ import ( | ||
8 | 8 | ||
9 | // 任务 | 9 | // 任务 |
10 | type Task struct { | 10 | type Task struct { |
11 | - tableName struct{} `comment:"任务" pg:"task"` | ||
12 | - Id int `pg:"id,pk"` // | ||
13 | - CreatedAt time.Time `pg:"created_at"` // | ||
14 | - UpdatedAt time.Time `pg:"updated_at"` // | ||
15 | - DeletedAt *time.Time `pg:"deleted_at"` // | ||
16 | - Name string `pg:"name"` // 任务名称 | ||
17 | - Alias string `pg:"alias"` // | ||
18 | - CompanyId int `pg:"company_id"` // | ||
19 | - Leader domain.TaskLeader `pg:"leader,type:jsonb"` // 任务负责人 | ||
20 | - Status int `pg:"status,use_zero"` // 任务的状态 | ||
21 | - Level int `pg:"level,use_zero"` // 优先级,值越小优先级越高 | ||
22 | - LevelName string `pg:"level_name"` // 优先级名称 | ||
23 | - RelatedUser []int `pg:"related_user"` // | ||
24 | - LastStage domain.TaskStage `pg:"last_stage,type:jsonb"` // 上一个完成的里程碑,添加type:jsonb 防止orm生成sql时字段丢失 | ||
25 | - RunAt int64 `pg:"run_at,use_zero"` // 启动的时间 | ||
26 | - StopAt int64 `pg:"stop_at,use_zero" ` // 停止的时间 | ||
27 | - Anomaly int `pg:"anomaly,use_zero"` // 异常反馈的数量 | ||
28 | - WarnFlag int `pg:"warn_flag,use_zero"` // 里程碑异常标记 | ||
29 | - CurrentStage domain.TaskStage `pg:"current_stage,type:jsonb"` // 添加type:jsonb 防止orm(可能是特性)生成sql时字段丢失 | ||
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:应用 | 11 | + tableName struct{} `comment:"任务" pg:"task"` |
12 | + Id int `pg:"id,pk"` // | ||
13 | + CreatedAt time.Time `pg:"created_at"` // | ||
14 | + UpdatedAt time.Time `pg:"updated_at"` // | ||
15 | + DeletedAt *time.Time `pg:"deleted_at"` // | ||
16 | + Name string `pg:"name"` // 任务名称 | ||
17 | + Alias string `pg:"alias"` // | ||
18 | + CompanyId int `pg:"company_id"` // | ||
19 | + Leader domain.TaskLeader `pg:"leader,type:jsonb"` // 任务负责人 | ||
20 | + Status int `pg:"status,use_zero"` // 任务的状态 | ||
21 | + Level int `pg:"level,use_zero"` // 优先级,值越小优先级越高 | ||
22 | + LevelName string `pg:"level_name"` // 优先级名称 | ||
23 | + RelatedUser []int `pg:"related_user"` // | ||
24 | + LastStage domain.TaskStage `pg:"last_stage,type:jsonb"` // 上一个完成的里程碑,添加type:jsonb 防止orm生成sql时字段丢失 | ||
25 | + RunAt int64 `pg:"run_at,use_zero"` // 启动的时间 | ||
26 | + StopAt int64 `pg:"stop_at,use_zero" ` // 停止的时间 | ||
27 | + Anomaly int `pg:"anomaly,use_zero"` // 异常反馈的数量 | ||
28 | + WarnFlag int `pg:"warn_flag,use_zero"` // 里程碑异常标记 | ||
29 | + CurrentStage domain.TaskStage `pg:"current_stage,type:jsonb"` // 添加type:jsonb 防止orm(可能是特性)生成sql时字段丢失 | ||
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 | + AssistFlag int `pg:"assist_flag,use_zero"` // 辅导异常标记 | ||
34 | + AssistFlagMax int `pg:"assist_flag_max,use_zero"` // 辅导异常标记最大值 | ||
35 | + CreatedBy int `pg:"created_by,use_zero"` | ||
33 | } | 36 | } |
@@ -26,27 +26,30 @@ func NewTaskRepository(transactionContext *pgTransaction.TransactionContext) *Ta | @@ -26,27 +26,30 @@ func NewTaskRepository(transactionContext *pgTransaction.TransactionContext) *Ta | ||
26 | 26 | ||
27 | func (repo *TaskRepository) TransformToDomain(d *models.Task) *domain.Task { | 27 | func (repo *TaskRepository) TransformToDomain(d *models.Task) *domain.Task { |
28 | return &domain.Task{ | 28 | return &domain.Task{ |
29 | - Id: d.Id, | ||
30 | - CreatedAt: d.CreatedAt, | ||
31 | - UpdatedAt: d.UpdatedAt, | ||
32 | - DeletedAt: d.DeletedAt, | ||
33 | - CompanyId: d.CompanyId, | ||
34 | - Name: d.Name, | ||
35 | - Alias: d.Alias, | ||
36 | - Leader: d.Leader, | ||
37 | - Status: domain.TaskState(d.Status), | ||
38 | - Level: d.Level, | ||
39 | - LevelName: d.LevelName, | ||
40 | - SortBy: domain.TaskSortBy(d.SortBy), | ||
41 | - EndTime: d.EndTime, | ||
42 | - UseEndTime: d.UseEndTime, | ||
43 | - RelatedUser: d.RelatedUser, | ||
44 | - RunAt: d.RunAt, | ||
45 | - StopAt: d.StopAt, | ||
46 | - Anomaly: d.Anomaly, | ||
47 | - WarnFlag: domain.TaskWarnFlag(d.WarnFlag), | ||
48 | - CurrentStage: d.CurrentStage, | ||
49 | - LastStage: d.LastStage, | 29 | + Id: d.Id, |
30 | + CreatedAt: d.CreatedAt, | ||
31 | + UpdatedAt: d.UpdatedAt, | ||
32 | + DeletedAt: d.DeletedAt, | ||
33 | + CompanyId: d.CompanyId, | ||
34 | + Name: d.Name, | ||
35 | + Alias: d.Alias, | ||
36 | + Leader: d.Leader, | ||
37 | + Status: domain.TaskState(d.Status), | ||
38 | + Level: d.Level, | ||
39 | + LevelName: d.LevelName, | ||
40 | + SortBy: domain.TaskSortBy(d.SortBy), | ||
41 | + EndTime: d.EndTime, | ||
42 | + UseEndTime: d.UseEndTime, | ||
43 | + RelatedUser: d.RelatedUser, | ||
44 | + RunAt: d.RunAt, | ||
45 | + StopAt: d.StopAt, | ||
46 | + Anomaly: d.Anomaly, | ||
47 | + WarnFlag: domain.TaskWarnFlag(d.WarnFlag), | ||
48 | + AssistFlag: d.AssistFlag, | ||
49 | + AssistFlagMax: d.AssistFlagMax, | ||
50 | + CurrentStage: d.CurrentStage, | ||
51 | + LastStage: d.LastStage, | ||
52 | + CreatedBy: d.CreatedBy, | ||
50 | } | 53 | } |
51 | } | 54 | } |
52 | 55 | ||
@@ -56,27 +59,30 @@ func (repo *TaskRepository) Save(param *domain.Task) error { | @@ -56,27 +59,30 @@ func (repo *TaskRepository) Save(param *domain.Task) error { | ||
56 | param.CreatedAt = time.Now() | 59 | param.CreatedAt = time.Now() |
57 | } | 60 | } |
58 | m := models.Task{ | 61 | m := models.Task{ |
59 | - Id: param.Id, | ||
60 | - CreatedAt: param.CreatedAt, | ||
61 | - UpdatedAt: param.UpdatedAt, | ||
62 | - DeletedAt: param.DeletedAt, | ||
63 | - Name: param.Name, | ||
64 | - Alias: param.Alias, | ||
65 | - CompanyId: param.CompanyId, | ||
66 | - Leader: param.Leader, | ||
67 | - Status: int(param.Status), | ||
68 | - Level: param.Level, | ||
69 | - LevelName: param.LevelName, | ||
70 | - RelatedUser: param.RelatedUser, | ||
71 | - LastStage: param.LastStage, | ||
72 | - RunAt: param.RunAt, | ||
73 | - StopAt: param.StopAt, | ||
74 | - Anomaly: param.Anomaly, | ||
75 | - WarnFlag: int(param.WarnFlag), | ||
76 | - CurrentStage: param.CurrentStage, | ||
77 | - SortBy: int(param.SortBy), | ||
78 | - EndTime: param.EndTime, | ||
79 | - UseEndTime: param.UseEndTime, | 62 | + Id: param.Id, |
63 | + CreatedAt: param.CreatedAt, | ||
64 | + UpdatedAt: param.UpdatedAt, | ||
65 | + DeletedAt: param.DeletedAt, | ||
66 | + Name: param.Name, | ||
67 | + Alias: param.Alias, | ||
68 | + CompanyId: param.CompanyId, | ||
69 | + Leader: param.Leader, | ||
70 | + Status: int(param.Status), | ||
71 | + Level: param.Level, | ||
72 | + LevelName: param.LevelName, | ||
73 | + RelatedUser: param.RelatedUser, | ||
74 | + LastStage: param.LastStage, | ||
75 | + RunAt: param.RunAt, | ||
76 | + StopAt: param.StopAt, | ||
77 | + Anomaly: param.Anomaly, | ||
78 | + WarnFlag: int(param.WarnFlag), | ||
79 | + CurrentStage: param.CurrentStage, | ||
80 | + SortBy: int(param.SortBy), | ||
81 | + EndTime: param.EndTime, | ||
82 | + UseEndTime: param.UseEndTime, | ||
83 | + AssistFlag: param.AssistFlag, | ||
84 | + AssistFlagMax: param.AssistFlagMax, | ||
85 | + CreatedBy: param.CreatedBy, | ||
80 | } | 86 | } |
81 | db := repo.transactionContext.PgTx | 87 | db := repo.transactionContext.PgTx |
82 | if m.Id == 0 { | 88 | if m.Id == 0 { |
@@ -148,6 +154,9 @@ func (repo *TaskRepository) Find(queryOptions map[string]interface{}) (int, []*d | @@ -148,6 +154,9 @@ func (repo *TaskRepository) Find(queryOptions map[string]interface{}) (int, []*d | ||
148 | if val, ok := queryOptions["status"]; ok { | 154 | if val, ok := queryOptions["status"]; ok { |
149 | query.Where("task.status=?", val) | 155 | query.Where("task.status=?", val) |
150 | } | 156 | } |
157 | + if val, ok := queryOptions["createdBy"]; ok { | ||
158 | + query.Where("created_by = ?", val) | ||
159 | + } | ||
151 | if val, ok := queryOptions["limit"]; ok { | 160 | if val, ok := queryOptions["limit"]; ok { |
152 | if limit, err := strconv.Atoi(fmt.Sprintf("%v", val)); err == nil { | 161 | if limit, err := strconv.Atoi(fmt.Sprintf("%v", val)); err == nil { |
153 | query.Limit(limit) | 162 | query.Limit(limit) |
@@ -56,8 +56,8 @@ func (c *TaskController) CreateTask() { | @@ -56,8 +56,8 @@ func (c *TaskController) CreateTask() { | ||
56 | return | 56 | return |
57 | } | 57 | } |
58 | 58 | ||
59 | - err = srv.CreateTaskTest(paramReq) | ||
60 | - c.Response(nil, err) | 59 | + resp, err := srv.CreateTask(paramReq) |
60 | + c.Response(resp, err) | ||
61 | } | 61 | } |
62 | 62 | ||
63 | // 启动任务 | 63 | // 启动任务 |
@@ -12,6 +12,7 @@ func init() { | @@ -12,6 +12,7 @@ func init() { | ||
12 | taskAdminNS := web.NewNamespace("/v1/admin/task", | 12 | taskAdminNS := web.NewNamespace("/v1/admin/task", |
13 | web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), | 13 | web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), |
14 | web.NSCtrlPost("/info", (*controllers.TaskController).GetTaskInfo), | 14 | web.NSCtrlPost("/info", (*controllers.TaskController).GetTaskInfo), |
15 | + web.NSCtrlPost("/", (*controllers.TaskController).CreateTask), | ||
15 | web.NSCtrlPut("/", (*controllers.TaskController).UpdateTask), | 16 | web.NSCtrlPut("/", (*controllers.TaskController).UpdateTask), |
16 | web.NSCtrlPut("/delete", (*controllers.TaskController).DeleteTask), | 17 | web.NSCtrlPut("/delete", (*controllers.TaskController).DeleteTask), |
17 | web.NSCtrlPost("/run", (*controllers.TaskController).RunTask), | 18 | web.NSCtrlPost("/run", (*controllers.TaskController).RunTask), |
-
请 注册 或 登录 后发表评论