Browse Source

Merge branch 'gn_2.6_add_ppt_cover_1121@guomengyuan' into debug

gmy 4 months ago
parent
commit
458406e65a
2 changed files with 90 additions and 62 deletions
  1. 72 62
      controllers/image_conf_controller.go
  2. 18 0
      routers/commentsRouter.go

+ 72 - 62
controllers/image_conf_controller.go

@@ -11,68 +11,12 @@ type ImageConfController struct {
 	BaseAuthController
 }
 
-func (this *ImageConfController) AddImageMaterial() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		if br.ErrMsg == "" {
-			br.IsSendEmail = false
-		}
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-	sysUser := this.SysUser
-	if sysUser == nil {
-		br.Msg = "请登录"
-		br.ErrMsg = "请登录,SysUser Is Empty"
-		br.Ret = 408
-		return
-	}
-	var req []*models.ImageConf
-	if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + e.Error()
-		return
-	}
-
-	// 校验图片名称是否重复
-	for _, item := range req {
-		if item.ImageType <= 0 {
-			br.Msg = "请选择图片类型!"
-			br.ErrMsg = "请选择图片类型!"
-			return
-		}
-
-		if item.Url == "" {
-			br.Msg = "请上传图片!"
-			br.ErrMsg = "请上传图片!"
-			return
-		}
-
-		// 校验名称是否重复
-		imageConfByName, err := models.GetImageConfByName(item.ImageName)
-		if err != nil {
-			return
-		}
-		if imageConfByName != nil {
-			br.Msg = "图片名称已存在,请重新上传!"
-			br.ErrMsg = "图片名称已存在,请重新上传!"
-			return
-		}
-	}
-
-	err := models.BatchAddImageMaterials(req, len(req))
-	if err != nil {
-		br.Msg = "操作失败"
-		br.ErrMsg = "操作失败,Err:" + err.Error()
-		return
-	}
-
-	br.Msg = "操作成功"
-	br.Ret = 200
-	return
-}
-
-func (this *ImageConfController) getImageMaterialList() {
+// GetImageMaterial
+// @Title 根据条件查询图片素材
+// @Description 根据条件查询图片素材
+// @Success 200 {object} models.ImageConf
+// @router /get/image/material [get]
+func (this *ImageConfController) GetImageMaterial() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
 		if br.ErrMsg == "" {
@@ -145,3 +89,69 @@ func (this *ImageConfController) getImageMaterialList() {
 	br.Data = imageConfList
 	return
 }
+
+// AddImageMaterial
+// @Title 新增图片素材
+// @Description 新增图片素材
+// @Success 200
+// @router /add/image/material [post]
+func (this *ImageConfController) AddImageMaterial() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req []*models.ImageConf
+	if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + e.Error()
+		return
+	}
+
+	// 校验图片名称是否重复
+	for _, item := range req {
+		if item.ImageType <= 0 {
+			br.Msg = "请选择图片类型!"
+			br.ErrMsg = "请选择图片类型!"
+			return
+		}
+
+		if item.Url == "" {
+			br.Msg = "请上传图片!"
+			br.ErrMsg = "请上传图片!"
+			return
+		}
+
+		// 校验名称是否重复
+		imageConfByName, err := models.GetImageConfByName(item.ImageName)
+		if err != nil {
+			return
+		}
+		if imageConfByName != nil {
+			br.Msg = "图片名称已存在,请重新上传!"
+			br.ErrMsg = "图片名称已存在,请重新上传!"
+			return
+		}
+	}
+
+	err := models.BatchAddImageMaterials(req, len(req))
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + err.Error()
+		return
+	}
+
+	br.Msg = "操作成功"
+	br.Ret = 200
+	return
+}

+ 18 - 0
routers/commentsRouter.go

@@ -6487,6 +6487,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta_gn/eta_api/controllers:ImageConfController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:ImageConfController"],
+        beego.ControllerComments{
+            Method: "AddImageMaterial",
+            Router: `/add/image/material`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta_gn/eta_api/controllers:ImageConfController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:ImageConfController"],
+        beego.ControllerComments{
+            Method: "GetImageMaterial",
+            Router: `/get/image/material`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta_gn/eta_api/controllers:MeetingProbabilitiesController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:MeetingProbabilitiesController"],
         beego.ControllerComments{
             Method: "Detail",