正在显示
9 个修改的文件
包含
59 行增加
和
55 行删除
| 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 | - Leader UserData `json:"leader"` // 任务负责人 | ||
| 8 | - Status int `json:"status"` // 任务的状态 | ||
| 9 | - Level int `json:"level"` // 优先级,值越小优先级越高 | ||
| 10 | - LevalName string `json:"levalName"` // 优先级名称 | ||
| 11 | - RelatedUserId []string `json:"relatedUserId"` // 相关的员工id | ||
| 12 | - RelatedUser []UserData `json:"relatedUser"` // 相关的员工id | ||
| 13 | - 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 | + StatusDescript string `json:"statusDescript"` // | ||
| 11 | + Level int `json:"level"` // 优先级,值越小优先级越高 | ||
| 12 | + LevalName string `json:"levalName"` // 优先级名称 | ||
| 13 | + RelatedUserId []string `json:"relatedUserId"` // 相关的员工id | ||
| 14 | + RelatedUser []UserData `json:"relatedUser"` // 相关的员工id | ||
| 15 | + StageList []TaskStage `json:"stageList"` | ||
| 14 | } | 16 | } |
| 15 | 17 | ||
| 16 | type UserData struct { | 18 | type UserData struct { |
| @@ -2,9 +2,8 @@ package command | @@ -2,9 +2,8 @@ package command | ||
| 2 | 2 | ||
| 3 | type UpdateTaskCommand struct { | 3 | type UpdateTaskCommand struct { |
| 4 | Id int `json:"id,string"` | 4 | Id int `json:"id,string"` |
| 5 | - Alias string `json:"alias"` //任务名称 | ||
| 6 | - LeaderId int `json:"leaderId,string"` //负责id | ||
| 7 | - LevelName string `json:"levelName"` //优先级 | 5 | + Alias string `json:"alias"` //任务名称 |
| 6 | + LevelName string `json:"levelName"` //优先级 | ||
| 8 | StageList []struct { | 7 | StageList []struct { |
| 9 | Id int `json:"id,string"` | 8 | Id int `json:"id,string"` |
| 10 | Name string `json:"name"` //里程碑名称 | 9 | Name string `json:"name"` //里程碑名称 |
| @@ -161,9 +161,6 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | @@ -161,9 +161,6 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | ||
| 161 | taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{ | 161 | taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{ |
| 162 | "transactionContext": transactionContext, | 162 | "transactionContext": transactionContext, |
| 163 | }) | 163 | }) |
| 164 | - userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
| 165 | - "transactionContext": transactionContext, | ||
| 166 | - }) | ||
| 167 | taskData, err := taskRepo.FindOne(map[string]interface{}{ | 164 | taskData, err := taskRepo.FindOne(map[string]interface{}{ |
| 168 | "id": param.Id, | 165 | "id": param.Id, |
| 169 | }) | 166 | }) |
| @@ -183,22 +180,9 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | @@ -183,22 +180,9 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] | ||
| 183 | if !ok { | 180 | if !ok { |
| 184 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "日评数据已生成,任务不能再被编辑") | 181 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "日评数据已生成,任务不能再被编辑") |
| 185 | } | 182 | } |
| 186 | - leaderData, err := userRepo.FindOne(map[string]interface{}{ | ||
| 187 | - "id": param.LeaderId, | ||
| 188 | - }) | ||
| 189 | - if err != nil { | ||
| 190 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 191 | - } | ||
| 192 | taskData.Alias = param.Alias | 183 | taskData.Alias = param.Alias |
| 193 | - taskData.Leader = domain.TaskLeader{ | ||
| 194 | - Id: leaderData.Id, | ||
| 195 | - Account: leaderData.Account, | ||
| 196 | - Name: leaderData.Name, | ||
| 197 | - } | ||
| 198 | taskData.ApplyLevelName(param.LevelName) | 184 | taskData.ApplyLevelName(param.LevelName) |
| 199 | - | ||
| 200 | nowTime := time.Now() | 185 | nowTime := time.Now() |
| 201 | - | ||
| 202 | stageMap := map[int]*domain.TaskStage{} | 186 | stageMap := map[int]*domain.TaskStage{} |
| 203 | for _, val := range stageList { | 187 | for _, val := range stageList { |
| 204 | val.DeletedAt = &nowTime | 188 | val.DeletedAt = &nowTime |
| @@ -292,31 +276,36 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | @@ -292,31 +276,36 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | ||
| 292 | } | 276 | } |
| 293 | 277 | ||
| 294 | relatedUserId := taskData.RelatedUser | 278 | relatedUserId := taskData.RelatedUser |
| 295 | - _, relatedUserList, err := userRepo.Find(map[string]interface{}{ | ||
| 296 | - "ids": relatedUserId, | ||
| 297 | - }) | ||
| 298 | - if err != nil { | ||
| 299 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取相关人员"+err.Error()) | 279 | + var relatedUserList []*domain.User |
| 280 | + if len(relatedUserId) > 0 { | ||
| 281 | + _, relatedUserList, err = userRepo.Find(map[string]interface{}{ | ||
| 282 | + "ids": relatedUserId, | ||
| 283 | + }) | ||
| 284 | + if err != nil { | ||
| 285 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取相关人员"+err.Error()) | ||
| 286 | + } | ||
| 300 | } | 287 | } |
| 301 | if err := transactionContext.CommitTransaction(); err != nil { | 288 | if err := transactionContext.CommitTransaction(); err != nil { |
| 302 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 289 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 303 | } | 290 | } |
| 304 | 291 | ||
| 305 | result := adapter.TaskInfoAdapter{ | 292 | result := adapter.TaskInfoAdapter{ |
| 306 | - Id: taskData.Id, | ||
| 307 | - Name: taskData.Name, | ||
| 308 | - Alias: taskData.Alias, | 293 | + Id: taskData.Id, |
| 294 | + Name: taskData.Name, | ||
| 295 | + Alias: taskData.Alias, | ||
| 296 | + LeaderId: taskData.Leader.Id, | ||
| 309 | Leader: adapter.UserData{ | 297 | Leader: adapter.UserData{ |
| 310 | Id: taskData.Leader.Id, | 298 | Id: taskData.Leader.Id, |
| 311 | Account: taskData.Leader.Account, | 299 | Account: taskData.Leader.Account, |
| 312 | Name: taskData.Leader.Name, | 300 | Name: taskData.Leader.Name, |
| 313 | }, | 301 | }, |
| 314 | - Status: int(taskData.Status), | ||
| 315 | - Level: taskData.Level, | ||
| 316 | - LevalName: taskData.LevelName, | ||
| 317 | - RelatedUserId: []string{}, | ||
| 318 | - RelatedUser: []adapter.UserData{}, | ||
| 319 | - StageList: []adapter.TaskStage{}, | 302 | + Status: int(taskData.Status), |
| 303 | + StatusDescript: taskData.StatusDescript(), | ||
| 304 | + Level: taskData.Level, | ||
| 305 | + LevalName: taskData.LevelName, | ||
| 306 | + RelatedUserId: []string{}, | ||
| 307 | + RelatedUser: []adapter.UserData{}, | ||
| 308 | + StageList: []adapter.TaskStage{}, | ||
| 320 | } | 309 | } |
| 321 | for _, val := range relatedUserList { | 310 | for _, val := range relatedUserList { |
| 322 | idStr := strconv.Itoa(int(val.Id)) | 311 | idStr := strconv.Itoa(int(val.Id)) |
| @@ -49,6 +49,19 @@ func (t *Task) ApplyLevelName(name string) { | @@ -49,6 +49,19 @@ func (t *Task) ApplyLevelName(name string) { | ||
| 49 | } | 49 | } |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | +// StatusDescript | ||
| 53 | +func (t *Task) StatusDescript() string { | ||
| 54 | + switch t.Status { | ||
| 55 | + case TaskWait: | ||
| 56 | + return "待启动" | ||
| 57 | + case TaskRunning: | ||
| 58 | + return "启动中" | ||
| 59 | + case TaskStop: | ||
| 60 | + return "停止" | ||
| 61 | + } | ||
| 62 | + return "" | ||
| 63 | +} | ||
| 64 | + | ||
| 52 | type TaskRepository interface { | 65 | type TaskRepository interface { |
| 53 | Save(param *Task) error | 66 | Save(param *Task) error |
| 54 | Remove(id int) error | 67 | Remove(id int) error |
| @@ -8,10 +8,10 @@ import ( | @@ -8,10 +8,10 @@ import ( | ||
| 8 | 8 | ||
| 9 | func TestGenerateToken(t *testing.T) { | 9 | func TestGenerateToken(t *testing.T) { |
| 10 | ut := UserAuth{ | 10 | ut := UserAuth{ |
| 11 | - CompanyId: 1, | ||
| 12 | - UserId: 3245763368183552, | ||
| 13 | - Phone: "18650060951", | ||
| 14 | - PlatformId: 29, | 11 | + CompanyId: 233, |
| 12 | + UserId: 3240357405361920, | ||
| 13 | + Phone: "13459147023", | ||
| 14 | + PlatformId: 28, | ||
| 15 | AdminType: 1, | 15 | AdminType: 1, |
| 16 | } | 16 | } |
| 17 | tk, _ := ut.CreateAccessToken() | 17 | tk, _ := ut.CreateAccessToken() |
| @@ -54,6 +54,7 @@ func init() { | @@ -54,6 +54,7 @@ func init() { | ||
| 54 | &models.MessagePersonal{}, | 54 | &models.MessagePersonal{}, |
| 55 | &models.Task{}, | 55 | &models.Task{}, |
| 56 | &models.TaskStage{}, | 56 | &models.TaskStage{}, |
| 57 | + &models.TaskIgnore{}, | ||
| 57 | } | 58 | } |
| 58 | for _, model := range tables { | 59 | for _, model := range tables { |
| 59 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ | 60 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ |
| @@ -5,7 +5,7 @@ import "time" | @@ -5,7 +5,7 @@ import "time" | ||
| 5 | // 不关注的任务列表 | 5 | // 不关注的任务列表 |
| 6 | type TaskIgnore struct { | 6 | type TaskIgnore struct { |
| 7 | tableName struct{} `comment:"不关注的任务列表" pg:"task_ignore"` | 7 | tableName struct{} `comment:"不关注的任务列表" pg:"task_ignore"` |
| 8 | - Id int `pg:"id"` | 8 | + Id int `pg:"id,pk"` |
| 9 | TaskId int `pg:"task_id"` | 9 | TaskId int `pg:"task_id"` |
| 10 | UserId int `pg:"user_id"` | 10 | UserId int `pg:"user_id"` |
| 11 | CreatedAt time.Time `pg:"created_at"` | 11 | CreatedAt time.Time `pg:"created_at"` |
| @@ -5,14 +5,14 @@ import "time" | @@ -5,14 +5,14 @@ import "time" | ||
| 5 | // 任务阶段 | 5 | // 任务阶段 |
| 6 | type TaskStage struct { | 6 | type TaskStage struct { |
| 7 | tableName struct{} `comment:"任务阶段" pg:"task_stage"` | 7 | tableName struct{} `comment:"任务阶段" pg:"task_stage"` |
| 8 | - Id int `pg:"id"` | 8 | + Id int `pg:"id,pk"` |
| 9 | TaskId int `pg:"task_id"` | 9 | TaskId int `pg:"task_id"` |
| 10 | CreatedAt time.Time `pg:"created_at"` | 10 | CreatedAt time.Time `pg:"created_at"` |
| 11 | UpdatedAt time.Time `pg:"updated_at"` | 11 | UpdatedAt time.Time `pg:"updated_at"` |
| 12 | DeletedAt *time.Time `pg:"deleted_at"` | 12 | DeletedAt *time.Time `pg:"deleted_at"` |
| 13 | - Name string `pg:"name"` //里程碑名称 | ||
| 14 | - SortBy int `pg:"sort_by"` //排序 | ||
| 15 | - Status int `pg:"status"` //里程碑完成情况 | ||
| 16 | - PlanCompletedAt int64 `pg:"plan_completed_at"` //计划完成时间 | ||
| 17 | - RealCompletedAt int64 `pg:"real_completed_at"` //时间完成时间 | 13 | + Name string `pg:"name"` //里程碑名称 |
| 14 | + SortBy int `pg:"sort_by"` //排序 | ||
| 15 | + Status int `pg:"status"` //里程碑完成情况 | ||
| 16 | + PlanCompletedAt int64 `pg:"plan_completed_at,use_zero"` //计划完成时间 | ||
| 17 | + RealCompletedAt int64 `pg:"real_completed_at,use_zero"` //时间完成时间 | ||
| 18 | } | 18 | } |
-
请 注册 或 登录 后发表评论