正在显示
13 个修改的文件
包含
44 行增加
和
39 行删除
| @@ -19,8 +19,7 @@ type CycleTemplateListCommand struct { | @@ -19,8 +19,7 @@ type CycleTemplateListCommand struct { | ||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | type CycleTemplateCommand struct { | 21 | type CycleTemplateCommand struct { |
| 22 | - CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | ||
| 23 | - TemplateId int64 `cname:"模板ID" json:"templateId,string" valid:"Required"` | 22 | + Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` |
| 24 | } | 23 | } |
| 25 | 24 | ||
| 26 | func (in *QueryCycleCommand) Valid(validation *validation.Validation) { | 25 | func (in *QueryCycleCommand) Valid(validation *validation.Validation) { |
| @@ -321,6 +321,10 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface | @@ -321,6 +321,10 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface | ||
| 321 | if err != nil { | 321 | if err != nil { |
| 322 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 322 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 323 | } | 323 | } |
| 324 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 325 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 326 | + } | ||
| 327 | + | ||
| 324 | return tool_funs.SimpleWrapGridMap(total, cycles), nil | 328 | return tool_funs.SimpleWrapGridMap(total, cycles), nil |
| 325 | } | 329 | } |
| 326 | 330 | ||
| @@ -333,7 +337,7 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP | @@ -333,7 +337,7 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP | ||
| 333 | transactionContext.RollbackTransaction() | 337 | transactionContext.RollbackTransaction() |
| 334 | }() | 338 | }() |
| 335 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 339 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 336 | - _, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | 340 | + _, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "template") |
| 337 | if err != nil { | 341 | if err != nil { |
| 338 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 342 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 339 | } | 343 | } |
| @@ -347,8 +351,8 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP | @@ -347,8 +351,8 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP | ||
| 347 | userIdMap[userId] = userId | 351 | userIdMap[userId] = userId |
| 348 | } | 352 | } |
| 349 | } | 353 | } |
| 350 | - for _, v := range userIdMap { | ||
| 351 | - userIds = append(userIds, v) | 354 | + for k := range userIdMap { |
| 355 | + userIds = append(userIds, k) | ||
| 352 | } | 356 | } |
| 353 | 357 | ||
| 354 | userTotal := 0 | 358 | userTotal := 0 |
| @@ -412,7 +416,7 @@ func (rs *EvaluationCycleService) CycleTemplate(in *command.CycleTemplateCommand | @@ -412,7 +416,7 @@ func (rs *EvaluationCycleService) CycleTemplate(in *command.CycleTemplateCommand | ||
| 412 | }() | 416 | }() |
| 413 | 417 | ||
| 414 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | 418 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 415 | - cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId}) | 419 | + cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.Id}) |
| 416 | if err != nil { | 420 | if err != nil { |
| 417 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 421 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 418 | } | 422 | } |
| @@ -132,7 +132,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -132,7 +132,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
| 132 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 132 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 133 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | 133 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 134 | 134 | ||
| 135 | - _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "linkNodes") | 135 | + _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template") |
| 136 | if err != nil { | 136 | if err != nil { |
| 137 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 137 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 138 | } | 138 | } |
| @@ -271,7 +271,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | @@ -271,7 +271,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | ||
| 271 | }() | 271 | }() |
| 272 | 272 | ||
| 273 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 273 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 274 | - total, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | 274 | + total, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "template") |
| 275 | if err != nil { | 275 | if err != nil { |
| 276 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 276 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 277 | } | 277 | } |
| @@ -371,7 +371,7 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo | @@ -371,7 +371,7 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo | ||
| 371 | 371 | ||
| 372 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 372 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 373 | 373 | ||
| 374 | - _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "linkNodes") | 374 | + _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template") |
| 375 | if err != nil { | 375 | if err != nil { |
| 376 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 376 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 377 | } | 377 | } |
| @@ -34,7 +34,7 @@ func (rs *RoleUserService) Create(in *command.UserRoleCreateCommand) (interface{ | @@ -34,7 +34,7 @@ func (rs *RoleUserService) Create(in *command.UserRoleCreateCommand) (interface{ | ||
| 34 | // int64Array = append(int64Array, int64Num) | 34 | // int64Array = append(int64Array, int64Num) |
| 35 | //} | 35 | //} |
| 36 | // 检测已存在的关联用户 | 36 | // 检测已存在的关联用户 |
| 37 | - _, rus, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.RoleId, "companyId": in.CompanyId, "userIds": in.UserIds, "limit": 9999999}) | 37 | + _, rus, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.RoleId, "companyId": in.CompanyId, "userIds": in.UserIds, "limit": int64(9999999)}) |
| 38 | if err != nil { | 38 | if err != nil { |
| 39 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 39 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 40 | } | 40 | } |
| @@ -127,11 +127,11 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | @@ -127,11 +127,11 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | ||
| 127 | query.Where("company_id = ?", v) | 127 | query.Where("company_id = ?", v) |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | - if v, ok := queryOptions["limit"].(int); ok { | ||
| 131 | - query.Limit(v) | 130 | + if v, ok := queryOptions["limit"].(int64); ok { |
| 131 | + query.Limit(int(v)) | ||
| 132 | } | 132 | } |
| 133 | - if v, ok := queryOptions["offset"].(int); ok { | ||
| 134 | - query.Offset(v) | 133 | + if v, ok := queryOptions["offset"].(int64); ok { |
| 134 | + query.Offset(int(v)) | ||
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | if v, ok := queryOptions["timeStart"]; ok { | 137 | if v, ok := queryOptions["timeStart"]; ok { |
| @@ -153,11 +153,11 @@ func (repo *EvaluationCycleTemplateRepository) Find(queryOptions map[string]inte | @@ -153,11 +153,11 @@ func (repo *EvaluationCycleTemplateRepository) Find(queryOptions map[string]inte | ||
| 153 | query.Where("cycle_id = ?", v) | 153 | query.Where("cycle_id = ?", v) |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | - if v, ok := queryOptions["limit"].(int); ok { | ||
| 157 | - query.Limit(v) | 156 | + if v, ok := queryOptions["limit"].(int64); ok { |
| 157 | + query.Limit(int(v)) | ||
| 158 | } | 158 | } |
| 159 | - if v, ok := queryOptions["offset"].(int); ok { | ||
| 160 | - query.Offset(v) | 159 | + if v, ok := queryOptions["offset"].(int64); ok { |
| 160 | + query.Offset(int(v)) | ||
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | count, err := query.SelectAndCount() | 163 | count, err := query.SelectAndCount() |
| @@ -159,11 +159,11 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ | @@ -159,11 +159,11 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ | ||
| 159 | } | 159 | } |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | - if v, ok := queryOptions["limit"].(int); ok { | ||
| 163 | - query.Limit(v) | 162 | + if v, ok := queryOptions["limit"].(int64); ok { |
| 163 | + query.Limit(int(v)) | ||
| 164 | } | 164 | } |
| 165 | - if v, ok := queryOptions["offset"].(int); ok { | ||
| 166 | - query.Offset(v) | 165 | + if v, ok := queryOptions["offset"].(int64); ok { |
| 166 | + query.Offset(int(v)) | ||
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | count, err := query.SelectAndCount() | 169 | count, err := query.SelectAndCount() |
| @@ -143,11 +143,11 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | @@ -143,11 +143,11 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | ||
| 143 | query.Where("type = ?", v) | 143 | query.Where("type = ?", v) |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | - if v, ok := queryOptions["limit"].(int); ok { | ||
| 147 | - query.Limit(v) | 146 | + if v, ok := queryOptions["limit"].(int64); ok { |
| 147 | + query.Limit(int(v)) | ||
| 148 | } | 148 | } |
| 149 | - if v, ok := queryOptions["offset"].(int); ok { | ||
| 150 | - query.Offset(v) | 149 | + if v, ok := queryOptions["offset"].(int64); ok { |
| 150 | + query.Offset(int(v)) | ||
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | count, err := query.SelectAndCount() | 153 | count, err := query.SelectAndCount() |
| @@ -150,11 +150,11 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | @@ -150,11 +150,11 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | ||
| 150 | query.Where("created_at <= ?", end) | 150 | query.Where("created_at <= ?", end) |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | - if v, ok := queryOptions["limit"].(int); ok { | ||
| 154 | - query.Limit(v) | 153 | + if v, ok := queryOptions["limit"].(int64); ok { |
| 154 | + query.Limit(int(v)) | ||
| 155 | } | 155 | } |
| 156 | - if v, ok := queryOptions["offset"].(int); ok { | ||
| 157 | - query.Offset(v) | 156 | + if v, ok := queryOptions["offset"].(int64); ok { |
| 157 | + query.Offset(int(v)) | ||
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | count, err := query.SelectAndCount() | 160 | count, err := query.SelectAndCount() |
| @@ -121,11 +121,11 @@ func (repo *RoleRepository) Find(queryOptions map[string]interface{}) (int64, [] | @@ -121,11 +121,11 @@ func (repo *RoleRepository) Find(queryOptions map[string]interface{}) (int64, [] | ||
| 121 | query.Where("company_id = ?", companyId) | 121 | query.Where("company_id = ?", companyId) |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | - if v, ok := queryOptions["limit"].(int); ok { | ||
| 125 | - query.Limit(v) | 124 | + if v, ok := queryOptions["limit"].(int64); ok { |
| 125 | + query.Limit(int(v)) | ||
| 126 | } | 126 | } |
| 127 | - if v, ok := queryOptions["offset"].(int); ok { | ||
| 128 | - query.Offset(v) | 127 | + if v, ok := queryOptions["offset"].(int64); ok { |
| 128 | + query.Offset(int(v)) | ||
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | count, err := query.SelectAndCount() | 131 | count, err := query.SelectAndCount() |
| @@ -128,11 +128,11 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64 | @@ -128,11 +128,11 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64 | ||
| 128 | query.Where("user_id in (?)", pg.In(userIds)) | 128 | query.Where("user_id in (?)", pg.In(userIds)) |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | - if v, ok := queryOptions["limit"].(int); ok { | ||
| 132 | - query.Limit(v) | 131 | + if v, ok := queryOptions["limit"].(int64); ok { |
| 132 | + query.Limit(int(v)) | ||
| 133 | } | 133 | } |
| 134 | - if v, ok := queryOptions["offset"].(int); ok { | ||
| 135 | - query.Offset(v) | 134 | + if v, ok := queryOptions["offset"].(int64); ok { |
| 135 | + query.Offset(int(v)) | ||
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | count, err := query.SelectAndCount() | 138 | count, err := query.SelectAndCount() |
| @@ -99,9 +99,10 @@ func (controller *CycleController) CycleTemplateList() { | @@ -99,9 +99,10 @@ func (controller *CycleController) CycleTemplateList() { | ||
| 99 | func (controller *CycleController) CycleTemplate() { | 99 | func (controller *CycleController) CycleTemplate() { |
| 100 | ruService := service.NewEvaluationCycleService() | 100 | ruService := service.NewEvaluationCycleService() |
| 101 | in := &command.CycleTemplateCommand{} | 101 | in := &command.CycleTemplateCommand{} |
| 102 | - if err := controller.Unmarshal(in); err != nil { | 102 | + if id, err := controller.GetInt64(":Id"); err != nil { |
| 103 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 103 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 104 | } else { | 104 | } else { |
| 105 | + in.Id = id | ||
| 105 | controller.Response(ruService.CycleTemplate(in)) | 106 | controller.Response(ruService.CycleTemplate(in)) |
| 106 | } | 107 | } |
| 107 | } | 108 | } |
| @@ -17,6 +17,7 @@ func init() { | @@ -17,6 +17,7 @@ func init() { | ||
| 17 | web.NSRouter("/list", &controllers.CycleController{}, "Post:ListCycle"), | 17 | web.NSRouter("/list", &controllers.CycleController{}, "Post:ListCycle"), |
| 18 | web.NSRouter("/statistic", &controllers.CycleController{}, "Post:StatisticCycleUser"), | 18 | web.NSRouter("/statistic", &controllers.CycleController{}, "Post:StatisticCycleUser"), |
| 19 | web.NSRouter("/templates", &controllers.CycleController{}, "Post:CycleTemplateList"), | 19 | web.NSRouter("/templates", &controllers.CycleController{}, "Post:CycleTemplateList"), |
| 20 | + web.NSRouter("/template/:Id", &controllers.CycleController{}, "Get:CycleTemplate"), | ||
| 20 | ) | 21 | ) |
| 21 | web.AddNamespace(ns) | 22 | web.AddNamespace(ns) |
| 22 | } | 23 | } |
-
请 注册 或 登录 后发表评论