作者 tangxvhui

更新

@@ -4,8 +4,10 @@ type TaskInfoAdapter struct { @@ -4,8 +4,10 @@ type TaskInfoAdapter struct {
4 Id int `json:"id,string"` 4 Id int `json:"id,string"`
5 Name string `json:"name"` // 任务名称 5 Name string `json:"name"` // 任务名称
6 Alias string `json:"alias"` // 任务别名 6 Alias string `json:"alias"` // 任务别名
  7 + LeaderId int64 `json:"leaderId,string"` //
7 Leader UserData `json:"leader"` // 任务负责人 8 Leader UserData `json:"leader"` // 任务负责人
8 Status int `json:"status"` // 任务的状态 9 Status int `json:"status"` // 任务的状态
  10 + StatusDescript string `json:"statusDescript"` //
9 Level int `json:"level"` // 优先级,值越小优先级越高 11 Level int `json:"level"` // 优先级,值越小优先级越高
10 LevalName string `json:"levalName"` // 优先级名称 12 LevalName string `json:"levalName"` // 优先级名称
11 RelatedUserId []string `json:"relatedUserId"` // 相关的员工id 13 RelatedUserId []string `json:"relatedUserId"` // 相关的员工id
@@ -2,6 +2,6 @@ package command @@ -2,6 +2,6 @@ package command
2 2
3 // 获取任务 3 // 获取任务
4 type GetTaskCommand struct { 4 type GetTaskCommand struct {
5 - TaskId int `json:"taskId"` 5 + TaskId int `json:"taskId,string"`
6 CompanyId int `json:"-"` 6 CompanyId int `json:"-"`
7 } 7 }
@@ -3,7 +3,6 @@ package command @@ -3,7 +3,6 @@ package command
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"` //任务名称 5 Alias string `json:"alias"` //任务名称
6 - LeaderId int `json:"leaderId,string"` //负责id  
7 LevelName string `json:"levelName"` //优先级 6 LevelName string `json:"levelName"` //优先级
8 StageList []struct { 7 StageList []struct {
9 Id int `json:"id,string"` 8 Id int `json:"id,string"`
@@ -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,12 +276,15 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task @@ -292,12 +276,15 @@ 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{}{ 279 + var relatedUserList []*domain.User
  280 + if len(relatedUserId) > 0 {
  281 + _, relatedUserList, err = userRepo.Find(map[string]interface{}{
296 "ids": relatedUserId, 282 "ids": relatedUserId,
297 }) 283 })
298 if err != nil { 284 if err != nil {
299 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取相关人员"+err.Error()) 285 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取相关人员"+err.Error())
300 } 286 }
  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 }
@@ -306,12 +293,14 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task @@ -306,12 +293,14 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task
306 Id: taskData.Id, 293 Id: taskData.Id,
307 Name: taskData.Name, 294 Name: taskData.Name,
308 Alias: taskData.Alias, 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), 302 Status: int(taskData.Status),
  303 + StatusDescript: taskData.StatusDescript(),
315 Level: taskData.Level, 304 Level: taskData.Level,
316 LevalName: taskData.LevelName, 305 LevalName: taskData.LevelName,
317 RelatedUserId: []string{}, 306 RelatedUserId: []string{},
@@ -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,7 +5,7 @@ import "time" @@ -5,7 +5,7 @@ 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"`
@@ -13,6 +13,6 @@ type TaskStage struct { @@ -13,6 +13,6 @@ type TaskStage struct {
13 Name string `pg:"name"` //里程碑名称 13 Name string `pg:"name"` //里程碑名称
14 SortBy int `pg:"sort_by"` //排序 14 SortBy int `pg:"sort_by"` //排序
15 Status int `pg:"status"` //里程碑完成情况 15 Status int `pg:"status"` //里程碑完成情况
16 - PlanCompletedAt int64 `pg:"plan_completed_at"` //计划完成时间  
17 - RealCompletedAt int64 `pg:"real_completed_at"` //时间完成时间 16 + PlanCompletedAt int64 `pg:"plan_completed_at,use_zero"` //计划完成时间
  17 + RealCompletedAt int64 `pg:"real_completed_at,use_zero"` //时间完成时间
18 } 18 }