...
|
...
|
@@ -349,11 +349,61 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
err = srv.SaveTaskLevel(param.LevelName, param.CompanyId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务等级"+err.Error())
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"id": param.Id,
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
func (srv TaskService) SaveTaskLevel(levelName string, companyId int) error {
|
|
|
defalutLevel := domain.DefaultTaskLevel()
|
|
|
for _, val := range defalutLevel {
|
|
|
if val.LevelName == levelName {
|
|
|
return nil
|
|
|
}
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
taskLevelRepo := factory.CreateTaskLevelRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
cnt, _, err := taskLevelRepo.Find(map[string]interface{}{
|
|
|
"companyId": companyId,
|
|
|
"levelName": levelName,
|
|
|
"limit": 1,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务优先级失败:"+err.Error())
|
|
|
}
|
|
|
if cnt > 0 {
|
|
|
return nil
|
|
|
}
|
|
|
newTaskLevel := domain.TaskLevel{
|
|
|
Id: 0,
|
|
|
LevelName: levelName,
|
|
|
CompanyId: companyId,
|
|
|
}
|
|
|
err = taskLevelRepo.Save(&newTaskLevel)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务优先级失败:"+err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 获取任务详情
|
|
|
func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.TaskInfoAdapter, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
...
|
...
|
@@ -1471,3 +1521,37 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s |
|
|
}
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
func (srv TaskService) ListTaskLevel(companyId int) (map[string]interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
taskLevelRepo := factory.CreateTaskLevelRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
_, taskLevelList, err := taskLevelRepo.Find(map[string]interface{}{
|
|
|
"companyId": companyId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务优先级失败:"+err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
taskLevelAll := []*domain.TaskLevel{}
|
|
|
taskLevelAll = append(taskLevelAll, domain.DefaultTaskLevel()...)
|
|
|
taskLevelAll = append(taskLevelAll, taskLevelList...)
|
|
|
result := map[string]interface{}{
|
|
|
"list": taskLevelAll,
|
|
|
}
|
|
|
return result, nil
|
|
|
} |
...
|
...
|
|