feat 奇怪的知识1.0.1
This commit is contained in:
2
go.mod
2
go.mod
@@ -3,7 +3,7 @@ module git.hlsq.asia/mmorpg/service-user
|
||||
go 1.23.1
|
||||
|
||||
require (
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260112082258-b1e7d33940d7
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260113014617-7812a3c669d7
|
||||
github.com/judwhite/go-svc v1.2.1
|
||||
google.golang.org/grpc v1.71.1
|
||||
gorm.io/gen v0.3.27
|
||||
|
||||
4
go.sum
4
go.sum
@@ -1,7 +1,7 @@
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260112082258-b1e7d33940d7 h1:C3quCA54dyFgmlCVgJXx+0rNqa+JZgGggdotbvHAsnA=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260112082258-b1e7d33940d7/go.mod h1:xv6m1I2jUA6mudKVznygpnzMoshBQarthHD1QnkW4qc=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260113014617-7812a3c669d7 h1:sNZWEsAy4G5HEigdnnIHQ4eqmifN3rDPPApeTG4c4h4=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260113014617-7812a3c669d7/go.mod h1:xv6m1I2jUA6mudKVznygpnzMoshBQarthHD1QnkW4qc=
|
||||
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
|
||||
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
|
||||
@@ -26,10 +26,10 @@ func NewUserDao(ctx context.Context, cache ...*redis.CacheClient) *UserDao {
|
||||
return dao
|
||||
}
|
||||
|
||||
func (d *UserDao) Create(user *model.User) error {
|
||||
func (d *UserDao) Create(user *model.User) (*model.User, error) {
|
||||
err := d.query.User.WithContext(d.ctx).
|
||||
Create(user)
|
||||
return err
|
||||
return user, err
|
||||
}
|
||||
|
||||
func (d *UserDao) Updates(user *model.User) error {
|
||||
|
||||
@@ -18,10 +18,9 @@ func (s *Server) Login(ctx context.Context, req *grpc_pb.LoginReq) (*grpc_pb.Log
|
||||
user, err := userDao.FindByPhone(req.Phone)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
user = &model.User{
|
||||
if user, err = userDao.Create(&model.User{
|
||||
Phone: req.Phone,
|
||||
}
|
||||
if err := userDao.Create(user); err != nil {
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
user.Name = fmt.Sprintf("user_%v", user.Sn)
|
||||
|
||||
Reference in New Issue
Block a user