Selaa lähdekoodia

feat:优化sql

wangchuanjin 1 vuosi sitten
vanhempi
commit
513159c1fb

+ 4 - 4
src/jfw/modules/publicapply/src/bidcollection/entity/entity.go

@@ -1,7 +1,6 @@
 package entity
 
 import (
-	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
 	"fmt"
 	"jy/src/jfw/modules/publicapply/src/config"
 	"jy/src/jfw/modules/publicapply/src/db"
@@ -9,6 +8,8 @@ import (
 	"strconv"
 	"strings"
 
+	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
+
 	qu "app.yhyue.com/moapp/jybase/common"
 	. "app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/encrypt"
@@ -136,10 +137,9 @@ func GetLabelByUser(userid string) (data []LabelByUser) {
 	labcount := map[string]int{}
 	selectsql := fmt.Sprintf(`SELECT a.labelname,COUNT(1) count,a.id
 				FROM %s a INNER JOIN %s b ON
-				FIND_IN_SET(a.id,b.labelid)
-				WHERE b.userid =?
+				a.userid =? and b.userid =? and FIND_IN_SET(a.id,b.labelid)
 				GROUP BY a.labelname,a.id`, db.DbConf.Bdlabel, db.DbConf.Bdcollection)
-	if data := *db.Mysql.SelectBySql(selectsql, userid); len(data) > 0 {
+	if data := *db.Mysql.SelectBySql(selectsql, userid, userid); len(data) > 0 {
 		for _, v := range data {
 			labcount[strconv.FormatInt(v["id"].(int64), 10)] = qu.IntAll(v["count"])
 		}