abiao лет назад: 5
Родитель
Сommit
e8cb96eff1

+ 18 - 8
go/gopath/src/fohow.com/apps/controllers/poster_controller/poster_controller.go

@@ -2,14 +2,13 @@ package poster_controller
 
 import (
 	"fmt"
-	"github.com/astaxie/beego"
-	"github.com/astaxie/beego/context"
-	"io/ioutil"
 	"fohow.com/apps"
 	"fohow.com/apps/models/poster_model"
-	"fohow.com/apps/models/project_model"
 	"fohow.com/libs/ali_oss"
 	"fohow.com/libs/wx_mp"
+	"github.com/astaxie/beego"
+	"github.com/astaxie/beego/context"
+	"io/ioutil"
 	"strconv"
 	"strings"
 	"time"
@@ -25,6 +24,17 @@ type PosterController struct {
 	apps.BaseController
 }
 
+func GetCdnFullImgUrl(img string) string {
+	if img == "" {
+		return ""
+	}
+	if strings.HasPrefix(img, "http://") || strings.HasPrefix(img, "https://") {
+		return img
+	} else {
+		return fmt.Sprintf("%s/%s", beego.AppConfig.String("AliCDNImgHost"), img)
+	}
+}
+
 var DEFAULT_HEAD string = "xcx/poster/default_head.png"
 
 func (self *PosterController) Init(ctx *context.Context, controllerName, actionName string, app interface{}) {
@@ -46,11 +56,11 @@ func (self *PosterController) GetPosterXcxQrcode() {
 	posterQrcodeRecord := poster_model.GetPosterQrcodeRecordByWIdAndTypeAndRId(wxUid, id, _type, useCache)
 
 	var qrcodeUrl string
-	var wxHead string = project_model.GetCdnFullImgUrl(DEFAULT_HEAD)
+	var wxHead string
 
 	wxUser := self.GetCurrentWxUser(true)
 	if wxUser != nil {
-		wxHead = project_model.GetCdnFullImgUrl(wxUser.Head)
+		wxHead = GetCdnFullImgUrl(wxUser.Head)
 	}
 
 	if posterQrcodeRecord == nil {
@@ -79,13 +89,13 @@ func (self *PosterController) GetPosterXcxQrcode() {
 		if err != nil {
 			beego.BeeLogger.Error("Upload Pngs err: %s", err)
 		} else {
-			qrcodeUrl = project_model.GetCdnFullImgUrl(uploadPath)
+			qrcodeUrl = GetCdnFullImgUrl(uploadPath)
 		}
 
 		new(poster_model.PosterQrcodeRecord).Create(wxUid, id, id, _type, uploadPath)
 
 	} else {
-		qrcodeUrl = project_model.GetCdnFullImgUrl(posterQrcodeRecord.QrcodeUrl)
+		qrcodeUrl = GetCdnFullImgUrl(posterQrcodeRecord.QrcodeUrl)
 	}
 
 	type Ret struct {