|
@@ -532,57 +532,59 @@ func (this *ResourceController) Add() {
|
|
br.Ret = 408
|
|
br.Ret = 408
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- var req knowledge.AddReq
|
|
|
|
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
|
|
|
+ var reqList []knowledge.AddReq
|
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqList)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "参数解析异常!"
|
|
br.Msg = "参数解析异常!"
|
|
br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- if req.Title == `` {
|
|
|
|
- br.Msg = "标题不能为空"
|
|
|
|
- br.ErrMsg = "标题不能为空"
|
|
|
|
- br.IsSendEmail = false
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- // 判断标题长度,如果超过600个字符则报错
|
|
|
|
- //fmt.Println(len(req.Title))
|
|
|
|
- if len(req.Title) > 600 {
|
|
|
|
- br.Msg = "标题过长"
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ for _, req := range reqList {
|
|
|
|
+ if req.Title == `` {
|
|
|
|
+ br.Msg = "标题不能为空"
|
|
|
|
+ br.ErrMsg = "标题不能为空"
|
|
|
|
+ br.IsSendEmail = false
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 判断标题长度,如果超过600个字符则报错
|
|
|
|
+ //fmt.Println(len(req.Title))
|
|
|
|
+ if len(req.Title) > 600 {
|
|
|
|
+ br.Msg = "标题过长"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
|
|
- if req.ClassifyId <= 0 {
|
|
|
|
- br.Msg = "分类必填"
|
|
|
|
- br.ErrMsg = "分类必填"
|
|
|
|
- br.IsSendEmail = false
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- if req.ResourceType == knowledge.KnowledgeResourceTypeEvent || req.ResourceType == knowledge.KnowledgeResourceTypePolicy {
|
|
|
|
- if req.StartTime == "" {
|
|
|
|
- br.Msg = "开始时间必填"
|
|
|
|
- br.ErrMsg = "开始时间必填"
|
|
|
|
|
|
+ if req.ClassifyId <= 0 {
|
|
|
|
+ br.Msg = "分类必填"
|
|
|
|
+ br.ErrMsg = "分类必填"
|
|
|
|
+ br.IsSendEmail = false
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- }
|
|
|
|
- item, err, errMsg := knowledgeServ.AddResource(&req, sysUser)
|
|
|
|
- if err != nil {
|
|
|
|
- br.Msg = "保存失败"
|
|
|
|
- if errMsg != "" {
|
|
|
|
- br.Msg = errMsg
|
|
|
|
|
|
+ if req.ResourceType == knowledge.KnowledgeResourceTypeEvent || req.ResourceType == knowledge.KnowledgeResourceTypePolicy {
|
|
|
|
+ if req.StartTime == "" {
|
|
|
|
+ br.Msg = "开始时间必填"
|
|
|
|
+ br.ErrMsg = "开始时间必填"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ _, err, errMsg := knowledgeServ.AddResource(&req, sysUser)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "保存失败"
|
|
|
|
+ if errMsg != "" {
|
|
|
|
+ br.Msg = errMsg
|
|
|
|
+ }
|
|
|
|
+ br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
|
- return
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- resp := new(knowledge.AddResp)
|
|
|
|
|
|
+ /*resp := new(knowledge.AddResp)
|
|
resp.KnowledgeResourceId = item.KnowledgeResourceId
|
|
resp.KnowledgeResourceId = item.KnowledgeResourceId
|
|
- resp.ResourceCode = item.ResourceCode
|
|
|
|
|
|
+ resp.ResourceCode = item.ResourceCode*/
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
br.Success = true
|
|
br.Success = true
|
|
br.Msg = "保存成功"
|
|
br.Msg = "保存成功"
|
|
- br.Data = resp
|
|
|
|
|
|
+ //br.Data = resp
|
|
}
|
|
}
|
|
|
|
|
|
// Edit
|
|
// Edit
|