Compare commits
4 Commits
release/v0
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 070c79842f | |||
| e31fead365 | |||
| 8817f2e052 | |||
| d7a4973642 |
12
app/app.go
12
app/app.go
@@ -2,11 +2,11 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
"git.hlsq.asia/alex/service-common/discover/common"
|
||||||
"git.hlsq.asia/mmorpg/service-common/log"
|
"git.hlsq.asia/alex/service-common/log"
|
||||||
"git.hlsq.asia/mmorpg/service-common/module"
|
"git.hlsq.asia/alex/service-common/module"
|
||||||
"git.hlsq.asia/mmorpg/service-user/config"
|
"git.hlsq.asia/alex/service-user/config"
|
||||||
"git.hlsq.asia/mmorpg/service-user/internal/grpc_server"
|
"git.hlsq.asia/alex/service-user/internal/grpcserver"
|
||||||
"github.com/judwhite/go-svc"
|
"github.com/judwhite/go-svc"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
@@ -19,7 +19,7 @@ func (p *Program) Init(_ svc.Environment) error {
|
|||||||
p.moduleList = append(p.moduleList, &module.Log{Cfg: config.Get().Log})
|
p.moduleList = append(p.moduleList, &module.Log{Cfg: config.Get().Log})
|
||||||
p.moduleList = append(p.moduleList, &module.DB{Cfg: config.Get().DB, AppName: config.Get().App.Name})
|
p.moduleList = append(p.moduleList, &module.DB{Cfg: config.Get().DB, AppName: config.Get().App.Name})
|
||||||
p.moduleList = append(p.moduleList, &module.Snowflake{})
|
p.moduleList = append(p.moduleList, &module.Snowflake{})
|
||||||
p.moduleList = append(p.moduleList, &module.Grpc{Server: grpc_server.NewServer(config.Get().Serve.Grpc)})
|
p.moduleList = append(p.moduleList, &module.Grpc{Server: grpcserver.NewServer(config.Get().Serve.Grpc)})
|
||||||
p.moduleList = append(p.moduleList, &module.Prometheus{Cfg: config.Get().Metric})
|
p.moduleList = append(p.moduleList, &module.Prometheus{Cfg: config.Get().Metric})
|
||||||
p.moduleList = append(p.moduleList, &module.Tracer{Cfg: config.Get().Metric, ServiceName: common.KeyDiscoverServiceNameUser})
|
p.moduleList = append(p.moduleList, &module.Tracer{Cfg: config.Get().Metric, ServiceName: common.KeyDiscoverServiceNameUser})
|
||||||
p.moduleList = append(p.moduleList, &module.Discover{})
|
p.moduleList = append(p.moduleList, &module.Discover{})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import "git.hlsq.asia/mmorpg/service-common/config"
|
import "git.hlsq.asia/alex/service-common/config"
|
||||||
|
|
||||||
const path = "./config"
|
const path = "./config"
|
||||||
|
|
||||||
|
|||||||
2
deploy/Jenkinsfile
vendored
2
deploy/Jenkinsfile
vendored
@@ -3,7 +3,7 @@ pipeline {
|
|||||||
|
|
||||||
environment {
|
environment {
|
||||||
// 仓库
|
// 仓库
|
||||||
REPO_URL = 'https://git.hlsq.asia/mmorpg/service-user.git'
|
REPO_URL = 'https://git.hlsq.asia/alex/service-user.git'
|
||||||
REPO_CREDENTIALS_ID = '80805ba2-f4ac-4d84-aee6-d4cce5fc0a96'
|
REPO_CREDENTIALS_ID = '80805ba2-f4ac-4d84-aee6-d4cce5fc0a96'
|
||||||
|
|
||||||
// Registry
|
// Registry
|
||||||
|
|||||||
4
go.mod
4
go.mod
@@ -1,9 +1,9 @@
|
|||||||
module git.hlsq.asia/mmorpg/service-user
|
module git.hlsq.asia/alex/service-user
|
||||||
|
|
||||||
go 1.24.0
|
go 1.24.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260207051302-0ca8a0ccbb14
|
git.hlsq.asia/alex/service-common master
|
||||||
github.com/judwhite/go-svc v1.2.1
|
github.com/judwhite/go-svc v1.2.1
|
||||||
google.golang.org/grpc v1.77.0
|
google.golang.org/grpc v1.77.0
|
||||||
gorm.io/gen v0.3.27
|
gorm.io/gen v0.3.27
|
||||||
|
|||||||
5
go.sum
5
go.sum
@@ -1,7 +1,8 @@
|
|||||||
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-20260207051302-0ca8a0ccbb14 h1:4r3tNWRzGVY3Xx6UiGjJJnwoMoWlVqbyGrljxl5d/nQ=
|
git.hlsq.asia/alex/service-common v0.0.0-20260211064821-558677bc3a2e h1:MNVS1NXNVn4DeTZPcvvA8YFM8afCzZedLPUYMffNgZs=
|
||||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260207051302-0ca8a0ccbb14/go.mod h1:mMhZcumphj6gaVTppVYsMTkd+5HupmQgAc53Pd4MH9I=
|
git.hlsq.asia/alex/service-common v0.0.0-20260211064821-558677bc3a2e/go.mod h1:mMhZcumphj6gaVTppVYsMTkd+5HupmQgAc53Pd4MH9I=
|
||||||
|
git.hlsq.asia/alex/service-common v0.0.0-20261028075842-c39cea86565e/go.mod h1:frhL9YsmMX58KHpJiWFCV31UqGGAQc/2V5ulL9rFxkE=
|
||||||
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/IBM/sarama v1.46.3 h1:njRsX6jNlnR+ClJ8XmkO+CM4unbrNr/2vB5KK6UA+IE=
|
github.com/IBM/sarama v1.46.3 h1:njRsX6jNlnR+ClJ8XmkO+CM4unbrNr/2vB5KK6UA+IE=
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.hlsq.asia/mmorpg/service-common/utils"
|
"git.hlsq.asia/alex/service-common/utils"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
"gorm.io/plugin/dbresolver"
|
"gorm.io/plugin/dbresolver"
|
||||||
|
|
||||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/model"
|
"git.hlsq.asia/alex/service-user/internal/dao/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
func newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package repository
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.hlsq.asia/mmorpg/service-common/db/mysql"
|
"git.hlsq.asia/alex/service-common/db/mysql"
|
||||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/query"
|
"git.hlsq.asia/alex/service-user/internal/dao/query"
|
||||||
)
|
)
|
||||||
|
|
||||||
var dbName mysql.DBName = "user_db"
|
var dbName mysql.DBName = "user_db"
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package repository
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
"git.hlsq.asia/alex/service-common/db/redis"
|
||||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/model"
|
"git.hlsq.asia/alex/service-user/internal/dao/model"
|
||||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/query"
|
"git.hlsq.asia/alex/service-user/internal/dao/query"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
package grpc_server
|
package grpcserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
"git.hlsq.asia/alex/service-common/db/redis"
|
||||||
"git.hlsq.asia/mmorpg/service-common/net/http/http_resp"
|
"git.hlsq.asia/alex/service-common/net/http/httpresp"
|
||||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
"git.hlsq.asia/alex/service-common/proto/rs/rspb"
|
||||||
"git.hlsq.asia/mmorpg/service-common/utils"
|
"git.hlsq.asia/alex/service-common/utils"
|
||||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/model"
|
"git.hlsq.asia/alex/service-user/internal/dao/model"
|
||||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/repository"
|
"git.hlsq.asia/alex/service-user/internal/dao/repository"
|
||||||
"git.hlsq.asia/mmorpg/service-user/internal/wechat"
|
"git.hlsq.asia/alex/service-user/internal/wechat"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Server) PhoneLogin(ctx context.Context, req *grpc_pb.PhoneLoginReq) (*grpc_pb.PhoneLoginResp, error) {
|
func (s *Server) PhoneLogin(ctx context.Context, req *rspb.PhoneLoginReq) (*rspb.PhoneLoginResp, error) {
|
||||||
userDao := repository.NewUserDao(ctx, s.query, redis.GetCacheClient())
|
userDao := repository.NewUserDao(ctx, s.query, redis.GetCacheClient())
|
||||||
user, err := userDao.FindByPhone(req.Phone)
|
user, err := userDao.FindByPhone(req.Phone)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -31,13 +31,13 @@ func (s *Server) PhoneLogin(ctx context.Context, req *grpc_pb.PhoneLoginReq) (*g
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &grpc_pb.PhoneLoginResp{
|
return &rspb.PhoneLoginResp{
|
||||||
USN: user.Sn,
|
USN: user.Sn,
|
||||||
Name: user.Name,
|
Name: user.Name,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) WxMiniLogin(ctx context.Context, req *grpc_pb.WxMiniLoginReq) (*grpc_pb.WxMiniLoginResp, error) {
|
func (s *Server) WxMiniLogin(ctx context.Context, req *rspb.WxMiniLoginReq) (*rspb.WxMiniLoginResp, error) {
|
||||||
session, err := wechat.MiniCode2Session(req.Code)
|
session, err := wechat.MiniCode2Session(req.Code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, utils.ErrorsWrap(err)
|
return nil, utils.ErrorsWrap(err)
|
||||||
@@ -59,15 +59,15 @@ func (s *Server) WxMiniLogin(ctx context.Context, req *grpc_pb.WxMiniLoginReq) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &grpc_pb.WxMiniLoginResp{
|
return &rspb.WxMiniLoginResp{
|
||||||
USN: user.Sn,
|
USN: user.Sn,
|
||||||
Name: user.Name,
|
Name: user.Name,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) GetUserInfo(ctx context.Context, req *grpc_pb.GetUserInfoReq) (*grpc_pb.GetUserInfoResp, error) {
|
func (s *Server) GetUserInfo(ctx context.Context, req *rspb.GetUserInfoReq) (*rspb.GetUserInfoResp, error) {
|
||||||
if !utils.ShouldBindUsn(ctx, &req.USN) {
|
if !utils.ShouldBindUsn(ctx, &req.USN) {
|
||||||
return nil, utils.ErrorsWrap(http_resp.ParamError)
|
return nil, utils.ErrorsWrap(httpresp.ParamError)
|
||||||
}
|
}
|
||||||
userDao := repository.NewUserDao(ctx, s.query, redis.GetCacheClient())
|
userDao := repository.NewUserDao(ctx, s.query, redis.GetCacheClient())
|
||||||
user, err := userDao.FindBySn(req.USN)
|
user, err := userDao.FindBySn(req.USN)
|
||||||
@@ -75,7 +75,7 @@ func (s *Server) GetUserInfo(ctx context.Context, req *grpc_pb.GetUserInfoReq) (
|
|||||||
return nil, utils.ErrorsWrap(err)
|
return nil, utils.ErrorsWrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &grpc_pb.GetUserInfoResp{
|
return &rspb.GetUserInfoResp{
|
||||||
USN: user.Sn,
|
USN: user.Sn,
|
||||||
Name: user.Name,
|
Name: user.Name,
|
||||||
}, nil
|
}, nil
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
package grpc_server
|
package grpcserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.hlsq.asia/mmorpg/service-common/config"
|
"git.hlsq.asia/alex/service-common/config"
|
||||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
"git.hlsq.asia/alex/service-common/discover/common"
|
||||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/service"
|
"git.hlsq.asia/alex/service-common/net/grpc/service"
|
||||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
"git.hlsq.asia/alex/service-common/proto/rs/rspb"
|
||||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/query"
|
"git.hlsq.asia/alex/service-user/internal/dao/query"
|
||||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/repository"
|
"git.hlsq.asia/alex/service-user/internal/dao/repository"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
grpc_pb.UnimplementedUserServer
|
rspb.UnimplementedUserServer
|
||||||
service.Base
|
service.Base
|
||||||
query *query.Query
|
query *query.Query
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ func (s *Server) OnCustomGrpcServerOption() []grpc.ServerOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) OnInit(serve *grpc.Server) {
|
func (s *Server) OnInit(serve *grpc.Server) {
|
||||||
grpc_pb.RegisterUserServer(serve, s)
|
rspb.RegisterUserServer(serve, s)
|
||||||
s.query = repository.Query()
|
s.query = repository.Query()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2,8 +2,8 @@ package wechat
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"git.hlsq.asia/mmorpg/service-common/log"
|
"git.hlsq.asia/alex/service-common/log"
|
||||||
"git.hlsq.asia/mmorpg/service-user/config"
|
"git.hlsq.asia/alex/service-user/config"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"git.hlsq.asia/mmorpg/service-common/log"
|
"git.hlsq.asia/alex/service-common/log"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|||||||
4
main.go
4
main.go
@@ -2,8 +2,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.hlsq.asia/mmorpg/service-user/app"
|
"git.hlsq.asia/alex/service-user/app"
|
||||||
"git.hlsq.asia/mmorpg/service-user/config"
|
"git.hlsq.asia/alex/service-user/config"
|
||||||
"github.com/judwhite/go-svc"
|
"github.com/judwhite/go-svc"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user