Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/performance into test
正在显示
7 个修改的文件
包含
68 行增加
和
3 行删除
@@ -8,3 +8,8 @@ type RuleAdapter struct { | @@ -8,3 +8,8 @@ type RuleAdapter struct { | ||
8 | *domain.EvaluationRule | 8 | *domain.EvaluationRule |
9 | CreatorName string `json:"creatorName" comment:"创建人名称"` | 9 | CreatorName string `json:"creatorName" comment:"创建人名称"` |
10 | } | 10 | } |
11 | + | ||
12 | +type CreatorAdapter struct { | ||
13 | + Id int64 `json:"id,string" comment:"创建人ID"` | ||
14 | + Name string `json:"name" comment:"创建人名称"` | ||
15 | +} |
@@ -11,9 +11,20 @@ type QueryRuleCommand struct { | @@ -11,9 +11,20 @@ type QueryRuleCommand struct { | ||
11 | PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | 11 | PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` |
12 | } | 12 | } |
13 | 13 | ||
14 | +type QueryCreatorCommand struct { | ||
15 | + CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
16 | +} | ||
17 | + | ||
14 | func (in *QueryRuleCommand) Valid(validation *validation.Validation) { | 18 | func (in *QueryRuleCommand) Valid(validation *validation.Validation) { |
15 | if in.CompanyId == 0 { | 19 | if in.CompanyId == 0 { |
16 | validation.SetError("companyId", "公司ID无效") | 20 | validation.SetError("companyId", "公司ID无效") |
17 | return | 21 | return |
18 | } | 22 | } |
19 | } | 23 | } |
24 | + | ||
25 | +func (in *QueryCreatorCommand) Valid(validation *validation.Validation) { | ||
26 | + if in.CompanyId == 0 { | ||
27 | + validation.SetError("companyId", "公司ID无效") | ||
28 | + return | ||
29 | + } | ||
30 | +} |
@@ -212,3 +212,40 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | @@ -212,3 +212,40 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | ||
212 | } | 212 | } |
213 | return tool_funs.SimpleWrapGridMap(total, ras), nil | 213 | return tool_funs.SimpleWrapGridMap(total, ras), nil |
214 | } | 214 | } |
215 | + | ||
216 | +func (rs *EvaluationRuleService) ListCreator(in *command.QueryCreatorCommand) (interface{}, error) { | ||
217 | + transactionContext, err := factory.StartTransaction() | ||
218 | + if err != nil { | ||
219 | + return nil, err | ||
220 | + } | ||
221 | + defer func() { | ||
222 | + transactionContext.RollbackTransaction() | ||
223 | + }() | ||
224 | + ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
225 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
226 | + | ||
227 | + _, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in)) | ||
228 | + if err != nil { | ||
229 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
230 | + } | ||
231 | + | ||
232 | + // 获取所有创建人ID | ||
233 | + creatorMap := map[int64]int64{} | ||
234 | + for i := range rules { | ||
235 | + creatorMap[rules[i].CreatorId] = rules[i].CreatorId | ||
236 | + } | ||
237 | + creatorIds := make([]int64, 0) | ||
238 | + for k := range creatorMap { | ||
239 | + creatorIds = append(creatorIds, k) | ||
240 | + } | ||
241 | + _, users, _ := userRepository.Find(map[string]interface{}{"ids": creatorIds, "limit": len(creatorIds)}) | ||
242 | + cas := make([]*adapter.CreatorAdapter, 0) | ||
243 | + for i := range users { | ||
244 | + ca := &adapter.CreatorAdapter{ | ||
245 | + Id: users[i].Id, | ||
246 | + Name: users[i].Name, | ||
247 | + } | ||
248 | + cas = append(cas, ca) | ||
249 | + } | ||
250 | + return map[string]interface{}{"list": cas}, nil | ||
251 | +} |
@@ -85,7 +85,19 @@ func (controller *RuleController) ListRuleRelCreator() { | @@ -85,7 +85,19 @@ func (controller *RuleController) ListRuleRelCreator() { | ||
85 | } | 85 | } |
86 | ua := middlewares.GetUser(controller.Ctx) | 86 | ua := middlewares.GetUser(controller.Ctx) |
87 | in.CompanyId = ua.CompanyId | 87 | in.CompanyId = ua.CompanyId |
88 | - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
89 | controller.Response(ruService.ListRelCreator(in)) | 88 | controller.Response(ruService.ListRelCreator(in)) |
90 | } | 89 | } |
91 | } | 90 | } |
91 | + | ||
92 | +func (controller *RuleController) ListCreator() { | ||
93 | + ruService := service.NewEvaluationRuleService() | ||
94 | + in := &command.QueryCreatorCommand{} | ||
95 | + if err := controller.Unmarshal(in); err != nil { | ||
96 | + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
97 | + } else { | ||
98 | + | ||
99 | + ua := middlewares.GetUser(controller.Ctx) | ||
100 | + in.CompanyId = ua.CompanyId | ||
101 | + controller.Response(ruService.ListCreator(in)) | ||
102 | + } | ||
103 | +} |
@@ -111,8 +111,6 @@ func (controller *TemplateController) CopyTemplate() { | @@ -111,8 +111,6 @@ func (controller *TemplateController) CopyTemplate() { | ||
111 | ua := middlewares.GetUser(controller.Ctx) | 111 | ua := middlewares.GetUser(controller.Ctx) |
112 | in.CompanyId = ua.CompanyId | 112 | in.CompanyId = ua.CompanyId |
113 | in.CreatorId = ua.UserId | 113 | in.CreatorId = ua.UserId |
114 | - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
115 | - //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
116 | controller.Response(ruService.Copy(in)) | 114 | controller.Response(ruService.Copy(in)) |
117 | } | 115 | } |
118 | } | 116 | } |
@@ -15,6 +15,7 @@ func init() { | @@ -15,6 +15,7 @@ func init() { | ||
15 | web.NSRouter("/", &controllers.RuleController{}, "Delete:RemoveRule"), | 15 | web.NSRouter("/", &controllers.RuleController{}, "Delete:RemoveRule"), |
16 | web.NSRouter("/:Id", &controllers.RuleController{}, "Get:GetRule"), | 16 | web.NSRouter("/:Id", &controllers.RuleController{}, "Get:GetRule"), |
17 | web.NSRouter("/list", &controllers.RuleController{}, "Post:ListRuleRelCreator"), | 17 | web.NSRouter("/list", &controllers.RuleController{}, "Post:ListRuleRelCreator"), |
18 | + web.NSRouter("/list-creator", &controllers.RuleController{}, "Post:ListCreator"), | ||
18 | ) | 19 | ) |
19 | web.AddNamespace(ns) | 20 | web.AddNamespace(ns) |
20 | } | 21 | } |
@@ -16,6 +16,7 @@ func init() { | @@ -16,6 +16,7 @@ func init() { | ||
16 | web.NSRouter("/:Id", &controllers.TemplateController{}, "Get:GetTemplate"), | 16 | web.NSRouter("/:Id", &controllers.TemplateController{}, "Get:GetTemplate"), |
17 | web.NSRouter("/list", &controllers.TemplateController{}, "Post:ListTemplate"), | 17 | web.NSRouter("/list", &controllers.TemplateController{}, "Post:ListTemplate"), |
18 | web.NSRouter("/list-enable", &controllers.TemplateController{}, "Post:ListEnableTemplate"), | 18 | web.NSRouter("/list-enable", &controllers.TemplateController{}, "Post:ListEnableTemplate"), |
19 | + web.NSRouter("/copy", &controllers.TemplateController{}, "Post:CopyTemplate"), | ||
19 | ) | 20 | ) |
20 | web.AddNamespace(ns) | 21 | web.AddNamespace(ns) |
21 | } | 22 | } |
-
请 注册 或 登录 后发表评论