|
@@ -1,33 +1,33 @@
|
|
|
package front
|
|
|
|
|
|
import (
|
|
|
- "database/sql"
|
|
|
- "errors"
|
|
|
- "fmt"
|
|
|
- "io/ioutil"
|
|
|
- utils "jy/src/jfw/modules/app/src/app/jyutil"
|
|
|
- "jy/src/jfw/modules/app/src/jfw/config"
|
|
|
- "net/http"
|
|
|
- "regexp"
|
|
|
- "strconv"
|
|
|
- "strings"
|
|
|
- "time"
|
|
|
-
|
|
|
- "github.com/gogf/gf/v2/util/gconv"
|
|
|
-
|
|
|
- "app.yhyue.com/moapp/jybase/date"
|
|
|
- "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
-
|
|
|
- //"math/rand"
|
|
|
- . "jy/src/jfw/modules/app/src/app/jyutil"
|
|
|
- "log"
|
|
|
-
|
|
|
- util "app.yhyue.com/moapp/jybase/common"
|
|
|
- elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
- "app.yhyue.com/moapp/jybase/redis"
|
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
- "app.yhyue.com/moapp/jypkg/public"
|
|
|
+ "database/sql"
|
|
|
+ "errors"
|
|
|
+ "fmt"
|
|
|
+ "io"
|
|
|
+ utils "jy/src/jfw/modules/app/src/app/jyutil"
|
|
|
+ "jy/src/jfw/modules/app/src/jfw/config"
|
|
|
+ "net/http"
|
|
|
+ "regexp"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+
|
|
|
+ "github.com/gogf/gf/v2/util/gconv"
|
|
|
+
|
|
|
+ "app.yhyue.com/moapp/jybase/date"
|
|
|
+ "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
+
|
|
|
+ //"math/rand"
|
|
|
+ . "jy/src/jfw/modules/app/src/app/jyutil"
|
|
|
+ "log"
|
|
|
+
|
|
|
+ util "app.yhyue.com/moapp/jybase/common"
|
|
|
+ elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
+ "app.yhyue.com/moapp/jypkg/public"
|
|
|
)
|
|
|
|
|
|
type Short struct {
|
|
@@ -99,52 +99,44 @@ func (s *Short) Article(contentType, stype, id string) error {
|
|
|
//userId = "637dcf3ff143ed326e9e1589"
|
|
|
//登录用户 权限
|
|
|
if userId != "" {
|
|
|
+ mobileHtmlKey := "jy_mobile_index_app"
|
|
|
var loginPageInfo = func() (body []byte) {
|
|
|
// 获取页面内容
|
|
|
- url := fmt.Sprintf("%s%s", config.Sysconfig["webdomain"].(string), "/jy_mobile/index.html")
|
|
|
- resp, err := http.Get(url)
|
|
|
- log.Println("article --- url :", url)
|
|
|
+ mobileUrl := fmt.Sprintf("%s%s", config.Sysconfig["webdomain"].(string), "/jy_mobile/index.html")
|
|
|
+ req, err := http.NewRequest("GET", mobileUrl, nil)
|
|
|
if err != nil {
|
|
|
- http.Error(s.ResponseWriter, "Failed to fetch page", http.StatusInternalServerError)
|
|
|
+ log.Println(s.ResponseWriter, "Failed to fetch page", http.StatusInternalServerError)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ req.Header.Set("X-Forwarded-For", util.GetIp(s.Request))
|
|
|
+ client := &http.Client{}
|
|
|
+ // 使用 Do 方法处理请求
|
|
|
+ resp, err := client.Do(req)
|
|
|
+ if err != nil {
|
|
|
+ log.Println(s.ResponseWriter, "Failed to create client", http.StatusInternalServerError)
|
|
|
return
|
|
|
}
|
|
|
defer resp.Body.Close()
|
|
|
-
|
|
|
- body, err = ioutil.ReadAll(resp.Body)
|
|
|
+ body, err = io.ReadAll(resp.Body)
|
|
|
if err != nil {
|
|
|
- http.Error(s.ResponseWriter, "Failed to read response body", http.StatusInternalServerError)
|
|
|
+ log.Println(s.ResponseWriter, "Failed to read response body", http.StatusInternalServerError)
|
|
|
return
|
|
|
}
|
|
|
+ err = redis.PutBytes(redisLimitation, mobileHtmlKey, &body, 3*24*60*60)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("mobile html redis cache err :", err.Error())
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
// 将页面内容返回给前端
|
|
|
s.ResponseWriter.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
|
+ body, err := redis.GetBytes(redisLimitation, mobileHtmlKey)
|
|
|
+ if err == nil && body != nil && len(*body) > 0 {
|
|
|
+ s.ResponseWriter.Write(*body)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
s.ResponseWriter.Write(loginPageInfo())
|
|
|
return nil
|
|
|
- belongUserId = GetbelongUserId(disWord, userId)
|
|
|
- b, _ := redis.Exists("sso", "req_"+userId)
|
|
|
- if b {
|
|
|
- return s.Redirect("/jyapp/free/mob/err")
|
|
|
- }
|
|
|
- isEntnicheNew = userPower.EntIsNew //新版超级订阅
|
|
|
- isOldVip = false //新购超级订阅不能查看拟建项目详情页
|
|
|
- isVip = userPower.VipStatus > 0 //超级订阅
|
|
|
- isMember = userPower.Status > 0 //大会员
|
|
|
- isEntniche = userPower.EntnicheStatus > 0 //商机管理
|
|
|
- email = userPower.Email
|
|
|
- if userPower.Data != nil && userPower.Data.Ent != nil && userPower.Data.Entniche != nil {
|
|
|
- isEntService = userPower.Data.Ent.PowerSource > 0 && userPower.Data.Entniche.IsEntPower > 0 //商机管理服务
|
|
|
- } //用户邮箱
|
|
|
- _, isOldVip, _, _, _ = UserPermission(userId)
|
|
|
- entId := util.IntAll(sess["entId"])
|
|
|
- if entId > 0 && userPower.EntInfo[entId] != nil {
|
|
|
- isEntniche = userPower.EntInfo[entId].Status == 1 && userPower.EntInfo[entId].IsPower
|
|
|
- isEntnicheNew = userPower.EntInfo[entId].IsNew && isEntniche
|
|
|
- if isEntService = userPower.EntInfo[entId].IsService && userPower.EntInfo[entId].IsPower; isEntService {
|
|
|
- isEntnicheNew = false
|
|
|
- isEntniche = false
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
s.T["isVip"] = isVip
|
|
|
s.T["member_status"] = userPower.Status
|