From d47be22596ad6dab1b159499c1ae3c822e482c71 Mon Sep 17 00:00:00 2001 From: tcq Date: Fri, 2 Feb 2024 17:46:51 +0800 Subject: [PATCH] =?UTF-8?q?user-base=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auth/auth.proto | 29 +++ buf.gen.yaml | 15 +- go.mod | 51 ----- go.sum | 131 ----------- model/user-model.go | 27 --- mysql/mysql.go | 90 -------- mysql/tables-mysql.go | 11 - pb/auth/auth.pb.go | 218 ++++++++++++++++++ pb/auth/auth.pb.gw.go | 163 ++++++++++++++ pb/auth/auth.swagger.json | 97 ++++++++ pb/auth/auth_grpc.pb.go | 107 +++++++++ {gen/proto => pb/user}/user.pb.go | 274 +++++++++++------------ {gen/proto => pb/user}/user.pb.gw.go | 2 +- {gen/proto => pb/user}/user.swagger.json | 2 +- {gen/proto => pb/user}/user_grpc.pb.go | 4 +- redis/redis.go | 177 --------------- redis/redis_test.go | 36 --- {proto => user}/user.proto | 2 +- utils/snowflake.go | 42 ---- utils/token.go | 80 ------- 20 files changed, 764 insertions(+), 794 deletions(-) create mode 100644 auth/auth.proto delete mode 100644 go.mod delete mode 100644 go.sum delete mode 100644 model/user-model.go delete mode 100644 mysql/mysql.go delete mode 100644 mysql/tables-mysql.go create mode 100644 pb/auth/auth.pb.go create mode 100644 pb/auth/auth.pb.gw.go create mode 100644 pb/auth/auth.swagger.json create mode 100644 pb/auth/auth_grpc.pb.go rename {gen/proto => pb/user}/user.pb.go (65%) rename {gen/proto => pb/user}/user.pb.gw.go (99%) rename {gen/proto => pb/user}/user.swagger.json (99%) rename {gen/proto => pb/user}/user_grpc.pb.go (99%) delete mode 100644 redis/redis.go delete mode 100644 redis/redis_test.go rename {proto => user}/user.proto (98%) delete mode 100644 utils/snowflake.go delete mode 100644 utils/token.go diff --git a/auth/auth.proto b/auth/auth.proto new file mode 100644 index 0000000..a91ac3c --- /dev/null +++ b/auth/auth.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +import "google/api/annotations.proto"; + +package user; + +option go_package=".;user"; + +service UserServiceNew { + //用户注册 + rpc RegisterNew (RegisterRequestRegisterNew) returns (RegisterResponseRegisterNew) { + option (google.api.http) = { + post: "/v1/user/register" + body: "*" + }; + } + + +} + +message RegisterRequestRegisterNew { + string UserName=1; + string Avatar=2; + +} +message RegisterResponseRegisterNew { + +} + diff --git a/buf.gen.yaml b/buf.gen.yaml index 4f08fdc..5d5da77 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -1,19 +1,20 @@ version: v1 plugins: - plugin: go - out: gen + out: ./pb opt: - paths=source_relative - plugin: go-grpc - out: gen + out: ./pb opt: - paths=source_relative - - name: grpc-gateway - out: gen + - plugin: grpc-gateway + out: ./pb opt: - paths=source_relative - generate_unbound_methods=true - - name: openapiv2 - out: gen + - plugin: openapiv2 + out: ./pb opt: - - logtostderr=true \ No newline at end of file + - logtostderr=true + \ No newline at end of file diff --git a/go.mod b/go.mod deleted file mode 100644 index 6cbf1d8..0000000 --- a/go.mod +++ /dev/null @@ -1,51 +0,0 @@ -module myschools.me/tcq/user-base - -go 1.21.1 - -require ( - github.com/bwmarrin/snowflake v0.3.0 - github.com/gin-gonic/gin v1.9.1 - github.com/go-playground/locales v0.14.1 - github.com/go-playground/universal-translator v0.18.1 - github.com/go-playground/validator/v10 v10.17.0 - github.com/gomodule/redigo v1.8.9 - github.com/google/uuid v1.6.0 - github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 - google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe - google.golang.org/grpc v1.61.0 - google.golang.org/protobuf v1.32.0 - gorm.io/driver/mysql v1.5.2 - gorm.io/gorm v1.25.6 - gorm.io/plugin/dbresolver v1.5.0 -) - -require ( - github.com/bytedance/sonic v1.9.1 // indirect - github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect - github.com/gabriel-vasile/mimetype v1.4.2 // indirect - github.com/gin-contrib/sse v0.1.0 // indirect - github.com/go-sql-driver/mysql v1.7.0 // indirect - github.com/goccy/go-json v0.10.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/jinzhu/inflection v1.0.0 // indirect - github.com/jinzhu/now v1.1.5 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/cpuid/v2 v2.2.4 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/leodido/go-urn v1.2.4 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pelletier/go-toml/v2 v2.0.8 // indirect - github.com/rogpeppe/go-internal v1.12.0 // indirect - github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.11 // indirect - golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.16.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/go.sum b/go.sum deleted file mode 100644 index 2d5812f..0000000 --- a/go.sum +++ /dev/null @@ -1,131 +0,0 @@ -github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0= -github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE= -github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= -github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= -github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= -github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= -github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= -github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= -github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.17.0 h1:SmVVlfAOtlZncTxRuinDPomC2DkXJ4E5T9gDA0AIH74= -github.com/go-playground/validator/v10 v10.17.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= -github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws= -github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -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.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= -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.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= -github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= -github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= -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/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -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/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= -github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -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.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -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/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= -github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= -golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac h1:ZL/Teoy/ZGnzyrqK/Optxxp2pmVh+fmJ97slxSRyzUg= -google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k= -google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe h1:0poefMBYvYbs7g5UkjS6HcxBPaTRAmznle9jnxYoAI8= -google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:4jWUdICTdgc3Ibxmr8nAJiiLHwQBY0UI0XZcEMaFKaA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe h1:bQnxqljG/wqi4NTXu2+DJ3n7APcEA882QZ1JvhQAq9o= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= -google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= -google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -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.4.3/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10c= -gorm.io/driver/mysql v1.5.2 h1:QC2HRskSE75wBuOxe0+iCkyJZ+RqpudsQtqkp+IMuXs= -gorm.io/driver/mysql v1.5.2/go.mod h1:pQLhh1Ut/WUAySdTHwBpBv6+JKcj+ua4ZFx1QQTBzb8= -gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= -gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= -gorm.io/gorm v1.25.2/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= -gorm.io/gorm v1.25.6 h1:V92+vVda1wEISSOMtodHVRcUIOPYa2tgQtyF+DfFx+A= -gorm.io/gorm v1.25.6/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= -gorm.io/plugin/dbresolver v1.5.0 h1:XVHLxh775eP0CqVh3vcfJtYqja3uFl5Wr3cKlY8jgDY= -gorm.io/plugin/dbresolver v1.5.0/go.mod h1:l4Cn87EHLEYuqUncpEeTC2tTJQkjngPSD+lo8hIvcT0= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/model/user-model.go b/model/user-model.go deleted file mode 100644 index 50c8b55..0000000 --- a/model/user-model.go +++ /dev/null @@ -1,27 +0,0 @@ -package model - -import ( - "time" - - "gorm.io/gorm" -) - -/* -通过分库来区别不同版本的产品-现在的demo逻辑 -用户在后台注册,前台扫码登录,组织ID肯定存在(后期如果开放注册-组织ID可以不存在) -*/ - -type User struct { - ID uint `gorm:"primarykey"` - UserName string `gorm:"column:user_name;type:varchar(30);comment:用户名"` - NickName string `gorm:"column:nick_name;type:varchar(40);comment:昵称"` - OpenID string `gorm:"column:openid;type:varchar(100);not null;index;comment:公众号openid" json:"-"` - Avatar string `gorm:"column:avatar;type:varchar(300);comment:头像地址"` - Mobile string `gorm:"column:mobile;type:varchar(12);not null;index ;comment:手机号"` - Email string `gorm:"column:email;type:varchar(30);comment:email"` - ProjectID string `gorm:"column:project_id;type:varchar(40);comment:项目ID"` //项目 Id admin项目 Id 为 0 - Role string `gorm:"column:role;type:varchar(15);not null;default:guest;comment:角色类型"` // sys、so、admin - CreatedAt time.Time `gorm:"autoCreateTime"` - UpdatedAt time.Time `gorm:"autoUpdateTime"` - DeletedAt gorm.DeletedAt `gorm:"index"` -} diff --git a/mysql/mysql.go b/mysql/mysql.go deleted file mode 100644 index c710112..0000000 --- a/mysql/mysql.go +++ /dev/null @@ -1,90 +0,0 @@ -package mysql - -import ( - "errors" - "time" - - "gorm.io/driver/mysql" - "gorm.io/gorm" - "gorm.io/gorm/logger" - "gorm.io/gorm/schema" - "gorm.io/plugin/dbresolver" -) - -var ( - _db *gorm.DB - _conf *Config -) - -type Config struct { - ConnString string - ConnMaxLifetime int64 //ConnMaxLifetime 最大连接时间,单位:小时 - MaxIdleConns int - MaxOpenConns int - InitTable bool -} - -// Init mysql初始化 -func Init(config *Config) { - if config == nil { - config = &Config{ - MaxIdleConns: 10, - MaxOpenConns: 100, - } - } - if config.ConnString == "" { - config.ConnString = "root:root@tcp(127.0.0.1:3306)/mysql?charset=utf8&parseTime=True&loc=Local" - } - if config.ConnMaxLifetime < 1 { - config.ConnMaxLifetime = 1 - } - if config.ConnMaxLifetime > 6 { - config.ConnMaxLifetime = 6 - } - if config.MaxIdleConns < 1 { - config.MaxIdleConns = 1 - } - if config.MaxIdleConns > 50 { - config.MaxIdleConns = 50 - } - if config.MaxOpenConns < 1 { - config.MaxOpenConns = 1 - } - if config.MaxOpenConns > 500 { - config.MaxOpenConns = 500 - } - _conf = config -} - -// New 创建实例 -func New() (*gorm.DB, error) { - if _db != nil { - return _db, nil - } - - if _conf == nil { - return nil, errors.New("组件未初始化,请执行Init!") - } - - var err error - _db, err = gorm.Open(mysql.Open(_conf.ConnString), &gorm.Config{ - SkipDefaultTransaction: true, - Logger: logger.Default.LogMode(logger.Silent), - NamingStrategy: schema.NamingStrategy{ - SingularTable: true, - }, - }) - if err != nil { - return nil, err - } - _db.Use( - dbresolver.Register(dbresolver.Config{ - Sources: []gorm.Dialector{mysql.Open(_conf.ConnString)}, - Replicas: []gorm.Dialector{mysql.Open(_conf.ConnString)}, - Policy: dbresolver.RandomPolicy{}, - }).SetConnMaxIdleTime(time.Hour). - SetConnMaxLifetime(time.Duration(_conf.ConnMaxLifetime) * time.Hour). - SetMaxIdleConns(_conf.MaxIdleConns). - SetMaxOpenConns(_conf.MaxOpenConns)) - return _db, nil -} diff --git a/mysql/tables-mysql.go b/mysql/tables-mysql.go deleted file mode 100644 index e851345..0000000 --- a/mysql/tables-mysql.go +++ /dev/null @@ -1,11 +0,0 @@ -package mysql - -func InitTable() error { - //不初始化表时返回 - if !_conf.InitTable { - return nil - } - - //成功初始化后返回 - return nil -} diff --git a/pb/auth/auth.pb.go b/pb/auth/auth.pb.go new file mode 100644 index 0000000..58fcdc5 --- /dev/null +++ b/pb/auth/auth.pb.go @@ -0,0 +1,218 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: auth/auth.proto + +package user + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +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 RegisterRequestRegisterNew struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserName string `protobuf:"bytes,1,opt,name=UserName,proto3" json:"UserName,omitempty"` + Avatar string `protobuf:"bytes,2,opt,name=Avatar,proto3" json:"Avatar,omitempty"` +} + +func (x *RegisterRequestRegisterNew) Reset() { + *x = RegisterRequestRegisterNew{} + if protoimpl.UnsafeEnabled { + mi := &file_auth_auth_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RegisterRequestRegisterNew) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterRequestRegisterNew) ProtoMessage() {} + +func (x *RegisterRequestRegisterNew) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterRequestRegisterNew.ProtoReflect.Descriptor instead. +func (*RegisterRequestRegisterNew) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{0} +} + +func (x *RegisterRequestRegisterNew) GetUserName() string { + if x != nil { + return x.UserName + } + return "" +} + +func (x *RegisterRequestRegisterNew) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +type RegisterResponseRegisterNew struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *RegisterResponseRegisterNew) Reset() { + *x = RegisterResponseRegisterNew{} + if protoimpl.UnsafeEnabled { + mi := &file_auth_auth_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RegisterResponseRegisterNew) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterResponseRegisterNew) ProtoMessage() {} + +func (x *RegisterResponseRegisterNew) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterResponseRegisterNew.ProtoReflect.Descriptor instead. +func (*RegisterResponseRegisterNew) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{1} +} + +var File_auth_auth_proto protoreflect.FileDescriptor + +var file_auth_auth_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x04, 0x75, 0x73, 0x65, 0x72, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x50, 0x0a, 0x1a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x4e, 0x65, 0x77, 0x12, 0x1a, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x55, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x16, 0x0a, 0x06, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x22, 0x1d, 0x0a, 0x1b, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x4e, 0x65, 0x77, 0x32, 0x82, 0x01, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x65, 0x77, 0x12, 0x70, 0x0a, 0x0b, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x77, 0x12, 0x20, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x77, 0x1a, 0x21, 0x2e, 0x75, 0x73, 0x65, + 0x72, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x77, 0x22, 0x1c, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x3a, 0x01, 0x2a, 0x22, 0x11, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, + 0x65, 0x72, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x42, 0x08, 0x5a, 0x06, 0x2e, + 0x3b, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_auth_auth_proto_rawDescOnce sync.Once + file_auth_auth_proto_rawDescData = file_auth_auth_proto_rawDesc +) + +func file_auth_auth_proto_rawDescGZIP() []byte { + file_auth_auth_proto_rawDescOnce.Do(func() { + file_auth_auth_proto_rawDescData = protoimpl.X.CompressGZIP(file_auth_auth_proto_rawDescData) + }) + return file_auth_auth_proto_rawDescData +} + +var file_auth_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_auth_auth_proto_goTypes = []interface{}{ + (*RegisterRequestRegisterNew)(nil), // 0: user.RegisterRequestRegisterNew + (*RegisterResponseRegisterNew)(nil), // 1: user.RegisterResponseRegisterNew +} +var file_auth_auth_proto_depIdxs = []int32{ + 0, // 0: user.UserServiceNew.RegisterNew:input_type -> user.RegisterRequestRegisterNew + 1, // 1: user.UserServiceNew.RegisterNew:output_type -> user.RegisterResponseRegisterNew + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_auth_auth_proto_init() } +func file_auth_auth_proto_init() { + if File_auth_auth_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_auth_auth_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RegisterRequestRegisterNew); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_auth_auth_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RegisterResponseRegisterNew); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_auth_auth_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_auth_auth_proto_goTypes, + DependencyIndexes: file_auth_auth_proto_depIdxs, + MessageInfos: file_auth_auth_proto_msgTypes, + }.Build() + File_auth_auth_proto = out.File + file_auth_auth_proto_rawDesc = nil + file_auth_auth_proto_goTypes = nil + file_auth_auth_proto_depIdxs = nil +} diff --git a/pb/auth/auth.pb.gw.go b/pb/auth/auth.pb.gw.go new file mode 100644 index 0000000..8d2be19 --- /dev/null +++ b/pb/auth/auth.pb.gw.go @@ -0,0 +1,163 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: auth/auth.proto + +/* +Package user is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package user + +import ( + "context" + "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 +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = metadata.Join + +func request_UserServiceNew_RegisterNew_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceNewClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq RegisterRequestRegisterNew + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.RegisterNew(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_UserServiceNew_RegisterNew_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceNewServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq RegisterRequestRegisterNew + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.RegisterNew(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterUserServiceNewHandlerServer registers the http handlers for service UserServiceNew to "mux". +// UnaryRPC :call UserServiceNewServer 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 RegisterUserServiceNewHandlerFromEndpoint instead. +func RegisterUserServiceNewHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServiceNewServer) error { + + mux.Handle("POST", pattern_UserServiceNew_RegisterNew_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) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/user.UserServiceNew/RegisterNew", runtime.WithHTTPPathPattern("/v1/user/register")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UserServiceNew_RegisterNew_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_UserServiceNew_RegisterNew_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterUserServiceNewHandlerFromEndpoint is same as RegisterUserServiceNewHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterUserServiceNewHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.DialContext(ctx, endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterUserServiceNewHandler(ctx, mux, conn) +} + +// RegisterUserServiceNewHandler registers the http handlers for service UserServiceNew to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterUserServiceNewHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterUserServiceNewHandlerClient(ctx, mux, NewUserServiceNewClient(conn)) +} + +// RegisterUserServiceNewHandlerClient registers the http handlers for service UserServiceNew +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserServiceNewClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserServiceNewClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "UserServiceNewClient" to call the correct interceptors. +func RegisterUserServiceNewHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserServiceNewClient) error { + + mux.Handle("POST", pattern_UserServiceNew_RegisterNew_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) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/user.UserServiceNew/RegisterNew", runtime.WithHTTPPathPattern("/v1/user/register")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UserServiceNew_RegisterNew_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_UserServiceNew_RegisterNew_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_UserServiceNew_RegisterNew_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "user", "register"}, "")) +) + +var ( + forward_UserServiceNew_RegisterNew_0 = runtime.ForwardResponseMessage +) diff --git a/pb/auth/auth.swagger.json b/pb/auth/auth.swagger.json new file mode 100644 index 0000000..365beed --- /dev/null +++ b/pb/auth/auth.swagger.json @@ -0,0 +1,97 @@ +{ + "swagger": "2.0", + "info": { + "title": "auth/auth.proto", + "version": "version not set" + }, + "tags": [ + { + "name": "UserServiceNew" + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/v1/user/register": { + "post": { + "summary": "用户注册", + "operationId": "UserServiceNew_RegisterNew", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/userRegisterResponseRegisterNew" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/userRegisterRequestRegisterNew" + } + } + ], + "tags": [ + "UserServiceNew" + ] + } + } + }, + "definitions": { + "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" + } + } + } + }, + "userRegisterRequestRegisterNew": { + "type": "object", + "properties": { + "UserName": { + "type": "string" + }, + "Avatar": { + "type": "string" + } + } + }, + "userRegisterResponseRegisterNew": { + "type": "object" + } + } +} diff --git a/pb/auth/auth_grpc.pb.go b/pb/auth/auth_grpc.pb.go new file mode 100644 index 0000000..f466956 --- /dev/null +++ b/pb/auth/auth_grpc.pb.go @@ -0,0 +1,107 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc (unknown) +// source: auth/auth.proto + +package user + +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.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// UserServiceNewClient is the client API for UserServiceNew 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 UserServiceNewClient interface { + // 用户注册 + RegisterNew(ctx context.Context, in *RegisterRequestRegisterNew, opts ...grpc.CallOption) (*RegisterResponseRegisterNew, error) +} + +type userServiceNewClient struct { + cc grpc.ClientConnInterface +} + +func NewUserServiceNewClient(cc grpc.ClientConnInterface) UserServiceNewClient { + return &userServiceNewClient{cc} +} + +func (c *userServiceNewClient) RegisterNew(ctx context.Context, in *RegisterRequestRegisterNew, opts ...grpc.CallOption) (*RegisterResponseRegisterNew, error) { + out := new(RegisterResponseRegisterNew) + err := c.cc.Invoke(ctx, "/user.UserServiceNew/RegisterNew", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// UserServiceNewServer is the server API for UserServiceNew service. +// All implementations must embed UnimplementedUserServiceNewServer +// for forward compatibility +type UserServiceNewServer interface { + // 用户注册 + RegisterNew(context.Context, *RegisterRequestRegisterNew) (*RegisterResponseRegisterNew, error) + mustEmbedUnimplementedUserServiceNewServer() +} + +// UnimplementedUserServiceNewServer must be embedded to have forward compatible implementations. +type UnimplementedUserServiceNewServer struct { +} + +func (UnimplementedUserServiceNewServer) RegisterNew(context.Context, *RegisterRequestRegisterNew) (*RegisterResponseRegisterNew, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterNew not implemented") +} +func (UnimplementedUserServiceNewServer) mustEmbedUnimplementedUserServiceNewServer() {} + +// UnsafeUserServiceNewServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to UserServiceNewServer will +// result in compilation errors. +type UnsafeUserServiceNewServer interface { + mustEmbedUnimplementedUserServiceNewServer() +} + +func RegisterUserServiceNewServer(s grpc.ServiceRegistrar, srv UserServiceNewServer) { + s.RegisterService(&UserServiceNew_ServiceDesc, srv) +} + +func _UserServiceNew_RegisterNew_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RegisterRequestRegisterNew) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceNewServer).RegisterNew(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/user.UserServiceNew/RegisterNew", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceNewServer).RegisterNew(ctx, req.(*RegisterRequestRegisterNew)) + } + return interceptor(ctx, in, info, handler) +} + +// UserServiceNew_ServiceDesc is the grpc.ServiceDesc for UserServiceNew service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var UserServiceNew_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "user.UserServiceNew", + HandlerType: (*UserServiceNewServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterNew", + Handler: _UserServiceNew_RegisterNew_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "auth/auth.proto", +} diff --git a/gen/proto/user.pb.go b/pb/user/user.pb.go similarity index 65% rename from gen/proto/user.pb.go rename to pb/user/user.pb.go index 3598ca9..b2f1585 100644 --- a/gen/proto/user.pb.go +++ b/pb/user/user.pb.go @@ -2,7 +2,7 @@ // versions: // protoc-gen-go v1.28.1 // protoc (unknown) -// source: proto/user.proto +// source: user/user.proto package user @@ -33,7 +33,7 @@ type RegisterRequest struct { func (x *RegisterRequest) Reset() { *x = RegisterRequest{} if protoimpl.UnsafeEnabled { - mi := &file_proto_user_proto_msgTypes[0] + mi := &file_user_user_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -46,7 +46,7 @@ func (x *RegisterRequest) String() string { func (*RegisterRequest) ProtoMessage() {} func (x *RegisterRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[0] + mi := &file_user_user_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -59,7 +59,7 @@ func (x *RegisterRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead. func (*RegisterRequest) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{0} + return file_user_user_proto_rawDescGZIP(), []int{0} } func (x *RegisterRequest) GetUserName() string { @@ -85,7 +85,7 @@ type RegisterResponse struct { func (x *RegisterResponse) Reset() { *x = RegisterResponse{} if protoimpl.UnsafeEnabled { - mi := &file_proto_user_proto_msgTypes[1] + mi := &file_user_user_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -98,7 +98,7 @@ func (x *RegisterResponse) String() string { func (*RegisterResponse) ProtoMessage() {} func (x *RegisterResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[1] + mi := &file_user_user_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -111,7 +111,7 @@ func (x *RegisterResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead. func (*RegisterResponse) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{1} + return file_user_user_proto_rawDescGZIP(), []int{1} } // 扫码登录 @@ -126,7 +126,7 @@ type LoginRequest struct { func (x *LoginRequest) Reset() { *x = LoginRequest{} if protoimpl.UnsafeEnabled { - mi := &file_proto_user_proto_msgTypes[2] + mi := &file_user_user_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -139,7 +139,7 @@ func (x *LoginRequest) String() string { func (*LoginRequest) ProtoMessage() {} func (x *LoginRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[2] + mi := &file_user_user_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -152,7 +152,7 @@ func (x *LoginRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. func (*LoginRequest) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{2} + return file_user_user_proto_rawDescGZIP(), []int{2} } func (x *LoginRequest) GetCode() string { @@ -174,7 +174,7 @@ type LoginResponse struct { func (x *LoginResponse) Reset() { *x = LoginResponse{} if protoimpl.UnsafeEnabled { - mi := &file_proto_user_proto_msgTypes[3] + mi := &file_user_user_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -187,7 +187,7 @@ func (x *LoginResponse) String() string { func (*LoginResponse) ProtoMessage() {} func (x *LoginResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[3] + mi := &file_user_user_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -200,7 +200,7 @@ func (x *LoginResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. func (*LoginResponse) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{3} + return file_user_user_proto_rawDescGZIP(), []int{3} } func (x *LoginResponse) GetToken() string { @@ -228,7 +228,7 @@ type GetUserInfoRequest struct { func (x *GetUserInfoRequest) Reset() { *x = GetUserInfoRequest{} if protoimpl.UnsafeEnabled { - mi := &file_proto_user_proto_msgTypes[4] + mi := &file_user_user_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -241,7 +241,7 @@ func (x *GetUserInfoRequest) String() string { func (*GetUserInfoRequest) ProtoMessage() {} func (x *GetUserInfoRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[4] + mi := &file_user_user_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -254,7 +254,7 @@ func (x *GetUserInfoRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserInfoRequest.ProtoReflect.Descriptor instead. func (*GetUserInfoRequest) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{4} + return file_user_user_proto_rawDescGZIP(), []int{4} } func (x *GetUserInfoRequest) GetId() string { @@ -273,7 +273,7 @@ type GetUserInfoResponse struct { func (x *GetUserInfoResponse) Reset() { *x = GetUserInfoResponse{} if protoimpl.UnsafeEnabled { - mi := &file_proto_user_proto_msgTypes[5] + mi := &file_user_user_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -286,7 +286,7 @@ func (x *GetUserInfoResponse) String() string { func (*GetUserInfoResponse) ProtoMessage() {} func (x *GetUserInfoResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[5] + mi := &file_user_user_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -299,7 +299,7 @@ func (x *GetUserInfoResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserInfoResponse.ProtoReflect.Descriptor instead. func (*GetUserInfoResponse) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{5} + return file_user_user_proto_rawDescGZIP(), []int{5} } type UpdateUserInfoRequest struct { @@ -313,7 +313,7 @@ type UpdateUserInfoRequest struct { func (x *UpdateUserInfoRequest) Reset() { *x = UpdateUserInfoRequest{} if protoimpl.UnsafeEnabled { - mi := &file_proto_user_proto_msgTypes[6] + mi := &file_user_user_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -326,7 +326,7 @@ func (x *UpdateUserInfoRequest) String() string { func (*UpdateUserInfoRequest) ProtoMessage() {} func (x *UpdateUserInfoRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[6] + mi := &file_user_user_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -339,7 +339,7 @@ func (x *UpdateUserInfoRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateUserInfoRequest.ProtoReflect.Descriptor instead. func (*UpdateUserInfoRequest) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{6} + return file_user_user_proto_rawDescGZIP(), []int{6} } func (x *UpdateUserInfoRequest) GetId() string { @@ -358,7 +358,7 @@ type UpdateUserInfoResponse struct { func (x *UpdateUserInfoResponse) Reset() { *x = UpdateUserInfoResponse{} if protoimpl.UnsafeEnabled { - mi := &file_proto_user_proto_msgTypes[7] + mi := &file_user_user_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -371,7 +371,7 @@ func (x *UpdateUserInfoResponse) String() string { func (*UpdateUserInfoResponse) ProtoMessage() {} func (x *UpdateUserInfoResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[7] + mi := &file_user_user_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -384,7 +384,7 @@ func (x *UpdateUserInfoResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateUserInfoResponse.ProtoReflect.Descriptor instead. func (*UpdateUserInfoResponse) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{7} + return file_user_user_proto_rawDescGZIP(), []int{7} } type DeleteUserRequest struct { @@ -398,7 +398,7 @@ type DeleteUserRequest struct { func (x *DeleteUserRequest) Reset() { *x = DeleteUserRequest{} if protoimpl.UnsafeEnabled { - mi := &file_proto_user_proto_msgTypes[8] + mi := &file_user_user_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -411,7 +411,7 @@ func (x *DeleteUserRequest) String() string { func (*DeleteUserRequest) ProtoMessage() {} func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[8] + mi := &file_user_user_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -424,7 +424,7 @@ func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteUserRequest.ProtoReflect.Descriptor instead. func (*DeleteUserRequest) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{8} + return file_user_user_proto_rawDescGZIP(), []int{8} } func (x *DeleteUserRequest) GetId() string { @@ -443,7 +443,7 @@ type DeleteUserResponse struct { func (x *DeleteUserResponse) Reset() { *x = DeleteUserResponse{} if protoimpl.UnsafeEnabled { - mi := &file_proto_user_proto_msgTypes[9] + mi := &file_user_user_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -456,7 +456,7 @@ func (x *DeleteUserResponse) String() string { func (*DeleteUserResponse) ProtoMessage() {} func (x *DeleteUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[9] + mi := &file_user_user_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -469,7 +469,7 @@ func (x *DeleteUserResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteUserResponse.ProtoReflect.Descriptor instead. func (*DeleteUserResponse) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{9} + return file_user_user_proto_rawDescGZIP(), []int{9} } type ListUserRequest struct { @@ -484,7 +484,7 @@ type ListUserRequest struct { func (x *ListUserRequest) Reset() { *x = ListUserRequest{} if protoimpl.UnsafeEnabled { - mi := &file_proto_user_proto_msgTypes[10] + mi := &file_user_user_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -497,7 +497,7 @@ func (x *ListUserRequest) String() string { func (*ListUserRequest) ProtoMessage() {} func (x *ListUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[10] + mi := &file_user_user_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -510,7 +510,7 @@ func (x *ListUserRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListUserRequest.ProtoReflect.Descriptor instead. func (*ListUserRequest) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{10} + return file_user_user_proto_rawDescGZIP(), []int{10} } func (x *ListUserRequest) GetPage() int32 { @@ -536,7 +536,7 @@ type ListUserResponse struct { func (x *ListUserResponse) Reset() { *x = ListUserResponse{} if protoimpl.UnsafeEnabled { - mi := &file_proto_user_proto_msgTypes[11] + mi := &file_user_user_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -549,7 +549,7 @@ func (x *ListUserResponse) String() string { func (*ListUserResponse) ProtoMessage() {} func (x *ListUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[11] + mi := &file_user_user_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -562,95 +562,95 @@ func (x *ListUserResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListUserResponse.ProtoReflect.Descriptor instead. func (*ListUserResponse) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{11} + return file_user_user_proto_rawDescGZIP(), []int{11} } -var File_proto_user_proto protoreflect.FileDescriptor +var File_user_user_proto protoreflect.FileDescriptor -var file_proto_user_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73, 0x65, 0x72, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x45, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x55, 0x73, 0x65, - 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x55, 0x73, 0x65, - 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x22, 0x12, 0x0a, - 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x22, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x3b, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, 0x0a, 0x05, - 0x4f, 0x72, 0x67, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4f, 0x72, 0x67, - 0x69, 0x64, 0x22, 0x24, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x55, - 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x27, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x18, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x23, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x14, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x42, 0x0a, - 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, - 0x70, 0x61, 0x67, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, - 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, - 0x65, 0x22, 0x12, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x94, 0x04, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x57, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, - 0x72, 0x12, 0x15, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, +var file_user_user_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x04, 0x75, 0x73, 0x65, 0x72, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x45, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, + 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x55, 0x73, 0x65, 0x72, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x22, 0x12, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x3a, 0x01, 0x2a, 0x22, 0x11, 0x2f, 0x76, 0x31, - 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x4b, - 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x12, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, - 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x75, 0x73, - 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x3a, 0x01, 0x2a, 0x22, 0x0e, 0x2f, 0x76, 0x31, - 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x59, 0x0a, 0x0b, 0x47, - 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x2e, 0x75, 0x73, 0x65, - 0x72, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x55, - 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x12, 0x0d, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, - 0x72, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x64, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1b, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x1a, 0x0f, 0x2f, 0x76, 0x31, - 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x51, 0x0a, 0x0a, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x17, 0x2e, 0x75, 0x73, 0x65, - 0x72, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x10, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x2a, 0x08, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x12, - 0x4b, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x75, 0x73, - 0x65, 0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x10, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x42, 0x08, 0x5a, 0x06, - 0x2e, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0x22, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x43, 0x6f, 0x64, 0x65, 0x22, 0x3b, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x4f, + 0x72, 0x67, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4f, 0x72, 0x67, 0x69, + 0x64, 0x22, 0x24, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x55, 0x73, + 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x27, + 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x18, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x23, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x14, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x42, 0x0a, 0x0f, + 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, + 0x61, 0x67, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, + 0x22, 0x12, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x94, 0x04, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x57, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x12, 0x15, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x3a, 0x01, 0x2a, 0x22, 0x11, 0x2f, 0x76, 0x31, 0x2f, + 0x75, 0x73, 0x65, 0x72, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x4b, 0x0a, + 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x12, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x6f, + 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x75, 0x73, 0x65, + 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x3a, 0x01, 0x2a, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, + 0x75, 0x73, 0x65, 0x72, 0x2f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x59, 0x0a, 0x0b, 0x47, 0x65, + 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x2e, 0x75, 0x73, 0x65, 0x72, + 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, + 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x15, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x12, 0x0d, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, + 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x64, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, + 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1b, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x1a, 0x0f, 0x2f, 0x76, 0x31, 0x2f, + 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x51, 0x0a, 0x0a, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x17, 0x2e, 0x75, 0x73, 0x65, 0x72, + 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x10, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x0a, 0x2a, 0x08, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x12, 0x4b, + 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x75, 0x73, 0x65, + 0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x16, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x10, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x0a, 0x12, 0x08, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x42, 0x08, 0x5a, 0x06, 0x2e, + 0x3b, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_proto_user_proto_rawDescOnce sync.Once - file_proto_user_proto_rawDescData = file_proto_user_proto_rawDesc + file_user_user_proto_rawDescOnce sync.Once + file_user_user_proto_rawDescData = file_user_user_proto_rawDesc ) -func file_proto_user_proto_rawDescGZIP() []byte { - file_proto_user_proto_rawDescOnce.Do(func() { - file_proto_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_user_proto_rawDescData) +func file_user_user_proto_rawDescGZIP() []byte { + file_user_user_proto_rawDescOnce.Do(func() { + file_user_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_user_proto_rawDescData) }) - return file_proto_user_proto_rawDescData + return file_user_user_proto_rawDescData } -var file_proto_user_proto_msgTypes = make([]protoimpl.MessageInfo, 12) -var file_proto_user_proto_goTypes = []interface{}{ +var file_user_user_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_user_user_proto_goTypes = []interface{}{ (*RegisterRequest)(nil), // 0: user.RegisterRequest (*RegisterResponse)(nil), // 1: user.RegisterResponse (*LoginRequest)(nil), // 2: user.LoginRequest @@ -664,7 +664,7 @@ var file_proto_user_proto_goTypes = []interface{}{ (*ListUserRequest)(nil), // 10: user.ListUserRequest (*ListUserResponse)(nil), // 11: user.ListUserResponse } -var file_proto_user_proto_depIdxs = []int32{ +var file_user_user_proto_depIdxs = []int32{ 0, // 0: user.UserService.Register:input_type -> user.RegisterRequest 2, // 1: user.UserService.Login:input_type -> user.LoginRequest 4, // 2: user.UserService.GetUserInfo:input_type -> user.GetUserInfoRequest @@ -684,13 +684,13 @@ var file_proto_user_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for field type_name } -func init() { file_proto_user_proto_init() } -func file_proto_user_proto_init() { - if File_proto_user_proto != nil { +func init() { file_user_user_proto_init() } +func file_user_user_proto_init() { + if File_user_user_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_proto_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_user_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RegisterRequest); i { case 0: return &v.state @@ -702,7 +702,7 @@ func file_proto_user_proto_init() { return nil } } - file_proto_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_user_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RegisterResponse); i { case 0: return &v.state @@ -714,7 +714,7 @@ func file_proto_user_proto_init() { return nil } } - file_proto_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_user_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*LoginRequest); i { case 0: return &v.state @@ -726,7 +726,7 @@ func file_proto_user_proto_init() { return nil } } - file_proto_user_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_user_user_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*LoginResponse); i { case 0: return &v.state @@ -738,7 +738,7 @@ func file_proto_user_proto_init() { return nil } } - file_proto_user_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_user_user_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetUserInfoRequest); i { case 0: return &v.state @@ -750,7 +750,7 @@ func file_proto_user_proto_init() { return nil } } - file_proto_user_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_user_user_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetUserInfoResponse); i { case 0: return &v.state @@ -762,7 +762,7 @@ func file_proto_user_proto_init() { return nil } } - file_proto_user_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_user_user_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UpdateUserInfoRequest); i { case 0: return &v.state @@ -774,7 +774,7 @@ func file_proto_user_proto_init() { return nil } } - file_proto_user_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_user_user_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UpdateUserInfoResponse); i { case 0: return &v.state @@ -786,7 +786,7 @@ func file_proto_user_proto_init() { return nil } } - file_proto_user_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_user_user_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeleteUserRequest); i { case 0: return &v.state @@ -798,7 +798,7 @@ func file_proto_user_proto_init() { return nil } } - file_proto_user_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_user_user_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeleteUserResponse); i { case 0: return &v.state @@ -810,7 +810,7 @@ func file_proto_user_proto_init() { return nil } } - file_proto_user_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_user_user_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListUserRequest); i { case 0: return &v.state @@ -822,7 +822,7 @@ func file_proto_user_proto_init() { return nil } } - file_proto_user_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_user_user_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListUserResponse); i { case 0: return &v.state @@ -839,18 +839,18 @@ func file_proto_user_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_proto_user_proto_rawDesc, + RawDescriptor: file_user_user_proto_rawDesc, NumEnums: 0, NumMessages: 12, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_proto_user_proto_goTypes, - DependencyIndexes: file_proto_user_proto_depIdxs, - MessageInfos: file_proto_user_proto_msgTypes, + GoTypes: file_user_user_proto_goTypes, + DependencyIndexes: file_user_user_proto_depIdxs, + MessageInfos: file_user_user_proto_msgTypes, }.Build() - File_proto_user_proto = out.File - file_proto_user_proto_rawDesc = nil - file_proto_user_proto_goTypes = nil - file_proto_user_proto_depIdxs = nil + File_user_user_proto = out.File + file_user_user_proto_rawDesc = nil + file_user_user_proto_goTypes = nil + file_user_user_proto_depIdxs = nil } diff --git a/gen/proto/user.pb.gw.go b/pb/user/user.pb.gw.go similarity index 99% rename from gen/proto/user.pb.gw.go rename to pb/user/user.pb.gw.go index a400be0..1ea6d6b 100644 --- a/gen/proto/user.pb.gw.go +++ b/pb/user/user.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: proto/user.proto +// source: user/user.proto /* Package user is a reverse proxy. diff --git a/gen/proto/user.swagger.json b/pb/user/user.swagger.json similarity index 99% rename from gen/proto/user.swagger.json rename to pb/user/user.swagger.json index e1b1576..7027972 100644 --- a/gen/proto/user.swagger.json +++ b/pb/user/user.swagger.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "title": "proto/user.proto", + "title": "user/user.proto", "version": "version not set" }, "tags": [ diff --git a/gen/proto/user_grpc.pb.go b/pb/user/user_grpc.pb.go similarity index 99% rename from gen/proto/user_grpc.pb.go rename to pb/user/user_grpc.pb.go index b165f11..9a6a36c 100644 --- a/gen/proto/user_grpc.pb.go +++ b/pb/user/user_grpc.pb.go @@ -2,7 +2,7 @@ // versions: // - protoc-gen-go-grpc v1.2.0 // - protoc (unknown) -// source: proto/user.proto +// source: user/user.proto package user @@ -293,5 +293,5 @@ var UserService_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "proto/user.proto", + Metadata: "user/user.proto", } diff --git a/redis/redis.go b/redis/redis.go deleted file mode 100644 index ae5f619..0000000 --- a/redis/redis.go +++ /dev/null @@ -1,177 +0,0 @@ -package redis - -import ( - "encoding/json" - "time" - - redigo "github.com/gomodule/redigo/redis" -) - -var pool *redigo.Pool - -// Config 配置 -type Config struct { - Host string `yml:"host" json:"host"` - Password string `yml:"password" json:"password"` - Database int `yml:"database" json:"database"` - MaxIdle int `yml:"max_idle" json:"max_idle"` - MaxActive int `yml:"max_active" json:"max_active"` - IdleTimeout int `yml:"idle_timeout" json:"idle_timeout"` //second -} - -// Init init -func Init(opts *Config) error { - if opts == nil { - opts = &Config{} - } - - if opts.Host == "" { - opts.Host = "127.0.0.1:6379" - } - if opts.MaxIdle == 0 { - opts.MaxIdle = 1 - } - if opts.MaxActive == 0 { - opts.MaxActive = 10 - } - if opts.IdleTimeout == 0 { - opts.IdleTimeout = 600 - } - - pool = &redigo.Pool{ - MaxActive: opts.MaxActive, - MaxIdle: opts.MaxIdle, - IdleTimeout: time.Second * time.Duration(opts.IdleTimeout), - Dial: func() (redigo.Conn, error) { - return redigo.Dial("tcp", opts.Host, - redigo.DialDatabase(opts.Database), - redigo.DialPassword(opts.Password), - ) - }, - TestOnBorrow: func(conn redigo.Conn, t time.Time) error { - if time.Since(t) < time.Minute { - return nil - } - _, err := conn.Do("PING") - return err - }, - } - return nil -} - -// GetBytes 获取一个字节数组值 -func GetBytes(key *string) (*[]byte, error) { - conn := pool.Get() - defer conn.Close() - - data, err := redigo.Bytes(conn.Do("GET", *key)) - return &data, err -} - -// Get 获取一个值 -func Get(key string) interface{} { - conn := pool.Get() - defer conn.Close() - - var data []byte - var err error - if data, err = redigo.Bytes(conn.Do("GET", key)); err != nil { - return nil - } - var reply interface{} - if err = json.Unmarshal(data, &reply); err != nil { - return nil - } - - return reply -} - -// 集合Set增加元素 -func SetAdd(key string, data ...interface{}) error { - conn := pool.Get() - defer conn.Close() - var err error - for _, d := range data { - _, e := conn.Do("SADD", key, d) - if e != nil { - err = e - break - } - } - return err -} - -// 集合Set删除元素 -func SetRem(key string, data ...interface{}) error { - conn := pool.Get() - defer conn.Close() - - var err error - for _, d := range data { - _, e := conn.Do("SREM", key, d) - if e != nil { - err = e - break - } - } - - return err -} - -// 集合Set判断是否存在成员member,结果.(int64)==1表示存在 -func SetIsMember(key string, member interface{}) (interface{}, error) { - conn := pool.Get() - defer conn.Close() - - return conn.Do("SISMEMBER", key, member) -} - -// 设置一个值 -func Set(key string, val interface{}, timeout time.Duration) error { - data, err := json.Marshal(val) - if err != nil { - return err - } - return SetBytes(&key, &data, timeout) -} - -func SetBytes(key *string, data *[]byte, timeout time.Duration) error { - conn := pool.Get() - defer conn.Close() - - _, err := conn.Do("SETEX", *key, int64(timeout/time.Second), *data) - return err -} - -// IsExist 判断key是否存在 -func IsExist(key string) bool { - conn := pool.Get() - defer conn.Close() - - a, _ := conn.Do("EXISTS", key) - i := a.(int64) - return i > 0 -} - -// Delete 删除 -func Delete(key string) error { - conn := pool.Get() - defer conn.Close() - - if _, err := conn.Do("DEL", key); err != nil { - return err - } - - return nil -} - -// Expire 失效时间配置 -func Expire(key string, t int64) error { - conn := pool.Get() - defer conn.Close() - - if _, err := conn.Do("expire", key, t); err != nil { - return err - } - return nil -} diff --git a/redis/redis_test.go b/redis/redis_test.go deleted file mode 100644 index a5f25a9..0000000 --- a/redis/redis_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package redis - -import ( - "fmt" - "testing" -) - -func TestRedis(t *testing.T) { - Init(&Config{ - Host: "192.168.0.254:6379", - Password: "", - Database: 0, - MaxIdle: 3, - MaxActive: 10, - IdleTimeout: 600, - }) - - err := SetAdd("aaa", "aaa", "aa1", "aa2", "aa4", "aa3") - if err != nil { - t.Fatal(err) - } - Expire("aaa", 100) - ret, err := SetIsMember("aaa", "aa1") - if err != nil { - t.Fatal(err) - } - fmt.Println(ret, ret.(int64)) - err = SetRem("aaa", "aa2", "aa3") - if err != nil { - t.Fatal(err) - } - err = Delete("aaa") - if err != nil { - t.Fatal(err) - } -} diff --git a/proto/user.proto b/user/user.proto similarity index 98% rename from proto/user.proto rename to user/user.proto index ff1e8a6..4f645f5 100644 --- a/proto/user.proto +++ b/user/user.proto @@ -4,7 +4,7 @@ import "google/api/annotations.proto"; package user; -option go_package="./user"; +option go_package=".;user"; service UserService { //用户注册 diff --git a/utils/snowflake.go b/utils/snowflake.go deleted file mode 100644 index 33aaa86..0000000 --- a/utils/snowflake.go +++ /dev/null @@ -1,42 +0,0 @@ -package utils - -import ( - "errors" - "time" - - sf "github.com/bwmarrin/snowflake" -) - -const ( - _dafaultStartTime = "2023-12-31" // 默认开始时间 -) - -var node *sf.Node - -// Init 雪花算法组件初始化,正常应该把雪花算法当成一个独立的服务部署 -// startTime 开始时间 -// machineID 机器id -func Init(startTime string, machineID int64) (err error) { - if machineID < 0 { - return errors.New("snowflake need machineID") - } - if len(startTime) == 0 { - startTime = _dafaultStartTime - } - var st time.Time - st, err = time.Parse("2006-01-02", startTime) - if err != nil { - return - } - sf.Epoch = st.UnixNano() / 1000000 // 时间戳的开始时间,默认从1970年开始计算 - node, err = sf.NewNode(machineID) // 机器编号,最多1024 - return -} - -func GenID() int64 { - return node.Generate().Int64() -} - -func GenIDStr() string { - return node.Generate().String() -} diff --git a/utils/token.go b/utils/token.go deleted file mode 100644 index ac8bdbc..0000000 --- a/utils/token.go +++ /dev/null @@ -1,80 +0,0 @@ -package utils - -import ( - "errors" - "fmt" - "reflect" - "strings" - - "github.com/gin-gonic/gin" - "github.com/go-playground/locales/zh" - ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" - zhtrans "github.com/go-playground/validator/v10/translations/zh" - "github.com/google/uuid" -) - -// 生成用户token -func NewUserToken() string { - id := uuid.Must(uuid.NewRandom()).String() - return strings.ReplaceAll(id, "-", "") -} - -// NewRequestID 新请求ID生成 -func NewRequestID(c *gin.Context) string { - if c == nil { - return uuid.Must(uuid.NewRandom()).String() - } - reqid := c.Request.Header.Get("requestid") - if reqid == "" { - reqid = uuid.Must(uuid.NewRandom()).String() - } - return reqid -} - -// 新项目ID生成 -func NewProjectID() string { - id := strings.ReplaceAll(uuid.Must(uuid.NewRandom()).String(), "-", "") - return id[6:] -} - -func NewUserID() string { - id := strings.ReplaceAll(uuid.Must(uuid.NewRandom()).String(), "-", "") - return id[4:] -} - -// NewGroupID 新组ID -func NewGroupID() string { - id := strings.ReplaceAll(uuid.Must(uuid.NewRandom()).String(), "-", "") - return id[2:] -} - -func init() { - validate = validator.New() -} - -var validate *validator.Validate - -func ValidateError(req interface{}) error { - zh := zh.New() - uni := ut.New(zh) - trans, _ := uni.GetTranslator("zh") - - validate.RegisterTagNameFunc(func(field reflect.StructField) string { - return field.Tag.Get("label") - }) - - e := zhtrans.RegisterDefaultTranslations(validate, trans) - if e != nil { - return errors.New("翻译器注册失败") - } - - err := validate.Struct(req) - - if err != nil { - for _, err := range err.(validator.ValidationErrors) { - return fmt.Errorf(err.Translate(trans)) - } - } - return nil -}