feat 奇怪的知识1.0.1

This commit is contained in:
2026-01-13 11:28:00 +08:00
parent b8e5aba27c
commit 7aec1c2d4f
4 changed files with 7 additions and 8 deletions

2
go.mod
View File

@@ -3,7 +3,7 @@ module git.hlsq.asia/mmorpg/service-user
go 1.23.1 go 1.23.1
require ( 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 github.com/judwhite/go-svc v1.2.1
google.golang.org/grpc v1.71.1 google.golang.org/grpc v1.71.1
gorm.io/gen v0.3.27 gorm.io/gen v0.3.27

4
go.sum
View File

@@ -1,7 +1,7 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
git.hlsq.asia/mmorpg/service-common v0.0.0-20260112082258-b1e7d33940d7 h1:C3quCA54dyFgmlCVgJXx+0rNqa+JZgGggdotbvHAsnA= git.hlsq.asia/mmorpg/service-common v0.0.0-20260113014617-7812a3c669d7 h1:sNZWEsAy4G5HEigdnnIHQ4eqmifN3rDPPApeTG4c4h4=
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/go.mod h1:xv6m1I2jUA6mudKVznygpnzMoshBQarthHD1QnkW4qc=
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=

View File

@@ -26,10 +26,10 @@ func NewUserDao(ctx context.Context, cache ...*redis.CacheClient) *UserDao {
return dao 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). err := d.query.User.WithContext(d.ctx).
Create(user) Create(user)
return err return user, err
} }
func (d *UserDao) Updates(user *model.User) error { func (d *UserDao) Updates(user *model.User) error {

View File

@@ -18,10 +18,9 @@ func (s *Server) Login(ctx context.Context, req *grpc_pb.LoginReq) (*grpc_pb.Log
user, err := userDao.FindByPhone(req.Phone) user, err := userDao.FindByPhone(req.Phone)
if err != nil { if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
user = &model.User{ if user, err = userDao.Create(&model.User{
Phone: req.Phone, Phone: req.Phone,
} }); err != nil {
if err := userDao.Create(user); err != nil {
return nil, err return nil, err
} }
user.Name = fmt.Sprintf("user_%v", user.Sn) user.Name = fmt.Sprintf("user_%v", user.Sn)