Browse Source

no message

xingzai 1 year ago
parent
commit
e46b51200b
2 changed files with 32 additions and 16 deletions
  1. 26 15
      controllers/config.go
  2. 6 1
      models/config.go

+ 26 - 15
controllers/config.go

@@ -1,6 +1,7 @@
 package controllers
 package controllers
 
 
 import (
 import (
+	"encoding/json"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/services"
 	"hongze/hongze_clpt/services"
 	"hongze/hongze_clpt/utils"
 	"hongze/hongze_clpt/utils"
@@ -97,22 +98,27 @@ func (this *BaseConfigController) ResearchIntroduce() {
 		this.ServeJSON()
 		this.ServeJSON()
 	}()
 	}()
 
 
-	detail, err := models.GetConfigByCode("research_introduce_img_url")
+	conf, err := models.GetConfigByCode("research_introduce_img_url")
 	if err != nil {
 	if err != nil {
 		br.Msg = "获取数据失败"
 		br.Msg = "获取数据失败"
 		br.ErrMsg = "买方研选产品介绍信息失败,Err:" + err.Error()
 		br.ErrMsg = "买方研选产品介绍信息失败,Err:" + err.Error()
 		return
 		return
 	}
 	}
-	resp := new(models.ConfigImgListResp)
-	list := strings.Split(detail.ConfigValue, "{|}")
-	if len(list) == 0 {
-		list = make([]string, 0)
+	if conf.ConfigValue == "" {
+		br.Msg = "获取失败"
+		br.ErrMsg = "买方研选产品介绍信息失败"
+		return
+	}
+	list := new(*models.ConfigImgListResp)
+	if err = json.Unmarshal([]byte(conf.ConfigValue), &list); err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "买方研选产品介绍信配置值解析失败, Err: " + err.Error()
+		return
 	}
 	}
-	resp.List = list
 	br.Msg = "获取成功!"
 	br.Msg = "获取成功!"
 	br.Ret = 200
 	br.Ret = 200
 	br.Success = true
 	br.Success = true
-	br.Data = resp
+	br.Data = list
 }
 }
 
 
 // @Title 买方研选报价单(无需token)
 // @Title 买方研选报价单(无需token)
@@ -125,22 +131,27 @@ func (this *BaseConfigController) ResearchQuotation() {
 		this.Data["json"] = br
 		this.Data["json"] = br
 		this.ServeJSON()
 		this.ServeJSON()
 	}()
 	}()
-	detail, err := models.GetConfigByCode("research_quotation_img_url")
+	conf, err := models.GetConfigByCode("research_quotation_img_url")
 	if err != nil {
 	if err != nil {
 		br.Msg = "获取数据失败"
 		br.Msg = "获取数据失败"
-		br.ErrMsg = "买方研选报价单信息失败,Err:" + err.Error()
+		br.ErrMsg = "买方研选产品介绍信息失败,Err:" + err.Error()
 		return
 		return
 	}
 	}
-	resp := new(models.ConfigImgListResp)
-	list := strings.Split(detail.ConfigValue, "{|}")
-	if len(list) == 0 {
-		list = make([]string, 0)
+	if conf.ConfigValue == "" {
+		br.Msg = "获取失败"
+		br.ErrMsg = "买方研选产品介绍信息失败"
+		return
+	}
+	list := new(*models.ConfigImgListResp)
+	if err = json.Unmarshal([]byte(conf.ConfigValue), &list); err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "买方研选产品介绍信配置值解析失败, Err: " + err.Error()
+		return
 	}
 	}
-	resp.List = list
 	br.Msg = "获取成功!"
 	br.Msg = "获取成功!"
 	br.Ret = 200
 	br.Ret = 200
 	br.Success = true
 	br.Success = true
-	br.Data = resp
+	br.Data = list
 }
 }
 
 
 // @Title 买方研选升级新资源海报(无需token)
 // @Title 买方研选升级新资源海报(无需token)

+ 6 - 1
models/config.go

@@ -96,7 +96,12 @@ type AboutUs struct {
 }
 }
 
 
 type ConfigImgListResp struct {
 type ConfigImgListResp struct {
-	List []string
+	List []*ConfigImgResp
+}
+
+type ConfigImgResp struct {
+	Img    string `description:"图片"`
+	Height string `description:"高度"`
 }
 }
 
 
 type ConfigImgHbResp struct {
 type ConfigImgHbResp struct {