modify user

master
jager 3 years ago
parent bbc1424b94
commit f8f203851a

@ -13,8 +13,6 @@
package main package main
import ( import (
"github.com/jageros/hawox/mysql"
"github.com/jageros/hawox/redis"
"idata/internal/api" "idata/internal/api"
"idata/internal/service/soup" "idata/internal/service/soup"
"idata/internal/service/user" "idata/internal/service/user"
@ -22,6 +20,8 @@ import (
"github.com/jageros/hawox/flags" "github.com/jageros/hawox/flags"
"github.com/jageros/hawox/httpx" "github.com/jageros/hawox/httpx"
"github.com/jageros/hawox/logx" "github.com/jageros/hawox/logx"
"github.com/jageros/hawox/mysql"
"github.com/jageros/hawox/redis"
) )
const appName = "idata" const appName = "idata"

@ -0,0 +1,32 @@
server:
id: 1
mode: "debug" #release
log:
dir: "logs"
caller: true
request: true
stat: true
http:
ip: "0.0.0.0"
port: 8001
mysql:
addr: "gz-cynosdbmysql-grp-niaolcgt.sql.tencentcdb.com:26529"
user: "root"
password: "Hawtech^666"
database: "idata"
#mongo:
# addr: "127.0.0.1:27017"
# database: "attribute"
# user: "mongo-user"
# password: "mongo-password"
redis:
addrs: "127.0.0.1:7001;127.0.0.1:7002;127.0.0.1:7003;127.0.0.1:7004;127.0.0.1:7005;127.0.0.1:7006"
db: 0
# user: "redis-user"
# password: "redis-passwd"

@ -0,0 +1,51 @@
server:
id: 1
mode: "release"
frontend:
addr: "ws://testapi.gzjy-game.xyz/ws"
log:
dir: "logs"
caller: true
request: true
stat: false
http:
ip: "0.0.0.0"
port: 8001
rpc:
ip: "127.0.0.1"
port: 8081
mysql:
addr: "127.0.0.1:3306"
user: "root"
password: "QianYin@66"
database: "hawox"
mongo:
addr: "127.0.0.1:27017"
database: "attribute"
# user: "mongo-user"
# password: "mongo-password"
etcd:
addrs: "127.0.0.1:2379"
# user: "etcd-user"
# password: "etcd-password"
redis:
addrs: "127.0.0.1:7001;127.0.0.1:7002;127.0.0.1:7003;127.0.0.1:7004;127.0.0.1:7005;127.0.0.1:7006;127.0.0.1:7007"
db: 0
# user: "redis-user"
# password: "redis-passwd"
queue:
type: "kafka"
addrs: "127.0.0.1:9092"
#queue:
# type: "nsq"
# addrs: "127.0.0.1:4161"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -4,13 +4,15 @@ go 1.17
require ( require (
github.com/gin-gonic/gin v1.7.7 github.com/gin-gonic/gin v1.7.7
github.com/jageros/hawox v0.1.4 github.com/jageros/hawox v0.1.5
github.com/tal-tech/go-zero v1.2.1
) )
require ( require (
github.com/cespare/xxhash/v2 v2.1.1 // indirect github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/eapache/queue v1.1.0 // indirect github.com/eapache/queue v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/fsnotify/fsnotify v1.4.9 // indirect
@ -22,6 +24,7 @@ require (
github.com/go-redis/redis v6.15.7+incompatible // indirect github.com/go-redis/redis v6.15.7+incompatible // indirect
github.com/go-redis/redis/v8 v8.11.0 // indirect github.com/go-redis/redis/v8 v8.11.0 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/go-xorm/builder v0.3.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect github.com/golang/protobuf v1.5.2 // indirect
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
@ -35,6 +38,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect github.com/pelletier/go-toml v1.9.3 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/smartystreets/assertions v1.1.0 // indirect github.com/smartystreets/assertions v1.1.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/afero v1.6.0 // indirect github.com/spf13/afero v1.6.0 // indirect
@ -43,7 +47,6 @@ require (
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.8.1 // indirect github.com/spf13/viper v1.8.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect github.com/subosito/gotenv v1.2.0 // indirect
github.com/tal-tech/go-zero v1.2.1 // indirect
github.com/ugorji/go/codec v1.1.7 // indirect github.com/ugorji/go/codec v1.1.7 // indirect
github.com/xiaonanln/go-xnsyncutil v0.0.5 // indirect github.com/xiaonanln/go-xnsyncutil v0.0.5 // indirect
go.etcd.io/etcd/api/v3 v3.5.0 // indirect go.etcd.io/etcd/api/v3 v3.5.0 // indirect

@ -102,6 +102,7 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4=
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
@ -124,6 +125,7 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
@ -166,6 +168,7 @@ github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmC
github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs= github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs=
github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U= github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U=
github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY=
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
@ -204,7 +207,9 @@ github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-xorm/builder v0.3.4 h1:FxkeGB4Cggdw3tPwutLCpfjng2jugfkg6LDMrd/KsoY=
github.com/go-xorm/builder v0.3.4/go.mod h1:KxkQkNN1DpPKTedxXyTQcmH+rXfvk4LZ9SOOBoZBAxw= github.com/go-xorm/builder v0.3.4/go.mod h1:KxkQkNN1DpPKTedxXyTQcmH+rXfvk4LZ9SOOBoZBAxw=
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk8V3XHWUcJmYTh+ZnlHVyc+A4oZYS3Y=
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM= github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
@ -317,8 +322,8 @@ github.com/iancoleman/strcase v0.1.2/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5N
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/jageros/hawox v0.1.4 h1:8cAC0gNqKJtKBiOaeA3JTrZlbio++t1JGZOvU1zKZFY= github.com/jageros/hawox v0.1.5 h1:awUzBuOf4SbT/4TZ098MRXFKsFQ8LGDuONd3U4NfiDU=
github.com/jageros/hawox v0.1.4/go.mod h1:HUCwWfPlVFx6BpWHEZ7LG4KwTp/T2exNI2/kDNPkwm8= github.com/jageros/hawox v0.1.5/go.mod h1:SmP4sI64uIP4Cg8CwU1///5Gii2z0jcn+BHi9ajnyyg=
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM=
github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o=
@ -378,6 +383,7 @@ github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2y
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
@ -385,6 +391,7 @@ github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3N
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
@ -403,7 +410,7 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nosixtools/solarlunar v0.0.0-20200711032723-669c9e27ecc5/go.mod h1:LjhyrWzOLJ9l1azMoNr9iCvfNrHEREqvJHzSLQcD0/o= github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
github.com/nsqio/go-nsq v1.0.8/go.mod h1:vKq36oyeVXgsS5Q8YEO7WghqidAVXQlcFxzQbQTuDEY= github.com/nsqio/go-nsq v1.0.8/go.mod h1:vKq36oyeVXgsS5Q8YEO7WghqidAVXQlcFxzQbQTuDEY=
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
@ -456,6 +463,7 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=

@ -39,7 +39,7 @@ func auth(ctx *gin.Context) {
httpx.ErrInterrupt(ctx, errcode.InvalidParam) httpx.ErrInterrupt(ctx, errcode.InvalidParam)
return return
} }
if !user.Auth(secret) { if !user.Auth(uid, secret) {
httpx.ErrInterrupt(ctx, errcode.VerifyErr) httpx.ErrInterrupt(ctx, errcode.VerifyErr)
return return
} }

@ -22,7 +22,6 @@ var (
cacheUsersIdPrefix = "cache#users#id#" cacheUsersIdPrefix = "cache#users#id#"
cacheUsersOpenidPrefix = "cache#users#openid#" cacheUsersOpenidPrefix = "cache#users#openid#"
cacheUsersPhonePrefix = "cache#users#phone#" cacheUsersPhonePrefix = "cache#users#phone#"
cacheUsersSecretPrefix = "cache#users#secret#"
cacheUsersUidPrefix = "cache#users#uid#" cacheUsersUidPrefix = "cache#users#uid#"
) )
@ -32,7 +31,6 @@ type (
FindOne(id int64) (*Users, error) FindOne(id int64) (*Users, error)
FindOneByOpenid(openid string) (*Users, error) FindOneByOpenid(openid string) (*Users, error)
FindOneByPhone(phone string) (*Users, error) FindOneByPhone(phone string) (*Users, error)
FindOneBySecret(secret string) (*Users, error)
FindOneByUid(uid string) (*Users, error) FindOneByUid(uid string) (*Users, error)
Update(data Users) error Update(data Users) error
Delete(id int64) error Delete(id int64) error
@ -45,14 +43,15 @@ type (
Users struct { Users struct {
Id int64 `db:"id"` Id int64 `db:"id"`
Uid string `db:"uid"` // 用户ID Uid string `db:"uid"` // 用户ID
Openid string `db:"openid"` // 微信openid Openid string `db:"openid"` // 微信openid
Secret string `db:"secret"` // secret Secret string `db:"secret"` // secret
Phone string `db:"phone"` // 手机号 Phone string `db:"phone"` // 手机号
Avatar string `db:"avatar"` // 头像url Password string `db:"password"` // 密码
Name string `db:"name"` // 昵称 Avatar string `db:"avatar"` // 头像url
Gender int64 `db:"gender"` // 性别 Name string `db:"name"` // 昵称
Score int64 `db:"score"` // 金币数量 Gender int64 `db:"gender"` // 性别
Score int64 `db:"score"` // 金币数量
CreateTime time.Time `db:"create_time"` CreateTime time.Time `db:"create_time"`
UpdateTime time.Time `db:"update_time"` UpdateTime time.Time `db:"update_time"`
} }
@ -68,12 +67,11 @@ func NewUsersModel(conn sqlx.SqlConn, c cache.CacheConf) UsersModel {
func (m *defaultUsersModel) Insert(data Users) (sql.Result, error) { func (m *defaultUsersModel) Insert(data Users) (sql.Result, error) {
usersOpenidKey := fmt.Sprintf("%s%v", cacheUsersOpenidPrefix, data.Openid) usersOpenidKey := fmt.Sprintf("%s%v", cacheUsersOpenidPrefix, data.Openid)
usersPhoneKey := fmt.Sprintf("%s%v", cacheUsersPhonePrefix, data.Phone) usersPhoneKey := fmt.Sprintf("%s%v", cacheUsersPhonePrefix, data.Phone)
usersSecretKey := fmt.Sprintf("%s%v", cacheUsersSecretPrefix, data.Secret)
usersUidKey := fmt.Sprintf("%s%v", cacheUsersUidPrefix, data.Uid) usersUidKey := fmt.Sprintf("%s%v", cacheUsersUidPrefix, data.Uid)
ret, err := m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) { ret, err := m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) {
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, usersRowsExpectAutoSet) query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, usersRowsExpectAutoSet)
return conn.Exec(query, data.Uid, data.Openid, data.Secret, data.Phone, data.Avatar, data.Name, data.Gender, data.Score) return conn.Exec(query, data.Uid, data.Openid, data.Secret, data.Phone, data.Password, data.Avatar, data.Name, data.Gender, data.Score)
}, usersOpenidKey, usersPhoneKey, usersSecretKey, usersUidKey) }, usersOpenidKey, usersPhoneKey, usersUidKey)
return ret, err return ret, err
} }
@ -134,26 +132,6 @@ func (m *defaultUsersModel) FindOneByPhone(phone string) (*Users, error) {
} }
} }
func (m *defaultUsersModel) FindOneBySecret(secret string) (*Users, error) {
usersSecretKey := fmt.Sprintf("%s%v", cacheUsersSecretPrefix, secret)
var resp Users
err := m.QueryRowIndex(&resp, usersSecretKey, m.formatPrimary, func(conn sqlx.SqlConn, v interface{}) (i interface{}, e error) {
query := fmt.Sprintf("select %s from %s where `secret` = ? limit 1", usersRows, m.table)
if err := conn.QueryRow(&resp, query, secret); err != nil {
return nil, err
}
return resp.Id, nil
}, m.queryPrimary)
switch err {
case nil:
return &resp, nil
case sqlc.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultUsersModel) FindOneByUid(uid string) (*Users, error) { func (m *defaultUsersModel) FindOneByUid(uid string) (*Users, error) {
usersUidKey := fmt.Sprintf("%s%v", cacheUsersUidPrefix, uid) usersUidKey := fmt.Sprintf("%s%v", cacheUsersUidPrefix, uid)
var resp Users var resp Users
@ -175,15 +153,14 @@ func (m *defaultUsersModel) FindOneByUid(uid string) (*Users, error) {
} }
func (m *defaultUsersModel) Update(data Users) error { func (m *defaultUsersModel) Update(data Users) error {
usersUidKey := fmt.Sprintf("%s%v", cacheUsersUidPrefix, data.Uid)
usersIdKey := fmt.Sprintf("%s%v", cacheUsersIdPrefix, data.Id) usersIdKey := fmt.Sprintf("%s%v", cacheUsersIdPrefix, data.Id)
usersOpenidKey := fmt.Sprintf("%s%v", cacheUsersOpenidPrefix, data.Openid) usersOpenidKey := fmt.Sprintf("%s%v", cacheUsersOpenidPrefix, data.Openid)
usersPhoneKey := fmt.Sprintf("%s%v", cacheUsersPhonePrefix, data.Phone) usersPhoneKey := fmt.Sprintf("%s%v", cacheUsersPhonePrefix, data.Phone)
usersSecretKey := fmt.Sprintf("%s%v", cacheUsersSecretPrefix, data.Secret) usersUidKey := fmt.Sprintf("%s%v", cacheUsersUidPrefix, data.Uid)
_, err := m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) { _, err := m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) {
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, usersRowsWithPlaceHolder) query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, usersRowsWithPlaceHolder)
return conn.Exec(query, data.Uid, data.Openid, data.Secret, data.Phone, data.Avatar, data.Name, data.Gender, data.Score, data.Id) return conn.Exec(query, data.Uid, data.Openid, data.Secret, data.Phone, data.Password, data.Avatar, data.Name, data.Gender, data.Score, data.Id)
}, usersIdKey, usersOpenidKey, usersPhoneKey, usersSecretKey, usersUidKey) }, usersUidKey, usersIdKey, usersOpenidKey, usersPhoneKey)
return err return err
} }
@ -195,13 +172,12 @@ func (m *defaultUsersModel) Delete(id int64) error {
usersOpenidKey := fmt.Sprintf("%s%v", cacheUsersOpenidPrefix, data.Openid) usersOpenidKey := fmt.Sprintf("%s%v", cacheUsersOpenidPrefix, data.Openid)
usersPhoneKey := fmt.Sprintf("%s%v", cacheUsersPhonePrefix, data.Phone) usersPhoneKey := fmt.Sprintf("%s%v", cacheUsersPhonePrefix, data.Phone)
usersSecretKey := fmt.Sprintf("%s%v", cacheUsersSecretPrefix, data.Secret)
usersUidKey := fmt.Sprintf("%s%v", cacheUsersUidPrefix, data.Uid) usersUidKey := fmt.Sprintf("%s%v", cacheUsersUidPrefix, data.Uid)
usersIdKey := fmt.Sprintf("%s%v", cacheUsersIdPrefix, id) usersIdKey := fmt.Sprintf("%s%v", cacheUsersIdPrefix, id)
_, err = m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) { _, err = m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) {
query := fmt.Sprintf("delete from %s where `id` = ?", m.table) query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
return conn.Exec(query, id) return conn.Exec(query, id)
}, usersIdKey, usersOpenidKey, usersPhoneKey, usersSecretKey, usersUidKey) }, usersIdKey, usersOpenidKey, usersPhoneKey, usersUidKey)
return err return err
} }

@ -14,11 +14,64 @@ package user
import ( import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/jageros/hawox/errcode"
"github.com/jageros/hawox/httpx"
"github.com/jageros/hawox/jwt"
"github.com/jageros/hawox/logx"
"github.com/jageros/hawox/uuid"
"idata/internal/service/user/dao"
"idata/internal/types" "idata/internal/types"
"idata/internal/utils"
) )
func Register(ctx *gin.Context) { func Register(ctx *gin.Context) {
arg, ok := httpx.BindJsonArgs(ctx)
if !ok {
return
}
ph, ok1 := arg["phone"]
pwd, ok2 := arg["password"]
if !ok1 || !ok2 {
httpx.ErrInterrupt(ctx, errcode.InvalidParam)
return
}
phone := ph.(string)
password := pwd.(string)
logx.Infof("phone=%s pwd=%s", phone, password)
_, err := userModel.FindOneByPhone(phone)
if err == nil {
httpx.ErrInterrupt(ctx, errcode.New(1, "phone has registry"))
return
}
if err != dao.ErrNotFound {
httpx.ErrInterrupt(ctx, errcode.WithErrcode(2, err))
return
}
uid, err := uuid.NewRandNumStr("user")
if err != nil {
httpx.ErrInterrupt(ctx, errcode.WithErrcode(3, err))
return
}
err = RegistryUser(uid, func(u types.RWUser) {
u.SetPhone(phone)
u.SetSecret(utils.GenSecret(uid))
u.SetPassword(password)
})
if err != nil {
httpx.ErrInterrupt(ctx, errcode.WithErrcode(4, err))
return
}
token, err := jwt.GenerateToken(uid)
if err != nil {
httpx.ErrInterrupt(ctx, errcode.WithErrcode(5, err))
return
}
httpx.PkgMsgWrite(ctx, map[string]interface{}{"uid": uid, "token": token})
} }
func Login(ctx *gin.Context) { func Login(ctx *gin.Context) {

@ -14,6 +14,7 @@ package user
import ( import (
"fmt" "fmt"
"github.com/jageros/hawox/encrypt"
"github.com/jageros/hawox/errcode" "github.com/jageros/hawox/errcode"
"github.com/jageros/hawox/redis" "github.com/jageros/hawox/redis"
"github.com/tal-tech/go-zero/core/stores/cache" "github.com/tal-tech/go-zero/core/stores/cache"
@ -44,7 +45,7 @@ type user struct {
data *dao.Users data *dao.Users
} }
func newUser(uid, phone, secret string) (*user, error) { func newUser(uid string) (*user, error) {
uData, err := userModel.FindOneByUid(uid) uData, err := userModel.FindOneByUid(uid)
if err == nil { if err == nil {
return nil, errcode.New(5000, "uid exist") return nil, errcode.New(5000, "uid exist")
@ -57,7 +58,7 @@ func newUser(uid, phone, secret string) (*user, error) {
Uid: uid, Uid: uid,
Phone: uid, Phone: uid,
Openid: uid, Openid: uid,
Secret: secret, Secret: uid,
Name: fmt.Sprintf("U_%s", uid), Name: fmt.Sprintf("U_%s", uid),
} }
usr := userPool.Get().(user) usr := userPool.Get().(user)
@ -91,7 +92,7 @@ func OperateSync(uid string, f func(types.RWUser)) error {
f(u) f(u)
err = userModel.Update(*u.data) err = userModel.Update(*u.data)
} }
userPool.Put(u) userPool.Put(*u)
}) })
if err2 != nil { if err2 != nil {
return err2 return err2
@ -108,8 +109,21 @@ func Operate(uid string, f func(u types.RUser)) error {
return err return err
} }
func CreateUser(uid string, f func(u types.RWUser)) error { func RegistryUser(uid string, f func(u types.RWUser)) error {
newUser() var err error
err2 := redis.LockExec(uid, func(key string) {
var u *user
u, err = newUser(uid)
if err == nil {
f(u)
_, err = userModel.Insert(*u.data)
}
userPool.Put(*u)
})
if err2 != nil {
return err2
}
return err
} }
// ====== Types.RUser 实现 ====== // ====== Types.RUser 实现 ======
@ -184,4 +198,8 @@ func (u *user) SetScore(score int64) {
u.data.Score = score u.data.Score = score
} }
func (u *user) SetPassword(pwd string) {
u.data.Password = encrypt.Md5(pwd)
}
// ========== end ========== // ========== end ==========

@ -12,6 +12,7 @@ CREATE TABLE `users`
`openid` varchar(255) NOT NULL COMMENT '微信openid', `openid` varchar(255) NOT NULL COMMENT '微信openid',
`secret` varchar(255) NOT NULL COMMENT 'secret', `secret` varchar(255) NOT NULL COMMENT 'secret',
`phone` varchar(63) NOT NULL COMMENT '手机号', `phone` varchar(63) NOT NULL COMMENT '手机号',
`password` varchar(255) NOT NULL DEFAULT '' COMMENT '密码',
`avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '头像url', `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '头像url',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '昵称', `name` varchar(255) NOT NULL DEFAULT '' COMMENT '昵称',
`gender` int NOT NULL DEFAULT 0 COMMENT '性别', `gender` int NOT NULL DEFAULT 0 COMMENT '性别',
@ -21,8 +22,7 @@ CREATE TABLE `users`
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uid_unique` (`uid`) USING BTREE, UNIQUE KEY `uid_unique` (`uid`) USING BTREE,
UNIQUE KEY `phone_unique` (`phone`) USING BTREE, UNIQUE KEY `phone_unique` (`phone`) USING BTREE,
UNIQUE key `openid_unique` (`openid`) USING BTREE, UNIQUE key `openid_unique` (`openid`) USING BTREE
UNIQUE key `secret_unique` (`secret`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
AUTO_INCREMENT = 1 AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8mb4; DEFAULT CHARSET = utf8mb4;

@ -32,4 +32,5 @@ type RWUser interface {
SetAvatar(avatar string) SetAvatar(avatar string)
SetGender(gender int64) SetGender(gender int64)
SetScore(score int64) SetScore(score int64)
SetPassword(pwd string)
} }

Loading…
Cancel
Save