feat 初始化
This commit is contained in:
8
PORTS.md
8
PORTS.md
@@ -13,13 +13,11 @@ user 18800-18899
|
|||||||
---
|
---
|
||||||
post 18900-18999
|
post 18900-18999
|
||||||
---
|
---
|
||||||
announcement 19000-19099
|
notice 19000-19099
|
||||||
---
|
|
||||||
court 19100-19199
|
|
||||||
---
|
---
|
||||||
admin 19200-19299
|
admin 19200-19299
|
||||||
---
|
---
|
||||||
court-physical 19300-19399
|
timer 19400-19499
|
||||||
---
|
---
|
||||||
court-timer 19400-19499
|
qgdzs 1 // TODO
|
||||||
---
|
---
|
||||||
@@ -77,14 +77,3 @@ type AddressConfig struct {
|
|||||||
Address string `yaml:"address"`
|
Address string `yaml:"address"`
|
||||||
Port int32 `yaml:"port"`
|
Port int32 `yaml:"port"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CosConfig struct {
|
|
||||||
SecretID string `yaml:"secretID"`
|
|
||||||
SecretKey string `yaml:"secretKey"`
|
|
||||||
BucketURL string `yaml:"bucketURL"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SensitiveWordConfig struct {
|
|
||||||
SourceType string `yaml:"sourceType"`
|
|
||||||
Source string `yaml:"sourceURL"`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,26 +19,22 @@ var (
|
|||||||
KeyDiscoverServiceNameGateway = "01-gateway" // 网关服
|
KeyDiscoverServiceNameGateway = "01-gateway" // 网关服
|
||||||
KeyDiscoverServiceNameScene = "02-scene" // 场景服
|
KeyDiscoverServiceNameScene = "02-scene" // 场景服
|
||||||
KeyDiscoverServiceNameUser = "03-user" // 用户中心
|
KeyDiscoverServiceNameUser = "03-user" // 用户中心
|
||||||
KeyDiscoverServiceNameThirdParty = "04-third-party" // 三方登录服
|
KeyDiscoverServiceNameThirdParty = "04-third-party" // 三方服
|
||||||
KeyDiscoverServiceNamePost = "05-post" // 推送服
|
KeyDiscoverServiceNamePost = "05-post" // 推送服
|
||||||
KeyDiscoverServiceNameAnnouncement = "06-announcement" // 公告服
|
KeyDiscoverServiceNameNotice = "06-notice" // 公告服
|
||||||
KeyDiscoverServiceNameCourt = "07-court" // 球场服
|
KeyDiscoverServiceNameAdmin = "07-admin" // 后台服
|
||||||
KeyDiscoverServiceNameAdmin = "08-admin" // 后台服
|
KeyDiscoverServiceNameTimer = "08-timer" // 定时任务服(只起一个)
|
||||||
KeyDiscoverServiceNameCourtPhysical = "09-court-physical" // 线下球场服
|
KeyDiscoverServiceNameQgdzs = "09-qgdzs" // 奇怪的知识
|
||||||
KeyDiscoverServiceNameTimer = "10-timer" // 定时任务服(只起一个)
|
|
||||||
KeyDiscoverServiceNameQgdzs = "11-qgdzs" // 奇怪的知识
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
KeyDiscoverGateway = KeyDiscoverService + "/" + KeyDiscoverServiceNameGateway // 网关服
|
KeyDiscoverGateway = KeyDiscoverService + "/" + KeyDiscoverServiceNameGateway // 网关服
|
||||||
KeyDiscoverScene = KeyDiscoverService + "/" + KeyDiscoverServiceNameScene // 场景服
|
KeyDiscoverScene = KeyDiscoverService + "/" + KeyDiscoverServiceNameScene // 场景服
|
||||||
KeyDiscoverUser = KeyDiscoverService + "/" + KeyDiscoverServiceNameUser // 用户中心
|
KeyDiscoverUser = KeyDiscoverService + "/" + KeyDiscoverServiceNameUser // 用户中心
|
||||||
KeyDiscoverThirdParty = KeyDiscoverService + "/" + KeyDiscoverServiceNameThirdParty // 三方登录服
|
KeyDiscoverThirdParty = KeyDiscoverService + "/" + KeyDiscoverServiceNameThirdParty // 三方服
|
||||||
KeyDiscoverPost = KeyDiscoverService + "/" + KeyDiscoverServiceNamePost // 推送服
|
KeyDiscoverPost = KeyDiscoverService + "/" + KeyDiscoverServiceNamePost // 推送服
|
||||||
KeyDiscoverAnnouncement = KeyDiscoverService + "/" + KeyDiscoverServiceNameAnnouncement // 公告服
|
KeyDiscoverNotice = KeyDiscoverService + "/" + KeyDiscoverServiceNameNotice // 公告服
|
||||||
KeyDiscoverCourt = KeyDiscoverService + "/" + KeyDiscoverServiceNameCourt // 球场服
|
|
||||||
KeyDiscoverAdmin = KeyDiscoverService + "/" + KeyDiscoverServiceNameAdmin // 后台服
|
KeyDiscoverAdmin = KeyDiscoverService + "/" + KeyDiscoverServiceNameAdmin // 后台服
|
||||||
KeyDiscoverCourtPhysical = KeyDiscoverService + "/" + KeyDiscoverServiceNameCourtPhysical // 线下球场服
|
|
||||||
KeyDiscoverTimer = KeyDiscoverService + "/" + KeyDiscoverServiceNameTimer // 定时任务服(只起一个)
|
KeyDiscoverTimer = KeyDiscoverService + "/" + KeyDiscoverServiceNameTimer // 定时任务服(只起一个)
|
||||||
KeyDiscoverQgdzs = KeyDiscoverService + "/" + KeyDiscoverServiceNameQgdzs // 奇怪的知识
|
KeyDiscoverQgdzs = KeyDiscoverService + "/" + KeyDiscoverServiceNameQgdzs // 奇怪的知识
|
||||||
)
|
)
|
||||||
|
|||||||
5
go.mod
5
go.mod
@@ -3,6 +3,7 @@ module git.hlsq.asia/alex/service-common
|
|||||||
go 1.24.0
|
go 1.24.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
git.hlsq.asia/alex/proto v0.0.0-20261029023453-16bb20cbcd2e
|
||||||
github.com/IBM/sarama v1.46.3
|
github.com/IBM/sarama v1.46.3
|
||||||
github.com/gin-gonic/gin v1.11.0
|
github.com/gin-gonic/gin v1.11.0
|
||||||
github.com/gobwas/ws v1.4.0
|
github.com/gobwas/ws v1.4.0
|
||||||
@@ -40,7 +41,6 @@ require (
|
|||||||
github.com/bytedance/sonic/loader v0.3.0 // indirect
|
github.com/bytedance/sonic/loader v0.3.0 // indirect
|
||||||
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/clbanning/mxj v1.8.4 // indirect
|
|
||||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||||
github.com/coreos/go-semver v0.3.1 // indirect
|
github.com/coreos/go-semver v0.3.1 // indirect
|
||||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||||
@@ -66,7 +66,6 @@ require (
|
|||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/protobuf v1.5.4 // indirect
|
github.com/golang/protobuf v1.5.4 // indirect
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/google/go-querystring v1.0.0 // indirect
|
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
|
||||||
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
||||||
@@ -82,11 +81,9 @@ require (
|
|||||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.4.3 // indirect
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/montanaflynn/stats v0.7.1 // indirect
|
github.com/montanaflynn/stats v0.7.1 // indirect
|
||||||
github.com/mozillazg/go-httpheader v0.2.1 // indirect
|
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/panjf2000/ants/v2 v2.11.3 // indirect
|
github.com/panjf2000/ants/v2 v2.11.3 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||||
|
|||||||
20
go.sum
20
go.sum
@@ -1,7 +1,7 @@
|
|||||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||||
git.hlsq.asia/alex/proto v0.1.7-0.20261019060756-d28143475e8e h1:8sQI9i9wKOc8a0HvsXvn0FWynvXeodFSd8Fw8LI3PL4=
|
git.hlsq.asia/alex/proto v0.0.0-20261029023453-16bb20cbcd2e h1:MCBfc5To7T6EuAWGJpr0U40BzJcnw9udJHOUWVr/qAE=
|
||||||
git.hlsq.asia/alex/proto v0.1.7-0.20261019060756-d28143475e8e/go.mod h1:O77R475sJfEtjQQnhf859EpecejAkpRqdz7K6zDiYAk=
|
git.hlsq.asia/alex/proto v0.0.0-20261029023453-16bb20cbcd2e/go.mod h1:f7oMNC/o7AzT+SLUw5DKHcURu55e/sAHLjtO7in1OCA=
|
||||||
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
|
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
|
||||||
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||||
github.com/IBM/sarama v1.46.3 h1:njRsX6jNlnR+ClJ8XmkO+CM4unbrNr/2vB5KK6UA+IE=
|
github.com/IBM/sarama v1.46.3 h1:njRsX6jNlnR+ClJ8XmkO+CM4unbrNr/2vB5KK6UA+IE=
|
||||||
@@ -20,8 +20,6 @@ github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1x
|
|||||||
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=
|
|
||||||
github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
|
|
||||||
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
||||||
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
||||||
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
|
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
|
||||||
@@ -81,7 +79,6 @@ github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7Lk
|
|||||||
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/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.3/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
|
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
||||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||||
@@ -90,10 +87,7 @@ github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
|||||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
|
||||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||||
@@ -137,8 +131,6 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
|||||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
|
|
||||||
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
@@ -146,8 +138,6 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
|||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
|
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
|
||||||
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
|
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
|
||||||
github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ=
|
|
||||||
github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60=
|
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||||
github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM=
|
github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM=
|
||||||
@@ -180,7 +170,6 @@ github.com/redis/go-redis/v9 v9.10.0 h1:FxwK3eV8p/CQa0Ch276C7u2d0eNC9kCmAYQ7mCXC
|
|||||||
github.com/redis/go-redis/v9 v9.10.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
|
github.com/redis/go-redis/v9 v9.10.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
|
||||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||||
github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529/go.mod h1:qe5TWALJ8/a1Lqznoc5BDHpYX/8HU60Hm2AwRmqzxqA=
|
|
||||||
github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc=
|
github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc=
|
||||||
github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik=
|
github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik=
|
||||||
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
||||||
@@ -211,11 +200,6 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
|
|||||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
|
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0=
|
|
||||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.72 h1:k9aD8ri7Sqy2hYGYo6I2+OslDgY6IT5R0jUOHHSjW5Y=
|
|
||||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.72/go.mod h1:STbTNaNKq03u+gscPEGOahKzLcGSYOj6Dzc5zNay7Pg=
|
|
||||||
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20250515025012-e0eec8a5d123/go.mod h1:b18KQa4IxHbxeseW1GcZox53d7J0z39VNONTxvvlkXw=
|
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
|
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
package module
|
|
||||||
|
|
||||||
import (
|
|
||||||
"git.hlsq.asia/alex/service-common/config"
|
|
||||||
"git.hlsq.asia/alex/service-common/cos"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Cos 对象存储模块
|
|
||||||
type Cos struct {
|
|
||||||
DefaultModule
|
|
||||||
Cfg map[string]*config.CosConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Cos) Init() error {
|
|
||||||
if cfg, ok := m.Cfg["tencent"]; ok {
|
|
||||||
if err := cos.InitTencent(cfg); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
package module
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"git.hlsq.asia/alex/service-common/config"
|
|
||||||
"git.hlsq.asia/alex/service-common/cos"
|
|
||||||
)
|
|
||||||
|
|
||||||
var SensitiveWordIns *SensitiveWord
|
|
||||||
|
|
||||||
type SensitiveWord struct {
|
|
||||||
DefaultModule
|
|
||||||
cfg *config.SensitiveWordConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewSensitiveWord(cfg *config.SensitiveWordConfig) Module {
|
|
||||||
SensitiveWordIns = &SensitiveWord{
|
|
||||||
cfg: cfg,
|
|
||||||
}
|
|
||||||
return SensitiveWordIns
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *SensitiveWord) Init() error {
|
|
||||||
if m.cfg == nil {
|
|
||||||
//下载文件
|
|
||||||
contentBytes, err := cos.DownloadSimple(context.Background(), "server_file/sensitive_words.txt", "sensitive-word.txt")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
var sensitiveWords map[string]struct{}
|
|
||||||
err = json.Unmarshal(contentBytes, &sensitiveWords)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
sensitiveWordsList := make([]string, 0, len(sensitiveWords))
|
|
||||||
for word := range sensitiveWords {
|
|
||||||
sensitiveWordsList = append(sensitiveWordsList, word)
|
|
||||||
}
|
|
||||||
sensitiveTrie = newTrie(sensitiveWordsList)
|
|
||||||
}
|
|
||||||
// todo 根据配置文件
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ContainsSensitiveWords 判断是否包含敏感词
|
|
||||||
func (m *SensitiveWord) ContainsSensitiveWords(text string) bool {
|
|
||||||
return sensitiveTrie.containsSensitiveWords(text)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FilterSensitiveWords 过滤敏感词
|
|
||||||
func (m *SensitiveWord) FilterSensitiveWords(text string) string {
|
|
||||||
return sensitiveTrie.filterSensitiveWords(text)
|
|
||||||
}
|
|
||||||
|
|
||||||
var sensitiveTrie *Trie
|
|
||||||
|
|
||||||
type trieNode struct {
|
|
||||||
children map[rune]*trieNode
|
|
||||||
isEnd bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type Trie struct {
|
|
||||||
root *trieNode
|
|
||||||
}
|
|
||||||
|
|
||||||
func newTrie(worlds []string) *Trie {
|
|
||||||
t := &Trie{
|
|
||||||
root: &trieNode{
|
|
||||||
children: make(map[rune]*trieNode),
|
|
||||||
isEnd: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, str := range worlds {
|
|
||||||
t.insert(str)
|
|
||||||
}
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
const replace = '*'
|
|
||||||
|
|
||||||
func (sensitiveTrie *Trie) insert(word string) {
|
|
||||||
node := sensitiveTrie.root
|
|
||||||
for _, c := range word {
|
|
||||||
if _, ok := node.children[c]; !ok {
|
|
||||||
node.children[c] = &trieNode{
|
|
||||||
children: make(map[rune]*trieNode),
|
|
||||||
isEnd: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
node = node.children[c]
|
|
||||||
}
|
|
||||||
node.isEnd = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sensitiveTrie *Trie) containsSensitiveWords(text string) bool {
|
|
||||||
if len(text) == 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
length := len([]rune(text))
|
|
||||||
runes := make([]rune, length)
|
|
||||||
index := 0
|
|
||||||
for _, char := range text {
|
|
||||||
runes[index] = char
|
|
||||||
index++
|
|
||||||
}
|
|
||||||
for pointIndex := 0; pointIndex < length; pointIndex++ {
|
|
||||||
//判断
|
|
||||||
node := sensitiveTrie.root
|
|
||||||
for currentIndex := pointIndex; currentIndex < length; currentIndex++ {
|
|
||||||
tn := node.children[runes[currentIndex]]
|
|
||||||
if tn == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if tn.isEnd {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
node = tn
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sensitiveTrie *Trie) filterSensitiveWords(text string) string {
|
|
||||||
if len(text) == 0 {
|
|
||||||
return text
|
|
||||||
}
|
|
||||||
length := len([]rune(text))
|
|
||||||
runes := make([]rune, length)
|
|
||||||
index := 0
|
|
||||||
for _, char := range text {
|
|
||||||
runes[index] = char
|
|
||||||
index++
|
|
||||||
}
|
|
||||||
for pointIndex := 0; pointIndex < length; pointIndex++ {
|
|
||||||
//判断
|
|
||||||
node := sensitiveTrie.root
|
|
||||||
for currentIndex := pointIndex; currentIndex < length; currentIndex++ {
|
|
||||||
tn := node.children[runes[currentIndex]]
|
|
||||||
if tn == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if tn.isEnd {
|
|
||||||
//替换字符
|
|
||||||
for i := pointIndex; i < currentIndex+1; i++ {
|
|
||||||
runes[i] = replace
|
|
||||||
}
|
|
||||||
pointIndex = currentIndex
|
|
||||||
break
|
|
||||||
}
|
|
||||||
node = tn
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return string(runes)
|
|
||||||
}
|
|
||||||
@@ -5,18 +5,17 @@ import (
|
|||||||
"git.hlsq.asia/alex/service-common/discover"
|
"git.hlsq.asia/alex/service-common/discover"
|
||||||
"git.hlsq.asia/alex/service-common/discover/common"
|
"git.hlsq.asia/alex/service-common/discover/common"
|
||||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func AdminNewClient(sid ...int64) (rspb.AdminClient, error) {
|
func AdminNewClient(sid ...int64) (rspb.AdminClient, error) {
|
||||||
c, err := discover.FindServer(common.KeyDiscoverAdmin, sid...)
|
var c *grpc.ClientConn
|
||||||
if err != nil {
|
var err error
|
||||||
return nil, err
|
if len(sid) == 0 {
|
||||||
}
|
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameAdmin)
|
||||||
return rspb.NewAdminClient(c), nil
|
} else {
|
||||||
}
|
c, err = discover.FindServer(common.KeyDiscoverAdmin, sid...)
|
||||||
|
}
|
||||||
func AdminNewClientLB() (rspb.AdminClient, error) {
|
|
||||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameAdmin)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package grpcclient
|
|
||||||
|
|
||||||
import (
|
|
||||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
|
||||||
"git.hlsq.asia/alex/service-common/discover"
|
|
||||||
"git.hlsq.asia/alex/service-common/discover/common"
|
|
||||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
|
||||||
)
|
|
||||||
|
|
||||||
func AnnouncementNewClient(sid ...int64) (rspb.AnnouncementClient, error) {
|
|
||||||
c, err := discover.FindServer(common.KeyDiscoverAnnouncement, sid...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return rspb.NewAnnouncementClient(c), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func AnnouncementNewClientLB() (rspb.AnnouncementClient, error) {
|
|
||||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameAnnouncement)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return rspb.NewAnnouncementClient(c), nil
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package grpcclient
|
|
||||||
|
|
||||||
import (
|
|
||||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
|
||||||
"git.hlsq.asia/alex/service-common/discover"
|
|
||||||
"git.hlsq.asia/alex/service-common/discover/common"
|
|
||||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
|
||||||
)
|
|
||||||
|
|
||||||
func CourtPhysicalNewClient(sid ...int64) (rspb.CourtPhysicalClient, error) {
|
|
||||||
c, err := discover.FindServer(common.KeyDiscoverCourtPhysical, sid...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return rspb.NewCourtPhysicalClient(c), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func CourtPhysicalNewClientLB() (rspb.CourtPhysicalClient, error) {
|
|
||||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameCourtPhysical)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return rspb.NewCourtPhysicalClient(c), nil
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package grpcclient
|
|
||||||
|
|
||||||
import (
|
|
||||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
|
||||||
"git.hlsq.asia/alex/service-common/discover"
|
|
||||||
"git.hlsq.asia/alex/service-common/discover/common"
|
|
||||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
|
||||||
)
|
|
||||||
|
|
||||||
func CourtNewClient(sid ...int64) (rspb.CourtClient, error) {
|
|
||||||
c, err := discover.FindServer(common.KeyDiscoverCourt, sid...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return rspb.NewCourtClient(c), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func CourtNewClientLB() (rspb.CourtClient, error) {
|
|
||||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameCourt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return rspb.NewCourtClient(c), nil
|
|
||||||
}
|
|
||||||
@@ -4,10 +4,18 @@ import (
|
|||||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||||
"git.hlsq.asia/alex/service-common/discover"
|
"git.hlsq.asia/alex/service-common/discover"
|
||||||
"git.hlsq.asia/alex/service-common/discover/common"
|
"git.hlsq.asia/alex/service-common/discover/common"
|
||||||
|
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GatewayNewClient(sid ...int64) (rspb.GatewayClient, error) {
|
func GatewayNewClient(sid ...int64) (rspb.GatewayClient, error) {
|
||||||
c, err := discover.FindServer(common.KeyDiscoverGateway, sid...)
|
var c *grpc.ClientConn
|
||||||
|
var err error
|
||||||
|
if len(sid) == 0 {
|
||||||
|
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameGateway)
|
||||||
|
} else {
|
||||||
|
c, err = discover.FindServer(common.KeyDiscoverGateway, sid...)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
23
net/grpc/grpcclient/client_notice.go
Normal file
23
net/grpc/grpcclient/client_notice.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package grpcclient
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||||
|
"git.hlsq.asia/alex/service-common/discover"
|
||||||
|
"git.hlsq.asia/alex/service-common/discover/common"
|
||||||
|
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NoticeNewClient(sid ...int64) (rspb.NoticeClient, error) {
|
||||||
|
var c *grpc.ClientConn
|
||||||
|
var err error
|
||||||
|
if len(sid) == 0 {
|
||||||
|
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameNotice)
|
||||||
|
} else {
|
||||||
|
c, err = discover.FindServer(common.KeyDiscoverNotice, sid...)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return rspb.NewNoticeClient(c), nil
|
||||||
|
}
|
||||||
@@ -5,18 +5,17 @@ import (
|
|||||||
"git.hlsq.asia/alex/service-common/discover"
|
"git.hlsq.asia/alex/service-common/discover"
|
||||||
"git.hlsq.asia/alex/service-common/discover/common"
|
"git.hlsq.asia/alex/service-common/discover/common"
|
||||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PostNewClient(sid ...int64) (rspb.PostClient, error) {
|
func PostNewClient(sid ...int64) (rspb.PostClient, error) {
|
||||||
c, err := discover.FindServer(common.KeyDiscoverPost, sid...)
|
var c *grpc.ClientConn
|
||||||
if err != nil {
|
var err error
|
||||||
return nil, err
|
if len(sid) == 0 {
|
||||||
}
|
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNamePost)
|
||||||
return rspb.NewPostClient(c), nil
|
} else {
|
||||||
}
|
c, err = discover.FindServer(common.KeyDiscoverPost, sid...)
|
||||||
|
}
|
||||||
func PostNewClientLB() (rspb.PostClient, error) {
|
|
||||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNamePost)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
package grpcclient
|
package grpcclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||||
"git.hlsq.asia/alex/service-common/discover"
|
"git.hlsq.asia/alex/service-common/discover"
|
||||||
"git.hlsq.asia/alex/service-common/discover/common"
|
"git.hlsq.asia/alex/service-common/discover/common"
|
||||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||||
"git.hlsq.asia/alex/service-common/proto/rs/rspb"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func QgdzsNewClient(sid ...int64) (rspb.QgdzsClient, error) {
|
func QgdzsNewClient(sid ...int64) (rspb.QgdzsClient, error) {
|
||||||
c, err := discover.FindServer(common.KeyDiscoverQgdzs, sid...)
|
var c *grpc.ClientConn
|
||||||
if err != nil {
|
var err error
|
||||||
return nil, err
|
if len(sid) == 0 {
|
||||||
}
|
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameQgdzs)
|
||||||
return rspb.NewQgdzsClient(c), nil
|
} else {
|
||||||
}
|
c, err = discover.FindServer(common.KeyDiscoverQgdzs, sid...)
|
||||||
|
}
|
||||||
func QgdzsNewClientLB() (rspb.QgdzsClient, error) {
|
|
||||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameQgdzs)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,18 @@ import (
|
|||||||
"git.hlsq.asia/alex/service-common/discover"
|
"git.hlsq.asia/alex/service-common/discover"
|
||||||
"git.hlsq.asia/alex/service-common/discover/common"
|
"git.hlsq.asia/alex/service-common/discover/common"
|
||||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SceneNewClient 根据SID查找场景服,一般不用这个函数
|
// SceneNewClient 根据SID查找场景服,一般不用这个函数
|
||||||
func SceneNewClient(sid ...int64) (rspb.SceneClient, error) {
|
func SceneNewClient(sid ...int64) (rspb.SceneClient, error) {
|
||||||
c, err := discover.FindServer(common.KeyDiscoverScene, sid...)
|
var c *grpc.ClientConn
|
||||||
|
var err error
|
||||||
|
if len(sid) == 0 {
|
||||||
|
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameScene)
|
||||||
|
} else {
|
||||||
|
c, err = discover.FindServer(common.KeyDiscoverScene, sid...)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -26,14 +33,6 @@ func SceneInstanceNewClient(uniqueNO int64) (rspb.SceneClient, error) {
|
|||||||
return SceneNewClient(sid)
|
return SceneNewClient(sid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SceneNewClientLB() (rspb.SceneClient, error) {
|
|
||||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameScene)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return rspb.NewSceneClient(c), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func SceneNewBroadcastClient() map[int64]rspb.SceneClient {
|
func SceneNewBroadcastClient() map[int64]rspb.SceneClient {
|
||||||
clientM := make(map[int64]rspb.SceneClient)
|
clientM := make(map[int64]rspb.SceneClient)
|
||||||
connM := discover.FindServerAll(common.KeyDiscoverScene)
|
connM := discover.FindServerAll(common.KeyDiscoverScene)
|
||||||
|
|||||||
@@ -5,18 +5,17 @@ import (
|
|||||||
"git.hlsq.asia/alex/service-common/discover"
|
"git.hlsq.asia/alex/service-common/discover"
|
||||||
"git.hlsq.asia/alex/service-common/discover/common"
|
"git.hlsq.asia/alex/service-common/discover/common"
|
||||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ThirdPartyNewClient(sid ...int64) (rspb.ThirdPartyClient, error) {
|
func ThirdPartyNewClient(sid ...int64) (rspb.ThirdPartyClient, error) {
|
||||||
c, err := discover.FindServer(common.KeyDiscoverThirdParty, sid...)
|
var c *grpc.ClientConn
|
||||||
if err != nil {
|
var err error
|
||||||
return nil, err
|
if len(sid) == 0 {
|
||||||
}
|
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameThirdParty)
|
||||||
return rspb.NewThirdPartyClient(c), nil
|
} else {
|
||||||
}
|
c, err = discover.FindServer(common.KeyDiscoverThirdParty, sid...)
|
||||||
|
}
|
||||||
func ThirdPartyNewClientLB() (rspb.ThirdPartyClient, error) {
|
|
||||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameThirdParty)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
23
net/grpc/grpcclient/client_timer.go
Normal file
23
net/grpc/grpcclient/client_timer.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package grpcclient
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||||
|
"git.hlsq.asia/alex/service-common/discover"
|
||||||
|
"git.hlsq.asia/alex/service-common/discover/common"
|
||||||
|
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TimerNewClient(sid ...int64) (rspb.TimerClient, error) {
|
||||||
|
var c *grpc.ClientConn
|
||||||
|
var err error
|
||||||
|
if len(sid) == 0 {
|
||||||
|
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameTimer)
|
||||||
|
} else {
|
||||||
|
c, err = discover.FindServer(common.KeyDiscoverTimer, sid...)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return rspb.NewTimerClient(c), nil
|
||||||
|
}
|
||||||
@@ -5,18 +5,17 @@ import (
|
|||||||
"git.hlsq.asia/alex/service-common/discover"
|
"git.hlsq.asia/alex/service-common/discover"
|
||||||
"git.hlsq.asia/alex/service-common/discover/common"
|
"git.hlsq.asia/alex/service-common/discover/common"
|
||||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func UserNewClient(sid ...int64) (rspb.UserClient, error) {
|
func UserNewClient(sid ...int64) (rspb.UserClient, error) {
|
||||||
c, err := discover.FindServer(common.KeyDiscoverUser, sid...)
|
var c *grpc.ClientConn
|
||||||
if err != nil {
|
var err error
|
||||||
return nil, err
|
if len(sid) == 0 {
|
||||||
}
|
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameUser)
|
||||||
return rspb.NewUserClient(c), nil
|
} else {
|
||||||
}
|
c, err = discover.FindServer(common.KeyDiscoverUser, sid...)
|
||||||
|
}
|
||||||
func UserNewClientLB() (rspb.UserClient, error) {
|
|
||||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameUser)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ func findSceneBySID(sid int64, fun SceneFun) (*sceneStream, error) {
|
|||||||
return ss, nil
|
return ss, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendMessageToScene(sid int64, fun SceneFun, msg proto.Message, re ...bool) error {
|
func sendMessageToScene(sid int64, fun SceneFun, msg proto.Message, re ...bool) error {
|
||||||
ss, err := findSceneBySID(sid, fun)
|
ss, err := findSceneBySID(sid, fun)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -71,7 +71,7 @@ func SendMessageToScene(sid int64, fun SceneFun, msg proto.Message, re ...bool)
|
|||||||
}
|
}
|
||||||
// 如果没有标识本次是重试的,就重试一次(默认重试)
|
// 如果没有标识本次是重试的,就重试一次(默认重试)
|
||||||
if re == nil || !re[0] {
|
if re == nil || !re[0] {
|
||||||
return SendMessageToScene(sid, fun, msg, true)
|
return sendMessageToScene(sid, fun, msg, true)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
package notice
|
|
||||||
|
|
||||||
import "git.hlsq.asia/alex/proto/topic"
|
|
||||||
|
|
||||||
const (
|
|
||||||
// 在线比赛通知
|
|
||||||
|
|
||||||
onlineMatchNoticeStart = iota // 在线比赛开始提醒
|
|
||||||
|
|
||||||
// 锦标赛通知
|
|
||||||
|
|
||||||
tournamentMatchRemind // 比赛提醒
|
|
||||||
tournamentMatchScoreAnnouncementPromoted // 成绩公告-晋级决赛
|
|
||||||
tournamentMatchScoreAnnouncementNotPromoted // 成绩公告-未晋级决赛
|
|
||||||
tournamentMatchScoreAnnouncementFinalEnd // 成绩公告-决赛结束后
|
|
||||||
tournamentMatchRewardDistribute // 奖励发放
|
|
||||||
tournamentMatchViolateNotice // 违规通报
|
|
||||||
)
|
|
||||||
|
|
||||||
type TemplateNoticeLang string
|
|
||||||
|
|
||||||
const (
|
|
||||||
ZhCN TemplateNoticeLang = "zh-CN"
|
|
||||||
)
|
|
||||||
|
|
||||||
var defaultLang = ZhCN
|
|
||||||
|
|
||||||
var noticeTemplate = map[int32]map[TemplateNoticeLang]topic.TemplateNoticeData{
|
|
||||||
onlineMatchNoticeStart: {
|
|
||||||
ZhCN: topic.TemplateNoticeData{
|
|
||||||
Title: "",
|
|
||||||
Msg: "您的队友正在等待您开局,点击返回>>",
|
|
||||||
XiaomiTemplateId: "P20513",
|
|
||||||
CustomParam: `{"type":1, "param":[]}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
tournamentMatchRemind: {
|
|
||||||
ZhCN: topic.TemplateNoticeData{
|
|
||||||
Title: "比赛提醒",
|
|
||||||
Msg: "%v锦标赛第%v轮将于明天开启,记得前来参赛!",
|
|
||||||
XiaomiTemplateId: "P20086",
|
|
||||||
CustomParam: `{"type":2, "param":["%v", "1", "%v"]}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
tournamentMatchScoreAnnouncementPromoted: {
|
|
||||||
ZhCN: topic.TemplateNoticeData{
|
|
||||||
Title: "成绩公告",
|
|
||||||
Msg: "恭喜您在%v锦标赛晋级赛获得第%v名,成功晋级决赛!",
|
|
||||||
XiaomiTemplateId: "P20088",
|
|
||||||
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
tournamentMatchScoreAnnouncementNotPromoted: {
|
|
||||||
ZhCN: topic.TemplateNoticeData{
|
|
||||||
Title: "成绩公告",
|
|
||||||
Msg: "很遗憾,您在%v锦标赛晋级赛中未能进入下一阶段比赛。感谢您的参与!",
|
|
||||||
XiaomiTemplateId: "P20088",
|
|
||||||
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
tournamentMatchScoreAnnouncementFinalEnd: {
|
|
||||||
ZhCN: topic.TemplateNoticeData{
|
|
||||||
Title: "成绩公告",
|
|
||||||
Msg: "恭喜您在%v锦标赛决赛获得第%v名!",
|
|
||||||
XiaomiTemplateId: "P20088",
|
|
||||||
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
tournamentMatchRewardDistribute: {
|
|
||||||
ZhCN: topic.TemplateNoticeData{
|
|
||||||
Title: "奖励发放",
|
|
||||||
Msg: "%v锦标赛于%v月%v日成功完赛,点击查看最终排名!",
|
|
||||||
XiaomiTemplateId: "P20084",
|
|
||||||
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
tournamentMatchViolateNotice: {
|
|
||||||
ZhCN: topic.TemplateNoticeData{
|
|
||||||
Title: "违规通报",
|
|
||||||
Msg: "后台检测到您在%v锦标赛第%v轮比赛中存在违规情况,本次比赛成绩无效,有任何疑问请联系客服。",
|
|
||||||
XiaomiTemplateId: "P20085",
|
|
||||||
CustomParam: `{"type":0, "param":[]}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
package notice
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"git.hlsq.asia/alex/proto/topic"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetOnlineMatchNoticeStart 在线比赛开始通知
|
|
||||||
// lang 语言
|
|
||||||
func GetOnlineMatchNoticeStart(lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
|
||||||
if len(lang) != 0 {
|
|
||||||
defaultLang = lang[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
return noticeTemplate[onlineMatchNoticeStart][defaultLang]
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTournamentMatchRemind 比赛提醒
|
|
||||||
// name 锦标赛名称
|
|
||||||
// wheel 锦标赛轮次
|
|
||||||
// sn 锦标赛sn
|
|
||||||
// channel 频道名称
|
|
||||||
func GetTournamentMatchRemind(name string, wheel int32, sn int64, channelName string,
|
|
||||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
|
||||||
if len(lang) != 0 {
|
|
||||||
defaultLang = lang[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
data := noticeTemplate[tournamentMatchRemind][defaultLang]
|
|
||||||
data.Msg = fmt.Sprintf(data.Msg, name, wheel)
|
|
||||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
|
||||||
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTournamentMatchScoreAnnouncementPromoted 成绩公告-晋级决赛
|
|
||||||
// name 锦标赛名称
|
|
||||||
// ranking 排名
|
|
||||||
// sn 锦标赛sn
|
|
||||||
// channel 频道名称
|
|
||||||
func GetTournamentMatchScoreAnnouncementPromoted(name string, ranking int32, sn int64, channelName string,
|
|
||||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
|
||||||
if len(lang) != 0 {
|
|
||||||
defaultLang = lang[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
data := noticeTemplate[tournamentMatchScoreAnnouncementPromoted][defaultLang]
|
|
||||||
data.Msg = fmt.Sprintf(data.Msg, name, ranking)
|
|
||||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
|
||||||
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTournamentMatchScoreAnnouncementNotPromoted 成绩公告-未晋级决赛
|
|
||||||
// name 锦标赛名称
|
|
||||||
// sn 锦标赛sn
|
|
||||||
// channel 频道名称
|
|
||||||
func GetTournamentMatchScoreAnnouncementNotPromoted(name string, sn int64, channelName string,
|
|
||||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
|
||||||
if len(lang) != 0 {
|
|
||||||
defaultLang = lang[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
data := noticeTemplate[tournamentMatchScoreAnnouncementNotPromoted][defaultLang]
|
|
||||||
data.Msg = fmt.Sprintf(data.Msg, name)
|
|
||||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
|
||||||
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTournamentMatchScoreAnnouncementFinalEnd 成绩公告-决赛结束后
|
|
||||||
// name 锦标赛名称
|
|
||||||
// ranking 排名
|
|
||||||
// sn 锦标赛sn
|
|
||||||
// channel 频道名称
|
|
||||||
func GetTournamentMatchScoreAnnouncementFinalEnd(name string, ranking int32, sn int64, channelName string,
|
|
||||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
|
||||||
if len(lang) != 0 {
|
|
||||||
defaultLang = lang[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
data := noticeTemplate[tournamentMatchScoreAnnouncementFinalEnd][defaultLang]
|
|
||||||
data.Msg = fmt.Sprintf(data.Msg, name, ranking)
|
|
||||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
|
||||||
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTournamentMatchRewardDistribute 奖励发放
|
|
||||||
// name 锦标赛名称
|
|
||||||
// month 月份
|
|
||||||
// day 日
|
|
||||||
// sn 锦标赛sn
|
|
||||||
// channel 频道名称
|
|
||||||
func GetTournamentMatchRewardDistribute(name string, month, day int32, sn int64, channelName string,
|
|
||||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
|
||||||
if len(lang) != 0 {
|
|
||||||
defaultLang = lang[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
data := noticeTemplate[tournamentMatchRewardDistribute][defaultLang]
|
|
||||||
data.Msg = fmt.Sprintf(data.Msg, name, month, day)
|
|
||||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
|
||||||
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTournamentMatchViolateNotice 违规通报
|
|
||||||
// name 锦标赛名称
|
|
||||||
// wheel 锦标赛轮次
|
|
||||||
func GetTournamentMatchViolateNotice(name string, wheel int32, lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
|
||||||
if len(lang) != 0 {
|
|
||||||
defaultLang = lang[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
data := noticeTemplate[tournamentMatchViolateNotice][defaultLang]
|
|
||||||
data.Msg = fmt.Sprintf(data.Msg, name, wheel)
|
|
||||||
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package utils
|
|
||||||
|
|
||||||
type AdminInfo struct {
|
|
||||||
Usn int64 `redis:"usn"`
|
|
||||||
RoleCode string `redis:"roleCode"`
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user