...
|
...
|
@@ -73,6 +73,10 @@ func (this *TemplateController) TemplateAdd() { |
|
|
if len(request.Videos) == 0 {
|
|
|
request.Videos = make([]string, 0)
|
|
|
}
|
|
|
if err := checkSelfCheckData(request.SelfCheck); err != nil {
|
|
|
msg = protocol.NewReturnResponse(nil, err)
|
|
|
return
|
|
|
}
|
|
|
request.Videos = arrayFilter(request.Videos, "")
|
|
|
rsp, err := audit.TemplateAdd(uid, companyId, request)
|
|
|
msg = protocol.NewReturnResponse(rsp, err)
|
...
|
...
|
@@ -128,6 +132,12 @@ func (this *TemplateController) TemplateUpdate() { |
|
|
} else {
|
|
|
request.Videos = arrayFilter(request.Videos, "")
|
|
|
}
|
|
|
|
|
|
if err := checkSelfCheckData(request.SelfCheck); err != nil {
|
|
|
msg = protocol.NewReturnResponse(nil, err)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
rsp, err := audit.TemplateUpdate(uid, companyId, request)
|
|
|
msg = protocol.NewReturnResponse(rsp, err)
|
|
|
return
|
...
|
...
|
@@ -414,3 +424,19 @@ func arrayFilter(arr1 []string, s string) (rsp []string) { |
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func checkSelfCheckData(data []protocol.TemplateSelfCheck) error {
|
|
|
|
|
|
var cnt int
|
|
|
for _, v := range data {
|
|
|
s := []rune(v.Title)
|
|
|
if len(s) == 0 || len(s) > 50 {
|
|
|
return protocol.NewErrWithMessage("10127")
|
|
|
}
|
|
|
cnt++
|
|
|
}
|
|
|
if cnt > 30 {
|
|
|
return protocol.NewErrWithMessage("10128")
|
|
|
}
|
|
|
return nil
|
|
|
} |
...
|
...
|
|