Selaa lähdekoodia

feat:sql查询修改

duxin 2 vuotta sitten
vanhempi
commit
dfa38f1a5f
1 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. 4 4
      jyBXSubscribe/rpc/model/push.go

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

@@ -516,7 +516,7 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 					for _, v := range *users {
 						userIds = append(userIds, common.InterfaceToStr(v.Id))
 					}
-					userStr += fmt.Sprintf(" a.userid in (%s)  ", strings.Join(userIds, ","))
+					userStr += fmt.Sprintf(" and  a.userid in (%s)  ", strings.Join(userIds, ","))
 				} else {
 					log.Printf("部门管理员为获取到部门员工:%s", spqp.EntUserId)
 					result = []*bxsubscribe.SubscribeInfo{}
@@ -527,14 +527,14 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 			//查询数量(需要去重)
 			if len(querys) > 1 {
 				//countSql = fmt.Sprintf("select count(1) as count from %s  a STRAIGHT_JOIN %s b ON %s and a.infoid = b.infoid  %s where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, userStr, leftJoinStr, strings.Join(querys, " and "))
-				countSql = fmt.Sprintf("SELECT count(1) AS count FROM (SELECT DISTINCT matchkeys,infoid FROM %s WHERE 1=1 and %s )  a STRAIGHT_JOIN %s b ON  a.infoid = b.infoid  %s where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr, Baseinfo, leftJoinStr, strings.Join(querys, " and "))
+				countSql = fmt.Sprintf("SELECT count(1) AS count FROM (SELECT DISTINCT matchkeys,infoid FROM %s a WHERE 1=1 and %s )  a STRAIGHT_JOIN %s b ON  a.infoid = b.infoid  %s where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr, Baseinfo, leftJoinStr, strings.Join(querys, " and "))
 			} else {
 				//countSql = fmt.Sprintf("select count(1) as count from %s  a where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr)
 				countSql = fmt.Sprintf("SELECT count(1) AS count FROM ( SELECT DISTINCT matchkeys,infoid FROM %s a WHERE %s ) AS data", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr)
 			}
 			//列表查询
-			findSql = fmt.Sprintf("select a.infoid,a.matchkeys,b.isvalidfile as attachment_count from (SELECT DISTINCT matchkeys,infoid FROM %s WHERE 1=1 and %s ) a STRAIGHT_JOIN %s b ON a.infoid = b.infoid  %s where %s"+
-				" order by a.date desc,a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr, Baseinfo, leftJoinStr, strings.Join(querys, " and "))
+			findSql = fmt.Sprintf("select a.infoid,a.matchkeys,b.isvalidfile as attachment_count from (SELECT DISTINCT matchkeys,infoid FROM %s a WHERE 1=1 and %s ) a STRAIGHT_JOIN %s b ON a.infoid = b.infoid  %s where %s"+
+				" order by b.publishtime desc", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr, Baseinfo, leftJoinStr, strings.Join(querys, " and "))
 		} else {
 			if spqp.BuySubject == 1 {
 				//企业主体是企业的个人查询