Browse Source

feat:项目数量

wangshan 3 years ago
parent
commit
97bbc65f50
1 changed files with 8 additions and 6 deletions
  1. 8 6
      src/jfw/modules/bigmember/src/entity/followProject.go

+ 8 - 6
src/jfw/modules/bigmember/src/entity/followProject.go

@@ -311,10 +311,8 @@ var (
 
 // GetFollowList 获取列表页
 func (this *ProjectFollow) GetFollowList(pNum, pSize, entUserId int) (followData []map[string]interface{}, hasNext bool, count int, err error) {
-	query := map[string]interface{}{
-		"s_userid": this.UserId,
-	}
-	count = qutil.IntAll(db.Base.Count(this.SaveTable, query))
+
+	count = qutil.IntAll(db.Base.CountBySql(`select count(id) as count from follow_project_monitor where s_userid= ?`, this.UserId))
 	log.Println("count:", count)
 	if count == 0 {
 		return
@@ -333,6 +331,9 @@ func (this *ProjectFollow) GetFollowList(pNum, pSize, entUserId int) (followData
 	//	hasNext = (pNum+1)*pSize < count
 	//}
 	//"l_lastpushtime,s_id,i_remind,id,l_createtime,i_apppushunread"
+	query := map[string]interface{}{
+		"s_userid": this.UserId,
+	}
 	t1 := time.Now()
 	followList := db.Base.Find(this.SaveTable, query, "l_lastpushtime,s_id,i_remind,id,l_createtime,i_apppushunread", "l_createtime desc", 0, pSize)
 	log.Println("查询耗时:", time.Since(t1), "数据量:", len(*followList))
@@ -501,7 +502,6 @@ func (this *ProjectFollow) CancelFollow(sid, fid string) error {
 // Remove30DayNoUpdate 批量删除30天未更新
 func (this *ProjectFollow) Remove30DayNoUpdate() (int, error) {
 	lt := time.Now().AddDate(0, 0, -30).Unix()
-
 	fData := db.Base.SelectBySql(`SELECT * FROM follow_project_monitor WHERE s_userid=? AND l_lastpushtime < ?`, this.UserId, lt)
 	//fData := db.Mysql.Find(this.SaveTable, query, "", "", -1, -1)
 	if fData == nil || len(*fData) == 0 {
@@ -514,7 +514,9 @@ func (this *ProjectFollow) Remove30DayNoUpdate() (int, error) {
 	if !db.Mgo.SaveBulk(this.SaveTable+"_back", *fData...) {
 		log.Println("批量删除备份出错")
 	}
-	db.Base.SelectBySql(`delete from follow_project_monitor WHERE s_userid=? AND l_lastpushtime < ?`, this.UserId, lt)
+	if c := db.Base.UpdateOrDeleteBySql(`delete from follow_project_monitor WHERE s_userid=? AND l_lastpushtime < ?`, this.UserId, lt); c < 0 {
+		log.Println("批量清除30天无更新异常")
+	}
 	return len(*fData), nil
 }