Quellcode durchsuchen

wip:数据源更换

wangkaiyue vor 1 Jahr
Ursprung
Commit
0c342905ef
7 geänderte Dateien mit 76 neuen und 87 gelöschten Zeilen
  1. 6 0
      go.mod
  2. 7 0
      go.sum
  3. 47 80
      internal/service/queryStruct.go
  4. 1 1
      internal/tags/list.go
  5. 1 0
      main.go
  6. 10 2
      manifest/config/config.yaml
  7. 4 4
      resource/template/pc/area_index.html

+ 6 - 0
go.mod

@@ -4,6 +4,7 @@ go 1.19
 
 
 require (
 require (
 	app.yhyue.com/moapp/jybase v0.0.0-20230727083622-4dfc804ea6cf
 	app.yhyue.com/moapp/jybase v0.0.0-20230727083622-4dfc804ea6cf
+	github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.5.2
 	github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.2
 	github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.2
 	github.com/gogf/gf/v2 v2.5.2
 	github.com/gogf/gf/v2 v2.5.2
 )
 )
@@ -11,6 +12,7 @@ require (
 require (
 require (
 	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d // indirect
 	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d // indirect
 	github.com/BurntSushi/toml v1.2.0 // indirect
 	github.com/BurntSushi/toml v1.2.0 // indirect
+	github.com/ClickHouse/clickhouse-go/v2 v2.2.0 // indirect
 	github.com/cespare/xxhash/v2 v2.2.0 // indirect
 	github.com/cespare/xxhash/v2 v2.2.0 // indirect
 	github.com/clbanning/mxj/v2 v2.7.0 // indirect
 	github.com/clbanning/mxj/v2 v2.7.0 // indirect
 	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
 	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
@@ -20,6 +22,7 @@ require (
 	github.com/go-logr/stdr v1.2.2 // indirect
 	github.com/go-logr/stdr v1.2.2 // indirect
 	github.com/go-stack/stack v1.8.0 // indirect
 	github.com/go-stack/stack v1.8.0 // indirect
 	github.com/golang/snappy v0.0.4 // indirect
 	github.com/golang/snappy v0.0.4 // indirect
+	github.com/google/uuid v1.3.0 // indirect
 	github.com/gorilla/websocket v1.5.0 // indirect
 	github.com/gorilla/websocket v1.5.0 // indirect
 	github.com/grokify/html-strip-tags-go v0.0.1 // indirect
 	github.com/grokify/html-strip-tags-go v0.0.1 // indirect
 	github.com/josharian/intern v1.0.0 // indirect
 	github.com/josharian/intern v1.0.0 // indirect
@@ -32,9 +35,12 @@ require (
 	github.com/olekukonko/tablewriter v0.0.5 // indirect
 	github.com/olekukonko/tablewriter v0.0.5 // indirect
 	github.com/olivere/elastic v6.2.37+incompatible // indirect
 	github.com/olivere/elastic v6.2.37+incompatible // indirect
 	github.com/olivere/elastic/v7 v7.0.22 // indirect
 	github.com/olivere/elastic/v7 v7.0.22 // indirect
+	github.com/paulmach/orb v0.7.1 // indirect
+	github.com/pierrec/lz4/v4 v4.1.15 // indirect
 	github.com/pkg/errors v0.9.1 // indirect
 	github.com/pkg/errors v0.9.1 // indirect
 	github.com/redis/go-redis/v9 v9.0.5 // indirect
 	github.com/redis/go-redis/v9 v9.0.5 // indirect
 	github.com/rivo/uniseg v0.4.4 // indirect
 	github.com/rivo/uniseg v0.4.4 // indirect
+	github.com/shopspring/decimal v1.3.1 // indirect
 	github.com/xdg-go/pbkdf2 v1.0.0 // indirect
 	github.com/xdg-go/pbkdf2 v1.0.0 // indirect
 	github.com/xdg-go/scram v1.0.2 // indirect
 	github.com/xdg-go/scram v1.0.2 // indirect
 	github.com/xdg-go/stringprep v1.0.2 // indirect
 	github.com/xdg-go/stringprep v1.0.2 // indirect

+ 7 - 0
go.sum

@@ -47,6 +47,7 @@ github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0
 github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
 github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
 github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI=
 github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI=
+github.com/ClickHouse/clickhouse-go/v2 v2.2.0 h1:dj00TDKY+xwuTJdbpspCSmTLFyWzRJerTHwaBxut1C0=
 github.com/ClickHouse/clickhouse-go/v2 v2.2.0/go.mod h1:8f2XZUi7XoeU+uPIytSi1cvx8fmJxi7vIgqpvYTF1+o=
 github.com/ClickHouse/clickhouse-go/v2 v2.2.0/go.mod h1:8f2XZUi7XoeU+uPIytSi1cvx8fmJxi7vIgqpvYTF1+o=
 github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
 github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
 github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
 github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
@@ -164,6 +165,8 @@ github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
 github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
 github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
 github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
 github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
 github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
 github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
+github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.5.2 h1:QwHoniewNRrQVcRE47yzpVG2l9kfqn+W9VSL91nkaxo=
+github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.5.2/go.mod h1:ihKUdWof54li5HwlW2H9qYqIxoJn0KAs1WvD8Ve9dHk=
 github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.2 h1:JzRIXB5J6vvnJGJmh7RfT8ntjXsn2jYXJf1+Q6oFe+A=
 github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.2 h1:JzRIXB5J6vvnJGJmh7RfT8ntjXsn2jYXJf1+Q6oFe+A=
 github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.2/go.mod h1:vLNtPgfInF5cXlcjLhVZxijIXD30+IiVjN6hP9sjjhY=
 github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.2/go.mod h1:vLNtPgfInF5cXlcjLhVZxijIXD30+IiVjN6hP9sjjhY=
 github.com/gogf/gf/v2 v2.5.2 h1:fACJE7DJH6iTGHGhgiNY1uuZIZtr2IqQkJ52E+wBnt8=
 github.com/gogf/gf/v2 v2.5.2 h1:fACJE7DJH6iTGHGhgiNY1uuZIZtr2IqQkJ52E+wBnt8=
@@ -237,6 +240,7 @@ github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLe
 github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
 github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
 github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
 github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
 github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
 github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
 github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
@@ -364,12 +368,14 @@ github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAl
 github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
 github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
 github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
 github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
 github.com/openzipkin/zipkin-go v0.4.0/go.mod h1:4c3sLeE8xjNqehmF5RpAFLPLJxXscc0R4l6Zg0P1tTQ=
 github.com/openzipkin/zipkin-go v0.4.0/go.mod h1:4c3sLeE8xjNqehmF5RpAFLPLJxXscc0R4l6Zg0P1tTQ=
+github.com/paulmach/orb v0.7.1 h1:Zha++Z5OX/l168sqHK3k4z18LDvr+YAO/VjK0ReQ9rU=
 github.com/paulmach/orb v0.7.1/go.mod h1:FWRlTgl88VI1RBx/MkrwWDRhQ96ctqMCh8boXhmqB/A=
 github.com/paulmach/orb v0.7.1/go.mod h1:FWRlTgl88VI1RBx/MkrwWDRhQ96ctqMCh8boXhmqB/A=
 github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY=
 github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY=
 github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI=
 github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI=
 github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
 github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
 github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
 github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
+github.com/pierrec/lz4/v4 v4.1.15 h1:MO0/ucJhngq7299dKLwIMtgTfbkoSPF6AoMYDd8Q4q0=
 github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
 github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -410,6 +416,7 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
 github.com/shirou/gopsutil v2.19.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
 github.com/shirou/gopsutil v2.19.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
 github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
 github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
 github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
 github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
+github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
 github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
 github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
 github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
 github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
 github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
 github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=

+ 47 - 80
internal/service/queryStruct.go

@@ -2,28 +2,22 @@ package service
 
 
 import (
 import (
 	"app.yhyue.com/moapp/jybase/encrypt"
 	"app.yhyue.com/moapp/jybase/encrypt"
-	elastic "app.yhyue.com/moapp/jybase/es"
 	"context"
 	"context"
 	"fmt"
 	"fmt"
 	"github.com/gogf/gf/v2/container/gvar"
 	"github.com/gogf/gf/v2/container/gvar"
 	"github.com/gogf/gf/v2/frame/g"
 	"github.com/gogf/gf/v2/frame/g"
 	"github.com/gogf/gf/v2/util/gconv"
 	"github.com/gogf/gf/v2/util/gconv"
 	"jyseo/utility"
 	"jyseo/utility"
-	"strings"
-	"time"
 )
 )
 
 
 type (
 type (
 	SeoBiddingQuery struct {
 	SeoBiddingQuery struct {
+		keys     string
 		area     string
 		area     string
 		city     string
 		city     string
 		district string
 		district string
 		topType  string
 		topType  string
 		subType  string
 		subType  string
-		industry string
-		keys     string
-		isBuyer  bool
-		isWinner bool
 	}
 	}
 	InfoList struct {
 	InfoList struct {
 		Title       string
 		Title       string
@@ -31,25 +25,19 @@ type (
 		Area        string
 		Area        string
 		Industry    string
 		Industry    string
 		Subtype     string
 		Subtype     string
-		FileExists  bool
-		Site        string //来自用户发版
 		Price       string
 		Price       string
 		PublishTime int64
 		PublishTime int64
-		BuyerClass  string //采购单位类型
-		LegalPerson string //企业法人
-		State       string //中标企业状态
-		Address     string //地址
 	}
 	}
 
 
 	ListResp struct {
 	ListResp struct {
-		Total int64
+		Total int
 		List  []*InfoList
 		List  []*InfoList
 	}
 	}
 )
 )
 
 
 var (
 var (
-	SettingPageSize     = g.Cfg().MustGet(context.Background(), "listPageSetting.pageSize").Int64()
-	SettingListTotal    = g.Cfg().MustGet(context.Background(), "listPageSetting.maxTotal").Int64()
+	SettingPageSize     = g.Cfg().MustGet(context.Background(), "listPageSetting.pageSize").Int()
+	SettingMaxBidSize   = g.Cfg().MustGet(context.Background(), "listPageSetting.maxBidSize").Int()
 	SettingBidCacheTime = g.Cfg().MustGet(context.Background(), "listPageSetting.cacheTime").Int64()
 	SettingBidCacheTime = g.Cfg().MustGet(context.Background(), "listPageSetting.cacheTime").Int64()
 	topTypeMap          = map[string]string{
 	topTypeMap          = map[string]string{
 		"招标预告":   "预告",
 		"招标预告":   "预告",
@@ -59,14 +47,6 @@ var (
 	}
 	}
 )
 )
 
 
-const (
-	field       = `"_id","title","publishtime","toptype","subtype","area","s_subscopeclass","buyerclass","budget","bidamount","isValidFile","spidercode","site"`
-	querySql    = `{"query":{"bool":{"filter":[%s],"should": [%s],"minimum_should_match": %d}},"_source":[%s],"sort":[{"publishtime":"desc"}],"size":%d}`
-	keywords    = `{"multi_match": {"query": "%s","type": "phrase", "fields": ["title","purchasing"]}}`
-	filterBool  = `{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}}`
-	filterRange = `{"range":{"publishtime":{"gte":%d,"lte":%d}}}`
-)
-
 func NewBiddingQuery() *SeoBiddingQuery {
 func NewBiddingQuery() *SeoBiddingQuery {
 	return &SeoBiddingQuery{}
 	return &SeoBiddingQuery{}
 }
 }
@@ -94,48 +74,39 @@ func (query *SeoBiddingQuery) EquipSType(sTypeNode *STypeNode) *SeoBiddingQuery
 	return query
 	return query
 }
 }
 
 
-func (query *SeoBiddingQuery) getSearchSql(total int64) string {
-	var filterMusts, filterShould, should, filter []string
-	now := time.Now()
-	filter = append(filter, fmt.Sprintf(filterRange, now.AddDate(-5, 0, 0).Unix(), now.Unix())) //发版前  改成最近一年
-	// 地区
+func (query *SeoBiddingQuery) getResult(ctx context.Context, total int) (int, []map[string]interface{}) {
+	var sql string
+	var values []interface{}
+
 	if query.district != "" {
 	if query.district != "" {
-		filterShould = append(filterShould, fmt.Sprintf(`{"term":{"district":"%s"}}`, query.district))
+		sql += " AND district=? "
+		values = append(values, query.district)
 	} else if query.city != "" {
 	} else if query.city != "" {
-		filterShould = append(filterShould, fmt.Sprintf(`{"term":{"city":"%s"}}`, query.city))
+		sql += " AND city=? "
+		values = append(values, query.city)
 	} else if query.area != "" {
 	} else if query.area != "" {
-		filterShould = append(filterShould, fmt.Sprintf(`{"term":{"area":"%s"}}`, query.area))
+		sql += " AND area=? "
+		values = append(values, query.area)
 	}
 	}
 
 
 	if query.topType != "" {
 	if query.topType != "" {
 		if val, _ := topTypeMap[query.topType]; val != "" {
 		if val, _ := topTypeMap[query.topType]; val != "" {
-			filterMusts = append(filterMusts, fmt.Sprintf(`{"term":{"toptype":"%s"}}`, val))
+			sql += " AND toptype=? "
+			values = append(values, val)
 		} else {
 		} else {
-			filterMusts = append(filterMusts, fmt.Sprintf(`{"term":{"toptype":"%s"}}`, query.topType))
+			sql += " AND toptype=? "
+			values = append(values, query.topType)
 		}
 		}
 	} else if query.subType != "" {
 	} else if query.subType != "" {
-		filterMusts = append(filterMusts, fmt.Sprintf(`{"term":{"subtype":"%s"}}`, query.subType))
-	}
-	//行业
-	if query.industry != "" {
-		filterMusts = append(filterMusts, fmt.Sprintf(`{"terms":{"s_subscopeclass":["%s"]}}`, query.industry))
-	}
-	if len(filterMusts) > 0 || len(filterShould) > 0 {
-		shouldMatch := 0
-		if len(filterShould) > 0 {
-			shouldMatch = 1
-		}
-		filter = append(filter, fmt.Sprintf(filterBool, strings.Join(filterMusts, ","), strings.Join(filterShould, ","), shouldMatch))
+		sql += " AND subtype=? "
+		values = append(values, query.subType)
 	}
 	}
-	//标的物
-	if query.keys != "" {
-		should = append(should, fmt.Sprintf(keywords, query.keys))
+	values = append(values, total)
+	res, err := g.DB("clickHouse").Query(ctx, "SELECT * FROM bidMsg WHERE 1=1 "+sql+" ORDER BY publish_time DESC limit 0,?", values...)
+	if err != nil {
+		return -1, nil
 	}
 	}
-	queryShouldMatch := 0
-	if len(should) > 0 {
-		queryShouldMatch = 1
-	}
-	return fmt.Sprintf(querySql, strings.Join(filter, ","), strings.Join(should, ","), queryShouldMatch, field, total)
+	return res.Len(), res.List()
 }
 }
 
 
 func (query *SeoBiddingQuery) dataFormat(data []map[string]interface{}) (bList []*InfoList) {
 func (query *SeoBiddingQuery) dataFormat(data []map[string]interface{}) (bList []*InfoList) {
@@ -143,23 +114,19 @@ func (query *SeoBiddingQuery) dataFormat(data []map[string]interface{}) (bList [
 		for _, v := range data {
 		for _, v := range data {
 			bl := &InfoList{
 			bl := &InfoList{
 				Title:   gconv.String(v["title"]),
 				Title:   gconv.String(v["title"]),
-				Url:     fmt.Sprintf("/nologin/content/%s.html", encrypt.CommonEncodeArticle("content", gconv.String(v["_id"]))),
+				Url:     fmt.Sprintf("/nologin/content/%s.html", encrypt.CommonEncodeArticle("content", gconv.String(v["bid_id"]))),
 				Area:    gconv.String(v["area"]),
 				Area:    gconv.String(v["area"]),
 				Subtype: gconv.String(v["subtype"]),
 				Subtype: gconv.String(v["subtype"]),
 			}
 			}
-			if gconv.String(v["site"]) == "剑鱼信息发布平台" {
-				bl.Site = "用户发布"
-			}
-			bl.PublishTime = gconv.Int64(v["publishtime"])
-			if subs := gconv.String(v["s_subscopeclass"]); subs != "" {
-				bl.Industry = strings.Split(strings.Split(subs, ",")[0], "_")[0]
-			}
-			if isValidFile, _ := v["isValidFile"].(bool); isValidFile {
-				bl.FileExists = true
+			bl.PublishTime = gconv.Int64(v["publish_time"])
+
+			if industry := gconv.String(v["industry"]); industry != "" {
+				bl.Industry = industry
 			}
 			}
-			if v["budget"] != nil {
+
+			if budget := gconv.Float64(v["budget"]); budget > 0 {
 				bl.Price = utility.ConversionMoney(v["budget"])
 				bl.Price = utility.ConversionMoney(v["budget"])
-			} else if v["bidamount"] != nil {
+			} else if bidamount := gconv.Float64(v["bidamount"]); bidamount > 0 {
 				bl.Price = utility.ConversionMoney(v["bidamount"])
 				bl.Price = utility.ConversionMoney(v["bidamount"])
 			}
 			}
 			bList = append(bList, bl)
 			bList = append(bList, bl)
@@ -170,7 +137,7 @@ func (query *SeoBiddingQuery) dataFormat(data []map[string]interface{}) (bList [
 
 
 // getBidListCacheKey 获取列表缓存
 // getBidListCacheKey 获取列表缓存
 func (query *SeoBiddingQuery) getBidListCacheKey(pageNum int) string {
 func (query *SeoBiddingQuery) getBidListCacheKey(pageNum int) string {
-	return fmt.Sprintf("JySeoListCache_%d_%d_%s_%s_%s_%s", SettingPageSize, pageNum, query.area, query.city, query.topType, query.subType)
+	return fmt.Sprintf("JySeoListCache_%d_%d_%s_%s_%s_%s_%s", SettingPageSize, pageNum, query.keys, query.area, query.city, query.topType, query.subType)
 }
 }
 
 
 // GetBidListList 列表页查询
 // GetBidListList 列表页查询
@@ -186,20 +153,19 @@ func (query *SeoBiddingQuery) GetBidListList(ctx context.Context, pageNum int) (
 			return
 			return
 		}
 		}
 		defer JySeoQueryListLimit.Reset()
 		defer JySeoQueryListLimit.Reset()
-		// 查询全量
-		sql := query.getSearchSql(SettingListTotal)
+
 		//g.Log().Info(ctx, sql)
 		//g.Log().Info(ctx, sql)
-		count, data := elastic.GetWithCount("bidding", "bidding", "", sql)
-		if count > SettingListTotal {
-			count = SettingListTotal
+		count, data := query.getResult(ctx, SettingMaxBidSize)
+		if count > SettingMaxBidSize {
+			count = SettingMaxBidSize
 		}
 		}
-		if data != nil && len(*data) > 0 && gconv.Int(count) == len(*data) {
-			totalPage, formatData := count/SettingPageSize, query.dataFormat(*data)
+		if data != nil && len(data) > 0 && gconv.Int(count) == len(data) {
+			totalPage, formatData := count/SettingPageSize, query.dataFormat(data)
 			if count%SettingPageSize != 0 {
 			if count%SettingPageSize != 0 {
 				totalPage++
 				totalPage++
 			}
 			}
 			for i := 1; i <= gconv.Int(totalPage); i++ {
 			for i := 1; i <= gconv.Int(totalPage); i++ {
-				start, end := gconv.Int64(i-1)*SettingPageSize, gconv.Int64(i)*SettingPageSize
+				start, end := (i-1)*SettingPageSize, (i)*SettingPageSize
 				if end > count {
 				if end > count {
 					end = count
 					end = count
 				}
 				}
@@ -222,12 +188,12 @@ func (query *SeoBiddingQuery) GetBidListList(ctx context.Context, pageNum int) (
 }
 }
 
 
 // getTabDataCacheKey 获取列表缓存
 // getTabDataCacheKey 获取列表缓存
-func (query *SeoBiddingQuery) getTabDataCacheKey(total int64) string {
+func (query *SeoBiddingQuery) getTabDataCacheKey(total int) string {
 	return fmt.Sprintf("JySeoTabData_%d_%s_%s_%s_%s", total, query.area, query.city, query.topType, query.subType)
 	return fmt.Sprintf("JySeoTabData_%d_%s_%s_%s_%s", total, query.area, query.city, query.topType, query.subType)
 }
 }
 
 
 // GetTabData 面包屑数据
 // GetTabData 面包屑数据
-func (query *SeoBiddingQuery) GetTabData(ctx context.Context, total int64) (res []*InfoList, err error) {
+func (query *SeoBiddingQuery) GetTabData(ctx context.Context, total int) (res []*InfoList, err error) {
 	var vars *gvar.Var
 	var vars *gvar.Var
 	cacheKey := query.getTabDataCacheKey(total)
 	cacheKey := query.getTabDataCacheKey(total)
 	vars, err = g.Redis().Get(ctx, cacheKey)
 	vars, err = g.Redis().Get(ctx, cacheKey)
@@ -238,9 +204,10 @@ func (query *SeoBiddingQuery) GetTabData(ctx context.Context, total int64) (res
 			return
 			return
 		}
 		}
 		defer JySeoQueryTabLimit.Reset()
 		defer JySeoQueryTabLimit.Reset()
-		data := elastic.Get("bidding", "bidding", query.getSearchSql(total))
-		if data != nil && len(*data) > 0 {
-			res = query.dataFormat(*data)
+
+		_, data := query.getResult(ctx, total)
+		if data != nil && len(data) > 0 {
+			res = query.dataFormat(data)
 		}
 		}
 		if err := g.Redis().SetEX(ctx, cacheKey, res, SettingBidCacheTime); err != nil {
 		if err := g.Redis().SetEX(ctx, cacheKey, res, SettingBidCacheTime); err != nil {
 			g.Log().Errorf(ctx, "GetTabData 存储redis err:%v", err)
 			g.Log().Errorf(ctx, "GetTabData 存储redis err:%v", err)

+ 1 - 1
internal/tags/list.go

@@ -7,7 +7,7 @@ import (
 )
 )
 
 
 // GetMiniTab 查询Tab数据
 // GetMiniTab 查询Tab数据
-func GetMiniTab(areaCode, sTypeCode string, size int64) []*service.InfoList {
+func GetMiniTab(areaCode, sTypeCode string, size int) []*service.InfoList {
 	ctx := context.Background()
 	ctx := context.Background()
 	query := service.NewBiddingQuery()
 	query := service.NewBiddingQuery()
 	if areaCode != "" {
 	if areaCode != "" {

+ 1 - 0
main.go

@@ -1,6 +1,7 @@
 package main
 package main
 
 
 import (
 import (
+	_ "github.com/gogf/gf/contrib/drivers/clickhouse/v2"
 	_ "github.com/gogf/gf/contrib/nosql/redis/v2"
 	_ "github.com/gogf/gf/contrib/nosql/redis/v2"
 	"github.com/gogf/gf/v2/os/gctx"
 	"github.com/gogf/gf/v2/os/gctx"
 	"jyseo/internal/cmd"
 	"jyseo/internal/cmd"

+ 10 - 2
manifest/config/config.yaml

@@ -21,6 +21,14 @@ elasticsearch:
   userName: ''
   userName: ''
   password: ''
   password: ''
 
 
+database:
+  default:
+    link: "mysql:root:=PDT49#80Z!RVv52_z@tcp(192.168.3.14:4000)/seo_words"
+    debug: true
+  clickHouse:
+    link: "clickhouse:jianyu_appl:Cli3#fkh4ouSe@tcp(cc-2zelp3xmkmsrtjhgp.public.clickhouse.ads.aliyuncs.com:9000)/jyseo?dial_timeout=2000ms&max_execution_time=60"
+    debug: true
+
 mongodb:
 mongodb:
   address: "192.168.3.206:27080"
   address: "192.168.3.206:27080"
   size: 5
   size: 5
@@ -35,8 +43,8 @@ redis:
     address: 127.0.0.1:6379
     address: 127.0.0.1:6379
 
 
 listPageSetting:
 listPageSetting:
-  pageSize: 5   #列表每页数量
-  maxTotal: 50  #列表查询最大数量
+  pageSize: 50   #列表每页数量
+  maxBidSize: 5000  #列表查询最大数量
   cacheTime: 43200 #60*60*12 一天更新两次
   cacheTime: 43200 #60*60*12 一天更新两次
 
 
 queryLimit:
 queryLimit:

+ 4 - 4
resource/template/pc/area_index.html

@@ -76,10 +76,10 @@
                 <span class="section-card-line no-select"><i class="line-mark">/</i></span>
                 <span class="section-card-line no-select"><i class="line-mark">/</i></span>
             </header>
             </header>
             <main class="section-card-content clearfix">
             <main class="section-card-content clearfix">
-              {{include "pc/components/seo-card.html" (CardFormat (concat .areaNode.Name "招标预告") (concat "/list/" .areaType "/" .areaNode.Code "_02/") (GetMiniTab .areaNode.Code "ZBYG" 8))}}
-              {{include "pc/components/seo-card.html" (CardFormat (concat .areaNode.Name "招标公告") (concat "/list/" .areaType "/" .areaNode.Code "_03/") (GetMiniTab .areaNode.Code "ZBGG" 8))}}
-              {{include "pc/components/seo-card.html" (CardFormat (concat .areaNode.Name "招标信用") (concat "/list/" .areaType "/" .areaNode.Code "_05/") (GetMiniTab .areaNode.Code "ZBXYXX" 8))}}
-              {{include "pc/components/seo-card.html" (CardFormat (concat .areaNode.Name "招标结果") (concat "/list/" .areaType "/" .areaNode.Code "_04/") (GetMiniTab .areaNode.Code "ZBJG" 8))}}
+              {{include "pc/components/seo-card.html" (CardFormat (concat .areaNode.Name "招标预告") (concat "/list/" .areaType "/" .areaNode.Code "_01/") (GetMiniTab .areaNode.Code "ZBYG" 8))}}
+              {{include "pc/components/seo-card.html" (CardFormat (concat .areaNode.Name "招标公告") (concat "/list/" .areaType "/" .areaNode.Code "_02/") (GetMiniTab .areaNode.Code "ZBGG" 8))}}
+              {{include "pc/components/seo-card.html" (CardFormat (concat .areaNode.Name "招标信用") (concat "/list/" .areaType "/" .areaNode.Code "_04/") (GetMiniTab .areaNode.Code "ZBXYXX" 8))}}
+              {{include "pc/components/seo-card.html" (CardFormat (concat .areaNode.Name "招标结果") (concat "/list/" .areaType "/" .areaNode.Code "_03/") (GetMiniTab .areaNode.Code "ZBJG" 8))}}
             </main>
             </main>
           </section>
           </section>
         </section>
         </section>