|
@@ -67,16 +67,18 @@ func Html2ImgHttpPost(url, postData string, params ...string) ([]byte, error) {
|
|
|
}
|
|
|
|
|
|
//func init() {
|
|
|
-// //MakeYanxuanSpecialMomentsImg(185)
|
|
|
-// var condition string
|
|
|
-// var pars []interface{}
|
|
|
-// condition += ` AND a.status = 3 `
|
|
|
+//MakeYanxuanSpecialMomentsImg(185)
|
|
|
+//var condition string
|
|
|
+//var pars []interface{}
|
|
|
+//condition += ` AND a.status = 3 `
|
|
|
//
|
|
|
-// list, err := models.GetYanxuanSpecialList(0, condition, pars, 0, 999)
|
|
|
-// fmt.Println(err)
|
|
|
-// for _, v := range list {
|
|
|
-// MakeYanxuanSpecialMomentsImg(v.Id)
|
|
|
-// }
|
|
|
+//list, err := models.GetYanxuanSpecialList(0, condition, pars, 0, 999)
|
|
|
+//fmt.Println(err)
|
|
|
+//for _, v := range list {
|
|
|
+// MakeYanxuanSpecialMomentsImg(v.Id)
|
|
|
+//}
|
|
|
+
|
|
|
+//GetYanxuanSpecialAuthoListMomentsImg()
|
|
|
//}
|
|
|
|
|
|
// 生成研选专栏分享到朋友圈的图片
|
|
@@ -206,17 +208,17 @@ func GetYanxuanSpecialAuthoListMomentsImg() (imgUrl string) {
|
|
|
}
|
|
|
|
|
|
// 生成研选专栏分享到朋友圈的图片
|
|
|
-func GetYanxuanSpecialAuthoMomentsImg(userId int) (imgUrl string) {
|
|
|
- var err error
|
|
|
+func GetYanxuanSpecialAuthoMomentsImg(userId int) (err error) {
|
|
|
+ //var err error
|
|
|
//time.Sleep(3*time.Second) // 有时候同时添加多个活动,延迟三秒
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Println("err:", err)
|
|
|
- go utils.SendAlarmMsg("生成研选专栏分享到朋友圈的图片,MakeArticleMomentsImg Err:"+err.Error()+"用户ID"+strconv.Itoa(userId), 3)
|
|
|
+ go utils.SendAlarmMsg("生成研选专栏分享到朋友圈的图片,GetYanxuanSpecialAuthoMomentsImg Err:"+err.Error()+"用户ID"+strconv.Itoa(userId), 3)
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
- articleInfo, e := models.GetYanxuanSpecialAuthor(userId, 0, "")
|
|
|
+ authorInfo, e := models.GetYanxuanSpecialAuthor(userId, 0, "")
|
|
|
if e != nil {
|
|
|
err = errors.New("GetYanxuanSpecialAuthor, Err: " + e.Error())
|
|
|
return
|
|
@@ -229,13 +231,13 @@ func GetYanxuanSpecialAuthoMomentsImg(userId int) (imgUrl string) {
|
|
|
return
|
|
|
}
|
|
|
configValue := detailConfig.ConfigValue
|
|
|
- configValue = strings.Replace(configValue, "{{HeadImg}}", articleInfo.HeadImg, -1)
|
|
|
- configValue = strings.Replace(configValue, "{{SpecialName}}", articleInfo.SpecialName, -1)
|
|
|
- configValue = strings.Replace(configValue, "{{NickName}}", articleInfo.NickName, -1)
|
|
|
- configValue = strings.Replace(configValue, "{{SpecialArticleNum}}", strconv.Itoa(articleInfo.SpecialArticleNum), -1)
|
|
|
- configValue = strings.Replace(configValue, "{{CollectNum}}", strconv.Itoa(articleInfo.CollectNum), -1)
|
|
|
- configValue = strings.Replace(configValue, "{{FollowNum}}", strconv.Itoa(articleInfo.FollowNum), -1)
|
|
|
- configValue = strings.Replace(configValue, "{{Introduction}}", articleInfo.Introduction, -1)
|
|
|
+ configValue = strings.Replace(configValue, "{{HeadImg}}", authorInfo.HeadImg, -1)
|
|
|
+ configValue = strings.Replace(configValue, "{{SpecialName}}", authorInfo.SpecialName, -1)
|
|
|
+ configValue = strings.Replace(configValue, "{{NickName}}", authorInfo.NickName, -1)
|
|
|
+ configValue = strings.Replace(configValue, "{{SpecialArticleNum}}", strconv.Itoa(authorInfo.SpecialArticleNum), -1)
|
|
|
+ configValue = strings.Replace(configValue, "{{CollectNum}}", strconv.Itoa(authorInfo.CollectNum), -1)
|
|
|
+ configValue = strings.Replace(configValue, "{{FollowNum}}", strconv.Itoa(authorInfo.FollowNum), -1)
|
|
|
+ configValue = strings.Replace(configValue, "{{Introduction}}", authorInfo.Introduction, -1)
|
|
|
|
|
|
htm2ImgReq := make(map[string]interface{})
|
|
|
htm2ImgReq["html_content"] = configValue
|
|
@@ -250,8 +252,13 @@ func GetYanxuanSpecialAuthoMomentsImg(userId int) (imgUrl string) {
|
|
|
err = errors.New("html转图片失败: " + res.Msg)
|
|
|
return
|
|
|
}
|
|
|
- imgUrl = res.Data
|
|
|
- err = models.UpdateYanxuanSpecialauthorMomentsImg(imgUrl, userId)
|
|
|
+ imgUrl := res.Data
|
|
|
+ e = models.UpdateYanxuanSpecialauthorMomentsImg(imgUrl, userId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateYanxuanSpecialauthorMomentsImg Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ DeleteUploadFileToAliyun(authorInfo.MomentsImg) // 删除老的图片
|
|
|
fmt.Println(imgUrl)
|
|
|
return
|
|
|
|