|
@@ -5,8 +5,10 @@ import (
|
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
+ "log"
|
|
|
. "salesLeads/src/config"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
const (
|
|
@@ -17,14 +19,23 @@ const (
|
|
|
|
|
|
// GetConfig 查询留资文案配置
|
|
|
func GetConfig(codes []string) (configData map[string]interface{}) {
|
|
|
+
|
|
|
configData = map[string]interface{}{}
|
|
|
args := []string{}
|
|
|
selectCode := []interface{}{}
|
|
|
+ start := time.Now()
|
|
|
+ defer func() {
|
|
|
+ log.Println("GetConfig total耗时:", time.Since(start))
|
|
|
+ }()
|
|
|
for i := 0; i < len(codes); i++ {
|
|
|
// 查缓存
|
|
|
+ redisStartTime := time.Now()
|
|
|
content := redis.Get(saleLeadConfigCacheRedis, fmt.Sprintf(saleLeadConfigCacheKey, codes[i]))
|
|
|
+ log.Println("GetConfig redis get耗时:", time.Since(redisStartTime))
|
|
|
if content != nil {
|
|
|
+ redistoMapTime := time.Now()
|
|
|
cMap := common.ObjToMap(content)
|
|
|
+ log.Println("GetConfig redis ObjToMap耗时:", time.Since(redistoMapTime))
|
|
|
if cMap != nil && len(*cMap) > 0 {
|
|
|
configData[codes[i]] = *cMap
|
|
|
} else {
|
|
@@ -35,12 +46,18 @@ func GetConfig(codes []string) (configData map[string]interface{}) {
|
|
|
args = append(args, "?")
|
|
|
selectCode = append(selectCode, codes[i])
|
|
|
}
|
|
|
+ log.Println("GetConfig redis 单次耗时:", time.Since(redisStartTime))
|
|
|
+
|
|
|
}
|
|
|
+ log.Println("GetConfig redis 总耗时:", time.Since(start))
|
|
|
if len(args) == 0 {
|
|
|
return
|
|
|
}
|
|
|
+ qStart := time.Now()
|
|
|
q := fmt.Sprintf("select `code`,title,subtitle,button_confirm,button_cancel from %s where `code` in (%s)", TableSalesLeadsConfig, strings.Join(args, ","))
|
|
|
rs := Mysql.SelectBySql(q, selectCode...)
|
|
|
+ log.Println("GetConfig SelectBySql 耗时:", time.Since(qStart))
|
|
|
+
|
|
|
// 格式化
|
|
|
if rs != nil && len(*rs) > 0 {
|
|
|
for i := 0; i < len(*rs); i++ {
|