|
@@ -1,57 +1,63 @@
|
|
|
package filter
|
|
|
|
|
|
import (
|
|
|
- "jy/src/jfw/modules/bigmember/src/config"
|
|
|
- "jy/src/jfw/modules/bigmember/src/db"
|
|
|
- "net/http"
|
|
|
- "regexp"
|
|
|
+ "jy/src/jfw/modules/bigmember/src/config"
|
|
|
+ "jy/src/jfw/modules/bigmember/src/db"
|
|
|
+ "net/http"
|
|
|
+ "regexp"
|
|
|
|
|
|
- . "app.yhyue.com/moapp/jybase/api"
|
|
|
- util "app.yhyue.com/moapp/jybase/common"
|
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
+ . "app.yhyue.com/moapp/jybase/api"
|
|
|
+ util "app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
|
|
|
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
)
|
|
|
|
|
|
-//登录限制
|
|
|
+// 登录限制
|
|
|
type sessionfilter struct {
|
|
|
- App *xweb.App
|
|
|
+ App *xweb.App
|
|
|
}
|
|
|
|
|
|
-//需要权限判断的地址
|
|
|
+// 需要权限判断的地址
|
|
|
var needReg = regexp.MustCompile("^/bigmember/(potential|forecast|decision|analysis|subscribe)/.+$") //画像接口中判断权限
|
|
|
|
|
|
func init() {
|
|
|
- jy.InitBigVipService(db.Mysql)
|
|
|
+ jy.InitBigVipService(db.Mysql)
|
|
|
}
|
|
|
|
|
|
func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
|
|
|
- session := l.App.SessionManager.Session(req, w)
|
|
|
- getSession := session.GetMultiple()
|
|
|
- if getSession["userId"] != nil && getSession["mgoUserId"] == nil && util.Int64All(getSession["positionType"]) == 0 {
|
|
|
- session.Set("mgoUserId", getSession["userId"])
|
|
|
- }
|
|
|
- match := needReg.FindStringSubmatch(req.URL.Path)
|
|
|
- if len(match) == 0 {
|
|
|
- return true
|
|
|
- }
|
|
|
- //免费用户搜索词订阅接口开放
|
|
|
- if req.URL.Path == "/bigmember/subscribe/freeUser/searchSubscribe" || req.URL.Path == "/bigmember/subscribe/freeUser/subscribeSearch" {
|
|
|
- return true
|
|
|
- }
|
|
|
- userId, ok := getSession["userId"].(string)
|
|
|
- if !ok || userId == "" {
|
|
|
- R.ServeJson(w, req, &Result{Error_code_1004, Error_msg_1004, nil})
|
|
|
- return false
|
|
|
- }
|
|
|
- //投标决策分析前置接口开放
|
|
|
- if req.URL.Path == "/bigmember/decision/freeDecInfo" || req.URL.Path == "/bigmember/analysis/projectName" || req.URL.Path == "/bigmember/analysis/projectInfo" || req.URL.Path == "/bigmember/project/getPdfDetail" {
|
|
|
- return true
|
|
|
- }
|
|
|
- bigMeg := jy.GetBigVipUserBaseMsg(session, *config.Middleground)
|
|
|
- if !bigMeg.CheckBigVipBackPower(match[1]) {
|
|
|
- R.ServeJson(w, req, &Result{Error_code_1004, Error_msg_1004, nil})
|
|
|
- return false
|
|
|
- }
|
|
|
- return true
|
|
|
+ session := l.App.SessionManager.Session(req, w)
|
|
|
+ getSession := session.GetMultiple()
|
|
|
+ if getSession["userId"] != nil && getSession["mgoUserId"] == nil && util.Int64All(getSession["positionType"]) == 0 {
|
|
|
+ session.Set("mgoUserId", getSession["userId"])
|
|
|
+ }
|
|
|
+ match := needReg.FindStringSubmatch(req.URL.Path)
|
|
|
+ if len(match) == 0 {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ //免费用户搜索词订阅接口开放
|
|
|
+ if req.URL.Path == "/bigmember/subscribe/freeUser/searchSubscribe" || req.URL.Path == "/bigmember/subscribe/freeUser/subscribeSearch" {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ userId, ok := getSession["userId"].(string)
|
|
|
+ if !ok || userId == "" {
|
|
|
+ R.ServeJson(w, req, &Result{Error_code_1004, Error_msg_1004, nil})
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ //投标决策分析前置接口开放
|
|
|
+ if req.URL.Path == "/bigmember/decision/freeDecInfo" || req.URL.Path == "/bigmember/analysis/projectName" || req.URL.Path == "/bigmember/analysis/projectInfo" || req.URL.Path == "/bigmember/project/getPdfDetail" {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ //企业画像部分免费功能接口开放
|
|
|
+ if req.URL.Path == "/bigmember/portrait/winner/getData" || //分析接口
|
|
|
+ req.URL.Path == "/bigmember/portrait/ent/detail" || //基本信息接口
|
|
|
+ req.URL.Path == "/bigmember/portrait/winner/getNewMsg" { //项目动态
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ bigMeg := jy.GetBigVipUserBaseMsg(session, *config.Middleground)
|
|
|
+ if !bigMeg.CheckBigVipBackPower(match[1]) {
|
|
|
+ R.ServeJson(w, req, &Result{Error_code_1004, Error_msg_1004, nil})
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
}
|