Selaa lähdekoodia

fix:管理平台信息发布列表查询sql修改

duxin 3 vuotta sitten
vanhempi
commit
69e5463f7f
1 muutettua tiedostoa jossa 15 lisäystä ja 5 poistoa
  1. 15 5
      rpc/manager/internal/logic/infolistlogic.go

+ 15 - 5
rpc/manager/internal/logic/infolistlogic.go

@@ -8,6 +8,7 @@ import (
 	se "app.yhyue.com/moapp/jybase/encrypt"
 	"context"
 	"fmt"
+	"log"
 	"strings"
 
 	"app.yhyue.com/moapp/jybase/common"
@@ -36,7 +37,9 @@ func (l *InfoListLogic) InfoList(in *manager.InfoListReq) (*manager.InfoListResp
 		queryInfo string
 		count     int64
 		results   []*manager.InfoList
+		allData   *[]map[string]interface{}
 	)
+	log.Println("管理平台信息发布列表查询参数:", in)
 	if in.MsgType != 0 {
 		query = append(query, `type=`+common.InterfaceToStr(in.MsgType)+` `)
 	}
@@ -85,19 +88,26 @@ func (l *InfoListLogic) InfoList(in *manager.InfoListReq) (*manager.InfoListResp
 		in.PageSize = 10
 	}
 
-	count = model.Mysql.CountBySql(`SELECT count(1)  from (SELECT id,type,status,phone,contact_person,contact_phone,title,create_time,is_del,published  from information ` + queryInfo + `
-			union all
-			SELECT id,type,status,phone,contact_person,contact_phone,title,create_time,is_del,published  from supply_info ` + queryInfo + ` ) a`)
-
 	var offset int
 	if in.PageIndex <= 1 {
 		offset = 0
 	} else {
 		offset = common.IntAll((in.PageIndex - 1) * in.PageSize)
 	}
-	allData := model.Mysql.SelectBySql(`SELECT * from (SELECT id,type,status,phone,contact_person,contact_phone,title,create_time,is_del,published  from information `+queryInfo+`
+
+	if in.RecommendedService != 0 || in.JyPublishingMedia != 0 {
+		count = model.Mysql.CountBySql(`SELECT count(1)  from information ` + queryInfo)
+		allData = model.Mysql.SelectBySql(`SELECT id,type,status,phone,contact_person,contact_phone,title,create_time,is_del,published  from information `+queryInfo+`
+		  order by create_time limit ?,? `, offset, in.PageSize)
+	} else {
+		count = model.Mysql.CountBySql(`SELECT count(1)  from (SELECT id,type,status,phone,contact_person,contact_phone,title,create_time,is_del,published  from information ` + queryInfo + `
+			union all
+			SELECT id,type,status,phone,contact_person,contact_phone,title,create_time,is_del,published  from supply_info ` + queryInfo + ` ) a`)
+		allData = model.Mysql.SelectBySql(`SELECT * from (SELECT id,type,status,phone,contact_person,contact_phone,title,create_time,is_del,published  from information `+queryInfo+`
 			union all
 			SELECT id,type,status,phone,contact_person,contact_phone,title,create_time,is_del,published  from supply_info `+queryInfo+` ) a  order by a.create_time limit ?,? `, offset, in.PageSize)
+	}
+
 	if allData != nil && len(*allData) > 0 {
 		for _, v := range *allData {
 			res := manager.InfoList{}