WH01243 2 år sedan
förälder
incheckning
f062bfdf38
1 ändrade filer med 6 tillägg och 4 borttagningar
  1. 6 4
      jyBXSubscribe/rpc/model/push.go

+ 6 - 4
jyBXSubscribe/rpc/model/push.go

@@ -305,9 +305,11 @@ func (s *subscribePush) Datas(spqp *SubPushQueryParam) (hasNextPage bool, total
 
 func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, endtime int64, size int, isLimit bool) (result []*bxsubscribe.SubscribeInfo, count int64) {
 	querys := []string{}
+	userStr := " "
 	var (
 		searchSql, findSql string
 	)
+	querys = append(querys, " 1=1 ")
 	if spqp.SelectInfoIds != nil && len(spqp.SelectInfoIds) > 0 {
 		searchSql = fmt.Sprintf(" from %s a LEFT JOIN %s b ON a.infoid = b.infoid where %s order by a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, fmt.Sprintf("a.id in ('%s')", strings.Join(spqp.SelectInfoIds, "','")))
 		fmt.Println("searchSql", searchSql)
@@ -316,9 +318,9 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 		findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
 	} else {
 		if spqp.IsEnt {
-			querys = []string{fmt.Sprintf("a.entid='%s'", spqp.EntId)}
+			userStr = fmt.Sprintf(" and a.entid='%s'", spqp.EntId)
 		} else {
-			querys = []string{fmt.Sprintf("a.userid='%s'", common.If(s.ModuleFlag == "eType", spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))}
+			userStr = fmt.Sprintf(" and a.userid='%s'", common.If(s.ModuleFlag == "eType", spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
 
 		}
 		codeMap, err := IC.CodeLib.CodeTransformation(context.Background(), &codeservice.Request{})
@@ -459,8 +461,8 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 				querys = append(querys, fmt.Sprintf("b.isvalidfile =0 "))
 			}
 		}
-		searchSql = fmt.Sprintf(" from %s  a LEFT JOIN %s b ON a.infoid = b.infoid LEFT JOIN %s t on t.infoid = b.infoid and t.labelcode=2  where %s"+
-			" order by a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, BidTags, strings.Join(querys, " and "))
+		searchSql = fmt.Sprintf(" from %s  a LEFT JOIN %s b ON a.infoid = b.infoid %s  LEFT JOIN %s t on t.infoid = b.infoid and t.labelcode=2  where %s"+
+			" order by a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, userStr, BidTags, strings.Join(querys, " and "))
 		logx.Info("searchSql", searchSql)
 		//查询总数
 		logx.Info(fmt.Sprintf("select count(a.id) " + searchSql))