作者 yangfu

去除空串

... ... @@ -6,6 +6,7 @@ import (
"oppmg/models"
"oppmg/protocol"
"oppmg/services/audit"
"strings"
)
//TemplateController 机会模板
... ... @@ -72,6 +73,7 @@ func (this *TemplateController) TemplateAdd() {
if len(request.Videos) == 0 {
request.Videos = make([]string, 0)
}
request.Videos = arrayFilter(request.Videos, "")
rsp, err := audit.TemplateAdd(uid, companyId, request)
msg = protocol.NewReturnResponse(rsp, err)
return
... ... @@ -123,6 +125,8 @@ func (this *TemplateController) TemplateUpdate() {
}
if len(request.Videos) == 0 {
request.Videos = make([]string, 0)
} else {
request.Videos = arrayFilter(request.Videos, "")
}
rsp, err := audit.TemplateUpdate(uid, companyId, request)
msg = protocol.NewReturnResponse(rsp, err)
... ... @@ -398,3 +402,15 @@ func (this *TemplateController) CategoryEditSort() {
rsp, err := audit.CategoryEditSort(uid, companyId, request)
msg = protocol.NewReturnResponse(rsp, err)
}
//从数组过滤掉特定元素的项
func arrayFilter(arr1 []string, s string) (rsp []string) {
rsp = make([]string, 0)
for _, v := range arr1 {
if strings.EqualFold(v, s) {
continue
}
rsp = append(rsp, v)
}
return
}
... ...