فهرست منبع

默认值处理

WH01243 7 ماه پیش
والد
کامیت
1e8dc5520b
1فایلهای تغییر یافته به همراه32 افزوده شده و 6 حذف شده
  1. 32 6
      jyBXCore/rpc/service/operator.go

+ 32 - 6
jyBXCore/rpc/service/operator.go

@@ -2,6 +2,7 @@ package service
 
 import (
 	"app.yhyue.com/moapp/jybase/common"
+	ME "app.yhyue.com/moapp/jybase/encrypt"
 	elastic "app.yhyue.com/moapp/jybase/es"
 	IC "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/init"
 	"fmt"
@@ -119,7 +120,7 @@ func getGetCriteriaType(entId, positionId, tag int64) []map[string]interface{} {
 			configName := gconv.String(v["config_name"])
 			switch configName {
 			case "行业":
-				industryArr := getConfiguration("行业", "industry", entId)
+				industryArr, _ := getConfiguration("行业", "industry", entId)
 				if len(industryArr) > 0 {
 					data = append(data, map[string]interface{}{
 						"key":        "industry",
@@ -134,7 +135,7 @@ func getGetCriteriaType(entId, positionId, tag int64) []map[string]interface{} {
 				}
 
 			case "中标人标签":
-				winnerArr := getConfiguration("运营商中标标签", "winner_tag", entId)
+				winnerArr, _ := getConfiguration("运营商中标标签", "winner_tag", entId)
 				if len(winnerArr) > 0 {
 					data = append(data, map[string]interface{}{
 						"key":        "winnerTag",
@@ -285,7 +286,8 @@ func getGetCriteriaType(entId, positionId, tag int64) []map[string]interface{} {
 	}
 	return data
 }
-func getConfiguration(conditionName, conditionType string, entId int64) []map[string]interface{} {
+func getConfiguration(conditionName, conditionType string, entId int64) ([]map[string]interface{}, map[string]interface{}) {
+	dataMap := make(map[string]interface{})
 	data := IC.BiMysql.SelectBySql(`SELECT
 					DISTINCT b.name,b.element_value as code
 				FROM
@@ -298,7 +300,7 @@ func getConfiguration(conditionName, conditionType string, entId int64) []map[st
 				and  b.element_field=? order by  code `, entId, conditionName, conditionType)
 	options := []map[string]interface{}{}
 	if data == nil {
-		return options
+		return options, dataMap
 	}
 	if len(*data) == 0 {
 		data = IC.BiMysql.SelectBySql(`SELECT
@@ -320,9 +322,10 @@ func getConfiguration(conditionName, conditionType string, entId int64) []map[st
 				"label": name,
 				"value": code,
 			})
+			dataMap[gconv.String(code)] = name
 		}
 	}
-	return options
+	return options, dataMap
 }
 func getLabel(entId int64) []map[string]interface{} {
 	// 私有标签查询
@@ -838,11 +841,22 @@ func SearchList(operator Operator) (int64, *[]map[string]interface{}, int64) {
 			idArr = append(idArr, id)
 			wh = append(wh, "?")
 		}
-
 		sqlStr := fmt.Sprintf(`select  * from customer_data where   id in (%s) %s `, strings.Join(wh, ","), mysqlOrderStr)
 		fmt.Println(sqlStr, idArr)
 		data = IC.BiMysql.SelectBySql(sqlStr,
 			idArr...)
+		if data != nil && len(*data) > 0 {
+			_, winnerMap := getConfiguration("运营商中标标签", "winner_tag", operator.EntId)
+			_, industryMap := getConfiguration("行业", "industry", operator.EntId)
+			for i, v := range *data {
+				(*data)[i]["publishtime"] = TimeHandle(gconv.String(v["publishtime"]))
+				(*data)[i]["bidopentime"] = TimeHandle(gconv.String(v["bidopentime"]))
+				(*data)[i]["expurasingtime"] = TimeHandle(gconv.String(v["expurasingtime"]))
+				(*data)[i]["infoid"] = ME.EncodeArticleId2ByCheck(gconv.String(v["infoid"]))
+				(*data)[i]["industry"] = industryMap[gconv.String(v["industry"])]
+				(*data)[i]["winner_tag"] = winnerMap[gconv.String(v["winner_tag"])]
+			}
+		}
 		total := count
 		count = gconv.Int64(common.If(count > 2000, 2000, count))
 		return count, data, total
@@ -851,3 +865,15 @@ func SearchList(operator Operator) (int64, *[]map[string]interface{}, int64) {
 	}
 
 }
+func TimeHandle(timeStr string) int64 {
+	// 定义一个布局,需要与时间字符串格式相匹配
+	layout := "2006-01-02 15:04:05"
+	// 使用Parse将字符串转换为time.Time类型
+	t, err := time.Parse(layout, timeStr)
+	if err != nil {
+		fmt.Println(err)
+		return 0
+	}
+	// 将time.Time类型转换为时间戳(单位:秒)
+	return t.Unix()
+}