...
|
...
|
@@ -73,6 +73,13 @@ func (this *TemplateController) TemplateAdd() { |
|
|
if len(request.Videos) == 0 {
|
|
|
request.Videos = make([]string, 0)
|
|
|
}
|
|
|
if len(request.SelfCheck) > 0 {
|
|
|
err := auditFlowMustActionTypeOr(request.AuditFlowConfig)
|
|
|
if err != nil {
|
|
|
msg = protocol.NewReturnResponse(nil, err)
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
if err := checkSelfCheckData(request.SelfCheck); err != nil {
|
|
|
msg = protocol.NewReturnResponse(nil, err)
|
|
|
return
|
...
|
...
|
@@ -133,6 +140,13 @@ func (this *TemplateController) TemplateUpdate() { |
|
|
request.Videos = arrayFilter(request.Videos, "")
|
|
|
}
|
|
|
|
|
|
if len(request.SelfCheck) > 0 {
|
|
|
err := auditFlowMustActionTypeOr(request.AuditFlowConfig)
|
|
|
if err != nil {
|
|
|
msg = protocol.NewReturnResponse(nil, err)
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
if err := checkSelfCheckData(request.SelfCheck); err != nil {
|
|
|
msg = protocol.NewReturnResponse(nil, err)
|
|
|
return
|
...
|
...
|
@@ -425,18 +439,48 @@ func arrayFilter(arr1 []string, s string) (rsp []string) { |
|
|
return
|
|
|
}
|
|
|
|
|
|
//checkSelfCheckData 校验自查内容数据
|
|
|
func checkSelfCheckData(data []protocol.TemplateSelfCheck) error {
|
|
|
|
|
|
var cnt int
|
|
|
for _, v := range data {
|
|
|
var (
|
|
|
cnt int
|
|
|
)
|
|
|
titleMap := make(map[string]int)
|
|
|
for i, v := range data {
|
|
|
s := []rune(v.Title)
|
|
|
if len(s) == 0 || len(s) > 50 {
|
|
|
return protocol.NewErrWithMessage("10127")
|
|
|
}
|
|
|
if _, ok := titleMap[v.Title]; ok {
|
|
|
return protocol.NewErrWithMessage("10130")
|
|
|
} else {
|
|
|
titleMap[v.Title] = 1
|
|
|
}
|
|
|
cnt++
|
|
|
childTitleMap := make(map[string]int)
|
|
|
for _, vv := range data[i].Child {
|
|
|
ss := []rune(vv.Title)
|
|
|
if len(ss) == 0 || len(ss) > 50 {
|
|
|
return protocol.NewErrWithMessage("10127")
|
|
|
}
|
|
|
if _, ok := childTitleMap[vv.Title]; ok {
|
|
|
return protocol.NewErrWithMessage("10130")
|
|
|
} else {
|
|
|
titleMap[vv.Title] = 1
|
|
|
}
|
|
|
cnt++
|
|
|
}
|
|
|
}
|
|
|
if cnt > 30 {
|
|
|
return protocol.NewErrWithMessage("10128")
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func auditFlowMustActionTypeOr(auditflow protocol.AuditFlowConfig) error {
|
|
|
for _, v := range auditflow.ProcessConfig {
|
|
|
if v.AcitonType != models.ActionTypeOr {
|
|
|
return protocol.NewErrWithMessage("10129")
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
|
} |
...
|
...
|
|