正在显示
3 个修改的文件
包含
76 行增加
和
13 行删除
@@ -73,6 +73,13 @@ func (this *TemplateController) TemplateAdd() { | @@ -73,6 +73,13 @@ func (this *TemplateController) TemplateAdd() { | ||
73 | if len(request.Videos) == 0 { | 73 | if len(request.Videos) == 0 { |
74 | request.Videos = make([]string, 0) | 74 | request.Videos = make([]string, 0) |
75 | } | 75 | } |
76 | + if len(request.SelfCheck) > 0 { | ||
77 | + err := auditFlowMustActionTypeOr(request.AuditFlowConfig) | ||
78 | + if err != nil { | ||
79 | + msg = protocol.NewReturnResponse(nil, err) | ||
80 | + return | ||
81 | + } | ||
82 | + } | ||
76 | if err := checkSelfCheckData(request.SelfCheck); err != nil { | 83 | if err := checkSelfCheckData(request.SelfCheck); err != nil { |
77 | msg = protocol.NewReturnResponse(nil, err) | 84 | msg = protocol.NewReturnResponse(nil, err) |
78 | return | 85 | return |
@@ -133,6 +140,13 @@ func (this *TemplateController) TemplateUpdate() { | @@ -133,6 +140,13 @@ func (this *TemplateController) TemplateUpdate() { | ||
133 | request.Videos = arrayFilter(request.Videos, "") | 140 | request.Videos = arrayFilter(request.Videos, "") |
134 | } | 141 | } |
135 | 142 | ||
143 | + if len(request.SelfCheck) > 0 { | ||
144 | + err := auditFlowMustActionTypeOr(request.AuditFlowConfig) | ||
145 | + if err != nil { | ||
146 | + msg = protocol.NewReturnResponse(nil, err) | ||
147 | + return | ||
148 | + } | ||
149 | + } | ||
136 | if err := checkSelfCheckData(request.SelfCheck); err != nil { | 150 | if err := checkSelfCheckData(request.SelfCheck); err != nil { |
137 | msg = protocol.NewReturnResponse(nil, err) | 151 | msg = protocol.NewReturnResponse(nil, err) |
138 | return | 152 | return |
@@ -425,18 +439,48 @@ func arrayFilter(arr1 []string, s string) (rsp []string) { | @@ -425,18 +439,48 @@ func arrayFilter(arr1 []string, s string) (rsp []string) { | ||
425 | return | 439 | return |
426 | } | 440 | } |
427 | 441 | ||
442 | +//checkSelfCheckData 校验自查内容数据 | ||
428 | func checkSelfCheckData(data []protocol.TemplateSelfCheck) error { | 443 | func checkSelfCheckData(data []protocol.TemplateSelfCheck) error { |
429 | - | ||
430 | - var cnt int | ||
431 | - for _, v := range data { | 444 | + var ( |
445 | + cnt int | ||
446 | + ) | ||
447 | + titleMap := make(map[string]int) | ||
448 | + for i, v := range data { | ||
432 | s := []rune(v.Title) | 449 | s := []rune(v.Title) |
433 | if len(s) == 0 || len(s) > 50 { | 450 | if len(s) == 0 || len(s) > 50 { |
434 | return protocol.NewErrWithMessage("10127") | 451 | return protocol.NewErrWithMessage("10127") |
435 | } | 452 | } |
453 | + if _, ok := titleMap[v.Title]; ok { | ||
454 | + return protocol.NewErrWithMessage("10130") | ||
455 | + } else { | ||
456 | + titleMap[v.Title] = 1 | ||
457 | + } | ||
436 | cnt++ | 458 | cnt++ |
459 | + childTitleMap := make(map[string]int) | ||
460 | + for _, vv := range data[i].Child { | ||
461 | + ss := []rune(vv.Title) | ||
462 | + if len(ss) == 0 || len(ss) > 50 { | ||
463 | + return protocol.NewErrWithMessage("10127") | ||
464 | + } | ||
465 | + if _, ok := childTitleMap[vv.Title]; ok { | ||
466 | + return protocol.NewErrWithMessage("10130") | ||
467 | + } else { | ||
468 | + titleMap[vv.Title] = 1 | ||
469 | + } | ||
470 | + cnt++ | ||
471 | + } | ||
437 | } | 472 | } |
438 | if cnt > 30 { | 473 | if cnt > 30 { |
439 | return protocol.NewErrWithMessage("10128") | 474 | return protocol.NewErrWithMessage("10128") |
440 | } | 475 | } |
441 | return nil | 476 | return nil |
442 | } | 477 | } |
478 | + | ||
479 | +func auditFlowMustActionTypeOr(auditflow protocol.AuditFlowConfig) error { | ||
480 | + for _, v := range auditflow.ProcessConfig { | ||
481 | + if v.AcitonType != models.ActionTypeOr { | ||
482 | + return protocol.NewErrWithMessage("10129") | ||
483 | + } | ||
484 | + } | ||
485 | + return nil | ||
486 | +} |
@@ -126,6 +126,8 @@ var errmessge ErrorMap = map[string]string{ | @@ -126,6 +126,8 @@ var errmessge ErrorMap = map[string]string{ | ||
126 | "10126": "被转移人员不能为空", | 126 | "10126": "被转移人员不能为空", |
127 | "10127": "自查内容维度名称最多输入50个字符", | 127 | "10127": "自查内容维度名称最多输入50个字符", |
128 | "10128": "自查内容维度最多输入30个字段", | 128 | "10128": "自查内容维度最多输入30个字段", |
129 | + "10129": "存在自查内容时只能进行或签设置", | ||
130 | + "10130": "同一级的自查内容不能重复", | ||
129 | } | 131 | } |
130 | 132 | ||
131 | //错误码转换 ,兼容需要 | 133 | //错误码转换 ,兼容需要 |
@@ -131,11 +131,13 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs | @@ -131,11 +131,13 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs | ||
131 | } | 131 | } |
132 | } | 132 | } |
133 | //添加自查内容 | 133 | //添加自查内容 |
134 | - err = addSelfCheckData(templateId, request.SelfCheck, orm) | ||
135 | - if err != nil { | ||
136 | - log.Error("模板设置,添加自查内容失败,err:%s", err) | ||
137 | - orm.Rollback() | ||
138 | - return nil, protocol.NewErrWithMessage("1") | 134 | + if len(request.SelfCheck) > 0 { |
135 | + err = addSelfCheckData(templateId, request.SelfCheck, orm) | ||
136 | + if err != nil { | ||
137 | + log.Error("模板设置,添加自查内容失败,err:%s", err) | ||
138 | + orm.Rollback() | ||
139 | + return nil, protocol.NewErrWithMessage("1") | ||
140 | + } | ||
139 | } | 141 | } |
140 | orm.Commit() | 142 | orm.Commit() |
141 | rsp = &protocol.TemplateAddResponse{} | 143 | rsp = &protocol.TemplateAddResponse{} |
@@ -208,6 +210,18 @@ func editSelfCheckData(templateId int64, data []protocol.TemplateSelfCheck, om o | @@ -208,6 +210,18 @@ func editSelfCheckData(templateId int64, data []protocol.TemplateSelfCheck, om o | ||
208 | return nil | 210 | return nil |
209 | } | 211 | } |
210 | 212 | ||
213 | +//editSelfCheckData2 编辑自查内容 | ||
214 | +func editSelfCheckData2(templateId int64, data []protocol.TemplateSelfCheck, om orm2.Ormer) error { | ||
215 | + // var ( | ||
216 | + // updateId []int64 | ||
217 | + // deleteId []int64 | ||
218 | + // updateSelfCheck []models.AuditCheck | ||
219 | + // newSelfCheckData []models.AuditCheck | ||
220 | + // ) | ||
221 | + | ||
222 | + return nil | ||
223 | +} | ||
224 | + | ||
211 | func getSelfCheckData(templateId int64) []protocol.TemplateSelfCheck { | 225 | func getSelfCheckData(templateId int64) []protocol.TemplateSelfCheck { |
212 | var ( | 226 | var ( |
213 | data []protocol.TemplateSelfCheck | 227 | data []protocol.TemplateSelfCheck |
@@ -366,12 +380,15 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques | @@ -366,12 +380,15 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques | ||
366 | } | 380 | } |
367 | } | 381 | } |
368 | } | 382 | } |
369 | - err = editSelfCheckData(template.Id, request.SelfCheck, orm) | ||
370 | - if err != nil { | ||
371 | - log.Error("更新audit_check数据失败:err:%s", err) | ||
372 | - orm.Rollback() | ||
373 | - return rsp, protocol.NewErrWithMessage("1") | 383 | + if len(request.SelfCheck) > 0 { |
384 | + err = editSelfCheckData(template.Id, request.SelfCheck, orm) | ||
385 | + if err != nil { | ||
386 | + log.Error("更新audit_check数据失败:err:%s", err) | ||
387 | + orm.Rollback() | ||
388 | + return rsp, protocol.NewErrWithMessage("1") | ||
389 | + } | ||
374 | } | 390 | } |
391 | + | ||
375 | orm.Commit() | 392 | orm.Commit() |
376 | rsp = &protocol.TemplateUpdateResponse{} | 393 | rsp = &protocol.TemplateUpdateResponse{} |
377 | return | 394 | return |
-
请 注册 或 登录 后发表评论