ziwen 2 years ago
parent
commit
6eedee548c
3 changed files with 16 additions and 8 deletions
  1. 8 6
      controller/pc/pc.go
  2. 1 1
      routers/pc.go
  3. 7 1
      services/sun_code.go

+ 8 - 6
controller/pc/pc.go

@@ -192,18 +192,20 @@ func CustomerComment(c *gin.Context) {
 // @Tags 公共模块
 // @Summary  获取分享海报
 // @Description 获取分享海报
-// @Param	CodeScene	query string true "scene值"
-// @Param	CodePage	query string true "codePage"
+// @Param	request	body services.SunCodeReq true "type json string"
 // @Success 200 {object} string "获取成功"
 // @failure 400 {string} string "获取失败"
 // @Router /pc/getSunCode [post]
 func GetSunCode(c *gin.Context) {
-	codeScene := c.Query("CodeScene")
-	codePage := c.Query("CodePage")
+	var req services.SunCodeReq
+	if c.ShouldBind(&req) != nil{
+		response.Fail("参数异常", c)
+		return
+	}
 
 	var sunCodeUrl string
 	//先查,查不到再去生成上传
-	item,err  := yb_pc_suncode.GetYbPcSunCode(codeScene, codePage)
+	item,err  := yb_pc_suncode.GetYbPcSunCode(req.CodeScene, req.CodePage)
 	sunCodeUrl = item.SuncodeURL
 	if err != nil && err != utils.ErrNoRow{
 		response.Fail(err.Error(), c)
@@ -211,7 +213,7 @@ func GetSunCode(c *gin.Context) {
 	}
 
 	if sunCodeUrl == ""{
-		sunCodeUrl, err = services.PcCreateAndUploadSunCode(codePage, codeScene)
+		sunCodeUrl, err = services.PcCreateAndUploadSunCode(req.CodeScene, req.CodePage)
 		if err != nil {
 			return
 		}

+ 1 - 1
routers/pc.go

@@ -16,5 +16,5 @@ func InitPc(r *gin.Engine)  {
 	rGroup.GET("/recommend", pc.Recommend)
 	rGroup.GET("/classify", pc.ClassifyFirstList)
 	rGroup.GET("/comment", pc.CustomerComment)
-	rGroup.GET("/getSunCode", pc.GetSunCode)
+	rGroup.POST("/getSunCode", pc.GetSunCode)
 }

+ 7 - 1
services/sun_code.go

@@ -10,7 +10,13 @@ import (
 	"time"
 )
 
-// CreateAndUploadSunCode 生成太阳码并上传OSS
+// SunCodeReq 获取太阳码请求体
+type SunCodeReq struct {
+	CodePage  string `json:"code_page" description:"太阳码page"`
+	CodeScene string `json:"code_scene" description:"太阳码scene"`
+}
+
+// PcCreateAndUploadSunCode 生成太阳码并上传OSS
 func PcCreateAndUploadSunCode(page, scene string) (imgUrl string, err error) {
 	if page == "" {
 		err = errors.New("page不能为空")