修改文件名

This commit is contained in:
xiabin 2025-02-14 10:30:15 +08:00
parent c09ed81544
commit 589843c02c
80 changed files with 337 additions and 337 deletions

View File

@ -1,4 +1,4 @@
name: Auth & User Management Service CI
dev: 打包镜像 & 在开发环境启动服务
on: [push]
@ -8,18 +8,18 @@ jobs:
strategy:
matrix:
include:
- service: user_management
dockerfile: app/user_management/Dockerfile
- service: user
dockerfile: app/user/Dockerfile
image: user_manager
- service: ranking_management
dockerfile: app/ranking_management/Dockerfile
image: ranking_management
- service: douyin_ecpm_calculation_service
dockerfile: app/douyin_ecpm_calculation_service/Dockerfile
image: douyin_ecpm_calculation_service
- service: auth_service
dockerfile: app/auth_service/Dockerfile
image: auth_service
- service: ranking
dockerfile: app/ranking/Dockerfile
image: ranking
- service: ecpm
dockerfile: app/ecpm/Dockerfile
image: ecpm
- service: auth
dockerfile: app/auth/Dockerfile
image: auth
steps:
- uses: https://gitea.youtukeji.com.cn/actions/checkout@v4

View File

@ -17,7 +17,7 @@ RUN go env -w GOPRIVATE=gitea.youtukeji.com.cn
RUN go mod download
COPY . .
RUN go build -ldflags="-s -w" -o /app/auth_service ./app/auth_service/auth_service.go
RUN go build -ldflags="-s -w" -o /app/auth ./app/auth/auth.go
FROM alpine

View File

@ -2,9 +2,9 @@ package main
import (
"fmt"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/auth_service"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/internal/server"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/auth"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/internal/server"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/pkg/config"
"github.com/zeromicro/go-zero/core/service"
@ -13,7 +13,7 @@ import (
"google.golang.org/grpc/reflection"
)
const ServiceName = "auth_service"
const ServiceName = "auth"
func main() {
var c config.Config
@ -25,7 +25,7 @@ func main() {
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
auth_service.RegisterAuthServiceServer(grpcServer, server.NewAuthServiceServer(ctx))
auth.RegisterAuthServiceServer(grpcServer, server.NewAuthServiceServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)

View File

@ -1,7 +1,7 @@
syntax = "proto3";
package auth_service;
option go_package = "./auth_service";
option go_package = "./auth";
message Request {
string ping = 1;

View File

@ -2,9 +2,9 @@
// versions:
// protoc-gen-go v1.36.4
// protoc v3.19.4
// source: auth_service.proto
// source: auth.proto
package auth_service
package auth
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
@ -398,20 +398,20 @@ func file_auth_service_proto_rawDescGZIP() []byte {
var file_auth_service_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_auth_service_proto_goTypes = []any{
(*Request)(nil), // 0: auth_service.Request
(*Response)(nil), // 1: auth_service.Response
(*Code2SessionRequest)(nil), // 2: auth_service.Code2SessionRequest
(*Code2SessionResponse)(nil), // 3: auth_service.Code2SessionResponse
(*GetAccessTokenRequest)(nil), // 4: auth_service.GetAccessTokenRequest
(*GetAccessTokenResponse)(nil), // 5: auth_service.GetAccessTokenResponse
(*Request)(nil), // 0: auth.Request
(*Response)(nil), // 1: auth.Response
(*Code2SessionRequest)(nil), // 2: auth.Code2SessionRequest
(*Code2SessionResponse)(nil), // 3: auth.Code2SessionResponse
(*GetAccessTokenRequest)(nil), // 4: auth.GetAccessTokenRequest
(*GetAccessTokenResponse)(nil), // 5: auth.GetAccessTokenResponse
}
var file_auth_service_proto_depIdxs = []int32{
0, // 0: auth_service.auth_service.Ping:input_type -> auth_service.Request
2, // 1: auth_service.auth_service.Code2Session:input_type -> auth_service.Code2SessionRequest
4, // 2: auth_service.auth_service.GetAccessToken:input_type -> auth_service.GetAccessTokenRequest
1, // 3: auth_service.auth_service.Ping:output_type -> auth_service.Response
3, // 4: auth_service.auth_service.Code2Session:output_type -> auth_service.Code2SessionResponse
5, // 5: auth_service.auth_service.GetAccessToken:output_type -> auth_service.GetAccessTokenResponse
0, // 0: auth.auth.Ping:input_type -> auth.Request
2, // 1: auth.auth.Code2Session:input_type -> auth.Code2SessionRequest
4, // 2: auth.auth.GetAccessToken:input_type -> auth.GetAccessTokenRequest
1, // 3: auth.auth.Ping:output_type -> auth.Response
3, // 4: auth.auth.Code2Session:output_type -> auth.Code2SessionResponse
5, // 5: auth.auth.GetAccessToken:output_type -> auth.GetAccessTokenResponse
3, // [3:6] is the sub-list for method output_type
0, // [0:3] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name

View File

@ -2,9 +2,9 @@
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v3.19.4
// source: auth_service.proto
// source: auth.proto
package auth_service
package auth
import (
context "context"
@ -19,9 +19,9 @@ import (
const _ = grpc.SupportPackageIsVersion9
const (
AuthService_Ping_FullMethodName = "/auth_service.auth_service/Ping"
AuthService_Code2Session_FullMethodName = "/auth_service.auth_service/Code2Session"
AuthService_GetAccessToken_FullMethodName = "/auth_service.auth_service/GetAccessToken"
AuthService_Ping_FullMethodName = "/auth.auth/Ping"
AuthService_Code2Session_FullMethodName = "/auth.auth/Code2Session"
AuthService_GetAccessToken_FullMethodName = "/auth.auth/GetAccessToken"
)
// AuthServiceClient is the client API for AuthService service.
@ -176,7 +176,7 @@ func _AuthService_GetAccessToken_Handler(srv interface{}, ctx context.Context, d
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var AuthService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "auth_service.auth_service",
ServiceName: "auth.auth",
HandlerType: (*AuthServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
@ -193,5 +193,5 @@ var AuthService_ServiceDesc = grpc.ServiceDesc{
},
},
Streams: []grpc.StreamDesc{},
Metadata: "auth_service.proto",
Metadata: "auth.proto",
}

View File

@ -1,25 +1,25 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.7.6
// Source: auth_service.proto
// Source: auth.proto
package auth_service_client
package auth_client
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/auth_service"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/auth"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
Code2SessionRequest = auth_service.Code2SessionRequest
Code2SessionResponse = auth_service.Code2SessionResponse
GetAccessTokenRequest = auth_service.GetAccessTokenRequest
GetAccessTokenResponse = auth_service.GetAccessTokenResponse
Request = auth_service.Request
Response = auth_service.Response
Code2SessionRequest = auth.Code2SessionRequest
Code2SessionResponse = auth.Code2SessionResponse
GetAccessTokenRequest = auth.GetAccessTokenRequest
GetAccessTokenResponse = auth.GetAccessTokenResponse
Request = auth.Request
Response = auth.Response
AuthService interface {
Ping(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
@ -39,16 +39,16 @@ func NewAuthService(cli zrpc.Client) AuthService {
}
func (m *defaultAuthService) Ping(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
client := auth_service.NewAuthServiceClient(m.cli.Conn())
client := auth.NewAuthServiceClient(m.cli.Conn())
return client.Ping(ctx, in, opts...)
}
func (m *defaultAuthService) Code2Session(ctx context.Context, in *Code2SessionRequest, opts ...grpc.CallOption) (*Code2SessionResponse, error) {
client := auth_service.NewAuthServiceClient(m.cli.Conn())
client := auth.NewAuthServiceClient(m.cli.Conn())
return client.Code2Session(ctx, in, opts...)
}
func (m *defaultAuthService) GetAccessToken(ctx context.Context, in *GetAccessTokenRequest, opts ...grpc.CallOption) (*GetAccessTokenResponse, error) {
client := auth_service.NewAuthServiceClient(m.cli.Conn())
client := auth.NewAuthServiceClient(m.cli.Conn())
return client.GetAccessToken(ctx, in, opts...)
}

View File

@ -1,13 +1,13 @@
Name: auth_service.rpc
Name: auth.rpc
ListenOn: 0.0.0.0:8080
Auth: true
Redis:
Key: auth_service.rpc.key
Key: auth.rpc.key
Host: 127.0.0.1:6379
Etcd:
Hosts:
- 127.0.0.1:2379
Key: auth_service.rpc
Key: auth.rpc
Mode: test
AppData:

View File

@ -16,7 +16,7 @@ import (
"gorm.io/plugin/dbresolver"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/internal/gen/dao/model"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/internal/gen/dao/model"
)
func newAppAccount(db *gorm.DB, opts ...gen.DOOption) appAccount {

View File

@ -9,7 +9,7 @@ import (
"fmt"
"testing"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/internal/gen/dao/model"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/internal/gen/dao/model"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/gorm/clause"

View File

@ -16,7 +16,7 @@ import (
"gorm.io/plugin/dbresolver"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/internal/gen/dao/model"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/internal/gen/dao/model"
)
func newAppUser(db *gorm.DB, opts ...gen.DOOption) appUser {

View File

@ -9,7 +9,7 @@ import (
"fmt"
"testing"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/internal/gen/dao/model"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/internal/gen/dao/model"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/gorm/clause"

View File

@ -2,9 +2,9 @@ package logic
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/auth_service"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/auth"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user"
"github.com/zeromicro/go-zero/core/logx"
)
@ -23,7 +23,7 @@ func NewCode2SessionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Code
}
}
func (l *Code2SessionLogic) Code2Session(in *auth_service.Code2SessionRequest) (*auth_service.Code2SessionResponse, error) {
func (l *Code2SessionLogic) Code2Session(in *auth.Code2SessionRequest) (*auth.Code2SessionResponse, error) {
//获取cli调用抖音或者微信api
cli, err := l.svcCtx.Cli.Get(in.AppId)
if err != nil {
@ -51,20 +51,20 @@ func (l *Code2SessionLogic) Code2Session(in *auth_service.Code2SessionRequest) (
var isNew bool
//如果没有用户id则创建一个空用户
if auModel.UserID == nil {
userId, err := l.svcCtx.UserManagerClient.CreateEmptyUser(l.ctx, &user_management.Empty{})
userId, err := l.svcCtx.UserManagerClient.CreateEmptyUser(l.ctx, &user.Empty{})
if err != nil {
return nil, err
}
auModel.UserID = &userId.UserId
} else {
user, err := l.svcCtx.UserManagerClient.FindById(l.ctx, &user_management.UserId{UserId: *auModel.UserID})
user, err := l.svcCtx.UserManagerClient.FindById(l.ctx, &user.UserId{UserId: *auModel.UserID})
if err != nil {
return nil, err
}
isNew = user.IsNew
}
return &auth_service.Code2SessionResponse{
return &auth.Code2SessionResponse{
OpenId: res.OpenID,
UnionId: res.UnionID,
UserId: *auModel.UserID,

View File

@ -2,8 +2,8 @@ package logic
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/auth_service"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/auth"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
@ -22,7 +22,7 @@ func NewGetAccessTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
}
}
func (l *GetAccessTokenLogic) GetAccessToken(in *auth_service.GetAccessTokenRequest) (*auth_service.GetAccessTokenResponse, error) {
func (l *GetAccessTokenLogic) GetAccessToken(in *auth.GetAccessTokenRequest) (*auth.GetAccessTokenResponse, error) {
cli, err := l.svcCtx.Cli.Get(in.AppId)
if err != nil {
return nil, err
@ -31,5 +31,5 @@ func (l *GetAccessTokenLogic) GetAccessToken(in *auth_service.GetAccessTokenRequ
if err != nil {
return nil, err
}
return &auth_service.GetAccessTokenResponse{AccessToken: accessToken}, nil
return &auth.GetAccessTokenResponse{AccessToken: accessToken}, nil
}

View File

@ -2,8 +2,8 @@ package logic
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/auth_service"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/auth"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
@ -22,6 +22,6 @@ func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic {
}
}
func (l *PingLogic) Ping(in *auth_service.Request) (*auth_service.Response, error) {
return &auth_service.Response{Pong: in.Ping}, nil
func (l *PingLogic) Ping(in *auth.Request) (*auth.Response, error) {
return &auth.Response{Pong: in.Ping}, nil
}

View File

@ -1,20 +1,20 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.7.6
// Source: auth_service.proto
// Source: auth.proto
package server
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/auth_service"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/internal/logic"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/auth"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/internal/logic"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/internal/svc"
)
type AuthServiceServer struct {
svcCtx *svc.ServiceContext
auth_service.UnimplementedAuthServiceServer
auth.UnimplementedAuthServiceServer
}
func NewAuthServiceServer(svcCtx *svc.ServiceContext) *AuthServiceServer {
@ -23,17 +23,17 @@ func NewAuthServiceServer(svcCtx *svc.ServiceContext) *AuthServiceServer {
}
}
func (s *AuthServiceServer) Ping(ctx context.Context, in *auth_service.Request) (*auth_service.Response, error) {
func (s *AuthServiceServer) Ping(ctx context.Context, in *auth.Request) (*auth.Response, error) {
l := logic.NewPingLogic(ctx, s.svcCtx)
return l.Ping(in)
}
func (s *AuthServiceServer) Code2Session(ctx context.Context, in *auth_service.Code2SessionRequest) (*auth_service.Code2SessionResponse, error) {
func (s *AuthServiceServer) Code2Session(ctx context.Context, in *auth.Code2SessionRequest) (*auth.Code2SessionResponse, error) {
l := logic.NewCode2SessionLogic(ctx, s.svcCtx)
return l.Code2Session(in)
}
func (s *AuthServiceServer) GetAccessToken(ctx context.Context, in *auth_service.GetAccessTokenRequest) (*auth_service.GetAccessTokenResponse, error) {
func (s *AuthServiceServer) GetAccessToken(ctx context.Context, in *auth.GetAccessTokenRequest) (*auth.GetAccessTokenResponse, error) {
l := logic.NewGetAccessTokenLogic(ctx, s.svcCtx)
return l.GetAccessToken(in)
}

View File

@ -3,10 +3,10 @@ package svc
import (
"context"
"encoding/json"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/internal/gen/dao/query"
cli2 "gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/pkg"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management_client"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/internal/gen/dao/query"
cli2 "gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/pkg"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_client"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/pkg/config"
"github.com/silenceper/wechat/v2/cache"
redisCache "github.com/silenceper/wechat/v2/cache"
@ -20,7 +20,7 @@ import (
type ServiceContext struct {
Config config.Config
Cli cli2.Helper
UserManagerClient user_management_client.UserManagement
UserManagerClient user_client.UserManagement
Query *query.Query
}
@ -35,14 +35,14 @@ func NewServiceContext(c config.Config) *ServiceContext {
if err != nil {
panic(err)
}
clientConf.Token = "user_management.rpc.key"
clientConf.App = "user_management.rpc"
clientConf.Token = "user.rpc.key"
clientConf.App = "user.rpc"
clientConf.Etcd = discov.EtcdConf{ // 通过 etcd 服务发现
Hosts: []string{viper.GetString(config.EtcdAddrKey)},
Key: "user_management.rpc",
Key: "user.rpc",
}
svc.UserManagerClient = user_management.NewUserManagementClient(zrpc.MustNewClient(clientConf).Conn())
svc.UserManagerClient = user.NewUserManagementClient(zrpc.MustNewClient(clientConf).Conn())
svc.InitClient()

View File

@ -4,7 +4,7 @@ import (
"context"
"errors"
douyinopenapi "gitea.youtukeji.com.cn/youtu/openapi-helper/douyin"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/pkg/douyin/access-token"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/pkg/douyin/access-token"
"github.com/silenceper/wechat/v2/cache"
)

View File

@ -1,6 +0,0 @@
Name: douyin_ecpm_calculation_service.rpc
ListenOn: 0.0.0.0:8081
Etcd:
Hosts:
- 127.0.0.1:2379
Key: douyin_ecpm_calculation_service.rpc

View File

@ -1,27 +0,0 @@
package logic
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/douyin_ecpm_calculation_service/douyin_ecpm_calculation_service"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/douyin_ecpm_calculation_service/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type PingLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic {
return &PingLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *PingLogic) Ping(in *douyin_ecpm_calculation_service.Request) (*douyin_ecpm_calculation_service.Response, error) {
return &douyin_ecpm_calculation_service.Response{Pong: in.Ping}, nil
}

View File

@ -17,7 +17,7 @@ RUN go env -w GOPRIVATE=gitea.youtukeji.com.cn
RUN go mod download
COPY . .
RUN go build -ldflags="-s -w" -o /app/douyin_ecpm_calculation_service ./app/douyin_ecpm_calculation_service/douyin_ecpm_calculation_service.go
RUN go build -ldflags="-s -w" -o /app/ecpm ./app/ecpm/ecpm.go
FROM alpine

View File

@ -1,10 +1,11 @@
package main
import (
"flag"
"fmt"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/server"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/ranking_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ecpm/ecpm"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ecpm/internal/server"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ecpm/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/pkg/config"
"github.com/zeromicro/go-zero/core/service"
@ -13,9 +14,10 @@ import (
"google.golang.org/grpc/reflection"
)
const ServiceName = "ranking_management"
const ServiceName = "douyin_ecpm"
func main() {
flag.Parse()
var c config.Config
err := config.GetConfig(&c, ServiceName)
@ -24,16 +26,16 @@ func main() {
}
c.RpcServerConf.Name = ServiceName + ".rpc"
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
ranking_management.RegisterRankingManagementServer(grpcServer, server.NewRankingManagementServer(ctx))
ecpm.RegisterDouyinEcpmCalculationServiceServer(grpcServer, server.NewDouyinEcpmCalculationServiceServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
defer s.Stop()
fmt.Printf("Starting rpc server at %s...\n", c.RpcServerConf.ListenOn)

View File

@ -1,7 +1,7 @@
syntax = "proto3";
package douyin_ecpm_calculation_service;
option go_package="./douyin_ecpm_calculation_service";
option go_package="./ecpm";
message Request {
string ping = 1;

View File

@ -2,9 +2,9 @@
// versions:
// protoc-gen-go v1.36.4
// protoc v3.19.4
// source: douyin_ecpm_calculation_service.proto
// source: ecpm.proto
package douyin_ecpm_calculation_service
package ecpm
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
@ -257,16 +257,16 @@ func file_douyin_ecpm_calculation_service_proto_rawDescGZIP() []byte {
var file_douyin_ecpm_calculation_service_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_douyin_ecpm_calculation_service_proto_goTypes = []any{
(*Request)(nil), // 0: douyin_ecpm_calculation_service.Request
(*Response)(nil), // 1: douyin_ecpm_calculation_service.Response
(*GetEcpmRequest)(nil), // 2: douyin_ecpm_calculation_service.GetEcpmRequest
(*GetEcpmResponse)(nil), // 3: douyin_ecpm_calculation_service.GetEcpmResponse
(*Request)(nil), // 0: ecpm.Request
(*Response)(nil), // 1: ecpm.Response
(*GetEcpmRequest)(nil), // 2: ecpm.GetEcpmRequest
(*GetEcpmResponse)(nil), // 3: ecpm.GetEcpmResponse
}
var file_douyin_ecpm_calculation_service_proto_depIdxs = []int32{
0, // 0: douyin_ecpm_calculation_service.douyin_ecpm_calculation_service.Ping:input_type -> douyin_ecpm_calculation_service.Request
2, // 1: douyin_ecpm_calculation_service.douyin_ecpm_calculation_service.GetEcpm:input_type -> douyin_ecpm_calculation_service.GetEcpmRequest
1, // 2: douyin_ecpm_calculation_service.douyin_ecpm_calculation_service.Ping:output_type -> douyin_ecpm_calculation_service.Response
3, // 3: douyin_ecpm_calculation_service.douyin_ecpm_calculation_service.GetEcpm:output_type -> douyin_ecpm_calculation_service.GetEcpmResponse
0, // 0: ecpm.ecpm.Ping:input_type -> ecpm.Request
2, // 1: ecpm.ecpm.GetEcpm:input_type -> ecpm.GetEcpmRequest
1, // 2: ecpm.ecpm.Ping:output_type -> ecpm.Response
3, // 3: ecpm.ecpm.GetEcpm:output_type -> ecpm.GetEcpmResponse
2, // [2:4] is the sub-list for method output_type
0, // [0:2] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name

View File

@ -2,9 +2,9 @@
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v3.19.4
// source: douyin_ecpm_calculation_service.proto
// source: ecpm.proto
package douyin_ecpm_calculation_service
package ecpm
import (
context "context"
@ -19,8 +19,8 @@ import (
const _ = grpc.SupportPackageIsVersion9
const (
DouyinEcpmCalculationService_Ping_FullMethodName = "/douyin_ecpm_calculation_service.douyin_ecpm_calculation_service/Ping"
DouyinEcpmCalculationService_GetEcpm_FullMethodName = "/douyin_ecpm_calculation_service.douyin_ecpm_calculation_service/GetEcpm"
DouyinEcpmCalculationService_Ping_FullMethodName = "/ecpm.ecpm/Ping"
DouyinEcpmCalculationService_GetEcpm_FullMethodName = "/ecpm.ecpm/GetEcpm"
)
// DouyinEcpmCalculationServiceClient is the client API for DouyinEcpmCalculationService service.
@ -143,7 +143,7 @@ func _DouyinEcpmCalculationService_GetEcpm_Handler(srv interface{}, ctx context.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var DouyinEcpmCalculationService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "douyin_ecpm_calculation_service.douyin_ecpm_calculation_service",
ServiceName: "ecpm.ecpm",
HandlerType: (*DouyinEcpmCalculationServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
@ -156,5 +156,5 @@ var DouyinEcpmCalculationService_ServiceDesc = grpc.ServiceDesc{
},
},
Streams: []grpc.StreamDesc{},
Metadata: "douyin_ecpm_calculation_service.proto",
Metadata: "ecpm.proto",
}

View File

@ -1,12 +1,12 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.7.6
// Source: douyin_ecpm_calculation_service.proto
// Source: ecpm.proto
package douyin_ecpm_calculation_service_client
package ecpm_client
import (
"context"
douyin_ecpm_calculation_service2 "gitea.youtukeji.com.cn/youtu/youtu_grpc/app/douyin_ecpm_calculation_service/douyin_ecpm_calculation_service"
douyin_ecpm_calculation_service2 "gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ecpm/ecpm"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"

6
app/ecpm/etc/ecpm.yaml Normal file
View File

@ -0,0 +1,6 @@
Name: ecpm.rpc
ListenOn: 0.0.0.0:8081
Etcd:
Hosts:
- 127.0.0.1:2379
Key: ecpm.rpc

View File

@ -5,9 +5,9 @@ import (
"encoding/json"
"errors"
"fmt"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/auth_service"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/douyin_ecpm_calculation_service/douyin_ecpm_calculation_service"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/douyin_ecpm_calculation_service/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/auth"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ecpm/ecpm"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ecpm/internal/svc"
"io"
"net/http"
"strconv"
@ -30,9 +30,9 @@ func NewGetEcpmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetEcpmLo
}
}
func (l *GetEcpmLogic) GetEcpm(in *douyin_ecpm_calculation_service.GetEcpmRequest) (response *douyin_ecpm_calculation_service.GetEcpmResponse, err error) {
func (l *GetEcpmLogic) GetEcpm(in *ecpm.GetEcpmRequest) (response *ecpm.GetEcpmResponse, err error) {
//获取抖音accessToken
res, err := l.svcCtx.AuthServiceClient.GetAccessToken(l.ctx, &auth_service.GetAccessTokenRequest{
res, err := l.svcCtx.AuthServiceClient.GetAccessToken(l.ctx, &auth.GetAccessTokenRequest{
AppId: in.AppId,
})
if err != nil {

View File

@ -2,8 +2,8 @@ package logic
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/ranking_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ecpm/ecpm"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ecpm/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
@ -22,6 +22,6 @@ func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic {
}
}
func (l *PingLogic) Ping(in *ranking_management.Request) (*ranking_management.Response, error) {
return &ranking_management.Response{Pong: in.Ping}, nil
func (l *PingLogic) Ping(in *ecpm.Request) (*ecpm.Response, error) {
return &ecpm.Response{Pong: in.Ping}, nil
}

View File

@ -1,14 +1,14 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.7.6
// Source: douyin_ecpm_calculation_service.proto
// Source: ecpm.proto
package server
import (
"context"
douyin_ecpm_calculation_service2 "gitea.youtukeji.com.cn/youtu/youtu_grpc/app/douyin_ecpm_calculation_service/douyin_ecpm_calculation_service"
logic2 "gitea.youtukeji.com.cn/youtu/youtu_grpc/app/douyin_ecpm_calculation_service/internal/logic"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/douyin_ecpm_calculation_service/internal/svc"
douyin_ecpm_calculation_service2 "gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ecpm/ecpm"
logic2 "gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ecpm/internal/logic"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ecpm/internal/svc"
)
type DouyinEcpmCalculationServiceServer struct {

View File

@ -2,7 +2,7 @@ package svc
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth_service/auth_service"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/auth/auth"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/pkg/config"
"github.com/spf13/viper"
"github.com/zeromicro/go-zero/core/conf"
@ -13,7 +13,7 @@ import (
type ServiceContext struct {
Config config.Config
AuthServiceClient auth_service.AuthServiceClient
AuthServiceClient auth.AuthServiceClient
etcdCli *clientv3.Client
EcpmConfig *EcpmConfigCli
}
@ -76,12 +76,12 @@ func (svc *ServiceContext) initAuthServiceClient() {
if err != nil {
panic(err)
}
clientConf.Token = "auth_service.rpc.key"
clientConf.App = "auth_service.rpc"
clientConf.Token = "auth.rpc.key"
clientConf.App = "auth.rpc"
clientConf.Etcd = discov.EtcdConf{ // 通过 etcd 服务发现
Hosts: []string{viper.GetString(config.EtcdAddrKey)},
Key: "auth_service.rpc",
Key: "auth.rpc",
}
svc.AuthServiceClient = auth_service.NewAuthServiceClient(zrpc.MustNewClient(clientConf).Conn())
svc.AuthServiceClient = auth.NewAuthServiceClient(zrpc.MustNewClient(clientConf).Conn())
}

View File

@ -17,7 +17,7 @@ RUN go env -w GOPRIVATE=gitea.youtukeji.com.cn
RUN go mod download
COPY . .
RUN go build -ldflags="-s -w" -o /app/ranking_management ./app/ranking_management/ranking_management.go
RUN go build -ldflags="-s -w" -o /app/ranking ./app/ranking/ranking.go
FROM alpine

View File

@ -1,9 +1,9 @@
Name: ranking_management.rpc
Name: ranking.rpc
ListenOn: 0.0.0.0:8080
Etcd:
Hosts:
- 127.0.0.1:2379
Key: ranking_management.rpc
Key: ranking.rpc
RedisHost: 127.0.0.1:6379
Mysql:
Dsn: root:youtu!0113@tcp(localhost:3306)/ecpm?charset=utf8mb4&parseTime=True&loc=Local

View File

@ -16,7 +16,7 @@ import (
"gorm.io/plugin/dbresolver"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/gen/dao/model"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/gen/dao/model"
)
func newGameScore(db *gorm.DB, opts ...gen.DOOption) gameScore {

View File

@ -9,7 +9,7 @@ import (
"fmt"
"testing"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/gen/dao/model"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/gen/dao/model"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/gorm/clause"

View File

@ -3,10 +3,10 @@ package logic
import (
"context"
"errors"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/logic/rankings"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/svc"
ranking_management2 "gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/ranking_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/logic/rankings"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/svc"
ranking_management2 "gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/ranking"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
"strconv"
@ -48,7 +48,7 @@ func (l *GetRankingListLogic) GetRankingList(in *ranking_management2.GetRankingL
continue
}
//查询用户数据FindOne带缓存
user, err := l.svcCtx.UserManagerClient.GetUserById(l.ctx, &user_management.UserId{UserId: uint64(userId)})
user, err := l.svcCtx.UserManagerClient.GetUserById(l.ctx, &user.UserId{UserId: uint64(userId)})
if err != nil {
return nil, err
}
@ -80,7 +80,7 @@ func (l *GetRankingListLogic) GetRankingList(in *ranking_management2.GetRankingL
if err != nil {
return nil, err
}
tmp, err := l.svcCtx.UserManagerClient.GetUserById(l.ctx, &user_management.UserId{UserId: in.UserId})
tmp, err := l.svcCtx.UserManagerClient.GetUserById(l.ctx, &user.UserId{UserId: in.UserId})
//tmp, err := l.svcCtx.Query.GameScore.GetUserRank(in.AppId, in.UserId, in.Type)
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return nil, err

View File

@ -0,0 +1,27 @@
package logic
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/ranking"
"github.com/zeromicro/go-zero/core/logx"
)
type PingLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic {
return &PingLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *PingLogic) Ping(in *ranking.Request) (*ranking.Response, error) {
return &ranking.Response{Pong: in.Ping}, nil
}

View File

@ -3,10 +3,10 @@ package logic
import (
"context"
"errors"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/gen/dao/model"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/logic/rankings"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/ranking_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/gen/dao/model"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/logic/rankings"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/ranking"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
"time"
@ -28,7 +28,7 @@ func NewSetUserGameScoreLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
}
}
func (l *SetUserGameScoreLogic) SetUserGameScore(in *ranking_management.SetUserGameScoreRequest) (*ranking_management.BaseResult, error) {
func (l *SetUserGameScoreLogic) SetUserGameScore(in *ranking.SetUserGameScoreRequest) (*ranking.BaseResult, error) {
gs := l.svcCtx.Query.GameScore
// 查询旧分数
@ -51,7 +51,7 @@ func (l *SetUserGameScoreLogic) SetUserGameScore(in *ranking_management.SetUserG
// 判断是否需要更新(只保留最高分)
if in.Score <= oldScore.Score {
return &ranking_management.BaseResult{}, nil
return &ranking.BaseResult{}, nil
}
oldScore.Score = in.Score
@ -70,5 +70,5 @@ func (l *SetUserGameScoreLogic) SetUserGameScore(in *ranking_management.SetUserG
Score: float64(uint64(in.Score)<<32 + uint64(time.Now().Unix())),
})
return &ranking_management.BaseResult{}, nil
return &ranking.BaseResult{}, nil
}

View File

@ -1,20 +1,20 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.7.6
// Source: ranking_management.proto
// Source: ranking.proto
package server
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/logic"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/ranking_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/logic"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/ranking"
)
type RankingManagementServer struct {
svcCtx *svc.ServiceContext
ranking_management.UnimplementedRankingManagementServer
ranking.UnimplementedRankingManagementServer
}
func NewRankingManagementServer(svcCtx *svc.ServiceContext) *RankingManagementServer {
@ -23,17 +23,17 @@ func NewRankingManagementServer(svcCtx *svc.ServiceContext) *RankingManagementSe
}
}
func (s *RankingManagementServer) Ping(ctx context.Context, in *ranking_management.Request) (*ranking_management.Response, error) {
func (s *RankingManagementServer) Ping(ctx context.Context, in *ranking.Request) (*ranking.Response, error) {
l := logic.NewPingLogic(ctx, s.svcCtx)
return l.Ping(in)
}
func (s *RankingManagementServer) SetUserGameScore(ctx context.Context, in *ranking_management.SetUserGameScoreRequest) (*ranking_management.BaseResult, error) {
func (s *RankingManagementServer) SetUserGameScore(ctx context.Context, in *ranking.SetUserGameScoreRequest) (*ranking.BaseResult, error) {
l := logic.NewSetUserGameScoreLogic(ctx, s.svcCtx)
return l.SetUserGameScore(in)
}
func (s *RankingManagementServer) GetRankingList(ctx context.Context, in *ranking_management.GetRankingListRequest) (*ranking_management.GetRankingListResponse, error) {
func (s *RankingManagementServer) GetRankingList(ctx context.Context, in *ranking.GetRankingListRequest) (*ranking.GetRankingListResponse, error) {
l := logic.NewGetRankingListLogic(ctx, s.svcCtx)
return l.GetRankingList(in)
}

View File

@ -2,10 +2,10 @@ package svc
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/gen/dao/query"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/internal/logic/rankings"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management_client"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/gen/dao/query"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/logic/rankings"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_client"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/pkg/config"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/pkg/my_gorm"
"github.com/redis/go-redis/v9"
@ -21,7 +21,7 @@ type ServiceContext struct {
Config config.Config
Query *query.Query
RedisRanking *rankings.Ranking
UserManagerClient user_management_client.UserManagement
UserManagerClient user_client.UserManagement
}
func NewServiceContext(c config.Config) *ServiceContext {
@ -47,14 +47,14 @@ func NewServiceContext(c config.Config) *ServiceContext {
if err != nil {
panic(err)
}
clientConf.Token = "user_management.rpc.key"
clientConf.App = "user_management.rpc"
clientConf.Token = "user.rpc.key"
clientConf.App = "user.rpc"
clientConf.Etcd = discov.EtcdConf{ // 通过 etcd 服务发现
Hosts: []string{viper.GetString(config.EtcdAddrKey)},
Key: "user_management.rpc",
Key: "user.rpc",
}
svc.UserManagerClient = user_management.NewUserManagementClient(zrpc.MustNewClient(clientConf).Conn())
svc.UserManagerClient = user.NewUserManagementClient(zrpc.MustNewClient(clientConf).Conn())
//初始化排行榜对象
svc.InitRankings(redisClient)

View File

@ -1,11 +1,10 @@
package main
import (
"flag"
"fmt"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/douyin_ecpm_calculation_service/douyin_ecpm_calculation_service"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/douyin_ecpm_calculation_service/internal/server"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/douyin_ecpm_calculation_service/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/server"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/ranking"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/pkg/config"
"github.com/zeromicro/go-zero/core/service"
@ -14,10 +13,9 @@ import (
"google.golang.org/grpc/reflection"
)
const ServiceName = "douyin_ecpm"
const ServiceName = "ranking"
func main() {
flag.Parse()
var c config.Config
err := config.GetConfig(&c, ServiceName)
@ -26,16 +24,16 @@ func main() {
}
c.RpcServerConf.Name = ServiceName + ".rpc"
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
douyin_ecpm_calculation_service.RegisterDouyinEcpmCalculationServiceServer(grpcServer, server.NewDouyinEcpmCalculationServiceServer(ctx))
ranking.RegisterRankingManagementServer(grpcServer, server.NewRankingManagementServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
defer s.Stop()
fmt.Printf("Starting rpc server at %s...\n", c.RpcServerConf.ListenOn)

View File

@ -1,7 +1,7 @@
syntax = "proto3";
package ranking_management;
option go_package = "./ranking_management";
option go_package = "./ranking";
message Request {
string ping = 1;

View File

@ -2,9 +2,9 @@
// versions:
// protoc-gen-go v1.36.4
// protoc v3.19.4
// source: ranking_management.proto
// source: ranking.proto
package ranking_management
package ranking
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
@ -500,22 +500,22 @@ func file_ranking_management_proto_rawDescGZIP() []byte {
var file_ranking_management_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_ranking_management_proto_goTypes = []any{
(*Request)(nil), // 0: ranking_management.Request
(*Response)(nil), // 1: ranking_management.Response
(*SetUserGameScoreRequest)(nil), // 2: ranking_management.SetUserGameScoreRequest
(*RankingList)(nil), // 3: ranking_management.RankingList
(*GetRankingListResponse)(nil), // 4: ranking_management.GetRankingListResponse
(*GetRankingListRequest)(nil), // 5: ranking_management.GetRankingListRequest
(*BaseResult)(nil), // 6: ranking_management.BaseResult
(*Request)(nil), // 0: ranking.Request
(*Response)(nil), // 1: ranking.Response
(*SetUserGameScoreRequest)(nil), // 2: ranking.SetUserGameScoreRequest
(*RankingList)(nil), // 3: ranking.RankingList
(*GetRankingListResponse)(nil), // 4: ranking.GetRankingListResponse
(*GetRankingListRequest)(nil), // 5: ranking.GetRankingListRequest
(*BaseResult)(nil), // 6: ranking.BaseResult
}
var file_ranking_management_proto_depIdxs = []int32{
3, // 0: ranking_management.GetRankingListResponse.rankingData:type_name -> ranking_management.RankingList
0, // 1: ranking_management.Ranking_management.Ping:input_type -> ranking_management.Request
2, // 2: ranking_management.Ranking_management.SetUserGameScore:input_type -> ranking_management.SetUserGameScoreRequest
5, // 3: ranking_management.Ranking_management.GetRankingList:input_type -> ranking_management.GetRankingListRequest
1, // 4: ranking_management.Ranking_management.Ping:output_type -> ranking_management.Response
6, // 5: ranking_management.Ranking_management.SetUserGameScore:output_type -> ranking_management.BaseResult
4, // 6: ranking_management.Ranking_management.GetRankingList:output_type -> ranking_management.GetRankingListResponse
3, // 0: ranking.GetRankingListResponse.rankingData:type_name -> ranking.RankingList
0, // 1: ranking.Ranking_management.Ping:input_type -> ranking.Request
2, // 2: ranking.Ranking_management.SetUserGameScore:input_type -> ranking.SetUserGameScoreRequest
5, // 3: ranking.Ranking_management.GetRankingList:input_type -> ranking.GetRankingListRequest
1, // 4: ranking.Ranking_management.Ping:output_type -> ranking.Response
6, // 5: ranking.Ranking_management.SetUserGameScore:output_type -> ranking.BaseResult
4, // 6: ranking.Ranking_management.GetRankingList:output_type -> ranking.GetRankingListResponse
4, // [4:7] is the sub-list for method output_type
1, // [1:4] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name

View File

@ -2,9 +2,9 @@
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v3.19.4
// source: ranking_management.proto
// source: ranking.proto
package ranking_management
package ranking
import (
context "context"
@ -19,9 +19,9 @@ import (
const _ = grpc.SupportPackageIsVersion9
const (
RankingManagement_Ping_FullMethodName = "/ranking_management.Ranking_management/Ping"
RankingManagement_SetUserGameScore_FullMethodName = "/ranking_management.Ranking_management/SetUserGameScore"
RankingManagement_GetRankingList_FullMethodName = "/ranking_management.Ranking_management/GetRankingList"
RankingManagement_Ping_FullMethodName = "/ranking.Ranking_management/Ping"
RankingManagement_SetUserGameScore_FullMethodName = "/ranking.Ranking_management/SetUserGameScore"
RankingManagement_GetRankingList_FullMethodName = "/ranking.Ranking_management/GetRankingList"
)
// RankingManagementClient is the client API for RankingManagement service.
@ -176,7 +176,7 @@ func _RankingManagement_GetRankingList_Handler(srv interface{}, ctx context.Cont
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var RankingManagement_ServiceDesc = grpc.ServiceDesc{
ServiceName: "ranking_management.Ranking_management",
ServiceName: "ranking.Ranking_management",
HandlerType: (*RankingManagementServer)(nil),
Methods: []grpc.MethodDesc{
{
@ -193,5 +193,5 @@ var RankingManagement_ServiceDesc = grpc.ServiceDesc{
},
},
Streams: []grpc.StreamDesc{},
Metadata: "ranking_management.proto",
Metadata: "ranking.proto",
}

View File

@ -1,26 +1,26 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.7.6
// Source: ranking_management.proto
// Source: ranking.proto
package ranking_management_client
package ranking_client
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_management/ranking_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking/ranking"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
BaseResult = ranking_management.BaseResult
GetRankingListRequest = ranking_management.GetRankingListRequest
GetRankingListResponse = ranking_management.GetRankingListResponse
RankingList = ranking_management.RankingList
Request = ranking_management.Request
Response = ranking_management.Response
SetUserGameScoreRequest = ranking_management.SetUserGameScoreRequest
BaseResult = ranking.BaseResult
GetRankingListRequest = ranking.GetRankingListRequest
GetRankingListResponse = ranking.GetRankingListResponse
RankingList = ranking.RankingList
Request = ranking.Request
Response = ranking.Response
SetUserGameScoreRequest = ranking.SetUserGameScoreRequest
RankingManagement interface {
Ping(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
@ -40,16 +40,16 @@ func NewRankingManagement(cli zrpc.Client) RankingManagement {
}
func (m *defaultRankingManagement) Ping(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
client := ranking_management.NewRankingManagementClient(m.cli.Conn())
client := ranking.NewRankingManagementClient(m.cli.Conn())
return client.Ping(ctx, in, opts...)
}
func (m *defaultRankingManagement) SetUserGameScore(ctx context.Context, in *SetUserGameScoreRequest, opts ...grpc.CallOption) (*BaseResult, error) {
client := ranking_management.NewRankingManagementClient(m.cli.Conn())
client := ranking.NewRankingManagementClient(m.cli.Conn())
return client.SetUserGameScore(ctx, in, opts...)
}
func (m *defaultRankingManagement) GetRankingList(ctx context.Context, in *GetRankingListRequest, opts ...grpc.CallOption) (*GetRankingListResponse, error) {
client := ranking_management.NewRankingManagementClient(m.cli.Conn())
client := ranking.NewRankingManagementClient(m.cli.Conn())
return client.GetRankingList(ctx, in, opts...)
}

View File

@ -17,7 +17,7 @@ RUN go env -w GOPRIVATE=gitea.youtukeji.com.cn
RUN go mod download
COPY . .
RUN go build -ldflags="-s -w" -o /app/user_management ./app/user_management/user_management.go
RUN go build -ldflags="-s -w" -o /app/user ./app/user/user.go
FROM alpine

View File

@ -1,6 +1,6 @@
Name: user_management.rpc
Name: user.rpc
ListenOn: 0.0.0.0:8080
Etcd:
Hosts:
- 127.0.0.1:2379
Key: user_management.rpc
Key: user.rpc

View File

@ -4,7 +4,7 @@ import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/internal/gen/dao/model"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user"
"github.com/zeromicro/go-zero/core/logx"
)
@ -23,7 +23,7 @@ func NewCreateEmptyUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C
}
}
func (l *CreateEmptyUserLogic) CreateEmptyUser(_ *user_management.Empty) (*user_management.UserId, error) {
func (l *CreateEmptyUserLogic) CreateEmptyUser(_ *user.Empty) (*user.UserId, error) {
userId, err := l.svcCtx.IDGen.NextID()
if err != nil {
return nil, err
@ -35,5 +35,5 @@ func (l *CreateEmptyUserLogic) CreateEmptyUser(_ *user_management.Empty) (*user_
return nil, err
}
return &user_management.UserId{UserId: userId}, nil
return &user.UserId{UserId: userId}, nil
}

View File

@ -4,7 +4,7 @@ import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/internal/gen/dao/model"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user"
"github.com/zeromicro/go-zero/core/logx"
)
@ -24,7 +24,7 @@ func NewCreateUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Create
}
// CreateUser 创建用户
func (l *CreateUserLogic) CreateUser(in *user_management.CreateUserRequest) (res *user_management.UserId, err error) {
func (l *CreateUserLogic) CreateUser(in *user.CreateUserRequest) (res *user.UserId, err error) {
user := l.svcCtx.Query.User
userModel := model.User{
Nickname: in.Nickname,
@ -39,5 +39,5 @@ func (l *CreateUserLogic) CreateUser(in *user_management.CreateUserRequest) (res
if err != nil {
return nil, err
}
return &user_management.UserId{UserId: userModel.ID}, nil
return &user.UserId{UserId: userModel.ID}, nil
}

View File

@ -4,7 +4,7 @@ import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user"
"github.com/zeromicro/go-zero/core/logx"
)
@ -24,12 +24,12 @@ func NewFindByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindById
}
// FindById 创建用户或者获取用户
func (l *FindByIdLogic) FindById(in *user_management.UserId) (*user_management.User, error) {
func (l *FindByIdLogic) FindById(in *user.UserId) (*user.User, error) {
userModel, err := l.svcCtx.Query.User.WithContext(l.ctx).Where(l.svcCtx.Query.User.ID.Eq(in.GetUserId())).FirstOrCreate()
if err != nil {
return nil, err
}
return &user_management.User{
return &user.User{
ID: userModel.ID,
Nickname: userModel.Nickname,
Avatar: userModel.Avatar,

View File

@ -5,7 +5,7 @@ import (
"errors"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user"
"github.com/zeromicro/go-zero/core/logx"
)
@ -25,18 +25,18 @@ func NewGetUserByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUs
}
// GetUserById 通过 ID 获取用户
func (l *GetUserByIdLogic) GetUserById(in *user_management.UserId) (*user_management.User, error) {
func (l *GetUserByIdLogic) GetUserById(in *user.UserId) (*user.User, error) {
if in.GetUserId() == 0 {
return &user_management.User{}, errors.New("userId is empty")
return &user.User{}, errors.New("userId is empty")
}
user, err := l.svcCtx.Query.User.WithContext(l.ctx).Where(l.svcCtx.Query.User.ID.Eq(in.UserId)).First()
if err != nil {
return &user_management.User{}, err
return &user.User{}, err
}
return &user_management.User{
return &user.User{
ID: user.ID,
Nickname: user.Nickname,
Avatar: user.Avatar,

View File

@ -3,7 +3,7 @@ package logic
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user"
"github.com/zeromicro/go-zero/core/logx"
)
@ -22,6 +22,6 @@ func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic {
}
}
func (l *PingLogic) Ping(in *user_management.Request) (*user_management.Response, error) {
return &user_management.Response{Pong: in.Ping}, nil
func (l *PingLogic) Ping(in *user.Request) (*user.Response, error) {
return &user.Response{Pong: in.Ping}, nil
}

View File

@ -6,7 +6,7 @@ import (
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/internal/gen/dao/model"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user"
"github.com/zeromicro/go-zero/core/logx"
)
@ -26,7 +26,7 @@ func NewSetUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetUserLo
}
// SetUser 设置用户信息
func (l *SetUserLogic) SetUser(in *user_management.SetUserRequest) (*user_management.SetUserResponse, error) {
func (l *SetUserLogic) SetUser(in *user.SetUserRequest) (*user.SetUserResponse, error) {
if in.UserId == 0 || in.Nickname == "" || in.Avatar == "" {
return nil, errors.New("参数错误")
}
@ -42,5 +42,5 @@ func (l *SetUserLogic) SetUser(in *user_management.SetUserRequest) (*user_manage
return nil, update.Error
}
return &user_management.SetUserResponse{RowsAffected: update.RowsAffected}, nil
return &user.SetUserResponse{RowsAffected: update.RowsAffected}, nil
}

View File

@ -1,6 +1,6 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.7.6
// Source: user_management.proto
// Source: user.proto
package server
@ -9,12 +9,12 @@ import (
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/internal/logic"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user"
)
type UserManagementServer struct {
svcCtx *svc.ServiceContext
user_management.UnimplementedUserManagementServer
user.UnimplementedUserManagementServer
}
func NewUserManagementServer(svcCtx *svc.ServiceContext) *UserManagementServer {
@ -23,37 +23,37 @@ func NewUserManagementServer(svcCtx *svc.ServiceContext) *UserManagementServer {
}
}
func (s *UserManagementServer) Ping(ctx context.Context, in *user_management.Request) (*user_management.Response, error) {
func (s *UserManagementServer) Ping(ctx context.Context, in *user.Request) (*user.Response, error) {
l := logic.NewPingLogic(ctx, s.svcCtx)
return l.Ping(in)
}
// SetUser 设置用户信息
func (s *UserManagementServer) SetUser(ctx context.Context, in *user_management.SetUserRequest) (*user_management.SetUserResponse, error) {
func (s *UserManagementServer) SetUser(ctx context.Context, in *user.SetUserRequest) (*user.SetUserResponse, error) {
l := logic.NewSetUserLogic(ctx, s.svcCtx)
return l.SetUser(in)
}
// CreateUser 获取用户或者创建用户
func (s *UserManagementServer) CreateUser(ctx context.Context, in *user_management.CreateUserRequest) (*user_management.UserId, error) {
func (s *UserManagementServer) CreateUser(ctx context.Context, in *user.CreateUserRequest) (*user.UserId, error) {
l := logic.NewCreateUserLogic(ctx, s.svcCtx)
return l.CreateUser(in)
}
// CreateEmptyUser 创建空用户,用于关联游戏账号的空数据
func (s *UserManagementServer) CreateEmptyUser(ctx context.Context, in *user_management.Empty) (*user_management.UserId, error) {
func (s *UserManagementServer) CreateEmptyUser(ctx context.Context, in *user.Empty) (*user.UserId, error) {
l := logic.NewCreateEmptyUserLogic(ctx, s.svcCtx)
return l.CreateEmptyUser(in)
}
// FirstOrCreateUser 创建用户或者获取用户
func (s *UserManagementServer) FindById(ctx context.Context, in *user_management.UserId) (*user_management.User, error) {
func (s *UserManagementServer) FindById(ctx context.Context, in *user.UserId) (*user.User, error) {
l := logic.NewFindByIdLogic(ctx, s.svcCtx)
return l.FindById(in)
}
// GetUserById 通过 ID 获取用户
func (s *UserManagementServer) GetUserById(ctx context.Context, in *user_management.UserId) (*user_management.User, error) {
func (s *UserManagementServer) GetUserById(ctx context.Context, in *user.UserId) (*user.User, error) {
l := logic.NewGetUserByIdLogic(ctx, s.svcCtx)
return l.GetUserById(in)
}

View File

@ -5,7 +5,7 @@ import (
"fmt"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/internal/server"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/internal/svc"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/pkg/config"
"github.com/zeromicro/go-zero/core/service"
"github.com/zeromicro/go-zero/zrpc"
@ -13,7 +13,7 @@ import (
"google.golang.org/grpc/reflection"
)
const ServiceName = "user_management"
const ServiceName = "user"
func main() {
flag.Parse()
@ -29,7 +29,7 @@ func main() {
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
user_management.RegisterUserManagementServer(grpcServer, server.NewUserManagementServer(ctx))
user.RegisterUserManagementServer(grpcServer, server.NewUserManagementServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)

View File

@ -1,7 +1,7 @@
syntax = "proto3";
package user_management;
option go_package = "./user_management";
option go_package = "./user";
message Request {
string ping = 1;

View File

@ -2,9 +2,9 @@
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v3.19.4
// source: user_management.proto
// source: user.proto
package user_management
package user
import (
context "context"
@ -19,12 +19,12 @@ import (
const _ = grpc.SupportPackageIsVersion9
const (
UserManagement_Ping_FullMethodName = "/user_management.user_management/Ping"
UserManagement_SetUser_FullMethodName = "/user_management.user_management/SetUser"
UserManagement_CreateUser_FullMethodName = "/user_management.user_management/CreateUser"
UserManagement_CreateEmptyUser_FullMethodName = "/user_management.user_management/CreateEmptyUser"
UserManagement_FindById_FullMethodName = "/user_management.user_management/FindById"
UserManagement_GetUserById_FullMethodName = "/user_management.user_management/GetUserById"
UserManagement_Ping_FullMethodName = "/user.user/Ping"
UserManagement_SetUser_FullMethodName = "/user.user/SetUser"
UserManagement_CreateUser_FullMethodName = "/user.user/CreateUser"
UserManagement_CreateEmptyUser_FullMethodName = "/user.user/CreateEmptyUser"
UserManagement_FindById_FullMethodName = "/user.user/FindById"
UserManagement_GetUserById_FullMethodName = "/user.user/GetUserById"
)
// UserManagementClient is the client API for UserManagement service.
@ -288,7 +288,7 @@ func _UserManagement_GetUserById_Handler(srv interface{}, ctx context.Context, d
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var UserManagement_ServiceDesc = grpc.ServiceDesc{
ServiceName: "user_management.user_management",
ServiceName: "user.user",
HandlerType: (*UserManagementServer)(nil),
Methods: []grpc.MethodDesc{
{
@ -317,5 +317,5 @@ var UserManagement_ServiceDesc = grpc.ServiceDesc{
},
},
Streams: []grpc.StreamDesc{},
Metadata: "user_management.proto",
Metadata: "user.proto",
}

View File

@ -2,9 +2,9 @@
// versions:
// protoc-gen-go v1.36.4
// protoc v3.19.4
// source: user_management.proto
// source: user.proto
package user_management
package user
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
@ -490,28 +490,28 @@ func file_user_management_proto_rawDescGZIP() []byte {
var file_user_management_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_user_management_proto_goTypes = []any{
(*Request)(nil), // 0: user_management.Request
(*Response)(nil), // 1: user_management.Response
(*SetUserRequest)(nil), // 2: user_management.SetUserRequest
(*SetUserResponse)(nil), // 3: user_management.SetUserResponse
(*CreateUserRequest)(nil), // 4: user_management.CreateUserRequest
(*UserId)(nil), // 5: user_management.UserId
(*Empty)(nil), // 6: user_management.Empty
(*User)(nil), // 7: user_management.User
(*Request)(nil), // 0: user.Request
(*Response)(nil), // 1: user.Response
(*SetUserRequest)(nil), // 2: user.SetUserRequest
(*SetUserResponse)(nil), // 3: user.SetUserResponse
(*CreateUserRequest)(nil), // 4: user.CreateUserRequest
(*UserId)(nil), // 5: user.UserId
(*Empty)(nil), // 6: user.Empty
(*User)(nil), // 7: user.User
}
var file_user_management_proto_depIdxs = []int32{
0, // 0: user_management.user_management.Ping:input_type -> user_management.Request
2, // 1: user_management.user_management.SetUser:input_type -> user_management.SetUserRequest
4, // 2: user_management.user_management.CreateUser:input_type -> user_management.CreateUserRequest
6, // 3: user_management.user_management.CreateEmptyUser:input_type -> user_management.Empty
5, // 4: user_management.user_management.FindById:input_type -> user_management.UserId
5, // 5: user_management.user_management.GetUserById:input_type -> user_management.UserId
1, // 6: user_management.user_management.Ping:output_type -> user_management.Response
3, // 7: user_management.user_management.SetUser:output_type -> user_management.SetUserResponse
5, // 8: user_management.user_management.CreateUser:output_type -> user_management.UserId
5, // 9: user_management.user_management.CreateEmptyUser:output_type -> user_management.UserId
7, // 10: user_management.user_management.FindById:output_type -> user_management.User
7, // 11: user_management.user_management.GetUserById:output_type -> user_management.User
0, // 0: user.user.Ping:input_type -> user.Request
2, // 1: user.user.SetUser:input_type -> user.SetUserRequest
4, // 2: user.user.CreateUser:input_type -> user.CreateUserRequest
6, // 3: user.user.CreateEmptyUser:input_type -> user.Empty
5, // 4: user.user.FindById:input_type -> user.UserId
5, // 5: user.user.GetUserById:input_type -> user.UserId
1, // 6: user.user.Ping:output_type -> user.Response
3, // 7: user.user.SetUser:output_type -> user.SetUserResponse
5, // 8: user.user.CreateUser:output_type -> user.UserId
5, // 9: user.user.CreateEmptyUser:output_type -> user.UserId
7, // 10: user.user.FindById:output_type -> user.User
7, // 11: user.user.GetUserById:output_type -> user.User
6, // [6:12] is the sub-list for method output_type
0, // [0:6] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name

View File

@ -1,27 +1,27 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.7.6
// Source: user_management.proto
// Source: user.proto
package user_management_client
package user_client
import (
"context"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user_management"
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/user_management/user"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
CreateUserRequest = user_management.CreateUserRequest
Empty = user_management.Empty
Request = user_management.Request
Response = user_management.Response
SetUserRequest = user_management.SetUserRequest
SetUserResponse = user_management.SetUserResponse
User = user_management.User
UserId = user_management.UserId
CreateUserRequest = user.CreateUserRequest
Empty = user.Empty
Request = user.Request
Response = user.Response
SetUserRequest = user.SetUserRequest
SetUserResponse = user.SetUserResponse
User = user.User
UserId = user.UserId
UserManagement interface {
Ping(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
@ -49,36 +49,36 @@ func NewUserManagement(cli zrpc.Client) UserManagement {
}
func (m *defaultUserManagement) Ping(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
client := user_management.NewUserManagementClient(m.cli.Conn())
client := user.NewUserManagementClient(m.cli.Conn())
return client.Ping(ctx, in, opts...)
}
// SetUser 设置用户信息
func (m *defaultUserManagement) SetUser(ctx context.Context, in *SetUserRequest, opts ...grpc.CallOption) (*SetUserResponse, error) {
client := user_management.NewUserManagementClient(m.cli.Conn())
client := user.NewUserManagementClient(m.cli.Conn())
return client.SetUser(ctx, in, opts...)
}
// CreateUser 获取用户或者创建用户
func (m *defaultUserManagement) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*UserId, error) {
client := user_management.NewUserManagementClient(m.cli.Conn())
client := user.NewUserManagementClient(m.cli.Conn())
return client.CreateUser(ctx, in, opts...)
}
// CreateEmptyUser 创建空用户,用于关联游戏账号的空数据
func (m *defaultUserManagement) CreateEmptyUser(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*UserId, error) {
client := user_management.NewUserManagementClient(m.cli.Conn())
client := user.NewUserManagementClient(m.cli.Conn())
return client.CreateEmptyUser(ctx, in, opts...)
}
// FirstOrCreateUser 创建用户或者获取用户
func (m *defaultUserManagement) FindById(ctx context.Context, in *UserId, opts ...grpc.CallOption) (*User, error) {
client := user_management.NewUserManagementClient(m.cli.Conn())
client := user.NewUserManagementClient(m.cli.Conn())
return client.FindById(ctx, in, opts...)
}
// GetUserById 通过 ID 获取用户
func (m *defaultUserManagement) GetUserById(ctx context.Context, in *UserId, opts ...grpc.CallOption) (*User, error) {
client := user_management.NewUserManagementClient(m.cli.Conn())
client := user.NewUserManagementClient(m.cli.Conn())
return client.GetUserById(ctx, in, opts...)
}

View File

@ -35,7 +35,7 @@ func TestGenConfig(t *testing.T) {
c.Mysql = "root:youtu!0113@tcp(192.168.0.47:3306)/ecpm?charset=utf8mb4&parseTime=True&loc=Local"
c.Redis = []Redis{{Host: "192.168.0.47:6379"}}
c.RpcServerConf.Etcd.Hosts = append(c.RpcServerConf.Etcd.Hosts, "192.168.0.47:2379")
c.RpcServerConf.Etcd.Key = "user_management.rpc"
c.RpcServerConf.Etcd.Key = "user.rpc"
b, err := json.Marshal(c)
if err != nil {
t.Fatal(err)