|
@@ -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
|
|
|
+}
|