refactor: reorganize modules and add Linux build tooling

This commit is contained in:
2026-08-09 12:41:08 +08:00
parent 86024fa81d
commit 5cc5fd92ed
1461 changed files with 4054 additions and 4724 deletions

View File

@@ -0,0 +1,2 @@
# address

View File

@@ -0,0 +1,7 @@
package main
import "log"
func main() {
log.Println("Hello World!")
}

View File

@@ -0,0 +1,45 @@
/**
* @Author: david.yan(david.yan@qq.com)
* @Date: 2021-11-26 15:25:03
*/
package service
import (
"bsm/full/module/ec/address/internal/config"
"bsm/full/module/ec/address/internal/impl"
"bsm/full/module/ec/address/internal/server"
"git.apinb.com/bsm-sdk/core/service"
)
var (
ServiceKey = "Address"
)
func Run() {
config.New(ServiceKey)
impl.NewImpl()
// 初始化服务
s := server.New(config.Spec.Addr)
srv := service.New(
s.Grpc,
&service.Options{
Addr: config.Spec.Addr,
MsConf: config.Spec.MicroService,
EtcdClient: impl.Etcd,
GatewayCtx: s.Ctx,
GatewayConf: config.Spec.Gateway,
GatewayMux: s.Mux,
},
)
// 停止服务
defer srv.Stop()
// 启动服务
srv.Start()
}
func main() {
Run()
}

View File

@@ -0,0 +1,38 @@
Service: order
Port: 12460
Databases:
Driver: postgres
Source:
- host=47.109.77.183 user=postgres password=CHANGE_ME dbname=ec_mall port=5432 sslmode=disable TimeZone=Asia/Shanghai
# cache DB的选择请在后面直接带参数不带会自动HASH计算选择DB库。
Cache: redis://null:CHANGE_ME@47.109.77.183:6379/
# 业务操作日志收集提交URL
OpLog: http://api-v2.traingo.cn/oplog/v2
# 微服务设置
MicroService:
Enable: false
Anonymous:
- order.ping.hello
# Gateway 设置
Gateway:
Enable: true
Port: 12459
# 微服务调用密钥
SecretKey: 6ad9529688041483f458f8de11ed16ff
# Rpc:
# fts:
# Endpoint: https://api-v2.traingo.cn/fts/v2
# SecretKey: 4ef05311358cd1c8f787281f08b38b1c
# 链路追踪,性能监控,日志收集
# APM:
# Platform: elasticAPM
# Endpoint: http://127.0.0.1:14268/api/traces

View File

@@ -0,0 +1,38 @@
Service: order
Port: 12460
Databases:
Driver: postgres
Source:
- host=47.109.77.183 user=postgres password=CHANGE_ME dbname=ec_mall port=5432 sslmode=disable TimeZone=Asia/Shanghai
# cache DB的选择请在后面直接带参数不带会自动HASH计算选择DB库。
Cache: redis://null:CHANGE_ME@47.109.77.183:6379/
# 业务操作日志收集提交URL
OpLog: http://api-v2.traingo.cn/oplog/v2
# 微服务设置
MicroService:
Enable: false
Anonymous:
- order.ping.hello
# Gateway 设置
Gateway:
Enable: true
Port: 12459
# 微服务调用密钥
SecretKey: 6ad9529688041483f458f8de11ed16ff
# Rpc:
# fts:
# Endpoint: https://api-v2.traingo.cn/fts/v2
# SecretKey: 4ef05311358cd1c8f787281f08b38b1c
# 链路追踪,性能监控,日志收集
# APM:
# Platform: elasticAPM
# Endpoint: http://127.0.0.1:14268/api/traces

View File

@@ -0,0 +1,38 @@
Service: order
Port: 12460
Databases:
Driver: postgres
Source:
- host=47.109.77.183 user=postgres password=CHANGE_ME dbname=ec_mall port=5432 sslmode=disable TimeZone=Asia/Shanghai
# cache DB的选择请在后面直接带参数不带会自动HASH计算选择DB库。
Cache: redis://null:CHANGE_ME@47.109.77.183:6379/
# 业务操作日志收集提交URL
OpLog: http://api-v2.traingo.cn/oplog/v2
# 微服务设置
MicroService:
Enable: false
Anonymous:
- order.ping.hello
# Gateway 设置
Gateway:
Enable: true
Port: 12459
# 微服务调用密钥
SecretKey: 6ad9529688041483f458f8de11ed16ff
# Rpc:
# fts:
# Endpoint: https://api-v2.traingo.cn/fts/v2
# SecretKey: 4ef05311358cd1c8f787281f08b38b1c
# 链路追踪,性能监控,日志收集
# APM:
# Platform: elasticAPM
# Endpoint: http://127.0.0.1:14268/api/traces

View File

@@ -0,0 +1,8 @@
[program:bsm-ec-address]
command=/data/app/bsm-ec-address
directory=/data/app
autostart=true
autorestart=true
user=root
redirect_stderr=true
stdout_logfile=/data/app/logs/ec-address.log

62
module/ec/address/go.mod Normal file
View File

@@ -0,0 +1,62 @@
module bsm/full/module/ec/address
go 1.26.5
tool (
git.apinb.com/bsm-tools/protoc-gen-slc
git.apinb.com/bsm-tools/protoc-gen-ts
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
google.golang.org/grpc/cmd/protoc-gen-go-grpc
google.golang.org/protobuf/cmd/protoc-gen-go
)
require (
git.apinb.com/bsm-sdk/core v0.2.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0
go.etcd.io/etcd/client/pkg/v3 v3.7.1
go.etcd.io/etcd/client/v3 v3.7.1
google.golang.org/grpc v1.83.0
google.golang.org/protobuf v1.36.11
gorm.io/driver/mysql v1.6.0
gorm.io/gorm v1.31.2
)
require (
filippo.io/edwards25519 v1.2.0 // indirect
git.apinb.com/bsm-tools/protoc-gen-slc v0.0.13 // indirect
git.apinb.com/bsm-tools/protoc-gen-ts v0.0.2 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.7.0 // indirect
github.com/go-sql-driver/mysql v1.10.0 // indirect
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.10.0 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/oklog/ulid/v2 v2.1.2 // indirect
github.com/redis/go-redis/v9 v9.22.0 // indirect
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
go.etcd.io/etcd/api/v3 v3.7.1 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.28.0 // indirect
go.yaml.in/yaml/v3 v3.0.5 // indirect
golang.org/x/mod v0.37.0 // indirect
golang.org/x/net v0.57.0 // indirect
golang.org/x/sync v0.22.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/text v0.40.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260807164820-c8921c73eeea // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260807164820-c8921c73eeea // indirect
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/postgres v1.6.2 // indirect
)
replace git.apinb.com/bsm-sdk/core => D:/work/bsm-sdk/core

140
module/ec/address/go.sum Normal file
View File

@@ -0,0 +1,140 @@
filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo=
filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc=
git.apinb.com/bsm-tools/protoc-gen-slc v0.0.13 h1:RGg2R2kHz6IAD7scH6So2FlZYctFUDxqWR8i/+fMfOU=
git.apinb.com/bsm-tools/protoc-gen-slc v0.0.13/go.mod h1:NpJaupVAxmyBleRMAug4mGS6BQV2E32rtuiqQzj1b+A=
git.apinb.com/bsm-tools/protoc-gen-ts v0.0.2 h1:T9C1kY6iIHl5cZ7xyNgV2xlPNWxXmaWfTbD8AzpBB9M=
git.apinb.com/bsm-tools/protoc-gen-ts v0.0.2/go.mod h1:5kAPyKSSLL7HcdZvyJa+ICnOiit/O/Z963nQpGJRrao=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
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/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
github.com/coreos/go-systemd/v22 v22.7.0 h1:LAEzFkke61DFROc7zNLX/WA2i5J8gYqe0rSj9KI28KA=
github.com/coreos/go-systemd/v22 v22.7.0/go.mod h1:xNUYtjHu2EDXbsxz1i41wouACIwT7Ybq9o0BQhMwD0w=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-sql-driver/mysql v1.10.0 h1:Q+1LV8DkHJvSYAdR83XzuhDaTykuDx0l6fkXxoWCWfw=
github.com/go-sql-driver/mysql v1.10.0/go.mod h1:M+cqaI7+xxXGG9swrdeUIoPG3Y3KCkF0pZej+SK+nWk=
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
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/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0 h1:/Tnpcb2E0Pz/tN9s3bfEY2Q8ePCEX9iuS+cneUwncnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0/go.mod h1:zOBXOsUaBSjKgmH4OGzV1esUpR3oUSCPYVd2cUBjKYY=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.10.0 h1:VhSvgU2jSli8o3AqIEOTJr7rZwAEUVo4E4XhR94Zfr0=
github.com/jackc/pgx/v5 v5.10.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/klauspost/cpuid/v2 v2.4.0 h1:S6Hrbc7+ywsr0r+RLapfGBHfyefhCTwEh3A0tV913Dw=
github.com/klauspost/cpuid/v2 v2.4.0/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/oklog/ulid/v2 v2.1.2 h1:IEclFb9JNvzYA6MW2SCxbLzcHTVsfqm3PrqGQJH5zec=
github.com/oklog/ulid/v2 v2.1.2/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/redis/go-redis/v9 v9.22.0 h1:laDvpYXTJtZLloinw1fA5Kqd6HAEH2XKxOkG/PDq2F0=
github.com/redis/go-redis/v9 v9.22.0/go.mod h1:y2g0Wj8rQvuK0ELM+oxSudcLtC09JScs98I/X9gRWY4=
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/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
go.etcd.io/etcd/api/v3 v3.7.1 h1:KJG0/DcWGfe3Y1otDf/fsBf0TSSgpxZ5RO/L8SFt73E=
go.etcd.io/etcd/api/v3 v3.7.1/go.mod h1:8bXIpCMeV7E3/XL0Ix123ATn3dB+0V7d9zklHbB0m78=
go.etcd.io/etcd/client/pkg/v3 v3.7.1 h1:rKYsj3pRkR0eK3yjT3XOgrhqfmIfj9pzNgxjh7mfFv4=
go.etcd.io/etcd/client/pkg/v3 v3.7.1/go.mod h1:cnzZGIUzSfjEwLC6UBVsSXlEK1eepS/JUD7wE6PLRT0=
go.etcd.io/etcd/client/v3 v3.7.1 h1:0PEMMC0KuZmVIN+RAbdqfkZ45pYTgKVtmBEbRCvZFUg=
go.etcd.io/etcd/client/v3 v3.7.1/go.mod h1:ffNqALa8tRCYhYo1F9oR489y23K39Gz+BSR3ApAGYq0=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/otel v1.45.0 h1:pdrWmLHofpubmArBv1LgFSv1Z0Ie/ppdZzu+kUN5EeU=
go.opentelemetry.io/otel v1.45.0/go.mod h1:XZxIqPapzEYnhNSScF5DIqXhm/rYi0FzCe2XddAwZfQ=
go.opentelemetry.io/otel/metric v1.45.0 h1:7Eg1uH7CJ5cXv9is6tnBe1FI6rj1nwUdbFypRm3br/M=
go.opentelemetry.io/otel/metric v1.45.0/go.mod h1:HAPbm1nd3p1PmFH7v2dR+6BjXxw+Lq4a2+pndMAm08s=
go.opentelemetry.io/otel/sdk v1.45.0 h1:4VVSMgQ83dUgW2aoX5f6JgLvHwIvzcuLnF9lUdCSpCw=
go.opentelemetry.io/otel/sdk v1.45.0/go.mod h1:Sr40LgXV7DsKMMJMKOhUWOgMWTfAaqvm2kF0g7ilwuA=
go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI=
go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA=
go.opentelemetry.io/otel/trace v1.45.0 h1:l/mP6Uv7oNO7/TblbhpbgMidxhq1uO/rPsikOyVhxag=
go.opentelemetry.io/otel/trace v1.45.0/go.mod h1:qoJJA2xNMnxRrdISU/kLtfUH2wNeQbiv+jhs/CxI8bc=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo=
go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ=
golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0=
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
google.golang.org/genproto/googleapis/api v0.0.0-20260807164820-c8921c73eeea h1:Jifw/kjs/r3B0uszvls/m3c3tmZs2YHGM9C+rvxP9gY=
google.golang.org/genproto/googleapis/api v0.0.0-20260807164820-c8921c73eeea/go.mod h1:K/+WGbmBY7aNW1HDw1fJnKYo10i0DkAX6pows00dLig=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260807164820-c8921c73eeea h1:kVhQEPTpKQahD5+JSBTfBB19wcgQTTjAIn45MBqnyHk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260807164820-c8921c73eeea/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/grpc v1.83.0 h1:JeNZEKJFbQxArAMl+hiytHauacDNqJUllNfmIMmpqnQ=
google.golang.org/grpc v1.83.0/go.mod h1:kDyl6SKsiHKt0uylY5gtn5cEjkrIOhQOGDgIc4JGwzQ=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.2 h1:rgSNvqscFZ1JgV/4wH5GOsZFSFkR2Eua9As3KIr2LlM=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.2/go.mod h1:iMEtFwDlAhjDU9L5mY6U1XLwlIId/G3h+QcBHDIvrJ8=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/mysql v1.6.0 h1:eNbLmNTpPpTOVZi8MMxCi2aaIm0ZpInbORNXDwyLGvg=
gorm.io/driver/mysql v1.6.0/go.mod h1:D/oCC2GWK3M/dqoLxnOlaNKmXz8WNTfcS9y5ovaSqKo=
gorm.io/driver/postgres v1.6.2 h1:BvXQ/cNUg63q5TFNg672DmDcowZSFrNLkkA3Xe6GXq4=
gorm.io/driver/postgres v1.6.2/go.mod h1:0c4fQA44XhOklXDkgtuKqysHCycTa5i9e3EIpDGCwXk=
gorm.io/driver/sqlite v1.6.0 h1:WHRRrIiulaPiPFmDcod6prc4l2VGVWHz80KspNsxSfQ=
gorm.io/driver/sqlite v1.6.0/go.mod h1:AO9V1qIQddBESngQUKWL9yoH93HIeA1X6V633rBwyT8=
gorm.io/gorm v1.31.2 h1:3o8FXNo9v9S858gil+3LlZA1LkCOzgb4g5BL64FgaCo=
gorm.io/gorm v1.31.2/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=

View File

@@ -0,0 +1,41 @@
package config
import (
"net"
"git.apinb.com/bsm-sdk/core/conf"
"git.apinb.com/bsm-sdk/core/crypto/encipher"
"git.apinb.com/bsm-sdk/core/env"
)
var (
Spec SrvConfig
)
type SrvConfig struct {
conf.Base `yaml:",inline"`
Databases *conf.DBConf `yaml:"Databases"`
MicroService *conf.MicroServiceConf `yaml:"MicroService"`
Rpc map[string]conf.RpcConf `yaml:"Rpc"`
Gateway *conf.GatewayConf `yaml:"Gateway"`
Apm *conf.ApmConf `yaml:"APM"`
Etcd *conf.EtcdConf `yaml:"Etcd"`
}
func New(srvKey string) {
// 初始化配置 创建一个新的配置实例,用于服务配置
conf.New(srvKey, &Spec)
// 配置校验 服务IP,端口; 端口如果不合规,则随机分配端口
Spec.Port = conf.CheckPort(Spec.Port)
Spec.BindIP = conf.CheckIP(Spec.BindIP)
Spec.Addr = net.JoinHostPort(Spec.BindIP, Spec.Port)
// 配置校验 服务名称地址及监听地址不能为空
conf.NotNil(Spec.Service, Spec.Cache)
// 初始化加密SecretKey
encipher.New(env.Runtime.JwtSecretKey)
conf.PrintInfo(Spec.Addr)
}

View File

@@ -0,0 +1,12 @@
package impl
import (
"git.apinb.com/bsm-sdk/core/vars"
)
func NewImpl() {
// with activating
withRedisCache(vars.ServiceKey) // redis cache
withDatabases() // model
withEtcd() // etcd
}

View File

@@ -0,0 +1,84 @@
package impl
import (
"time"
"bsm/full/module/ec/address/internal/config"
"bsm/full/module/ec/address/internal/models"
"git.apinb.com/bsm-sdk/core/cache/redis"
"git.apinb.com/bsm-sdk/core/errcode"
"git.apinb.com/bsm-sdk/core/printer"
"git.apinb.com/bsm-sdk/core/vars"
"go.etcd.io/etcd/client/pkg/v3/transport"
clientv3 "go.etcd.io/etcd/client/v3"
)
var (
RedisCache *redis.RedisClient
Etcd *clientv3.Client
)
func withRedisCache(srvKey string) {
if config.Spec.Cache != "" {
RedisCache = redis.New(config.Spec.Cache, srvKey)
}
// print inform.
printer.Info("[BSM - %s] Cache: %s, DBIndex: %d", vars.ServiceKey, config.Spec.Cache, RedisCache.DB)
}
func withDatabases() {
if config.Spec.Databases == nil || len(config.Spec.Databases.Source) == 0 {
panic("No Database Source Found !")
}
// print inform.
printer.Info("[BSM - %s] Databases: %v", vars.ServiceKey, config.Spec.Databases)
err := models.New(config.Spec.Databases.Driver, config.Spec.Databases.Source, nil)
if err != nil {
printer.Error("Database Init Failed !")
panic(err)
}
}
func withEtcd() {
if config.Spec.Etcd != nil {
if len(config.Spec.Etcd.Endpoints) == 0 {
panic(errcode.ErrNotFound(0, "Etcd Endpoints"))
}
cfg := clientv3.Config{
Endpoints: config.Spec.Etcd.Endpoints,
DialTimeout: 5 * time.Second,
}
if config.Spec.Etcd.Passwd != nil {
cfg.Username = config.Spec.Etcd.Passwd.Account
cfg.Password = config.Spec.Etcd.Passwd.Password
}
if config.Spec.Etcd.TLS != nil {
tlsInfo := transport.TLSInfo{
TrustedCAFile: config.Spec.Etcd.TLS.CaFile,
CertFile: config.Spec.Etcd.TLS.CertFile,
KeyFile: config.Spec.Etcd.TLS.KeyFile,
}
tlsConfig, err := tlsInfo.ClientConfig()
if err != nil {
printer.Error(errcode.ErrEtcd.Error())
panic(err)
}
cfg.TLS = tlsConfig
}
etcd, err := clientv3.New(cfg)
if err != nil {
printer.Error(errcode.ErrEtcd.Error())
panic(err)
}
Etcd = etcd
// print inform.
printer.Info("[BSM - %s] Service Center: %v", vars.ServiceKey, config.Spec.Etcd.Endpoints)
}
}

View File

@@ -0,0 +1,56 @@
package library
import (
"context"
"time"
"bsm/full/module/ec/address/internal/models"
pb "bsm/full/module/ec/address/pb"
"git.apinb.com/bsm-sdk/core/errcode"
"git.apinb.com/bsm-sdk/core/printer"
"git.apinb.com/bsm-sdk/core/service"
"git.apinb.com/bsm-sdk/core/utils"
)
// 新增地址
func Create(ctx context.Context, in *pb.AddressCreateRequest) (reply *pb.StatusReply, err error) {
// parse authorization meta.
auth, err := service.ParseMetaCtx(ctx, nil)
if err != nil {
return nil, err
}
address := &models.AddressLibrary{
Country: in.Country,
Phone: in.Phone,
Province: in.Province,
City: in.City,
Area: in.Area,
Detail: in.Detail,
Contact: in.Contact,
Name: in.Name,
Pics: in.Pics,
}
address.Identity = utils.UUID()
address.OwnerID = auth.ID
address.OwnerIdentity = auth.Identity
address.Status = int8(in.Status)
if address.Status == 2 {
models.DBService.Model(&models.AddressLibrary{}).Where("owner_id = ? and status=2", auth.ID).UpdateColumn("status", "1")
}
err = models.DBService.Create(address).Error
if err != nil {
printer.Error(err.Error())
return nil, errcode.ErrDB
}
return &pb.StatusReply{
Code: 0,
Message: "OK",
Timeseq: time.Now().UnixNano(),
}, nil
}

View File

@@ -0,0 +1,34 @@
package library
import (
"context"
"time"
"bsm/full/module/ec/address/internal/models"
pb "bsm/full/module/ec/address/pb"
"git.apinb.com/bsm-sdk/core/errcode"
"git.apinb.com/bsm-sdk/core/printer"
"git.apinb.com/bsm-sdk/core/service"
)
// 删除一个地址
func Delete(ctx context.Context, in *pb.AddressDeleteRequest) (reply *pb.StatusReply, err error) {
// parse authorization meta.
_, err = service.ParseMetaCtx(ctx, nil)
if err != nil {
return nil, err
}
err = models.DBService.Delete(&models.AddressLibrary{}, "id in ?", in.Id).Error
if err != nil {
printer.Error(err.Error())
return nil, errcode.ErrDB
}
return &pb.StatusReply{
Code: 0,
Message: "OK",
Timeseq: time.Now().UnixNano(),
}, nil
}

View File

@@ -0,0 +1,60 @@
package library
import (
"context"
"bsm/full/module/ec/address/internal/models"
pb "bsm/full/module/ec/address/pb"
"git.apinb.com/bsm-sdk/core/errcode"
"git.apinb.com/bsm-sdk/core/printer"
"git.apinb.com/bsm-sdk/core/service"
)
// 获取地址列表
func Fetch(ctx context.Context, in *pb.IdentRequest) (reply *pb.AddressListReply, err error) {
// parse authorization meta.
auth, err := service.ParseMetaCtx(ctx, nil)
if err != nil {
return nil, err
}
var (
address = make([]*models.AddressLibrary, 0)
result = make([]*pb.AddressItem, 0)
)
err = models.DBService.Where("owner_identity=?", auth.Identity).Find(&address).Error
if err != nil {
printer.Error(err.Error())
return nil, errcode.ErrDB
}
for _, item := range address {
result = append(result, ReflectProtoAddress(item))
}
// TODO: add your logic code & delete this line.
return
}
func ReflectProtoAddress(v *models.AddressLibrary) *pb.AddressItem {
if nil == v {
return nil
}
result := &pb.AddressItem{
Id: int64(v.ID),
Identity: v.Identity,
Country: v.Country,
Phone: v.Phone,
Province: v.Province,
City: v.City,
Area: v.Area,
Detail: v.Detail,
Contact: v.Contact,
Name: v.Name,
Pics: v.Pics,
Status: int32(v.Status),
}
return result
}

View File

@@ -0,0 +1,51 @@
package library
import (
"context"
"errors"
"bsm/full/module/ec/address/internal/models"
pb "bsm/full/module/ec/address/pb"
"git.apinb.com/bsm-sdk/core/errcode"
"git.apinb.com/bsm-sdk/core/printer"
"git.apinb.com/bsm-sdk/core/service"
)
// 获取一条地址
func Get(ctx context.Context, in *pb.IdentRequest) (reply *pb.AddressItem, err error) {
// parse authorization meta.
_, err = service.ParseMetaCtx(ctx, nil)
if err != nil {
return nil, err
}
if in.GetId() == 0 {
return nil, errcode.ErrInvalidArgument
}
address := new(models.AddressLibrary)
err = models.DBService.Where("id=?", in.Id).First(&address).Error
if err != nil {
if errors.Is(err, models.ErrNotFound) {
return nil, errcode.ErrRecordNotFound
}
printer.Error(err.Error())
return nil, errcode.ErrDB
}
return &pb.AddressItem{
Id: int64(address.ID),
Identity: address.Identity,
Name: address.Name,
Phone: address.Phone,
Province: address.Province,
City: address.City,
Area: address.Area,
Detail: address.Detail,
Country: address.Country,
Pics: address.Pics,
Contact: address.Contact,
Status: int32(address.Status),
}, nil
}

View File

@@ -0,0 +1,49 @@
package library
import (
"context"
"time"
"bsm/full/module/ec/address/internal/models"
pb "bsm/full/module/ec/address/pb"
"git.apinb.com/bsm-sdk/core/errcode"
"git.apinb.com/bsm-sdk/core/printer"
"git.apinb.com/bsm-sdk/core/service"
)
// 修改地址
func Modify(ctx context.Context, in *pb.AddressItem) (reply *pb.StatusReply, err error) {
// parse authorization meta.
auth, err := service.ParseMetaCtx(ctx, nil)
if err != nil {
return nil, err
}
address := &models.AddressLibrary{
Country: in.Country,
Phone: in.Phone,
Province: in.Province,
City: in.City,
Area: in.Area,
Detail: in.Detail,
Contact: in.Contact,
}
address.Status = int8(in.Status)
if address.Status == 2 {
models.DBService.Model(&models.AddressLibrary{}).Where("owner_id = ? and status=2", auth.ID).UpdateColumn("status", "1")
}
err = models.DBService.Where("id=?", in.Id).Updates(&address).Error
if err != nil {
printer.Error(err.Error())
return nil, errcode.ErrDB
}
return &pb.StatusReply{
Code: 0,
Message: "OK",
Timeseq: time.Now().UnixNano(),
}, nil
}

View File

@@ -0,0 +1,32 @@
// Models generated by mesh dev cli,@Author: David Yan(david.yan@qq.com).
package models
import (
"git.apinb.com/bsm-sdk/core/types"
)
/*
* OrderAddress
* Comment:
* Version: 10
* Created: 2022-04-12 18:21:15 , Updated:0001-01-01 00:00:00
*/
type AddressLibrary struct {
types.Std_IICUDS
OwnerID uint `gorm:"column:owner_id;Index;" json:"owner_id"`
OwnerIdentity string `gorm:"column:owner_identity;type:varchar(36);Index;" json:"owner_identity"` // 用户唯一标识24位NanoID,36位为UUID
Phone string `gorm:"column:phone;type:varchar(20);default:'';" json:"phone"` // 地址电话
Country string `gorm:"column:country;type:varchar(255);default:'';" json:"country"` // 国家
Province string `gorm:"column:province;type:varchar(255);default:'';" json:"province"` // 省
City string `gorm:"column:city;type:varchar(255);default:'';" json:"city"` // 市
Area string `gorm:"column:area;type:varchar(255);default:'';" json:"area"` // 区
Detail string `gorm:"column:detail;type:varchar(255);default:'';" json:"detail"` // 详细地址
Contact string `gorm:"column:contact;type:varchar(20);default:'';" json:"contact"` // 收件人
Name string `gorm:"column:name;type:varchar(255);default:'';" json:"name"` // 名称
Pics string `gorm:"column:pics;default:'';" json:"pics"` // 图片信息
}
// TableName .
func (table *AddressLibrary) TableName() string {
return "address_library" //对应数据库表名
}

View File

@@ -0,0 +1,84 @@
package models
import (
"log"
"strings"
"git.apinb.com/bsm-sdk/core/database/sql"
"git.apinb.com/bsm-sdk/core/types"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
var DBService *gorm.DB
var migrateTables = []any{
&AddressLibrary{},
}
func New(driver string, dsn []string, options *types.SqlOptions) (err error) {
driver = strings.ToLower(driver)
switch driver {
case "mysql":
DBService, err = NewMysql(dsn, options)
case "postgres":
DBService, err = NewPostgres(dsn, options)
default:
log.Fatalln("Unsupported database driver:", driver)
return
}
if err != nil {
log.Fatalln(err)
return err
}
// auto migrate table.
err = DBService.AutoMigrate(migrateTables...)
if err != nil {
log.Fatalln(err)
return err
}
return
}
func NewMysql(dsn []string, options *types.SqlOptions) (gormDb *gorm.DB, err error) {
//set connection default val.
options = sql.SetOptions(options)
gormDb, err = gorm.Open(mysql.Open(dsn[0]), &gorm.Config{
SkipDefaultTransaction: true,
})
if err != nil {
return nil, err
}
if options.Debug {
gormDb = gormDb.Debug()
}
// 获取通用数据库对象 sql.DB ,然后使用其提供的功能
sqlDB, _ := gormDb.DB()
// SetMaxIdleConns 用于设置连接池中空闲连接的最大数量。
sqlDB.SetMaxIdleConns(options.MaxIdleConns)
// SetMaxOpenConns 设置打开数据库连接的最大数量。
sqlDB.SetMaxOpenConns(options.MaxOpenConns)
// SetConnMaxLifetime 设置了连接可复用的最大时间。
sqlDB.SetConnMaxLifetime(options.ConnMaxLifetime)
return gormDb, nil
}
func NewPostgres(dsn []string, options *types.SqlOptions) (gormDb *gorm.DB, err error) {
//set connection default val.
options = sql.SetOptions(options)
db, err := sql.NewPostgreSql(dsn[0], options)
if err != nil {
return nil, err
}
db = db.Debug()
return db, nil
}

View File

@@ -0,0 +1,5 @@
package models
import "gorm.io/gorm"
var ErrNotFound = gorm.ErrRecordNotFound

View File

@@ -0,0 +1,41 @@
// Code generated by protoc-gen-slc. DO NOT EDIT.
package server
import (
"context"
"bsm/full/module/ec/address/internal/logic/library"
pb "bsm/full/module/ec/address/pb"
)
type LibraryServer struct {
pb.UnimplementedLibraryServer
}
func NewLibraryServer() *LibraryServer {
return &LibraryServer{}
}
// 新增地址
func (s *LibraryServer) Create(ctx context.Context, in *pb.AddressCreateRequest) (*pb.StatusReply, error) {
return library.Create(ctx, in)
}
// 修改地址
func (s *LibraryServer) Modify(ctx context.Context, in *pb.AddressItem) (*pb.StatusReply, error) {
return library.Modify(ctx, in)
}
// 获取一条地址
func (s *LibraryServer) Get(ctx context.Context, in *pb.IdentRequest) (*pb.AddressItem, error) {
return library.Get(ctx, in)
}
// 获取地址列表
func (s *LibraryServer) Fetch(ctx context.Context, in *pb.IdentRequest) (*pb.AddressListReply, error) {
return library.Fetch(ctx, in)
}
// 删除一个地址
func (s *LibraryServer) Delete(ctx context.Context, in *pb.AddressDeleteRequest) (*pb.StatusReply, error) {
return library.Delete(ctx, in)
}

View File

@@ -0,0 +1,71 @@
// Code generated by protoc-gen-slc. DO NOT EDIT.
package server
import (
"context"
pb "bsm/full/module/ec/address/pb"
"git.apinb.com/bsm-sdk/core/vars"
gwRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"google.golang.org/protobuf/proto"
"net/http"
"os"
"strings"
)
type Server struct {
Grpc *grpc.Server
Ctx context.Context
Mux *gwRuntime.ServeMux
}
func New(addr string) *Server {
srv := &Server{Ctx: context.Background(), Grpc: grpc.NewServer(), Mux: gwRuntime.NewServeMux(
gwRuntime.WithForwardResponseRewriter(responseEnvelope),
)}
// register service to grpc.Server
pb.RegisterLibraryServer(srv.Grpc, NewLibraryServer())
reflection.Register(srv.Grpc)
// 将服务注册到Gateway
opts := []grpc.DialOption{grpc.WithInsecure()}
pb.RegisterLibraryHandlerFromEndpoint(srv.Ctx, srv.Mux, addr, opts)
// Register services swagger
srv.RegisterSwagger()
return srv
}
// RegisterSwagger 注册swagger
func (s *Server) RegisterSwagger() {
srvKey := strings.ToLower(vars.ServiceKey)
s.Mux.HandlePath("GET", "/"+srvKey+".swagger.json", func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) {
w.Header().Set("Content-Type", "application/json")
bytes, err := os.ReadFile("./swagger/" + srvKey + ".swagger.json")
if err != nil {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte(err.Error()))
return
}
w.Write(bytes)
return
})
}
// response envelope
func responseEnvelope(_ context.Context, response proto.Message) (interface{}, error) {
name := string(response.ProtoReflect().Descriptor().Name())
if name == "Status" || name == "Error" || name == "StatusReply" {
return response, nil
}
return map[string]any{
"code": 0,
"message": "OK",
"result": response,
}, nil
}

View File

@@ -0,0 +1,662 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc (unknown)
// source: address.proto
package address
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type AddressItem struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // ID
Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"`
Phone string `protobuf:"bytes,3,opt,name=phone,proto3" json:"phone,omitempty"` // 手机号
Country string `protobuf:"bytes,4,opt,name=country,proto3" json:"country,omitempty"` // 国家
Province string `protobuf:"bytes,5,opt,name=province,proto3" json:"province,omitempty"` // 省
City string `protobuf:"bytes,6,opt,name=city,proto3" json:"city,omitempty"` // 市
Area string `protobuf:"bytes,7,opt,name=area,proto3" json:"area,omitempty"` // 区
Detail string `protobuf:"bytes,8,opt,name=detail,proto3" json:"detail,omitempty"` // 详情地址
Contact string `protobuf:"bytes,9,opt,name=contact,proto3" json:"contact,omitempty"` // 联系人
Name string `protobuf:"bytes,10,opt,name=name,proto3" json:"name,omitempty"`
Pics string `protobuf:"bytes,11,opt,name=pics,proto3" json:"pics,omitempty"`
Status int32 `protobuf:"varint,12,opt,name=status,proto3" json:"status,omitempty"` // 状态 -1为删除1为正常2为设置成默认
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AddressItem) Reset() {
*x = AddressItem{}
mi := &file_address_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AddressItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddressItem) ProtoMessage() {}
func (x *AddressItem) ProtoReflect() protoreflect.Message {
mi := &file_address_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddressItem.ProtoReflect.Descriptor instead.
func (*AddressItem) Descriptor() ([]byte, []int) {
return file_address_proto_rawDescGZIP(), []int{0}
}
func (x *AddressItem) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *AddressItem) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
func (x *AddressItem) GetPhone() string {
if x != nil {
return x.Phone
}
return ""
}
func (x *AddressItem) GetCountry() string {
if x != nil {
return x.Country
}
return ""
}
func (x *AddressItem) GetProvince() string {
if x != nil {
return x.Province
}
return ""
}
func (x *AddressItem) GetCity() string {
if x != nil {
return x.City
}
return ""
}
func (x *AddressItem) GetArea() string {
if x != nil {
return x.Area
}
return ""
}
func (x *AddressItem) GetDetail() string {
if x != nil {
return x.Detail
}
return ""
}
func (x *AddressItem) GetContact() string {
if x != nil {
return x.Contact
}
return ""
}
func (x *AddressItem) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *AddressItem) GetPics() string {
if x != nil {
return x.Pics
}
return ""
}
func (x *AddressItem) GetStatus() int32 {
if x != nil {
return x.Status
}
return 0
}
type AddressCreateRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Phone string `protobuf:"bytes,1,opt,name=phone,proto3" json:"phone,omitempty"` // 手机号
Country string `protobuf:"bytes,2,opt,name=country,proto3" json:"country,omitempty"` // 国家
Province string `protobuf:"bytes,3,opt,name=province,proto3" json:"province,omitempty"` // 省
City string `protobuf:"bytes,4,opt,name=city,proto3" json:"city,omitempty"` // 市
Area string `protobuf:"bytes,5,opt,name=area,proto3" json:"area,omitempty"` // 区
Detail string `protobuf:"bytes,6,opt,name=detail,proto3" json:"detail,omitempty"` // 详情地址
Contact string `protobuf:"bytes,7,opt,name=contact,proto3" json:"contact,omitempty"` // 联系人
Name string `protobuf:"bytes,8,opt,name=name,proto3" json:"name,omitempty"`
Pics string `protobuf:"bytes,9,opt,name=pics,proto3" json:"pics,omitempty"`
Status int32 `protobuf:"varint,10,opt,name=status,proto3" json:"status,omitempty"` // 状态 -1为删除1为正常2为设置成默认
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AddressCreateRequest) Reset() {
*x = AddressCreateRequest{}
mi := &file_address_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AddressCreateRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddressCreateRequest) ProtoMessage() {}
func (x *AddressCreateRequest) ProtoReflect() protoreflect.Message {
mi := &file_address_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddressCreateRequest.ProtoReflect.Descriptor instead.
func (*AddressCreateRequest) Descriptor() ([]byte, []int) {
return file_address_proto_rawDescGZIP(), []int{1}
}
func (x *AddressCreateRequest) GetPhone() string {
if x != nil {
return x.Phone
}
return ""
}
func (x *AddressCreateRequest) GetCountry() string {
if x != nil {
return x.Country
}
return ""
}
func (x *AddressCreateRequest) GetProvince() string {
if x != nil {
return x.Province
}
return ""
}
func (x *AddressCreateRequest) GetCity() string {
if x != nil {
return x.City
}
return ""
}
func (x *AddressCreateRequest) GetArea() string {
if x != nil {
return x.Area
}
return ""
}
func (x *AddressCreateRequest) GetDetail() string {
if x != nil {
return x.Detail
}
return ""
}
func (x *AddressCreateRequest) GetContact() string {
if x != nil {
return x.Contact
}
return ""
}
func (x *AddressCreateRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *AddressCreateRequest) GetPics() string {
if x != nil {
return x.Pics
}
return ""
}
func (x *AddressCreateRequest) GetStatus() int32 {
if x != nil {
return x.Status
}
return 0
}
type FetchRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
PageNo int64 `protobuf:"varint,1,opt,name=page_no,json=pageNo,proto3" json:"page_no,omitempty"` // 页数
PageSize int64 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` // 每页记录数
Params map[string]string `protobuf:"bytes,3,rep,name=params,proto3" json:"params,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // 条件参数,key=val,eg key:category_id=?,vlaue=11
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *FetchRequest) Reset() {
*x = FetchRequest{}
mi := &file_address_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *FetchRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FetchRequest) ProtoMessage() {}
func (x *FetchRequest) ProtoReflect() protoreflect.Message {
mi := &file_address_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FetchRequest.ProtoReflect.Descriptor instead.
func (*FetchRequest) Descriptor() ([]byte, []int) {
return file_address_proto_rawDescGZIP(), []int{2}
}
func (x *FetchRequest) GetPageNo() int64 {
if x != nil {
return x.PageNo
}
return 0
}
func (x *FetchRequest) GetPageSize() int64 {
if x != nil {
return x.PageSize
}
return 0
}
func (x *FetchRequest) GetParams() map[string]string {
if x != nil {
return x.Params
}
return nil
}
type IdentRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // 唯一ID
Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` // 唯一码
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *IdentRequest) Reset() {
*x = IdentRequest{}
mi := &file_address_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *IdentRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*IdentRequest) ProtoMessage() {}
func (x *IdentRequest) ProtoReflect() protoreflect.Message {
mi := &file_address_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use IdentRequest.ProtoReflect.Descriptor instead.
func (*IdentRequest) Descriptor() ([]byte, []int) {
return file_address_proto_rawDescGZIP(), []int{3}
}
func (x *IdentRequest) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *IdentRequest) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
type StatusReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` // 状态码
Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` // 标识码
Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` //状态说明
Timeseq int64 `protobuf:"varint,4,opt,name=timeseq,proto3" json:"timeseq,omitempty"` // 响应时间序列
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *StatusReply) Reset() {
*x = StatusReply{}
mi := &file_address_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *StatusReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StatusReply) ProtoMessage() {}
func (x *StatusReply) ProtoReflect() protoreflect.Message {
mi := &file_address_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use StatusReply.ProtoReflect.Descriptor instead.
func (*StatusReply) Descriptor() ([]byte, []int) {
return file_address_proto_rawDescGZIP(), []int{4}
}
func (x *StatusReply) GetCode() int32 {
if x != nil {
return x.Code
}
return 0
}
func (x *StatusReply) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
func (x *StatusReply) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
func (x *StatusReply) GetTimeseq() int64 {
if x != nil {
return x.Timeseq
}
return 0
}
type AddressListReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
Data []*AddressItem `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"` // 地址列表
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AddressListReply) Reset() {
*x = AddressListReply{}
mi := &file_address_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AddressListReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddressListReply) ProtoMessage() {}
func (x *AddressListReply) ProtoReflect() protoreflect.Message {
mi := &file_address_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddressListReply.ProtoReflect.Descriptor instead.
func (*AddressListReply) Descriptor() ([]byte, []int) {
return file_address_proto_rawDescGZIP(), []int{5}
}
func (x *AddressListReply) GetData() []*AddressItem {
if x != nil {
return x.Data
}
return nil
}
type AddressDeleteRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id []int64 `protobuf:"varint,1,rep,packed,name=id,proto3" json:"id,omitempty"` // ID
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AddressDeleteRequest) Reset() {
*x = AddressDeleteRequest{}
mi := &file_address_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AddressDeleteRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddressDeleteRequest) ProtoMessage() {}
func (x *AddressDeleteRequest) ProtoReflect() protoreflect.Message {
mi := &file_address_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddressDeleteRequest.ProtoReflect.Descriptor instead.
func (*AddressDeleteRequest) Descriptor() ([]byte, []int) {
return file_address_proto_rawDescGZIP(), []int{6}
}
func (x *AddressDeleteRequest) GetId() []int64 {
if x != nil {
return x.Id
}
return nil
}
var File_address_proto protoreflect.FileDescriptor
const file_address_proto_rawDesc = "" +
"\n" +
"\x18ec/address/address.proto\x12\aaddress\"\x9f\x02\n" +
"\vAddressItem\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x1a\n" +
"\bidentity\x18\x02 \x01(\tR\bidentity\x12\x14\n" +
"\x05phone\x18\x03 \x01(\tR\x05phone\x12\x18\n" +
"\acountry\x18\x04 \x01(\tR\acountry\x12\x1a\n" +
"\bprovince\x18\x05 \x01(\tR\bprovince\x12\x12\n" +
"\x04city\x18\x06 \x01(\tR\x04city\x12\x12\n" +
"\x04area\x18\a \x01(\tR\x04area\x12\x16\n" +
"\x06detail\x18\b \x01(\tR\x06detail\x12\x18\n" +
"\acontact\x18\t \x01(\tR\acontact\x12\x12\n" +
"\x04name\x18\n" +
" \x01(\tR\x04name\x12\x12\n" +
"\x04pics\x18\v \x01(\tR\x04pics\x12\x16\n" +
"\x06status\x18\f \x01(\x05R\x06status\"\xfc\x01\n" +
"\x14AddressCreateRequest\x12\x14\n" +
"\x05phone\x18\x01 \x01(\tR\x05phone\x12\x18\n" +
"\acountry\x18\x02 \x01(\tR\acountry\x12\x1a\n" +
"\bprovince\x18\x03 \x01(\tR\bprovince\x12\x12\n" +
"\x04city\x18\x04 \x01(\tR\x04city\x12\x12\n" +
"\x04area\x18\x05 \x01(\tR\x04area\x12\x16\n" +
"\x06detail\x18\x06 \x01(\tR\x06detail\x12\x18\n" +
"\acontact\x18\a \x01(\tR\acontact\x12\x12\n" +
"\x04name\x18\b \x01(\tR\x04name\x12\x12\n" +
"\x04pics\x18\t \x01(\tR\x04pics\x12\x16\n" +
"\x06status\x18\n" +
" \x01(\x05R\x06status\"\xba\x01\n" +
"\fFetchRequest\x12\x17\n" +
"\apage_no\x18\x01 \x01(\x03R\x06pageNo\x12\x1b\n" +
"\tpage_size\x18\x02 \x01(\x03R\bpageSize\x129\n" +
"\x06params\x18\x03 \x03(\v2!.address.FetchRequest.ParamsEntryR\x06params\x1a9\n" +
"\vParamsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\":\n" +
"\fIdentRequest\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x1a\n" +
"\bidentity\x18\x02 \x01(\tR\bidentity\"q\n" +
"\vStatusReply\x12\x12\n" +
"\x04code\x18\x01 \x01(\x05R\x04code\x12\x1a\n" +
"\bidentity\x18\x02 \x01(\tR\bidentity\x12\x18\n" +
"\amessage\x18\x03 \x01(\tR\amessage\x12\x18\n" +
"\atimeseq\x18\x04 \x01(\x03R\atimeseq\"<\n" +
"\x10AddressListReply\x12(\n" +
"\x04data\x18\x01 \x03(\v2\x14.address.AddressItemR\x04data\"&\n" +
"\x14AddressDeleteRequest\x12\x0e\n" +
"\x02id\x18\x01 \x03(\x03R\x02id2\xb6\x02\n" +
"\aLibrary\x12?\n" +
"\x06Create\x12\x1d.address.AddressCreateRequest\x1a\x14.address.StatusReply\"\x00\x126\n" +
"\x06Modify\x12\x14.address.AddressItem\x1a\x14.address.StatusReply\"\x00\x124\n" +
"\x03Get\x12\x15.address.IdentRequest\x1a\x14.address.AddressItem\"\x00\x12;\n" +
"\x05Fetch\x12\x15.address.IdentRequest\x1a\x19.address.AddressListReply\"\x00\x12?\n" +
"\x06Delete\x12\x1d.address.AddressDeleteRequest\x1a\x14.address.StatusReply\"\x00B\vZ\t./addressb\x06proto3"
var (
file_address_proto_rawDescOnce sync.Once
file_address_proto_rawDescData []byte
)
func file_address_proto_rawDescGZIP() []byte {
file_address_proto_rawDescOnce.Do(func() {
file_address_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_address_proto_rawDesc), len(file_address_proto_rawDesc)))
})
return file_address_proto_rawDescData
}
var file_address_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_address_proto_goTypes = []any{
(*AddressItem)(nil), // 0: address.AddressItem
(*AddressCreateRequest)(nil), // 1: address.AddressCreateRequest
(*FetchRequest)(nil), // 2: address.FetchRequest
(*IdentRequest)(nil), // 3: address.IdentRequest
(*StatusReply)(nil), // 4: address.StatusReply
(*AddressListReply)(nil), // 5: address.AddressListReply
(*AddressDeleteRequest)(nil), // 6: address.AddressDeleteRequest
nil, // 7: address.FetchRequest.ParamsEntry
}
var file_address_proto_depIdxs = []int32{
7, // 0: address.FetchRequest.params:type_name -> address.FetchRequest.ParamsEntry
0, // 1: address.AddressListReply.data:type_name -> address.AddressItem
1, // 2: address.Library.Create:input_type -> address.AddressCreateRequest
0, // 3: address.Library.Modify:input_type -> address.AddressItem
3, // 4: address.Library.Get:input_type -> address.IdentRequest
3, // 5: address.Library.Fetch:input_type -> address.IdentRequest
6, // 6: address.Library.Delete:input_type -> address.AddressDeleteRequest
4, // 7: address.Library.Create:output_type -> address.StatusReply
4, // 8: address.Library.Modify:output_type -> address.StatusReply
0, // 9: address.Library.Get:output_type -> address.AddressItem
5, // 10: address.Library.Fetch:output_type -> address.AddressListReply
4, // 11: address.Library.Delete:output_type -> address.StatusReply
7, // [7:12] is the sub-list for method output_type
2, // [2:7] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_address_proto_init() }
func file_address_proto_init() {
if File_address_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_address_proto_rawDesc), len(file_address_proto_rawDesc)),
NumEnums: 0,
NumMessages: 8,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_address_proto_goTypes,
DependencyIndexes: file_address_proto_depIdxs,
MessageInfos: file_address_proto_msgTypes,
}.Build()
File_address_proto = out.File
file_address_proto_goTypes = nil
file_address_proto_depIdxs = nil
}

View File

@@ -0,0 +1,406 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: address.proto
/*
Package address is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package address
import (
"context"
"errors"
"io"
"net/http"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
// Suppress "imported and not used" errors
var (
_ codes.Code
_ io.Reader
_ status.Status
_ = errors.New
_ = runtime.String
_ = utilities.NewDoubleArray
_ = metadata.Join
)
func request_Library_Create_0(ctx context.Context, marshaler runtime.Marshaler, client LibraryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq AddressCreateRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.Create(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Library_Create_0(ctx context.Context, marshaler runtime.Marshaler, server LibraryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq AddressCreateRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Create(ctx, &protoReq)
return msg, metadata, err
}
func request_Library_Modify_0(ctx context.Context, marshaler runtime.Marshaler, client LibraryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq AddressItem
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.Modify(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Library_Modify_0(ctx context.Context, marshaler runtime.Marshaler, server LibraryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq AddressItem
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Modify(ctx, &protoReq)
return msg, metadata, err
}
func request_Library_Get_0(ctx context.Context, marshaler runtime.Marshaler, client LibraryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq IdentRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.Get(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Library_Get_0(ctx context.Context, marshaler runtime.Marshaler, server LibraryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq IdentRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Get(ctx, &protoReq)
return msg, metadata, err
}
func request_Library_Fetch_0(ctx context.Context, marshaler runtime.Marshaler, client LibraryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq IdentRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.Fetch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Library_Fetch_0(ctx context.Context, marshaler runtime.Marshaler, server LibraryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq IdentRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Fetch(ctx, &protoReq)
return msg, metadata, err
}
func request_Library_Delete_0(ctx context.Context, marshaler runtime.Marshaler, client LibraryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq AddressDeleteRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.Delete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Library_Delete_0(ctx context.Context, marshaler runtime.Marshaler, server LibraryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq AddressDeleteRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Delete(ctx, &protoReq)
return msg, metadata, err
}
// RegisterLibraryHandlerServer registers the http handlers for service Library to "mux".
// UnaryRPC :call LibraryServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterLibraryHandlerFromEndpoint instead.
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterLibraryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server LibraryServer) error {
mux.Handle(http.MethodPost, pattern_Library_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/address.Library/Create", runtime.WithHTTPPathPattern("/address.Library/Create"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Library_Create_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Library_Create_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Library_Modify_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/address.Library/Modify", runtime.WithHTTPPathPattern("/address.Library/Modify"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Library_Modify_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Library_Modify_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Library_Get_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/address.Library/Get", runtime.WithHTTPPathPattern("/address.Library/Get"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Library_Get_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Library_Get_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Library_Fetch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/address.Library/Fetch", runtime.WithHTTPPathPattern("/address.Library/Fetch"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Library_Fetch_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Library_Fetch_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Library_Delete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/address.Library/Delete", runtime.WithHTTPPathPattern("/address.Library/Delete"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Library_Delete_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Library_Delete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterLibraryHandlerFromEndpoint is same as RegisterLibraryHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterLibraryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.NewClient(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterLibraryHandler(ctx, mux, conn)
}
// RegisterLibraryHandler registers the http handlers for service Library to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterLibraryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterLibraryHandlerClient(ctx, mux, NewLibraryClient(conn))
}
// RegisterLibraryHandlerClient registers the http handlers for service Library
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "LibraryClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "LibraryClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "LibraryClient" to call the correct interceptors. This client ignores the HTTP middlewares.
func RegisterLibraryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client LibraryClient) error {
mux.Handle(http.MethodPost, pattern_Library_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/address.Library/Create", runtime.WithHTTPPathPattern("/address.Library/Create"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Library_Create_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Library_Create_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Library_Modify_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/address.Library/Modify", runtime.WithHTTPPathPattern("/address.Library/Modify"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Library_Modify_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Library_Modify_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Library_Get_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/address.Library/Get", runtime.WithHTTPPathPattern("/address.Library/Get"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Library_Get_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Library_Get_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Library_Fetch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/address.Library/Fetch", runtime.WithHTTPPathPattern("/address.Library/Fetch"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Library_Fetch_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Library_Fetch_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Library_Delete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/address.Library/Delete", runtime.WithHTTPPathPattern("/address.Library/Delete"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Library_Delete_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Library_Delete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Library_Create_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"address.Library", "Create"}, ""))
pattern_Library_Modify_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"address.Library", "Modify"}, ""))
pattern_Library_Get_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"address.Library", "Get"}, ""))
pattern_Library_Fetch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"address.Library", "Fetch"}, ""))
pattern_Library_Delete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"address.Library", "Delete"}, ""))
)
var (
forward_Library_Create_0 = runtime.ForwardResponseMessage
forward_Library_Modify_0 = runtime.ForwardResponseMessage
forward_Library_Get_0 = runtime.ForwardResponseMessage
forward_Library_Fetch_0 = runtime.ForwardResponseMessage
forward_Library_Delete_0 = runtime.ForwardResponseMessage
)

View File

@@ -0,0 +1,287 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc (unknown)
// source: address.proto
package address
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Library_Create_FullMethodName = "/address.Library/Create"
Library_Modify_FullMethodName = "/address.Library/Modify"
Library_Get_FullMethodName = "/address.Library/Get"
Library_Fetch_FullMethodName = "/address.Library/Fetch"
Library_Delete_FullMethodName = "/address.Library/Delete"
)
// LibraryClient is the client API for Library service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// 地址库
type LibraryClient interface {
// 新增地址
Create(ctx context.Context, in *AddressCreateRequest, opts ...grpc.CallOption) (*StatusReply, error)
// 修改地址
Modify(ctx context.Context, in *AddressItem, opts ...grpc.CallOption) (*StatusReply, error)
// 获取一条地址
Get(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*AddressItem, error)
// 获取地址列表
Fetch(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*AddressListReply, error)
// 删除一个地址
Delete(ctx context.Context, in *AddressDeleteRequest, opts ...grpc.CallOption) (*StatusReply, error)
}
type libraryClient struct {
cc grpc.ClientConnInterface
}
func NewLibraryClient(cc grpc.ClientConnInterface) LibraryClient {
return &libraryClient{cc}
}
func (c *libraryClient) Create(ctx context.Context, in *AddressCreateRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Library_Create_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *libraryClient) Modify(ctx context.Context, in *AddressItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Library_Modify_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *libraryClient) Get(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*AddressItem, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AddressItem)
err := c.cc.Invoke(ctx, Library_Get_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *libraryClient) Fetch(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*AddressListReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AddressListReply)
err := c.cc.Invoke(ctx, Library_Fetch_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *libraryClient) Delete(ctx context.Context, in *AddressDeleteRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Library_Delete_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// LibraryServer is the server API for Library service.
// All implementations must embed UnimplementedLibraryServer
// for forward compatibility.
//
// 地址库
type LibraryServer interface {
// 新增地址
Create(context.Context, *AddressCreateRequest) (*StatusReply, error)
// 修改地址
Modify(context.Context, *AddressItem) (*StatusReply, error)
// 获取一条地址
Get(context.Context, *IdentRequest) (*AddressItem, error)
// 获取地址列表
Fetch(context.Context, *IdentRequest) (*AddressListReply, error)
// 删除一个地址
Delete(context.Context, *AddressDeleteRequest) (*StatusReply, error)
mustEmbedUnimplementedLibraryServer()
}
// UnimplementedLibraryServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedLibraryServer struct{}
func (UnimplementedLibraryServer) Create(context.Context, *AddressCreateRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Create not implemented")
}
func (UnimplementedLibraryServer) Modify(context.Context, *AddressItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Modify not implemented")
}
func (UnimplementedLibraryServer) Get(context.Context, *IdentRequest) (*AddressItem, error) {
return nil, status.Errorf(codes.Unimplemented, "method Get not implemented")
}
func (UnimplementedLibraryServer) Fetch(context.Context, *IdentRequest) (*AddressListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Fetch not implemented")
}
func (UnimplementedLibraryServer) Delete(context.Context, *AddressDeleteRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented")
}
func (UnimplementedLibraryServer) mustEmbedUnimplementedLibraryServer() {}
func (UnimplementedLibraryServer) testEmbeddedByValue() {}
// UnsafeLibraryServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to LibraryServer will
// result in compilation errors.
type UnsafeLibraryServer interface {
mustEmbedUnimplementedLibraryServer()
}
func RegisterLibraryServer(s grpc.ServiceRegistrar, srv LibraryServer) {
// If the following call pancis, it indicates UnimplementedLibraryServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Library_ServiceDesc, srv)
}
func _Library_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AddressCreateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LibraryServer).Create(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Library_Create_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LibraryServer).Create(ctx, req.(*AddressCreateRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Library_Modify_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AddressItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LibraryServer).Modify(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Library_Modify_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LibraryServer).Modify(ctx, req.(*AddressItem))
}
return interceptor(ctx, in, info, handler)
}
func _Library_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LibraryServer).Get(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Library_Get_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LibraryServer).Get(ctx, req.(*IdentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Library_Fetch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LibraryServer).Fetch(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Library_Fetch_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LibraryServer).Fetch(ctx, req.(*IdentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Library_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AddressDeleteRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LibraryServer).Delete(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Library_Delete_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LibraryServer).Delete(ctx, req.(*AddressDeleteRequest))
}
return interceptor(ctx, in, info, handler)
}
// Library_ServiceDesc is the grpc.ServiceDesc for Library service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Library_ServiceDesc = grpc.ServiceDesc{
ServiceName: "address.Library",
HandlerType: (*LibraryServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Create",
Handler: _Library_Create_Handler,
},
{
MethodName: "Modify",
Handler: _Library_Modify_Handler,
},
{
MethodName: "Get",
Handler: _Library_Get_Handler,
},
{
MethodName: "Fetch",
Handler: _Library_Fetch_Handler,
},
{
MethodName: "Delete",
Handler: _Library_Delete_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "address.proto",
}

View File

@@ -0,0 +1,76 @@
syntax = "proto3";
package address;
option go_package = "./address";
// 地址库
service Library {
// 新增地址
rpc Create(AddressCreateRequest) returns (StatusReply) {};
// 修改地址
rpc Modify(AddressItem) returns (StatusReply) {};
// 获取一条地址
rpc Get(IdentRequest) returns (AddressItem) {};
// 获取地址列表
rpc Fetch(IdentRequest) returns (AddressListReply) {};
// 删除一个地址
rpc Delete(AddressDeleteRequest) returns (StatusReply) {};
}
message AddressItem {
int64 id = 1; // ID
string identity=2;
string phone = 3; // 手机号
string country = 4; // 国家
string province = 5; // 省
string city = 6; // 市
string area = 7; // 区
string detail = 8; // 详情地址
string contact = 9; // 联系人
string name=10;
string pics=11;
int32 status = 12; // 状态 -1为删除1为正常2为设置成默认
}
message AddressCreateRequest {
string phone = 1; // 手机号
string country = 2; // 国家
string province = 3; // 省
string city = 4; // 市
string area = 5; // 区
string detail = 6; // 详情地址
string contact = 7; // 联系人
string name=8;// 名称
string pics=9;// 图片
int32 status = 10; // 状态 -1为删除1为正常2为设置成默认
}
message FetchRequest {
int64 page_no=1; // 页数
int64 page_size=2; // 每页记录数
map<string,string> params=3; // 条件参数,key=val,eg key:category_id=?,vlaue=11
}
message IdentRequest{
int64 id = 1; // 唯一ID
string identity = 2; // 唯一码
}
message StatusReply{
int32 code = 1; // 状态码
string identity=2; // 标识码
string message=3; //状态说明
int64 timeseq=4; // 响应时间序列
}
message AddressListReply {
repeated AddressItem data = 1; // 地址列表
}
message AddressDeleteRequest {
repeated int64 id = 1; // ID
}

View File

@@ -0,0 +1,32 @@
filebeat.inputs:
- type: log
enabled: true
# 开启json解析
json.keys_under_root: true
json.add_error_key: true
# 日志文件路径
paths:
- ./logs/address/error.log
- ./logs/address/slow.log
setup.template.settings:
index.number_of_shards: 1
# 定义kafka topic field
fields:
log_topic: scf.address.dev
# 输出到kafka
output.kafka:
hosts: ["127.0.0.1:9092"]
topic: '%{[fields.log_topic]}'
partition.round_robin:
reachable_only: false
required_acks: 1
keep_alive: 10s
# ================================= Processors =================================
processors:
- decode_json_fields:
fields: ['@timestamp','level','content','trace','span','duration']
target: ""

View File

@@ -0,0 +1,5 @@
#install
go install github.com/securego/gosec/v2/cmd/gosec@latest
#run
gosec -fmt=json -out=./test/lint/gosec.json ./...

View File

@@ -0,0 +1,30 @@
/** 新增地址
* - Request: AddressCreateRequest
* - Response: StatusReply
*/
export const URL_Library_Create = "/address.Library/Create"
/** 修改地址
* - Request: AddressItem
* - Response: StatusReply
*/
export const URL_Library_Modify = "/address.Library/Modify"
/** 获取一条地址
* - Request: IdentRequest
* - Response: AddressItem
*/
export const URL_Library_Get = "/address.Library/Get"
/** 获取地址列表
* - Request: IdentRequest
* - Response: AddressListReply
*/
export const URL_Library_Fetch = "/address.Library/Fetch"
/** 删除一个地址
* - Request: AddressDeleteRequest
* - Response: StatusReply
*/
export const URL_Library_Delete = "/address.Library/Delete"

View File

@@ -0,0 +1,106 @@
// Code generated by protoc-gen-typescript-http. DO NOT EDIT.
/* eslint-disable camelcase */
// @ts-nocheck
export type AddressItem = {
/** ID */
id?: number;
identity?: string;
/** 手机号 */
phone?: string;
/** 国家 */
country?: string;
/** 省 */
province?: string;
/** 市 */
city?: string;
/** 区 */
area?: string;
/** 详情地址 */
detail?: string;
/** 联系人 */
contact?: string;
name?: string;
pics?: string;
/** 状态 -1为删除1为正常2为设置成默认 */
status?: number;
};
export type AddressCreateRequest = {
/** 手机号 */
phone?: string;
/** 国家 */
country?: string;
/** 省 */
province?: string;
/** 市 */
city?: string;
/** 区 */
area?: string;
/** 详情地址 */
detail?: string;
/** 联系人 */
contact?: string;
name?: string;
pics?: string;
/** 状态 -1为删除1为正常2为设置成默认 */
status?: number;
};
export type FetchRequest = {
/** 页数 */
pageNo?: number;
/** 每页记录数 */
pageSize?: number;
/** 条件参数,key=val,eg key:category_id=?,vlaue=11 */
params?: { [key: string]: string };
};
export type IdentRequest = {
/** 唯一ID */
id?: number;
/** 唯一码 */
identity?: string;
};
export type StatusReply = {
/** 状态码 */
code?: number;
/** 标识码 */
identity?: string;
/** 状态说明 */
message?: string;
/** 响应时间序列 */
timeseq?: number;
};
export type AddressListReply = {
/** 地址列表 */
data?: AddressItem[];
};
export type AddressDeleteRequest = {
/** ID */
id?: number[];
};
/** 地址库 */
export interface Library {
}
type RequestType = {
path: string;
method: string;
body: string | null;
};
type RequestHandler = (request: RequestType, meta: { service: string, method: string }) => Promise<unknown>;
export function createLibraryClient(
handler: RequestHandler
): Library {
return {
};
}
// @@protoc_insertion_point(typescript-http-eof)

View File

@@ -0,0 +1,137 @@
{
"swagger": "2.0",
"info": {
"title": "address.proto",
"version": "version not set"
},
"tags": [
{
"name": "Library"
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"addressAddressItem": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "int64",
"title": "ID"
},
"identity": {
"type": "string"
},
"phone": {
"type": "string",
"title": "手机号"
},
"country": {
"type": "string",
"title": "国家"
},
"province": {
"type": "string",
"title": "省"
},
"city": {
"type": "string",
"title": "市"
},
"area": {
"type": "string",
"title": "区"
},
"detail": {
"type": "string",
"title": "详情地址"
},
"contact": {
"type": "string",
"title": "联系人"
},
"name": {
"type": "string"
},
"pics": {
"type": "string"
},
"status": {
"type": "integer",
"format": "int32",
"title": "状态 -1为删除1为正常2为设置成默认"
}
}
},
"addressAddressListReply": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/addressAddressItem"
},
"title": "地址列表"
}
}
},
"addressStatusReply": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32",
"title": "状态码"
},
"identity": {
"type": "string",
"title": "标识码"
},
"message": {
"type": "string",
"title": "状态说明"
},
"timeseq": {
"type": "string",
"format": "int64",
"title": "响应时间序列"
}
}
},
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}

View File

@@ -0,0 +1,16 @@
POST http://127.0.0.1:12459/address.Library/Create
content-type: application/json
Authorization: {{BSM_TOKEN}}
{
"phone": "789012345513",
"country": "中国",
"province": "山东",
"city": "青岛",
"area": "崂山区",
"detail": "崂山风景区入口处",
"contact": "陈九",
"name": "崂山脚下",
"pics": "https://example.com/images/cccc.jpg",
"status": 1
}

View File

@@ -0,0 +1,7 @@
POST http://127.0.0.1:12459/address.Library/Get
content-type: application/json
Authorization: {{BSM_TOKEN}}
{
"id":1
}

View File

@@ -0,0 +1,7 @@
POST http://127.0.0.1:12459/address.Library/Modify
content-type: application/json
Authorization: {{BSM_TOKEN}}
{
}

View File

@@ -0,0 +1,23 @@
package rpc
/*
func main() {
md := metadata.New(map[string]string{"request_id": utils.UUID(), "workspace": "scf"})
ctx := metadata.NewOutgoingContext(context.Background(), md)
// 建立GRPC连接
conn, err := grpc.Dial("127.0.0.1:12201", grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
panic(err)
}
defer conn.Close()
c := pb.NewCheckClient(conn)
r, err := c.Hello(ctx, &pb.Crc{
Code: "david",
})
if err != nil {
panic(err)
}
fmt.Printf("返回的消息: %s", r.Message)
}
*/