瀏覽代碼

排序处理

WH01243 7 月之前
父節點
當前提交
9f1d87bad6

+ 1 - 1
jyBXCore/api/bxcore.api

@@ -245,7 +245,7 @@ type (
 		PurchaseTime string `json:"purchaseTime,optional"`
 		PurchaseTime string `json:"purchaseTime,optional"`
 		WinnerTag    string `json:"winnerTag,optional"`
 		WinnerTag    string `json:"winnerTag,optional"`
 		PositionId   int64  `header:"positionId,optional"` //职位id
 		PositionId   int64  `header:"positionId,optional"` //职位id
-		Order        string `json:"order,optional"`
+		Order        int64  `json:"order,optional"`
 	}
 	}
 	mobileHotWordReq {
 	mobileHotWordReq {
 		AppId   string `header:"appId"`
 		AppId   string `header:"appId"`

+ 1 - 1
jyBXCore/api/internal/types/types.go

@@ -245,7 +245,7 @@ type OperatorSearchReq struct {
 	PurchaseTime string `json:"purchaseTime,optional"`
 	PurchaseTime string `json:"purchaseTime,optional"`
 	WinnerTag    string `json:"winnerTag,optional"`
 	WinnerTag    string `json:"winnerTag,optional"`
 	PositionId   int64  `header:"positionId,optional"` //职位id
 	PositionId   int64  `header:"positionId,optional"` //职位id
-	Order        string `json:"order,optional"`
+	Order        int64  `json:"order,optional"`
 }
 }
 
 
 type MobileHotWordReq struct {
 type MobileHotWordReq struct {

+ 1 - 1
jyBXCore/rpc/bxcore.proto

@@ -753,7 +753,7 @@ message OperatorSearchReq{
   string purchaseTime=21;
   string purchaseTime=21;
   string winnerTag=7;
   string winnerTag=7;
   int64 positionId=15;
   int64 positionId=15;
-  string  order =22;
+  int64  order =22;
 }
 }
 message  OperatorSearchResp{
 message  OperatorSearchResp{
   int64 error_code = 1;
   int64 error_code = 1;

+ 31 - 14
jyBXCore/rpc/service/operator.go

@@ -498,7 +498,7 @@ type Operator struct {
 	Industry     string
 	Industry     string
 	WinnerTag    string
 	WinnerTag    string
 	PositionId   int64
 	PositionId   int64
-	Order        string
+	Order        int64
 }
 }
 
 
 func SearchList(operator Operator) (int64, *[]map[string]interface{}) {
 func SearchList(operator Operator) (int64, *[]map[string]interface{}) {
@@ -510,7 +510,7 @@ func SearchList(operator Operator) (int64, *[]map[string]interface{}) {
 		start = 0
 		start = 0
 	}
 	}
 	var query = `{"query":{"bool":{"must":[%s],"filter":[%s],"minimum_should_match":1,
 	var query = `{"query":{"bool":{"must":[%s],"filter":[%s],"minimum_should_match":1,
-	"should":[{"exists":{"field":"bidamount"}},{"bool":{"should":[{"exists":{"field":"budget"}},{"bool":{"must_not":[{"exists":{"field":"budget"}}]}}],"must_not":[{"exists":{"field":"bidamount"}}]}}]}},"from":"%d","size":"%d","sort":[{"publishtime":{"order":"%s"}}%s]
+	"should":[{"exists":{"field":"bidamount"}},{"bool":{"should":[{"exists":{"field":"budget"}},{"bool":{"must_not":[{"exists":{"field":"budget"}}]}}],"must_not":[{"exists":{"field":"bidamount"}}]}}]}},"from":"%d","size":"%d","sort":[%s]
 	}`
 	}`
 	shouldStr := `{"bool":{"should":[%s]}}`
 	shouldStr := `{"bool":{"should":[%s]}}`
 	mustArr := []string{}
 	mustArr := []string{}
@@ -780,15 +780,35 @@ func SearchList(operator Operator) (int64, *[]map[string]interface{}) {
 			}
 			}
 		}*/
 		}*/
 	//es  sql拼接
 	//es  sql拼接
-	if operator.Order == "" {
-		operator.Order = "desc"
-	}
 	queryStr := ""
 	queryStr := ""
+	orderStr := ""
+	mysqlOrderStr := ""
 	if operator.Tag == 1 {
 	if operator.Tag == 1 {
-		queryStr = fmt.Sprintf(query, strings.Join(mustArr, ","), strings.Join(filterArr, ","), start, operator.PageSize, operator.Order, `,{"expurasingtime":{"order":"asc"}}`)
+		if operator.Order == 0 {
+			orderStr = `{"publishtime":{"order":"desc"}}`
+			mysqlOrderStr = ` order by   publishtime desc`
+		} else {
+			orderStr = `{"publishtime":{"order":"asc"}}`
+			mysqlOrderStr = ` order by   publishtime asc`
+		}
 	} else if operator.Tag == 2 {
 	} else if operator.Tag == 2 {
-		queryStr = fmt.Sprintf(query, strings.Join(mustArr, ","), strings.Join(filterArr, ","), start, operator.PageSize, operator.Order, `,{"bidopentime":{"order":"asc"}}`)
+		if operator.Order == 0 {
+			orderStr = `{"publishtime":{"order":"desc"}}`
+			mysqlOrderStr = ` order by   publishtime desc`
+		} else {
+			orderStr = `{"expurasingtime":{"order":"asc"}}`
+			mysqlOrderStr = ` order by   expurasingtime asc`
+		}
+	} else {
+		if operator.Order == 0 {
+			orderStr = `{"publishtime":{"order":"desc"}}`
+			mysqlOrderStr = ` order by   publishtime desc`
+		} else {
+			orderStr = `{"bidopentime":{"order":"asc"}}`
+			mysqlOrderStr = ` order by   bidopentime asc`
+		}
 	}
 	}
+	queryStr = fmt.Sprintf(query, strings.Join(mustArr, ","), strings.Join(filterArr, ","), start, operator.PageSize, orderStr)
 	fmt.Println(queryStr)
 	fmt.Println(queryStr)
 	start1 := time.Now().Unix()
 	start1 := time.Now().Unix()
 	fmt.Println(start1)
 	fmt.Println(start1)
@@ -805,13 +825,10 @@ func SearchList(operator Operator) (int64, *[]map[string]interface{}) {
 			id := gconv.String(v["id"])
 			id := gconv.String(v["id"])
 			idArr = append(idArr, id)
 			idArr = append(idArr, id)
 		}
 		}
-		if operator.Order == "desc" {
-			data = IC.BiMysql.SelectBySql("select  * from customer_data where  FIND_IN_SET (id,?) ORDER BY  publishtime  desc  ",
-				strings.Join(idArr, ","))
-		} else {
-			data = IC.BiMysql.SelectBySql("select  * from customer_data where  FIND_IN_SET (id,?) ORDER BY  publishtime  asc ",
-				strings.Join(idArr, ","))
-		}
+		sqlStr := fmt.Sprintf(`select  * from customer_data where  FIND_IN_SET (id,?)  %s   `, mysqlOrderStr)
+		fmt.Println(sqlStr)
+		data = IC.BiMysql.SelectBySql(sqlStr,
+			strings.Join(idArr, ","))
 		return count, data
 		return count, data
 	} else {
 	} else {
 		return count, &[]map[string]interface{}{}
 		return count, &[]map[string]interface{}{}

+ 4 - 4
jyBXCore/rpc/type/bxcore/bxcore.pb.go

@@ -6921,7 +6921,7 @@ type OperatorSearchReq struct {
 	PurchaseTime string `protobuf:"bytes,21,opt,name=purchaseTime,proto3" json:"purchaseTime,omitempty"`
 	PurchaseTime string `protobuf:"bytes,21,opt,name=purchaseTime,proto3" json:"purchaseTime,omitempty"`
 	WinnerTag    string `protobuf:"bytes,7,opt,name=winnerTag,proto3" json:"winnerTag,omitempty"`
 	WinnerTag    string `protobuf:"bytes,7,opt,name=winnerTag,proto3" json:"winnerTag,omitempty"`
 	PositionId   int64  `protobuf:"varint,15,opt,name=positionId,proto3" json:"positionId,omitempty"`
 	PositionId   int64  `protobuf:"varint,15,opt,name=positionId,proto3" json:"positionId,omitempty"`
-	Order        string `protobuf:"bytes,22,opt,name=order,proto3" json:"order,omitempty"`
+	Order        int64  `protobuf:"varint,22,opt,name=order,proto3" json:"order,omitempty"`
 }
 }
 
 
 func (x *OperatorSearchReq) Reset() {
 func (x *OperatorSearchReq) Reset() {
@@ -7096,11 +7096,11 @@ func (x *OperatorSearchReq) GetPositionId() int64 {
 	return 0
 	return 0
 }
 }
 
 
-func (x *OperatorSearchReq) GetOrder() string {
+func (x *OperatorSearchReq) GetOrder() int64 {
 	if x != nil {
 	if x != nil {
 		return x.Order
 		return x.Order
 	}
 	}
-	return ""
+	return 0
 }
 }
 
 
 type OperatorSearchResp struct {
 type OperatorSearchResp struct {
@@ -8311,7 +8311,7 @@ var file_bxcore_proto_rawDesc = []byte{
 	0x28, 0x09, 0x52, 0x09, 0x77, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x54, 0x61, 0x67, 0x12, 0x1e, 0x0a,
 	0x28, 0x09, 0x52, 0x09, 0x77, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x54, 0x61, 0x67, 0x12, 0x1e, 0x0a,
 	0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28,
 	0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28,
 	0x03, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a,
 	0x03, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a,
-	0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x18, 0x16, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x72,
+	0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x18, 0x16, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x6f, 0x72,
 	0x64, 0x65, 0x72, 0x22, 0x64, 0x0a, 0x12, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x53,
 	0x64, 0x65, 0x72, 0x22, 0x64, 0x0a, 0x12, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x53,
 	0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72,
 	0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72,
 	0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65,
 	0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65,