|
@@ -15,6 +15,7 @@ import (
|
|
"hongze/hongze_yb/models/tables/company"
|
|
"hongze/hongze_yb/models/tables/company"
|
|
"hongze/hongze_yb/models/tables/wx_user"
|
|
"hongze/hongze_yb/models/tables/wx_user"
|
|
"hongze/hongze_yb/models/tables/yb_config"
|
|
"hongze/hongze_yb/models/tables/yb_config"
|
|
|
|
+ "hongze/hongze_yb/models/tables/yb_research_banner"
|
|
"hongze/hongze_yb/models/tables/yb_research_signup_statistics"
|
|
"hongze/hongze_yb/models/tables/yb_research_signup_statistics"
|
|
"hongze/hongze_yb/models/tables/yb_resource"
|
|
"hongze/hongze_yb/models/tables/yb_resource"
|
|
"hongze/hongze_yb/models/tables/yb_suncode_pars"
|
|
"hongze/hongze_yb/models/tables/yb_suncode_pars"
|
|
@@ -567,7 +568,7 @@ func BannerGetQRCode(c *gin.Context) {
|
|
companyName := companyInfo.CompanyName
|
|
companyName := companyInfo.CompanyName
|
|
|
|
|
|
companyNameCode := url.QueryEscape(companyName) // 进行URL编码
|
|
companyNameCode := url.QueryEscape(companyName) // 进行URL编码
|
|
- remarkCode := url.QueryEscape(remark) // 进行URL编码
|
|
|
|
|
|
+ remarkCode := url.QueryEscape(remark) // 进行URL编码
|
|
url := "pages-report/signUpPage/signUpPage?RealName=%s&CompanyName=%s&Mobile=%s&BannerId=%d&Title=%s"
|
|
url := "pages-report/signUpPage/signUpPage?RealName=%s&CompanyName=%s&Mobile=%s&BannerId=%d&Title=%s"
|
|
url = fmt.Sprintf(url, wxUserInfo.RealName, companyNameCode, wxUserInfo.Mobile, bannerId, remarkCode)
|
|
url = fmt.Sprintf(url, wxUserInfo.RealName, companyNameCode, wxUserInfo.Mobile, bannerId, remarkCode)
|
|
|
|
|
|
@@ -597,6 +598,7 @@ func BannerGetQRCode(c *gin.Context) {
|
|
response.FailData("文件上传失败", "文件上传失败,Err:"+err.Error(), c)
|
|
response.FailData("文件上传失败", "文件上传失败,Err:"+err.Error(), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
response.OkData("获取成功", resourceUrl, c)
|
|
response.OkData("获取成功", resourceUrl, c)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -674,24 +676,47 @@ func BannerDowload(c *gin.Context) {
|
|
response.Fail("参数有误:"+err.Error(), c)
|
|
response.Fail("参数有误:"+err.Error(), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-
|
|
|
|
- randStr := utils.GetRandStringNoSpecialChar(28)
|
|
|
|
- jpegPath := `./static/` + randStr + ".jpeg"
|
|
|
|
- err := services.ReportToJpeg(req.BannerUrl, jpegPath)
|
|
|
|
-
|
|
|
|
- dateDir := time.Now().Format("20060102")
|
|
|
|
- uploadDir := global.CONFIG.Serve.StaticDir + "hongze/" + dateDir
|
|
|
|
- err = os.MkdirAll(uploadDir, 0766)
|
|
|
|
- if err != nil {
|
|
|
|
- response.FailData("存储目录创建失败", "存储目录创建失败,Err:"+err.Error(), c)
|
|
|
|
|
|
+ obj := yb_research_banner.YbResearchBanner{}
|
|
|
|
+ item, err := obj.Fetch(req.UserId, req.BannerId)
|
|
|
|
+ if err != nil && err != utils.ErrNoRow {
|
|
|
|
+ response.Fail(err.Error(), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ resourceUrl := ""
|
|
|
|
|
|
- //上传到阿里云
|
|
|
|
- resourceUrl, err := services.UploadAliyun(randStr + ".jpeg", jpegPath)
|
|
|
|
- if err != nil {
|
|
|
|
- response.FailData("文件上传失败", "文件上传失败,Err:"+err.Error(), c)
|
|
|
|
- return
|
|
|
|
|
|
+ if item == nil {
|
|
|
|
+ randStr := utils.GetRandStringNoSpecialChar(28)
|
|
|
|
+ jpegPath := `./static/` + randStr + ".jpeg"
|
|
|
|
+ err := services.ReportToJpeg(req.BannerUrl, jpegPath)
|
|
|
|
+
|
|
|
|
+ dateDir := time.Now().Format("20060102")
|
|
|
|
+ uploadDir := global.CONFIG.Serve.StaticDir + "hongze/" + dateDir
|
|
|
|
+ err = os.MkdirAll(uploadDir, 0766)
|
|
|
|
+ if err != nil {
|
|
|
|
+ response.FailData("存储目录创建失败", "存储目录创建失败,Err:"+err.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ defer func() {
|
|
|
|
+ os.Remove(jpegPath)
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+ //上传到阿里云
|
|
|
|
+ resourceUrl, err := services.UploadAliyun(randStr+".jpeg", jpegPath)
|
|
|
|
+ if err != nil {
|
|
|
|
+ response.FailData("文件上传失败", "文件上传失败,Err:"+err.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ obj.BannerID = req.BannerId
|
|
|
|
+ obj.UserID = req.UserId
|
|
|
|
+ obj.ImgURL = resourceUrl
|
|
|
|
+ err = obj.Create()
|
|
|
|
+ if err != nil {
|
|
|
|
+ response.FailData("创建banner长图记录失败", "创建banner长图记录失败,Err:"+err.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ resourceUrl = item.ImgURL
|
|
}
|
|
}
|
|
response.OkData("获取成功", resourceUrl, c)
|
|
response.OkData("获取成功", resourceUrl, c)
|
|
-}
|
|
|
|
|
|
+}
|