浏览代码

Merge branch 'dev2.6.4' into release

lianbingjie 5 年之前
父节点
当前提交
f3da581b5a
共有 3 个文件被更改,包括 46 次插入21 次删除
  1. 21 21
      common/src/qfw/util/jy/entnichepush.go
  2. 11 0
      common/src/qfw/util/jy/jy.go
  3. 14 0
      common/src/qfw/util/weedcl/client.go

+ 21 - 21
common/src/qfw/util/jy/entnichepush.go

@@ -21,8 +21,8 @@ type entnichePush struct {
 }
 
 //从pushcache_2_a中取
-func (e *entnichePush) GetTodayCache(userId int) (*SubPush, error) {
-	pc_a, err := redis.GetNewBytes("pushcache_2_b", e.todayKey(userId))
+func (e *entnichePush) GetTodayCache(entId, userId int) (*SubPush, error) {
+	pc_a, err := redis.GetNewBytes("pushcache_2_b", e.todayKey(entId, userId))
 	if err != nil {
 		return nil, err
 	}
@@ -37,13 +37,13 @@ func (e *entnichePush) GetTodayCache(userId int) (*SubPush, error) {
 }
 
 //往pushcache_2_a中放
-func (e *entnichePush) PutTodayCache(userId int, pc_a *SubPush) {
-	redis.Put("pushcache_2_b", e.todayKey(userId), pc_a, threeDay)
+func (e *entnichePush) PutTodayCache(entId, userId int, pc_a *SubPush) {
+	redis.Put("pushcache_2_b", e.todayKey(entId, userId), pc_a, threeDay)
 }
 
 //获取redis key
-func (e *entnichePush) todayKey(userId int) string {
-	return fmt.Sprintf("entnichepush_%d", userId)
+func (e *entnichePush) todayKey(entId, userId int) string {
+	return fmt.Sprintf("entnichepush_%d_%d", userId)
 }
 
 func (e *entnichePush) Datas(MQFW mg.MongodbSim, PushMysql *mysql.Mysql, entId, userId int, pageNum int, selectTime, area string) (hasNextPage bool, result []*SubPushList) {
@@ -54,7 +54,7 @@ func (e *entnichePush) Datas(MQFW mg.MongodbSim, PushMysql *mysql.Mysql, entId,
 	start := (pageNum - 1) * pageSize
 	end := start + pageSize
 	if now == selectTime && area == "" {
-		subPush, err := e.GetTodayCache(userId)
+		subPush, err := e.GetTodayCache(entId, userId)
 		if err != nil {
 			log.Println(userId, "GetTodayCache Error", err)
 		}
@@ -64,7 +64,7 @@ func (e *entnichePush) Datas(MQFW mg.MongodbSim, PushMysql *mysql.Mysql, entId,
 				Date:  now,
 				Datas: list,
 			}
-			e.PutTodayCache(userId, subPush)
+			e.PutTodayCache(entId, userId, subPush)
 		}
 		length := len(subPush.Datas)
 		if end > length {
@@ -74,13 +74,13 @@ func (e *entnichePush) Datas(MQFW mg.MongodbSim, PushMysql *mysql.Mysql, entId,
 			result = subPush.Datas[start:end]
 		}
 	} else if selectTime == "" && area == "" && pageNum <= 5 {
-		allCache, err := e.GetAllCache(userId)
+		allCache, err := e.GetAllCache(entId, userId)
 		if err != nil {
 			log.Println(userId, "GetAllCache Error", err)
 		}
 		if err != nil || allCache == nil || len(allCache) == 0 {
 			allCache = e.getDatasFromMysql(MQFW, PushMysql, entId, userId, 1, AllSubPushCacheSize, selectTime, area, true)
-			e.PutAllCache(userId, allCache)
+			e.PutAllCache(entId, userId, allCache)
 		}
 		length := len(allCache)
 		if end > length {
@@ -241,12 +241,12 @@ func (e *entnichePush) GetInfoByIds(MQFW mg.MongodbSim, pushCas []*PushCa) []*Su
 	return array
 }
 
-func (e *entnichePush) Visit(PushMysql *mysql.Mysql, userId, id int) {
+func (e *entnichePush) Visit(PushMysql *mysql.Mysql, entId, userId, id int) {
 	if id <= 0 {
 		return
 	}
 	PushMysql.UpdateOrDeleteBySql("update pushsubscribe set isvisit=1 where userid=? and id=?", userId, id)
-	todaySubPush, err := e.GetTodayCache(userId)
+	todaySubPush, err := e.GetTodayCache(entId, userId)
 	if err == nil && todaySubPush != nil {
 		for _, v := range todaySubPush.Datas {
 			if v.Ca_index == Int64All(id) {
@@ -254,10 +254,10 @@ func (e *entnichePush) Visit(PushMysql *mysql.Mysql, userId, id int) {
 				break
 			}
 		}
-		e.PutTodayCache(userId, todaySubPush)
+		e.PutTodayCache(entId, userId, todaySubPush)
 	}
 	//
-	allSubPush, err := e.GetAllCache(userId)
+	allSubPush, err := e.GetAllCache(entId, userId)
 	if err == nil && allSubPush != nil {
 		for _, v := range allSubPush {
 			if v.Ca_index == Int64All(id) {
@@ -265,21 +265,21 @@ func (e *entnichePush) Visit(PushMysql *mysql.Mysql, userId, id int) {
 				break
 			}
 		}
-		e.PutAllCache(userId, allSubPush)
+		e.PutAllCache(entId, userId, allSubPush)
 	}
 }
 
 //查看全部列表缓存
-func (e *entnichePush) allKey(userId int) string {
-	return fmt.Sprintf("all_entnichepush_%d", userId)
+func (e *entnichePush) allKey(entId, userId int) string {
+	return fmt.Sprintf("all_entnichepush_%d_%d", userId)
 }
 
-func (e *entnichePush) PutAllCache(userId int, datas []*SubPushList) {
-	redis.Put("pushcache_2_a", e.allKey(userId), datas, threeDay)
+func (e *entnichePush) PutAllCache(entId, userId int, datas []*SubPushList) {
+	redis.Put("pushcache_2_a", e.allKey(entId, userId), datas, threeDay)
 }
 
-func (e *entnichePush) GetAllCache(userId int) ([]*SubPushList, error) {
-	return e.GetCache("pushcache_2_a", e.allKey(userId))
+func (e *entnichePush) GetAllCache(entId, userId int) ([]*SubPushList, error) {
+	return e.GetCache("pushcache_2_a", e.allKey(entId, userId))
 }
 
 func (e *entnichePush) GetCache(code, key string) ([]*SubPushList, error) {

+ 11 - 0
common/src/qfw/util/jy/jy.go

@@ -181,6 +181,17 @@ func SendPhoneIdentCode(phone string, session *httpsession.Session) bool {
 	return true
 }
 
+//短信验证码校验
+func CheckPhoneIdent(session *httpsession.Session, code string) string {
+	identCodeKey, _ := session.Get("identCodeValue").(string)
+	if identCodeKey != "" && identCodeKey == code {
+		identCodeKey, _ := session.Get("identCodeKey").(string)
+		ClearPhoneIdentSession(session)
+		return identCodeKey
+	}
+	return ""
+}
+
 //删除短信验证码有关的session
 func ClearPhoneIdentSession(session *httpsession.Session) {
 	session.Del("identCodeValue")

+ 14 - 0
common/src/qfw/util/weedcl/client.go

@@ -86,6 +86,20 @@ func (c *Client) Delete(fid, url string) (err error) {
 	return
 }
 
+//删除文件
+func (c *Client) NewDelete(fid, url string) ([]byte, error) {
+	req, err := http.NewRequest("DELETE", fmt.Sprintf("http://%s/%s", url, fid), nil)
+	if err != nil {
+		return nil, err
+	}
+	resp, err := c.httpclient.Do(req)
+	if err != nil {
+		return nil, err
+	}
+	defer resp.Body.Close()
+	return ioutil.ReadAll(resp.Body)
+}
+
 //更新文件
 func (c *Client) Update(path, url, fid string) (string, string, error) {
 	fi, err := os.Open(path)