作者 tangxvhui

更新

@@ -1256,7 +1256,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1256,7 +1256,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1256 if v.Check == domain.TaskStageUncompleted { 1256 if v.Check == domain.TaskStageUncompleted {
1257 it.TaskStageCheck.RealCompletedAt = 0 1257 it.TaskStageCheck.RealCompletedAt = 0
1258 } else { 1258 } else {
1259 - it.TaskStageCheck.RealCompletedAt = time.Now().Unix() 1259 + it.TaskStageCheck.SetRealCompleted(time.Now())
1260 } 1260 }
1261 } 1261 }
1262 for j := range it.TaskStages { 1262 for j := range it.TaskStages {
@@ -1264,7 +1264,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1264,7 +1264,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1264 if v.Check == domain.TaskStageUncompleted { 1264 if v.Check == domain.TaskStageUncompleted {
1265 it.TaskStages[j].RealCompletedAt = 0 1265 it.TaskStages[j].RealCompletedAt = 0
1266 } else { 1266 } else {
1267 - it.TaskStages[j].RealCompletedAt = time.Now().Unix() 1267 + it.TaskStages[j].SetRealCompleted(time.Now())
1268 } 1268 }
1269 } 1269 }
1270 } 1270 }
@@ -151,7 +151,6 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont @@ -151,7 +151,6 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont
151 } 151 }
152 152
153 // 更新任务 153 // 更新任务
154 -// TODO 检查是否可以修改,和通知  
155 func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]interface{}, error) { 154 func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]interface{}, error) {
156 transactionContext, err := factory.CreateTransactionContext(nil) 155 transactionContext, err := factory.CreateTransactionContext(nil)
157 if err != nil { 156 if err != nil {
@@ -209,13 +208,6 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] @@ -209,13 +208,6 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]
209 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务的相关人员"+err.Error()) 208 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务的相关人员"+err.Error())
210 } 209 }
211 } 210 }
212 - ok, err := srv.canUpdateTask(taskData, stageList)  
213 - if err != nil {  
214 - return nil, err  
215 - }  
216 - if !ok {  
217 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "日评数据已生成,任务不能再被编辑")  
218 - }  
219 //更新相关人员 211 //更新相关人员
220 taskData.RelatedUser = []int{} 212 taskData.RelatedUser = []int{}
221 for _, val := range relatedUser { 213 for _, val := range relatedUser {
@@ -622,10 +614,6 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte @@ -622,10 +614,6 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte
622 return result, nil 614 return result, nil
623 } 615 }
624 616
625 -func (srv TaskService) canUpdateTask(taskData *domain.Task, stageList []*domain.TaskStage) (bool, error) {  
626 - return true, nil  
627 -}  
628 -  
629 // CancelAttention 用户取消关注某个任务 617 // CancelAttention 用户取消关注某个任务
630 func (srv TaskService) CancelAttention(param *command.CancelAttentionCommand) error { 618 func (srv TaskService) CancelAttention(param *command.CancelAttentionCommand) error {
631 transactionContext, err := factory.CreateTransactionContext(nil) 619 transactionContext, err := factory.CreateTransactionContext(nil)
@@ -155,7 +155,7 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage @@ -155,7 +155,7 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage
155 if param.OnlyMy { 155 if param.OnlyMy {
156 condition = append(condition, param.UserId) 156 condition = append(condition, param.UserId)
157 whereSql += ` and t_task_tage_1.leader_id = '?' ` 157 whereSql += ` and t_task_tage_1.leader_id = '?' `
158 - } else if param.LeaderId != "" { 158 + } else if param.LeaderId != "" && param.LeaderId != "0" {
159 condition = append(condition, param.LeaderId) 159 condition = append(condition, param.LeaderId)
160 whereSql += ` and t_task_tage_1.leader_id = ? ` 160 whereSql += ` and t_task_tage_1.leader_id = ? `
161 } 161 }
@@ -186,7 +186,7 @@ func (d *TaskDao) CountTaskStageNotHrbp(param ListTaskCondition) (int, error) { @@ -186,7 +186,7 @@ func (d *TaskDao) CountTaskStageNotHrbp(param ListTaskCondition) (int, error) {
186 if param.OnlyMy { 186 if param.OnlyMy {
187 condition = append(condition, param.UserId) 187 condition = append(condition, param.UserId)
188 whereSql += ` and task.leader ->>'id' = '?' ` 188 whereSql += ` and task.leader ->>'id' = '?' `
189 - } else if param.LeaderId != "" { 189 + } else if param.LeaderId != "" && param.LeaderId != "0" {
190 condition = append(condition, param.LeaderId) 190 condition = append(condition, param.LeaderId)
191 whereSql += ` and task.leader ->>'id' = ? ` 191 whereSql += ` and task.leader ->>'id' = ? `
192 } 192 }
@@ -274,18 +274,18 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage, @@ -274,18 +274,18 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
274 whereSql := `` 274 whereSql := ``
275 if param.OnlyMy { 275 if param.OnlyMy {
276 condition = append(condition, param.UserId) 276 condition = append(condition, param.UserId)
277 - whereSql += ` and task.leader ->>'id' = '?' `  
278 - } else if param.LeaderId != "" { 277 + whereSql += ` and t_task_tage_1.leader_id = '?' `
  278 + } else if param.LeaderId != "" && param.LeaderId != "0" {
279 condition = append(condition, param.LeaderId) 279 condition = append(condition, param.LeaderId)
280 - whereSql += ` and task.leader ->>'id' = ? ` 280 + whereSql += ` and t_task_tage_1.leader_id = ? `
281 } 281 }
282 if len(param.TaskName) > 0 { 282 if len(param.TaskName) > 0 {
283 condition = append(condition, param.TaskName) 283 condition = append(condition, param.TaskName)
284 - whereSql += ` and task.name like ? ` 284 + whereSql += ` and t_task_tage_1.task_name like ? `
285 } 285 }
286 if len(param.LevelName) > 0 { 286 if len(param.LevelName) > 0 {
287 condition = append(condition, param.LevelName) 287 condition = append(condition, param.LevelName)
288 - whereSql += ` and task.level_name like ? ` 288 + whereSql += ` and t_task_tage_1.level_name like ? `
289 } 289 }
290 condition = append(condition, param.Limit, param.Offset) 290 condition = append(condition, param.Limit, param.Offset)
291 sqlStr := fmt.Sprintf(withSql, whereSql) 291 sqlStr := fmt.Sprintf(withSql, whereSql)
@@ -309,7 +309,7 @@ func (d *TaskDao) CountTaskStageByHrbp(param ListTaskCondition) (int, error) { @@ -309,7 +309,7 @@ func (d *TaskDao) CountTaskStageByHrbp(param ListTaskCondition) (int, error) {
309 if param.OnlyMy { 309 if param.OnlyMy {
310 condition = append(condition, param.UserId) 310 condition = append(condition, param.UserId)
311 whereSql += ` and task.leader ->>'id' = '?' ` 311 whereSql += ` and task.leader ->>'id' = '?' `
312 - } else if param.LeaderId != "" { 312 + } else if param.LeaderId != "" && param.LeaderId != "0" {
313 condition = append(condition, param.LeaderId) 313 condition = append(condition, param.LeaderId)
314 whereSql += ` and task.leader ->>'id' = ? ` 314 whereSql += ` and task.leader ->>'id' = ? `
315 } 315 }
@@ -346,7 +346,7 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er @@ -346,7 +346,7 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er
346 if param.OnlyMy { 346 if param.OnlyMy {
347 condition = append(condition, param.UserId) 347 condition = append(condition, param.UserId)
348 whereSql += ` and task.leader ->>'id' = '?' ` 348 whereSql += ` and task.leader ->>'id' = '?' `
349 - } else if param.LeaderId != "" { 349 + } else if param.LeaderId != "" && param.LeaderId != "0" {
350 condition = append(condition, param.LeaderId) 350 condition = append(condition, param.LeaderId)
351 whereSql += ` and task.leader ->>'id' = ? ` 351 whereSql += ` and task.leader ->>'id' = ? `
352 } 352 }
@@ -385,7 +385,7 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err @@ -385,7 +385,7 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err
385 if param.OnlyMy { 385 if param.OnlyMy {
386 condition = append(condition, param.UserId) 386 condition = append(condition, param.UserId)
387 whereSql += ` and task.leader ->>'id' = '?' ` 387 whereSql += ` and task.leader ->>'id' = '?' `
388 - } else if param.LeaderId != "" { 388 + } else if param.LeaderId != "" && param.LeaderId != "0" {
389 condition = append(condition, param.LeaderId) 389 condition = append(condition, param.LeaderId)
390 whereSql += ` and task.leader ->>'id' = ? ` 390 whereSql += ` and task.leader ->>'id' = ? `
391 } 391 }
@@ -118,6 +118,7 @@ func (c *TaskController) CancelAttention() { @@ -118,6 +118,7 @@ func (c *TaskController) CancelAttention() {
118 return 118 return
119 } 119 }
120 userReq := middlewares.GetUser(c.Ctx) 120 userReq := middlewares.GetUser(c.Ctx)
  121 + paramReq.UserId = int(userReq.UserId)
121 paramReq.CompanyId = int(userReq.CompanyId) 122 paramReq.CompanyId = int(userReq.CompanyId)
122 err = srv.CancelAttention(paramReq) 123 err = srv.CancelAttention(paramReq)
123 c.Response(nil, err) 124 c.Response(nil, err)