Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/performance into test
正在显示
23 个修改的文件
包含
397 行增加
和
218 行删除
@@ -11,7 +11,7 @@ type CreateCycleCommand struct { | @@ -11,7 +11,7 @@ type CreateCycleCommand struct { | ||
11 | Name string `cname:"周期名称" json:"name" valid:"Required"` | 11 | Name string `cname:"周期名称" json:"name" valid:"Required"` |
12 | TimeStart *time.Time `cname:"起始时间" json:"timeStart"` | 12 | TimeStart *time.Time `cname:"起始时间" json:"timeStart"` |
13 | TimeEnd *time.Time `cname:"截至时间" json:"timeEnd"` | 13 | TimeEnd *time.Time `cname:"截至时间" json:"timeEnd"` |
14 | - KpiCycle int `cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"` | 14 | + KpiCycle int `cname:"考核周期" json:"kpiCycle" valid:"Required"` |
15 | TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` | 15 | TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` |
16 | } | 16 | } |
17 | 17 |
@@ -15,3 +15,12 @@ func (in *QueryCycleCommand) Valid(validation *validation.Validation) { | @@ -15,3 +15,12 @@ func (in *QueryCycleCommand) Valid(validation *validation.Validation) { | ||
15 | return | 15 | return |
16 | } | 16 | } |
17 | } | 17 | } |
18 | + | ||
19 | +type StatisticCycleProjectUserCommand struct { | ||
20 | + CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
21 | + CycleId int64 `cname:"周期ID" json:"cycleId,string"` | ||
22 | +} | ||
23 | + | ||
24 | +func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) { | ||
25 | + | ||
26 | +} |
@@ -62,6 +62,9 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -62,6 +62,9 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
62 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 62 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
63 | } | 63 | } |
64 | 64 | ||
65 | + ctAdapter := &adapter.CycleTemplateAdapter{} | ||
66 | + ctAdapter.EvaluationCycle = cycle | ||
67 | + | ||
65 | for i := range templates { | 68 | for i := range templates { |
66 | v := templates[i] | 69 | v := templates[i] |
67 | cycleTemplate := &domain.EvaluationCycleTemplate{ | 70 | cycleTemplate := &domain.EvaluationCycleTemplate{ |
@@ -74,12 +77,18 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -74,12 +77,18 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
74 | if err != nil { | 77 | if err != nil { |
75 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 78 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
76 | } | 79 | } |
80 | + | ||
81 | + ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ | ||
82 | + Id: v.Id, | ||
83 | + Name: v.Name, | ||
84 | + CreatedAt: v.CreatedAt, | ||
85 | + }) | ||
77 | } | 86 | } |
78 | 87 | ||
79 | if err := transactionContext.CommitTransaction(); err != nil { | 88 | if err := transactionContext.CommitTransaction(); err != nil { |
80 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 89 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
81 | } | 90 | } |
82 | - return cycle, nil | 91 | + return ctAdapter, nil |
83 | 92 | ||
84 | } | 93 | } |
85 | 94 | ||
@@ -166,10 +175,26 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | @@ -166,10 +175,26 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | ||
166 | if err != nil { | 175 | if err != nil { |
167 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 176 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
168 | } | 177 | } |
178 | + | ||
179 | + _, cycleTemplates, err := cycleTemplateRepository.Find(map[string]interface{}{"cycleId": cycle.Id}, "template") | ||
180 | + if err != nil { | ||
181 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
182 | + } | ||
183 | + | ||
184 | + ctAdapter := &adapter.CycleTemplateAdapter{} | ||
185 | + ctAdapter.EvaluationCycle = cycle | ||
186 | + for i := range cycleTemplates { | ||
187 | + ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ | ||
188 | + Id: cycleTemplates[i].Id, | ||
189 | + Name: cycleTemplates[i].Name, | ||
190 | + CreatedAt: cycleTemplates[i].CreatedAt, | ||
191 | + }) | ||
192 | + } | ||
193 | + | ||
169 | if err := transactionContext.CommitTransaction(); err != nil { | 194 | if err := transactionContext.CommitTransaction(); err != nil { |
170 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 195 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
171 | } | 196 | } |
172 | - return cycle, nil | 197 | + return ctAdapter, nil |
173 | } | 198 | } |
174 | 199 | ||
175 | func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, error) { | 200 | func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, error) { |
@@ -255,3 +280,51 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface | @@ -255,3 +280,51 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface | ||
255 | } | 280 | } |
256 | return tool_funs.SimpleWrapGridMap(total, cycles), nil | 281 | return tool_funs.SimpleWrapGridMap(total, cycles), nil |
257 | } | 282 | } |
283 | + | ||
284 | +func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleProjectUserCommand) (interface{}, error) { | ||
285 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
286 | + if err != nil { | ||
287 | + return nil, err | ||
288 | + } | ||
289 | + defer func() { | ||
290 | + transactionContext.RollbackTransaction() | ||
291 | + }() | ||
292 | + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
293 | + _, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | ||
294 | + if err != nil { | ||
295 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
296 | + } | ||
297 | + | ||
298 | + userIds := make([]int64, 0) | ||
299 | + userIdMap := map[int64]int64{} | ||
300 | + for i := range projects { | ||
301 | + project := projects[i] | ||
302 | + for j := range project.Recipients { | ||
303 | + userId, _ := strconv.ParseInt(project.Recipients[j], 10, 64) | ||
304 | + userIdMap[userId] = userId | ||
305 | + } | ||
306 | + } | ||
307 | + for _, v := range userIdMap { | ||
308 | + userIds = append(userIds, v) | ||
309 | + } | ||
310 | + | ||
311 | + userTotal := 0 | ||
312 | + departmentTotal := 0 | ||
313 | + if len(userIds) > 0 { | ||
314 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
315 | + _, users, _ := userRepository.Find(map[string]interface{}{"ids": userIds, "limit": len(userIds)}) | ||
316 | + departmentIdMap := map[int]int{} | ||
317 | + for i := range users { | ||
318 | + for _, v := range users[i].DepartmentId { | ||
319 | + departmentIdMap[v] = v | ||
320 | + } | ||
321 | + } | ||
322 | + userTotal = len(users) | ||
323 | + departmentTotal = len(departmentIdMap) | ||
324 | + } | ||
325 | + | ||
326 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
327 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
328 | + } | ||
329 | + return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil | ||
330 | +} |
@@ -2,25 +2,19 @@ package command | @@ -2,25 +2,19 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | -type StateProjectCommand struct { | 7 | +type ActivateProjectCommand struct { |
9 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | 8 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` |
10 | - State int `cname:"项目状态" json:"state"` | ||
11 | } | 9 | } |
12 | 10 | ||
13 | type CopyProjectCommand struct { | 11 | type CopyProjectCommand struct { |
12 | + CreatorId int64 `cname:"创建人ID" json:"creatorId"` | ||
14 | Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` | 13 | Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` |
15 | } | 14 | } |
16 | 15 | ||
17 | -func (in *StateProjectCommand) Valid(validation *validation.Validation) { | ||
18 | - switch in.State { | ||
19 | - case domain.ProjectStateWaitConfig, domain.ProjectStateWaitActive, domain.ProjectStateEnable, domain.ProjectStateDisable: | ||
20 | - default: | ||
21 | - validation.SetError("state", "状态设置错误") | ||
22 | - return | ||
23 | - } | 16 | +func (in *ActivateProjectCommand) Valid(validation *validation.Validation) { |
17 | + | ||
24 | } | 18 | } |
25 | 19 | ||
26 | func (in *CopyProjectCommand) Valid(*validation.Validation) { | 20 | func (in *CopyProjectCommand) Valid(*validation.Validation) { |
@@ -18,12 +18,3 @@ func (in *QueryProjectCommand) Valid(validation *validation.Validation) { | @@ -18,12 +18,3 @@ func (in *QueryProjectCommand) Valid(validation *validation.Validation) { | ||
18 | return | 18 | return |
19 | } | 19 | } |
20 | } | 20 | } |
21 | - | ||
22 | -type StatisticCycleProjectUserCommand struct { | ||
23 | - CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
24 | - CycleId int64 `cname:"周期ID" json:"cycleId,string"` | ||
25 | -} | ||
26 | - | ||
27 | -func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) { | ||
28 | - | ||
29 | -} |
@@ -2,7 +2,7 @@ package command | @@ -2,7 +2,7 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 5 | + "time" |
6 | ) | 6 | ) |
7 | 7 | ||
8 | type UpdateProjectCommand struct { | 8 | type UpdateProjectCommand struct { |
@@ -22,15 +22,18 @@ type UpdateProjectTemplateCommand struct { | @@ -22,15 +22,18 @@ type UpdateProjectTemplateCommand struct { | ||
22 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | 22 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` |
23 | TemplateId int64 `cname:"模板ID" json:"templateId,string"` | 23 | TemplateId int64 `cname:"模板ID" json:"templateId,string"` |
24 | Recipients []string `cname:"被评估人ID" json:"recipients"` | 24 | Recipients []string `cname:"被评估人ID" json:"recipients"` |
25 | + TimeStart *time.Time `cname:"自评起始时间" json:"timeStart" valid:"Required"` | ||
26 | + TimeEnd *time.Time `cname:"自评截止时间" json:"timeEnd" valid:"Required"` | ||
27 | + KpiCycle int `cname:"评估周期" json:"kpiCycle" valid:"Required"` | ||
28 | + KpiResultStart *time.Time `cname:"绩效结果开始查看时间" json:"kpiResultStart"` | ||
29 | + Activate int `cname:"启动项目" json:"activate"` | ||
25 | } | 30 | } |
26 | 31 | ||
27 | -type UpdateProjectTemplateNodeCommand struct { | 32 | +type CheckRecipientCommand struct { |
28 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 33 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
29 | CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | 34 | CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` |
30 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | 35 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` |
31 | - TemplateId int64 `cname:"模板ID" json:"templateId,string" valid:"Required"` | ||
32 | - LinkNodes []*domain.LinkNode `cname:"评估流程" json:"linkNodes"` | ||
33 | - Activate int `cname:"启动项目" json:"activate"` | 36 | + Recipients []string `cname:"被评估人ID" json:"recipients"` |
34 | } | 37 | } |
35 | 38 | ||
36 | func (in *UpdateProjectCommand) Valid(validation *validation.Validation) { | 39 | func (in *UpdateProjectCommand) Valid(validation *validation.Validation) { |
@@ -46,10 +49,3 @@ func (in *UpdateProjectTemplateCommand) Valid(validation *validation.Validation) | @@ -46,10 +49,3 @@ func (in *UpdateProjectTemplateCommand) Valid(validation *validation.Validation) | ||
46 | return | 49 | return |
47 | } | 50 | } |
48 | } | 51 | } |
49 | - | ||
50 | -func (in *UpdateProjectTemplateNodeCommand) Valid(validation *validation.Validation) { | ||
51 | - if len(in.LinkNodes) == 0 { | ||
52 | - validation.SetError("linkNodes", "请添加评估流程") | ||
53 | - return | ||
54 | - } | ||
55 | -} |
@@ -55,10 +55,19 @@ func (rs *EvaluationProjectService) Create(in *command.CreateProjectCommand) (in | @@ -55,10 +55,19 @@ func (rs *EvaluationProjectService) Create(in *command.CreateProjectCommand) (in | ||
55 | if err != nil { | 55 | if err != nil { |
56 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 56 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
57 | } | 57 | } |
58 | + | ||
59 | + projectAdapter := &adapter.EvaluationProjectAdapter{} | ||
60 | + projectAdapter.EvaluationProject = project | ||
61 | + if len(project.PmpIds) > 0 { | ||
62 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
63 | + _, users, _ := userRepository.Find(map[string]interface{}{"ids": project.PmpIds, "limit": len(project.PmpIds)}) | ||
64 | + projectAdapter.TransformPmpAdapter(users) | ||
65 | + } | ||
66 | + | ||
58 | if err := transactionContext.CommitTransaction(); err != nil { | 67 | if err := transactionContext.CommitTransaction(); err != nil { |
59 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 68 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
60 | } | 69 | } |
61 | - return project, nil | 70 | + return projectAdapter, nil |
62 | 71 | ||
63 | } | 72 | } |
64 | 73 | ||
@@ -96,10 +105,19 @@ func (rs *EvaluationProjectService) Update(in *command.UpdateProjectCommand) (in | @@ -96,10 +105,19 @@ func (rs *EvaluationProjectService) Update(in *command.UpdateProjectCommand) (in | ||
96 | if err != nil { | 105 | if err != nil { |
97 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 106 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
98 | } | 107 | } |
108 | + | ||
109 | + projectAdapter := &adapter.EvaluationProjectAdapter{} | ||
110 | + projectAdapter.EvaluationProject = project | ||
111 | + if len(project.PmpIds) > 0 { | ||
112 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
113 | + _, users, _ := userRepository.Find(map[string]interface{}{"ids": project.PmpIds, "limit": len(project.PmpIds)}) | ||
114 | + projectAdapter.TransformPmpAdapter(users) | ||
115 | + } | ||
116 | + | ||
99 | if err := transactionContext.CommitTransaction(); err != nil { | 117 | if err := transactionContext.CommitTransaction(); err != nil { |
100 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 118 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
101 | } | 119 | } |
102 | - return project, nil | 120 | + return projectAdapter, nil |
103 | } | 121 | } |
104 | 122 | ||
105 | func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemplateCommand) (interface{}, error) { | 123 | func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemplateCommand) (interface{}, error) { |
@@ -145,48 +163,33 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -145,48 +163,33 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
145 | if err != nil { | 163 | if err != nil { |
146 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 164 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
147 | } | 165 | } |
166 | + | ||
148 | cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true}) | 167 | cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true}) |
149 | if err != nil { | 168 | if err != nil { |
150 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 169 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
151 | } | 170 | } |
152 | 171 | ||
153 | - project.Recipients = in.Recipients | ||
154 | - project.Template = cycleTemplate.Template | ||
155 | - | ||
156 | - project, err = projectRepository.Insert(project) | ||
157 | - if err != nil { | ||
158 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 172 | + // FIXME 启动时,需要激活定时任务 |
173 | + if in.Activate == 1 { | ||
174 | + if len(in.Recipients) == 0 { | ||
175 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人") | ||
159 | } | 176 | } |
160 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
161 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 177 | + project.State = domain.ProjectStateEnable |
162 | } | 178 | } |
163 | - return project, nil | ||
164 | -} | ||
165 | 179 | ||
166 | -func (rs *EvaluationProjectService) UpdateTemplateNode(in *command.UpdateProjectTemplateNodeCommand) (interface{}, error) { | ||
167 | - transactionContext, err := factory.ValidateStartTransaction(in) | ||
168 | - if err != nil { | ||
169 | - return nil, err | ||
170 | - } | ||
171 | - defer func() { | ||
172 | - transactionContext.RollbackTransaction() | ||
173 | - }() | ||
174 | - | ||
175 | - projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
176 | - | ||
177 | - project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
178 | - if err != nil { | ||
179 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 180 | + project.Recipients = in.Recipients |
181 | + project.Template = cycleTemplate.Template | ||
182 | + for i := range project.Template.LinkNodes { | ||
183 | + node := project.Template.LinkNodes[i] | ||
184 | + node.KpiCycle = in.KpiCycle // 设置周期 | ||
185 | + if node.Type == domain.LinkNodeViewResult { | ||
186 | + if in.KpiResultStart != nil { | ||
187 | + node.TimeStart = in.KpiResultStart | ||
180 | } | 188 | } |
181 | - | ||
182 | - // FIXME 启动时,需要激活定时任务 | ||
183 | - if in.Activate == 1 { | ||
184 | - project.State = domain.ProjectStateEnable | 189 | + } else { |
190 | + node.TimeStart = in.TimeStart | ||
191 | + node.TimeEnd = in.TimeEnd | ||
185 | } | 192 | } |
186 | - for i := range in.LinkNodes { | ||
187 | - project.Template.LinkNodes[i].TimeStart = in.LinkNodes[i].TimeStart | ||
188 | - project.Template.LinkNodes[i].TimeEnd = in.LinkNodes[i].TimeEnd | ||
189 | - project.Template.LinkNodes[i].KpiCycle = in.LinkNodes[i].KpiCycle | ||
190 | } | 193 | } |
191 | 194 | ||
192 | project, err = projectRepository.Insert(project) | 195 | project, err = projectRepository.Insert(project) |
@@ -290,7 +293,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | @@ -290,7 +293,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | ||
290 | return tool_funs.SimpleWrapGridMap(total, projectAdapters), nil | 293 | return tool_funs.SimpleWrapGridMap(total, projectAdapters), nil |
291 | } | 294 | } |
292 | 295 | ||
293 | -func (rs *EvaluationProjectService) State(in *command.StateProjectCommand) (interface{}, error) { | 296 | +func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) (interface{}, error) { |
294 | transactionContext, err := factory.ValidateStartTransaction(in) | 297 | transactionContext, err := factory.ValidateStartTransaction(in) |
295 | if err != nil { | 298 | if err != nil { |
296 | return nil, err | 299 | return nil, err |
@@ -300,13 +303,20 @@ func (rs *EvaluationProjectService) State(in *command.StateProjectCommand) (inte | @@ -300,13 +303,20 @@ func (rs *EvaluationProjectService) State(in *command.StateProjectCommand) (inte | ||
300 | }() | 303 | }() |
301 | 304 | ||
302 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 305 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
303 | - | ||
304 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) | 306 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) |
305 | if err != nil { | 307 | if err != nil { |
306 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 308 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
307 | } | 309 | } |
308 | 310 | ||
309 | - project.State = in.State | 311 | + if project.Template == nil { |
312 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加评估模板") | ||
313 | + } | ||
314 | + | ||
315 | + if len(project.Recipients) == 0 { | ||
316 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人") | ||
317 | + } | ||
318 | + | ||
319 | + project.State = domain.TemplateStateEnable | ||
310 | project, err = projectRepository.Insert(project) | 320 | project, err = projectRepository.Insert(project) |
311 | if err != nil { | 321 | if err != nil { |
312 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 322 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -332,6 +342,10 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | @@ -332,6 +342,10 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | ||
332 | } | 342 | } |
333 | // ID重置 | 343 | // ID重置 |
334 | project.Id = 0 | 344 | project.Id = 0 |
345 | + project.Name = project.Name + " 副本" | ||
346 | + project.CreatorId = in.CreatorId | ||
347 | + project.Recipients = make([]string, 0) // 重置被评估人 | ||
348 | + | ||
335 | // 如果拷贝已经启用的模板,默认先设置为待启用 | 349 | // 如果拷贝已经启用的模板,默认先设置为待启用 |
336 | if project.State == domain.ProjectStateEnable { | 350 | if project.State == domain.ProjectStateEnable { |
337 | project.State = domain.ProjectStateWaitActive | 351 | project.State = domain.ProjectStateWaitActive |
@@ -346,7 +360,7 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | @@ -346,7 +360,7 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | ||
346 | return project, nil | 360 | return project, nil |
347 | } | 361 | } |
348 | 362 | ||
349 | -func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycleProjectUserCommand) (interface{}, error) { | 363 | +func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCommand) (interface{}, error) { |
350 | transactionContext, err := factory.ValidateStartTransaction(in) | 364 | transactionContext, err := factory.ValidateStartTransaction(in) |
351 | if err != nil { | 365 | if err != nil { |
352 | return nil, err | 366 | return nil, err |
@@ -354,42 +368,41 @@ func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycl | @@ -354,42 +368,41 @@ func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycl | ||
354 | defer func() { | 368 | defer func() { |
355 | transactionContext.RollbackTransaction() | 369 | transactionContext.RollbackTransaction() |
356 | }() | 370 | }() |
371 | + | ||
357 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 372 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
358 | - _, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | 373 | + |
374 | + _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "linkNodes") | ||
359 | if err != nil { | 375 | if err != nil { |
360 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 376 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
361 | } | 377 | } |
362 | 378 | ||
363 | - userIds := make([]int64, 0) | ||
364 | - userIdMap := map[int64]int64{} | 379 | + // 周期内的所有项目,员工不能重复被评估 |
380 | + rids := map[string]bool{} | ||
365 | for i := range projects { | 381 | for i := range projects { |
366 | - project := projects[i] | ||
367 | - for j := range project.Recipients { | ||
368 | - userId, _ := strconv.ParseInt(project.Recipients[j], 10, 64) | ||
369 | - userIdMap[userId] = userId | ||
370 | - } | 382 | + // 排除当前项目 |
383 | + if in.Id != projects[i].Id { | ||
384 | + ids := projects[i].Recipients | ||
385 | + for j := range ids { | ||
386 | + rids[ids[j]] = true | ||
371 | } | 387 | } |
372 | - for _, v := range userIdMap { | ||
373 | - userIds = append(userIds, v) | ||
374 | } | 388 | } |
375 | - | ||
376 | - userTotal := 0 | ||
377 | - departmentTotal := 0 | ||
378 | - if len(userIds) > 0 { | ||
379 | - userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
380 | - _, users, _ := userRepository.Find(map[string]interface{}{"ids": userIds, "limit": len(userIds)}) | ||
381 | - departmentIdMap := map[int]int{} | ||
382 | - for i := range users { | ||
383 | - for _, v := range users[i].DepartmentId { | ||
384 | - departmentIdMap[v] = v | ||
385 | } | 389 | } |
390 | + repeatNum := 0 | ||
391 | + for i := range in.Recipients { | ||
392 | + id := in.Recipients[i] | ||
393 | + if _, ok := rids[id]; ok { | ||
394 | + repeatNum++ | ||
386 | } | 395 | } |
387 | - userTotal = len(users) | ||
388 | - departmentTotal = len(departmentIdMap) | ||
389 | } | 396 | } |
397 | + //if repeatNum > 0 { | ||
398 | + // return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("有%d人已经在本周期其他项目内,需要将他们移除", repeatNum)) | ||
399 | + //} | ||
390 | 400 | ||
401 | + if err != nil { | ||
402 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
403 | + } | ||
391 | if err := transactionContext.CommitTransaction(); err != nil { | 404 | if err := transactionContext.CommitTransaction(); err != nil { |
392 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 405 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
393 | } | 406 | } |
394 | - return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil | 407 | + return repeatNum, nil |
395 | } | 408 | } |
@@ -4,6 +4,16 @@ import ( | @@ -4,6 +4,16 @@ import ( | ||
4 | "time" | 4 | "time" |
5 | ) | 5 | ) |
6 | 6 | ||
7 | +const ( | ||
8 | + KpiCycleDay int = 1 // 考核周期-日 | ||
9 | + KpiCycleWeek int = 2 // 考核周期-周 | ||
10 | + KpiCycleOneMonth int = 3 // 考核周期-月 | ||
11 | + KpiCycleTwoMonth int = 4 // 考核周期-双月 | ||
12 | + KpiCycleThreeMonth int = 5 // 考核周期-季度 | ||
13 | + KpiCycleSixMonth int = 6 // 考核周期-半年 | ||
14 | + KpiCycleYear int = 7 // 考核周期-年 | ||
15 | +) | ||
16 | + | ||
7 | type TemplateSimple struct { | 17 | type TemplateSimple struct { |
8 | Id int64 `json:"id,string" comment:"模板ID"` | 18 | Id int64 `json:"id,string" comment:"模板ID"` |
9 | Name string `json:"name" comment:"模板名称"` | 19 | Name string `json:"name" comment:"模板名称"` |
@@ -17,7 +27,7 @@ type EvaluationCycle struct { | @@ -17,7 +27,7 @@ type EvaluationCycle struct { | ||
17 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` | 27 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` |
18 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` | 28 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` |
19 | CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` | 29 | CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` |
20 | - KpiCycle int `json:"state" comment:"考核周期(1日、2周、3月)"` | 30 | + KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"` |
21 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | 31 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` |
22 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | 32 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` |
23 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | 33 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` |
@@ -24,16 +24,6 @@ const ( | @@ -24,16 +24,6 @@ const ( | ||
24 | 24 | ||
25 | ) | 25 | ) |
26 | 26 | ||
27 | -const ( | ||
28 | - KpiCycleDay int = 1 // 考核周期-日 | ||
29 | - KpiCycleWeek int = 2 // 考核周期-周 | ||
30 | - KpiCycleOneMonth int = 3 // 考核周期-月 | ||
31 | - KpiCycleTwoMonth int = 4 // 考核周期-双月 | ||
32 | - KpiCycleThreeMonth int = 5 // 考核周期-季度 | ||
33 | - KpiCycleSixMonth int = 6 // 考核周期-半年 | ||
34 | - KpiCycleYear int = 7 // 考核周期-年 | ||
35 | -) | ||
36 | - | ||
37 | type EntryItem struct { | 27 | type EntryItem struct { |
38 | Title string `json:"title" comment:"填写标题"` | 28 | Title string `json:"title" comment:"填写标题"` |
39 | HintText string `json:"hintText" comment:"文本内容提示"` | 29 | HintText string `json:"hintText" comment:"文本内容提示"` |
@@ -12,14 +12,17 @@ type CycleController struct { | @@ -12,14 +12,17 @@ type CycleController struct { | ||
12 | beego.BaseController | 12 | beego.BaseController |
13 | } | 13 | } |
14 | 14 | ||
15 | -func (controller *RoleController) CreateCycle() { | 15 | +func (controller *CycleController) CreateCycle() { |
16 | ruService := service.NewEvaluationCycleService() | 16 | ruService := service.NewEvaluationCycleService() |
17 | in := &command.CreateCycleCommand{} | 17 | in := &command.CreateCycleCommand{} |
18 | if err := controller.Unmarshal(in); err != nil { | 18 | if err := controller.Unmarshal(in); err != nil { |
19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
20 | } else { | 20 | } else { |
21 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
22 | - in.CreatorId = middlewares.GetUserId(controller.Ctx) | 21 | + ua := middlewares.GetUser(controller.Ctx) |
22 | + in.CompanyId = ua.CompanyId | ||
23 | + in.CreatorId = ua.UserId | ||
24 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
25 | + //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
23 | controller.Response(ruService.Create(in)) | 26 | controller.Response(ruService.Create(in)) |
24 | } | 27 | } |
25 | } | 28 | } |
@@ -30,7 +33,9 @@ func (controller *CycleController) UpdateCycle() { | @@ -30,7 +33,9 @@ func (controller *CycleController) UpdateCycle() { | ||
30 | if err := controller.Unmarshal(in); err != nil { | 33 | if err := controller.Unmarshal(in); err != nil { |
31 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 34 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
32 | } else { | 35 | } else { |
33 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 36 | + ua := middlewares.GetUser(controller.Ctx) |
37 | + in.CompanyId = ua.CompanyId | ||
38 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
34 | controller.Response(ruService.Update(in)) | 39 | controller.Response(ruService.Update(in)) |
35 | } | 40 | } |
36 | } | 41 | } |
@@ -65,7 +70,20 @@ func (controller *CycleController) ListCycle() { | @@ -65,7 +70,20 @@ func (controller *CycleController) ListCycle() { | ||
65 | if len(in.Name) > 0 { | 70 | if len(in.Name) > 0 { |
66 | in.Name = "%" + in.Name + "%" | 71 | in.Name = "%" + in.Name + "%" |
67 | } | 72 | } |
68 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 73 | + ua := middlewares.GetUser(controller.Ctx) |
74 | + in.CompanyId = ua.CompanyId | ||
69 | controller.Response(ruService.List(in)) | 75 | controller.Response(ruService.List(in)) |
70 | } | 76 | } |
71 | } | 77 | } |
78 | + | ||
79 | +func (controller *CycleController) StatisticCycleUser() { | ||
80 | + ruService := service.NewEvaluationCycleService() | ||
81 | + in := &command.StatisticCycleProjectUserCommand{} | ||
82 | + if err := controller.Unmarshal(in); err != nil { | ||
83 | + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
84 | + } else { | ||
85 | + ua := middlewares.GetUser(controller.Ctx) | ||
86 | + in.CompanyId = ua.CompanyId | ||
87 | + controller.Response(ruService.StatisticCycleUser(in)) | ||
88 | + } | ||
89 | +} |
@@ -12,14 +12,17 @@ type ProjectController struct { | @@ -12,14 +12,17 @@ type ProjectController struct { | ||
12 | beego.BaseController | 12 | beego.BaseController |
13 | } | 13 | } |
14 | 14 | ||
15 | -func (controller *RoleController) CreateProject() { | 15 | +func (controller *ProjectController) CreateProject() { |
16 | ruService := service.NewEvaluationProjectService() | 16 | ruService := service.NewEvaluationProjectService() |
17 | in := &command.CreateProjectCommand{} | 17 | in := &command.CreateProjectCommand{} |
18 | if err := controller.Unmarshal(in); err != nil { | 18 | if err := controller.Unmarshal(in); err != nil { |
19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
20 | } else { | 20 | } else { |
21 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
22 | - in.CreatorId = middlewares.GetUserId(controller.Ctx) | 21 | + ua := middlewares.GetUser(controller.Ctx) |
22 | + in.CompanyId = ua.CompanyId | ||
23 | + in.CreatorId = ua.UserId | ||
24 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
25 | + //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
23 | controller.Response(ruService.Create(in)) | 26 | controller.Response(ruService.Create(in)) |
24 | } | 27 | } |
25 | } | 28 | } |
@@ -30,7 +33,9 @@ func (controller *ProjectController) UpdateProject() { | @@ -30,7 +33,9 @@ func (controller *ProjectController) UpdateProject() { | ||
30 | if err := controller.Unmarshal(in); err != nil { | 33 | if err := controller.Unmarshal(in); err != nil { |
31 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 34 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
32 | } else { | 35 | } else { |
33 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 36 | + ua := middlewares.GetUser(controller.Ctx) |
37 | + in.CompanyId = ua.CompanyId | ||
38 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
34 | controller.Response(ruService.Update(in)) | 39 | controller.Response(ruService.Update(in)) |
35 | } | 40 | } |
36 | } | 41 | } |
@@ -41,22 +46,13 @@ func (controller *ProjectController) UpdateProjectForTemplate() { | @@ -41,22 +46,13 @@ func (controller *ProjectController) UpdateProjectForTemplate() { | ||
41 | if err := controller.Unmarshal(in); err != nil { | 46 | if err := controller.Unmarshal(in); err != nil { |
42 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 47 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
43 | } else { | 48 | } else { |
44 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 49 | + ua := middlewares.GetUser(controller.Ctx) |
50 | + in.CompanyId = ua.CompanyId | ||
51 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
45 | controller.Response(ruService.UpdateTemplate(in)) | 52 | controller.Response(ruService.UpdateTemplate(in)) |
46 | } | 53 | } |
47 | } | 54 | } |
48 | 55 | ||
49 | -func (controller *ProjectController) UpdateProjectForTemplateNode() { | ||
50 | - ruService := service.NewEvaluationProjectService() | ||
51 | - in := &command.UpdateProjectTemplateNodeCommand{} | ||
52 | - if err := controller.Unmarshal(in); err != nil { | ||
53 | - controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
54 | - } else { | ||
55 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
56 | - controller.Response(ruService.UpdateTemplateNode(in)) | ||
57 | - } | ||
58 | -} | ||
59 | - | ||
60 | func (controller *ProjectController) GetProject() { | 56 | func (controller *ProjectController) GetProject() { |
61 | ruService := service.NewEvaluationProjectService() | 57 | ruService := service.NewEvaluationProjectService() |
62 | in := &command.GetProjectCommand{} | 58 | in := &command.GetProjectCommand{} |
@@ -88,18 +84,20 @@ func (controller *ProjectController) ListProject() { | @@ -88,18 +84,20 @@ func (controller *ProjectController) ListProject() { | ||
88 | if len(in.Name) > 0 { | 84 | if len(in.Name) > 0 { |
89 | in.Name = "%" + in.Name + "%" | 85 | in.Name = "%" + in.Name + "%" |
90 | } | 86 | } |
91 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 87 | + ua := middlewares.GetUser(controller.Ctx) |
88 | + in.CompanyId = ua.CompanyId | ||
89 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
92 | controller.Response(ruService.List(in)) | 90 | controller.Response(ruService.List(in)) |
93 | } | 91 | } |
94 | } | 92 | } |
95 | 93 | ||
96 | func (controller *ProjectController) StateProject() { | 94 | func (controller *ProjectController) StateProject() { |
97 | ruService := service.NewEvaluationProjectService() | 95 | ruService := service.NewEvaluationProjectService() |
98 | - in := &command.StateProjectCommand{} | 96 | + in := &command.ActivateProjectCommand{} |
99 | if err := controller.Unmarshal(in); err != nil { | 97 | if err := controller.Unmarshal(in); err != nil { |
100 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 98 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
101 | } else { | 99 | } else { |
102 | - controller.Response(ruService.State(in)) | 100 | + controller.Response(ruService.Activate(in)) |
103 | } | 101 | } |
104 | } | 102 | } |
105 | 103 | ||
@@ -109,17 +107,20 @@ func (controller *ProjectController) CopyProject() { | @@ -109,17 +107,20 @@ func (controller *ProjectController) CopyProject() { | ||
109 | if err := controller.Unmarshal(in); err != nil { | 107 | if err := controller.Unmarshal(in); err != nil { |
110 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 108 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
111 | } else { | 109 | } else { |
110 | + ua := middlewares.GetUser(controller.Ctx) | ||
111 | + in.CreatorId = ua.UserId | ||
112 | controller.Response(ruService.Copy(in)) | 112 | controller.Response(ruService.Copy(in)) |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | -func (controller *ProjectController) StatisticCycleUser() { | 116 | +func (controller *ProjectController) CheckRecipients() { |
117 | ruService := service.NewEvaluationProjectService() | 117 | ruService := service.NewEvaluationProjectService() |
118 | - in := &command.StatisticCycleProjectUserCommand{} | 118 | + in := &command.CheckRecipientCommand{} |
119 | if err := controller.Unmarshal(in); err != nil { | 119 | if err := controller.Unmarshal(in); err != nil { |
120 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 120 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
121 | } else { | 121 | } else { |
122 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
123 | - controller.Response(ruService.StatisticCycleUser(in)) | 122 | + ua := middlewares.GetUser(controller.Ctx) |
123 | + in.CompanyId = ua.CompanyId | ||
124 | + controller.Response(ruService.CheckRecipients(in)) | ||
124 | } | 125 | } |
125 | } | 126 | } |
@@ -18,8 +18,11 @@ func (controller *RuleController) CreateRule() { | @@ -18,8 +18,11 @@ func (controller *RuleController) CreateRule() { | ||
18 | if err := controller.Unmarshal(in); err != nil { | 18 | if err := controller.Unmarshal(in); err != nil { |
19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
20 | } else { | 20 | } else { |
21 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
22 | - in.CreatorId = middlewares.GetUserId(controller.Ctx) | 21 | + ua := middlewares.GetUser(controller.Ctx) |
22 | + in.CompanyId = ua.CompanyId | ||
23 | + in.CreatorId = ua.UserId | ||
24 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
25 | + //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
23 | controller.Response(ruService.Create(in)) | 26 | controller.Response(ruService.Create(in)) |
24 | } | 27 | } |
25 | } | 28 | } |
@@ -30,8 +33,11 @@ func (controller *RuleController) UpdateRule() { | @@ -30,8 +33,11 @@ func (controller *RuleController) UpdateRule() { | ||
30 | if err := controller.Unmarshal(in); err != nil { | 33 | if err := controller.Unmarshal(in); err != nil { |
31 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 34 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
32 | } else { | 35 | } else { |
33 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
34 | - in.CreatorId = middlewares.GetUserId(controller.Ctx) | 36 | + ua := middlewares.GetUser(controller.Ctx) |
37 | + in.CompanyId = ua.CompanyId | ||
38 | + in.CreatorId = ua.UserId | ||
39 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
40 | + //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
35 | controller.Response(ruService.Update(in)) | 41 | controller.Response(ruService.Update(in)) |
36 | } | 42 | } |
37 | } | 43 | } |
@@ -82,7 +88,9 @@ func (controller *RuleController) ListRuleRelCreator() { | @@ -82,7 +88,9 @@ func (controller *RuleController) ListRuleRelCreator() { | ||
82 | if len(in.NameOrRemark) > 0 { | 88 | if len(in.NameOrRemark) > 0 { |
83 | in.NameOrRemark = "%" + in.NameOrRemark + "%" | 89 | in.NameOrRemark = "%" + in.NameOrRemark + "%" |
84 | } | 90 | } |
85 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 91 | + ua := middlewares.GetUser(controller.Ctx) |
92 | + in.CompanyId = ua.CompanyId | ||
93 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
86 | controller.Response(ruService.ListRelCreator(in)) | 94 | controller.Response(ruService.ListRelCreator(in)) |
87 | } | 95 | } |
88 | } | 96 | } |
@@ -13,14 +13,17 @@ type TemplateController struct { | @@ -13,14 +13,17 @@ type TemplateController struct { | ||
13 | beego.BaseController | 13 | beego.BaseController |
14 | } | 14 | } |
15 | 15 | ||
16 | -func (controller *RoleController) CreateTemplate() { | 16 | +func (controller *TemplateController) CreateTemplate() { |
17 | ruService := service.NewEvaluationTemplateService() | 17 | ruService := service.NewEvaluationTemplateService() |
18 | in := &command.CreateTemplateCommand{} | 18 | in := &command.CreateTemplateCommand{} |
19 | if err := controller.Unmarshal(in); err != nil { | 19 | if err := controller.Unmarshal(in); err != nil { |
20 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 20 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
21 | } else { | 21 | } else { |
22 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
23 | - in.CreatorId = middlewares.GetUserId(controller.Ctx) | 22 | + ua := middlewares.GetUser(controller.Ctx) |
23 | + in.CompanyId = ua.CompanyId | ||
24 | + in.CreatorId = ua.UserId | ||
25 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
26 | + //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
24 | controller.Response(ruService.Create(in)) | 27 | controller.Response(ruService.Create(in)) |
25 | } | 28 | } |
26 | } | 29 | } |
@@ -31,7 +34,9 @@ func (controller *TemplateController) UpdateTemplate() { | @@ -31,7 +34,9 @@ func (controller *TemplateController) UpdateTemplate() { | ||
31 | if err := controller.Unmarshal(in); err != nil { | 34 | if err := controller.Unmarshal(in); err != nil { |
32 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 35 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
33 | } else { | 36 | } else { |
34 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 37 | + ua := middlewares.GetUser(controller.Ctx) |
38 | + in.CompanyId = ua.CompanyId | ||
39 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
35 | controller.Response(ruService.Update(in)) | 40 | controller.Response(ruService.Update(in)) |
36 | } | 41 | } |
37 | } | 42 | } |
@@ -67,7 +72,9 @@ func (controller *TemplateController) ListTemplate() { | @@ -67,7 +72,9 @@ func (controller *TemplateController) ListTemplate() { | ||
67 | if len(in.Name) > 0 { | 72 | if len(in.Name) > 0 { |
68 | in.Name = "%" + in.Name + "%" | 73 | in.Name = "%" + in.Name + "%" |
69 | } | 74 | } |
70 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 75 | + ua := middlewares.GetUser(controller.Ctx) |
76 | + in.CompanyId = ua.CompanyId | ||
77 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
71 | controller.Response(ruService.List(in)) | 78 | controller.Response(ruService.List(in)) |
72 | } | 79 | } |
73 | } | 80 | } |
@@ -81,7 +88,9 @@ func (controller *TemplateController) ListEnableTemplate() { | @@ -81,7 +88,9 @@ func (controller *TemplateController) ListEnableTemplate() { | ||
81 | if err := controller.Unmarshal(in); err != nil { | 88 | if err := controller.Unmarshal(in); err != nil { |
82 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 89 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
83 | } else { | 90 | } else { |
84 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 91 | + ua := middlewares.GetUser(controller.Ctx) |
92 | + in.CompanyId = ua.CompanyId | ||
93 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
85 | controller.Response(ruService.List(in)) | 94 | controller.Response(ruService.List(in)) |
86 | } | 95 | } |
87 | } | 96 | } |
@@ -92,7 +101,9 @@ func (controller *TemplateController) StateTemplate() { | @@ -92,7 +101,9 @@ func (controller *TemplateController) StateTemplate() { | ||
92 | if err := controller.Unmarshal(in); err != nil { | 101 | if err := controller.Unmarshal(in); err != nil { |
93 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 102 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
94 | } else { | 103 | } else { |
95 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 104 | + ua := middlewares.GetUser(controller.Ctx) |
105 | + in.CompanyId = ua.CompanyId | ||
106 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
96 | controller.Response(ruService.State(in)) | 107 | controller.Response(ruService.State(in)) |
97 | } | 108 | } |
98 | } | 109 | } |
@@ -103,8 +114,11 @@ func (controller *TemplateController) CopyTemplate() { | @@ -103,8 +114,11 @@ func (controller *TemplateController) CopyTemplate() { | ||
103 | if err := controller.Unmarshal(in); err != nil { | 114 | if err := controller.Unmarshal(in); err != nil { |
104 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 115 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
105 | } else { | 116 | } else { |
106 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
107 | - in.CreatorId = middlewares.GetUserId(controller.Ctx) | 117 | + ua := middlewares.GetUser(controller.Ctx) |
118 | + in.CompanyId = ua.CompanyId | ||
119 | + in.CreatorId = ua.UserId | ||
120 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
121 | + //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
108 | controller.Response(ruService.Copy(in)) | 122 | controller.Response(ruService.Copy(in)) |
109 | } | 123 | } |
110 | } | 124 | } |
@@ -51,7 +51,9 @@ func (controller *RoleController) ListForUserRole() { | @@ -51,7 +51,9 @@ func (controller *RoleController) ListForUserRole() { | ||
51 | if err := controller.Unmarshal(in); err != nil { | 51 | if err := controller.Unmarshal(in); err != nil { |
52 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 52 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
53 | } else { | 53 | } else { |
54 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 54 | + ua := middlewares.GetUser(controller.Ctx) |
55 | + in.CompanyId = ua.CompanyId | ||
56 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
55 | controller.Response(ruService.ListForUser(in)) | 57 | controller.Response(ruService.ListForUser(in)) |
56 | } | 58 | } |
57 | } | 59 | } |
@@ -18,7 +18,9 @@ func (controller *RoleUserController) CreateRoleUser() { | @@ -18,7 +18,9 @@ func (controller *RoleUserController) CreateRoleUser() { | ||
18 | if err := controller.Unmarshal(in); err != nil { | 18 | if err := controller.Unmarshal(in); err != nil { |
19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
20 | } else { | 20 | } else { |
21 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 21 | + ua := middlewares.GetUser(controller.Ctx) |
22 | + in.CompanyId = ua.CompanyId | ||
23 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
22 | controller.Response(ruService.Create(in)) | 24 | controller.Response(ruService.Create(in)) |
23 | } | 25 | } |
24 | } | 26 | } |
@@ -29,7 +31,9 @@ func (controller *RoleUserController) RemoveRoleUser() { | @@ -29,7 +31,9 @@ func (controller *RoleUserController) RemoveRoleUser() { | ||
29 | if err := controller.Unmarshal(in); err != nil { | 31 | if err := controller.Unmarshal(in); err != nil { |
30 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 32 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
31 | } else { | 33 | } else { |
32 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 34 | + ua := middlewares.GetUser(controller.Ctx) |
35 | + in.CompanyId = ua.CompanyId | ||
36 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
33 | controller.Response(ruService.Remove(in)) | 37 | controller.Response(ruService.Remove(in)) |
34 | } | 38 | } |
35 | } | 39 | } |
@@ -40,7 +44,9 @@ func (controller *RoleUserController) ListRoleUser() { | @@ -40,7 +44,9 @@ func (controller *RoleUserController) ListRoleUser() { | ||
40 | if err := controller.Unmarshal(in); err != nil { | 44 | if err := controller.Unmarshal(in); err != nil { |
41 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 45 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
42 | } else { | 46 | } else { |
43 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 47 | + ua := middlewares.GetUser(controller.Ctx) |
48 | + in.CompanyId = ua.CompanyId | ||
49 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
44 | controller.Response(ruService.ListRole(in)) | 50 | controller.Response(ruService.ListRole(in)) |
45 | } | 51 | } |
46 | } | 52 | } |
@@ -6,6 +6,14 @@ import ( | @@ -6,6 +6,14 @@ import ( | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
7 | ) | 7 | ) |
8 | 8 | ||
9 | +func GetUser(ctx *context.Context) *domain.UserAuth { | ||
10 | + user := ctx.Input.GetData(domain.UserAuth{}) | ||
11 | + if user != nil { | ||
12 | + return user.(*domain.UserAuth) | ||
13 | + } | ||
14 | + return nil | ||
15 | +} | ||
16 | + | ||
9 | func CheckAdminToken() func(ctx *context.Context) { | 17 | func CheckAdminToken() func(ctx *context.Context) { |
10 | return func(ctx *context.Context) { | 18 | return func(ctx *context.Context) { |
11 | adminToken := ctx.Input.Header("x-admin-token") | 19 | adminToken := ctx.Input.Header("x-admin-token") |
1 | package middlewares | 1 | package middlewares |
2 | 2 | ||
3 | -import ( | ||
4 | - "github.com/beego/beego/v2/server/web/context" | ||
5 | -) | ||
6 | - | ||
7 | -func setUserId(userId int64, ctx *context.Context) { | ||
8 | - ctx.Input.SetData("_UserId", userId) | ||
9 | -} | ||
10 | - | ||
11 | -func GetUserId(ctx *context.Context) int64 { | ||
12 | - userId := ctx.Input.GetData("_UserId") | ||
13 | - return userId.(int64) | ||
14 | -} | ||
15 | - | ||
16 | -func setCompanyId(companyId int64, ctx *context.Context) { | ||
17 | - ctx.Input.SetData("_CompanyId", companyId) | ||
18 | -} | ||
19 | - | ||
20 | -func GetCompanyId(ctx *context.Context) int64 { | ||
21 | - companyId := ctx.Input.GetData("_CompanyId") | ||
22 | - return companyId.(int64) | ||
23 | -} | ||
24 | - | ||
25 | -func setCompanyType(companyId int, ctx *context.Context) { | ||
26 | - ctx.Input.SetData("_CompanyType", companyId) | ||
27 | -} | ||
28 | - | ||
29 | -func GetCompanyType(ctx *context.Context) int { | ||
30 | - companyId := ctx.Input.GetData("_CompanyType") | ||
31 | - return companyId.(int) | ||
32 | -} | ||
33 | - | ||
34 | -func invalidOrExpired(ctx *context.Context) { | ||
35 | - resp := map[string]interface{}{ | ||
36 | - "code": 902, | ||
37 | - "msg": "Authorization过期或无效,需要进行重新获取令牌", | ||
38 | - } | ||
39 | - _ = ctx.Output.JSON(resp, false, false) | ||
40 | -} | ||
41 | - | ||
42 | -func CheckToken() func(ctx *context.Context) { | ||
43 | - return func(ctx *context.Context) { | ||
44 | - tokenStr := ctx.Input.Header("x-mmm-accesstoken") | ||
45 | - if tokenStr == "" { //没有带token | ||
46 | - invalidOrExpired(ctx) | ||
47 | - return | ||
48 | - } | ||
49 | - | ||
50 | - //userServe := service.UserService{} | ||
51 | - //userTk, err := userServe.ValidLoginToken(tokenStr) | ||
52 | - //if err != nil { | ||
53 | - // invalidOrExpired(ctx) | ||
54 | - // return | ||
55 | - //} | ||
56 | - //setUserId(userTk.UserId, ctx) | ||
57 | - //setCompanyId(userTk.CompanyId, ctx) | ||
58 | - //setCompanyType(userTk.CompanyType, ctx) | ||
59 | - } | ||
60 | -} | 3 | +// |
4 | +//import ( | ||
5 | +// "github.com/beego/beego/v2/server/web/context" | ||
6 | +//) | ||
7 | +// | ||
8 | +//func setUserId(userId int64, ctx *context.Context) { | ||
9 | +// ctx.Input.SetData("_UserId", userId) | ||
10 | +//} | ||
11 | +// | ||
12 | +//func GetUserId(ctx *context.Context) int64 { | ||
13 | +// userId := ctx.Input.GetData("_UserId") | ||
14 | +// return userId.(int64) | ||
15 | +//} | ||
16 | +// | ||
17 | +//func setCompanyId(companyId int64, ctx *context.Context) { | ||
18 | +// ctx.Input.SetData("_CompanyId", companyId) | ||
19 | +//} | ||
20 | +// | ||
21 | +//func GetCompanyId(ctx *context.Context) int64 { | ||
22 | +// companyId := ctx.Input.GetData("_CompanyId") | ||
23 | +// return companyId.(int64) | ||
24 | +//} | ||
25 | +// | ||
26 | +//func setCompanyType(companyId int, ctx *context.Context) { | ||
27 | +// ctx.Input.SetData("_CompanyType", companyId) | ||
28 | +//} | ||
29 | +// | ||
30 | +//func GetCompanyType(ctx *context.Context) int { | ||
31 | +// companyId := ctx.Input.GetData("_CompanyType") | ||
32 | +// return companyId.(int) | ||
33 | +//} | ||
34 | +// | ||
35 | +//func invalidOrExpired(ctx *context.Context) { | ||
36 | +// resp := map[string]interface{}{ | ||
37 | +// "code": 902, | ||
38 | +// "msg": "Authorization过期或无效,需要进行重新获取令牌", | ||
39 | +// } | ||
40 | +// _ = ctx.Output.JSON(resp, false, false) | ||
41 | +//} | ||
42 | +// | ||
43 | +//func CheckToken() func(ctx *context.Context) { | ||
44 | +// return func(ctx *context.Context) { | ||
45 | +// tokenStr := ctx.Input.Header("x-mmm-accesstoken") | ||
46 | +// if tokenStr == "" { //没有带token | ||
47 | +// invalidOrExpired(ctx) | ||
48 | +// return | ||
49 | +// } | ||
50 | +// | ||
51 | +// //userServe := service.UserService{} | ||
52 | +// //userTk, err := userServe.ValidLoginToken(tokenStr) | ||
53 | +// //if err != nil { | ||
54 | +// // invalidOrExpired(ctx) | ||
55 | +// // return | ||
56 | +// //} | ||
57 | +// //setUserId(userTk.UserId, ctx) | ||
58 | +// //setCompanyId(userTk.CompanyId, ctx) | ||
59 | +// //setCompanyType(userTk.CompanyType, ctx) | ||
60 | +// } | ||
61 | +//} |
1 | +package routers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web" | ||
5 | + "github.com/linmadan/egglib-go/web/beego/filters" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
8 | +) | ||
9 | + | ||
10 | +func init() { | ||
11 | + ns := web.NewNamespace("/v1/evaluation-cycle", | ||
12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), | ||
13 | + web.NSRouter("/", &controllers.CycleController{}, "Post:CreateCycle"), | ||
14 | + web.NSRouter("/", &controllers.CycleController{}, "Put:UpdateCycle"), | ||
15 | + web.NSRouter("/", &controllers.CycleController{}, "Delete:RemoveCycle"), | ||
16 | + web.NSRouter("/:Id", &controllers.CycleController{}, "Get:GetCycle"), | ||
17 | + web.NSRouter("/list", &controllers.CycleController{}, "Post:ListCycle"), | ||
18 | + web.NSRouter("/statistic", &controllers.CycleController{}, "Post:StatisticCycleUser"), | ||
19 | + ) | ||
20 | + web.AddNamespace(ns) | ||
21 | +} |
1 | +package routers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web" | ||
5 | + "github.com/linmadan/egglib-go/web/beego/filters" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
8 | +) | ||
9 | + | ||
10 | +func init() { | ||
11 | + ns := web.NewNamespace("/v1/evaluation-project", | ||
12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), | ||
13 | + web.NSRouter("/", &controllers.ProjectController{}, "Post:CreateProject"), | ||
14 | + web.NSRouter("/", &controllers.ProjectController{}, "Put:UpdateProject"), | ||
15 | + web.NSRouter("/", &controllers.ProjectController{}, "Delete:RemoveProject"), | ||
16 | + web.NSRouter("/:Id", &controllers.ProjectController{}, "Get:GetProject"), | ||
17 | + web.NSRouter("/list", &controllers.ProjectController{}, "Post:ListProject"), | ||
18 | + web.NSRouter("/detail", &controllers.ProjectController{}, "Put:UpdateProjectForTemplate"), | ||
19 | + web.NSRouter("/check-recipients", &controllers.ProjectController{}, "Post:CheckRecipients"), | ||
20 | + web.NSRouter("/copy", &controllers.ProjectController{}, "Post:CopyProject"), | ||
21 | + ) | ||
22 | + web.AddNamespace(ns) | ||
23 | +} |
@@ -9,7 +9,7 @@ import ( | @@ -9,7 +9,7 @@ import ( | ||
9 | 9 | ||
10 | func init() { | 10 | func init() { |
11 | ns := web.NewNamespace("/v1/evaluation-rule", | 11 | ns := web.NewNamespace("/v1/evaluation-rule", |
12 | - web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), | 12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), |
13 | web.NSRouter("/", &controllers.RuleController{}, "Post:CreateRule"), | 13 | web.NSRouter("/", &controllers.RuleController{}, "Post:CreateRule"), |
14 | web.NSRouter("/", &controllers.RuleController{}, "Put:UpdateRule"), | 14 | web.NSRouter("/", &controllers.RuleController{}, "Put:UpdateRule"), |
15 | web.NSRouter("/", &controllers.RuleController{}, "Delete:RemoveRule"), | 15 | web.NSRouter("/", &controllers.RuleController{}, "Delete:RemoveRule"), |
@@ -9,8 +9,8 @@ import ( | @@ -9,8 +9,8 @@ import ( | ||
9 | 9 | ||
10 | func init() { | 10 | func init() { |
11 | ns := web.NewNamespace("/v1/evaluation-template", | 11 | ns := web.NewNamespace("/v1/evaluation-template", |
12 | - web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), | ||
13 | - // web.NSRouter("/", &controllers.TemplateController{}, "Post:CreateTemplate"), | 12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), |
13 | + web.NSRouter("/", &controllers.TemplateController{}, "Post:CreateTemplate"), | ||
14 | web.NSRouter("/", &controllers.TemplateController{}, "Put:UpdateTemplate"), | 14 | web.NSRouter("/", &controllers.TemplateController{}, "Put:UpdateTemplate"), |
15 | web.NSRouter("/", &controllers.TemplateController{}, "Delete:RemoveTemplate"), | 15 | web.NSRouter("/", &controllers.TemplateController{}, "Delete:RemoveTemplate"), |
16 | web.NSRouter("/:Id", &controllers.TemplateController{}, "Get:GetTemplate"), | 16 | web.NSRouter("/:Id", &controllers.TemplateController{}, "Get:GetTemplate"), |
@@ -9,7 +9,7 @@ import ( | @@ -9,7 +9,7 @@ import ( | ||
9 | 9 | ||
10 | func init() { | 10 | func init() { |
11 | ns := web.NewNamespace("/v1/role", | 11 | ns := web.NewNamespace("/v1/role", |
12 | - web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), | 12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), |
13 | //web.NSRouter("/", &controllers.RoleController{}, "Post:CreateRole"), | 13 | //web.NSRouter("/", &controllers.RoleController{}, "Post:CreateRole"), |
14 | //web.NSRouter("/", &controllers.RoleController{}, "Put:UpdateRole"), | 14 | //web.NSRouter("/", &controllers.RoleController{}, "Put:UpdateRole"), |
15 | //web.NSRouter("/", &controllers.RoleController{}, "Delete:RemoveRole"), | 15 | //web.NSRouter("/", &controllers.RoleController{}, "Delete:RemoveRole"), |
@@ -3,15 +3,16 @@ package routers | @@ -3,15 +3,16 @@ package routers | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/server/web" | 4 | "github.com/beego/beego/v2/server/web" |
5 | "github.com/linmadan/egglib-go/web/beego/filters" | 5 | "github.com/linmadan/egglib-go/web/beego/filters" |
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" |
7 | ) | 8 | ) |
8 | 9 | ||
9 | func init() { | 10 | func init() { |
10 | ns := web.NewNamespace("/v1/role-user", | 11 | ns := web.NewNamespace("/v1/role-user", |
11 | - web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), | ||
12 | - // web.NSRouter("/", &controllers.RoleUserController{}, "Post:CreateRole"), | ||
13 | - // web.NSRouter("/", &controllers.RoleUserController{}, "Delete:RemoveRole"), | ||
14 | - // web.NSRouter("/all", &controllers.RoleUserController{}, "Post:ListRoleUser"), | 12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), |
13 | + web.NSRouter("/", &controllers.RoleUserController{}, "Post:CreateRoleUser"), | ||
14 | + web.NSRouter("/", &controllers.RoleUserController{}, "Delete:RemoveRoleUser"), | ||
15 | + web.NSRouter("/all", &controllers.RoleUserController{}, "Post:ListRoleUser"), | ||
15 | ) | 16 | ) |
16 | web.AddNamespace(ns) | 17 | web.AddNamespace(ns) |
17 | } | 18 | } |
-
请 注册 或 登录 后发表评论