feat: import services and standardize Go 1.26.5
This commit is contained in:
36
apps/social/relation/internal/server/follow_server.go
Normal file
36
apps/social/relation/internal/server/follow_server.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// Code generated by protoc-gen-slc. DO NOT EDIT.
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.apinb.com/bsm-social/relation/internal/logic/follow"
|
||||
pb "git.apinb.com/bsm-social/relation/pb"
|
||||
)
|
||||
|
||||
type FollowServer struct {
|
||||
pb.UnimplementedFollowServer
|
||||
}
|
||||
|
||||
func NewFollowServer() *FollowServer {
|
||||
return &FollowServer{}
|
||||
}
|
||||
|
||||
// 执行关注
|
||||
func (s *FollowServer) Doing(ctx context.Context, in *pb.IdentRequest) (*pb.StatusReply, error) {
|
||||
return follow.Doing(ctx, in)
|
||||
}
|
||||
|
||||
// 撤销关注
|
||||
func (s *FollowServer) Undo(ctx context.Context, in *pb.IdentRequest) (*pb.StatusReply, error) {
|
||||
return follow.Undo(ctx, in)
|
||||
}
|
||||
|
||||
// 关注状态
|
||||
func (s *FollowServer) State(ctx context.Context, in *pb.IdentRequest) (*pb.StatusReply, error) {
|
||||
return follow.State(ctx, in)
|
||||
}
|
||||
|
||||
// 获取关注列表
|
||||
func (s *FollowServer) Fetch(ctx context.Context, in *pb.FetchRequest) (*pb.FetchRelationItemReply, error) {
|
||||
return follow.Fetch(ctx, in)
|
||||
}
|
||||
101
apps/social/relation/internal/server/friend_server.go
Normal file
101
apps/social/relation/internal/server/friend_server.go
Normal file
@@ -0,0 +1,101 @@
|
||||
// Code generated by protoc-gen-slc. DO NOT EDIT.
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.apinb.com/bsm-social/relation/internal/logic/friend"
|
||||
pb "git.apinb.com/bsm-social/relation/pb"
|
||||
)
|
||||
|
||||
type FriendServer struct {
|
||||
pb.UnimplementedFriendServer
|
||||
}
|
||||
|
||||
func NewFriendServer() *FriendServer {
|
||||
return &FriendServer{}
|
||||
}
|
||||
|
||||
// 搜索
|
||||
func (s *FriendServer) Search(ctx context.Context, in *pb.SearchRequest) (*pb.PartFriendReply, error) {
|
||||
return friend.Search(ctx, in)
|
||||
}
|
||||
|
||||
// 获取好友列表
|
||||
func (s *FriendServer) Fetch(ctx context.Context, in *pb.VersionRequest) (*pb.FriendsReply, error) {
|
||||
return friend.Fetch(ctx, in)
|
||||
}
|
||||
|
||||
// 获取用户信息卡片
|
||||
func (s *FriendServer) Get(ctx context.Context, in *pb.IdentRequest) (*pb.RelationItem, error) {
|
||||
return friend.Get(ctx, in)
|
||||
}
|
||||
|
||||
// 修改好友备注名称,如果要清除备注,直接nickname传空值
|
||||
func (s *FriendServer) ModifyNickname(ctx context.Context, in *pb.ModifyNicknameRequest) (*pb.StatusReply, error) {
|
||||
return friend.ModifyNickname(ctx, in)
|
||||
}
|
||||
|
||||
// 受你欢迎的,置顶
|
||||
func (s *FriendServer) DoPopular(ctx context.Context, in *pb.IdentRequest) (*pb.StatusReply, error) {
|
||||
return friend.DoPopular(ctx, in)
|
||||
}
|
||||
|
||||
// 取消受欢迎的,取消置顶
|
||||
func (s *FriendServer) UndoPopular(ctx context.Context, in *pb.IdentRequest) (*pb.StatusReply, error) {
|
||||
return friend.UndoPopular(ctx, in)
|
||||
}
|
||||
|
||||
// 删除好友
|
||||
func (s *FriendServer) Delete(ctx context.Context, in *pb.IdentRequest) (*pb.StatusReply, error) {
|
||||
return friend.Delete(ctx, in)
|
||||
}
|
||||
|
||||
// 好友申请列表
|
||||
func (s *FriendServer) ApplyFetch(ctx context.Context, in *pb.VersionRequest) (*pb.ApplyFetchReply, error) {
|
||||
return friend.ApplyFetch(ctx, in)
|
||||
}
|
||||
|
||||
// 好友申请详情
|
||||
func (s *FriendServer) ApplyGet(ctx context.Context, in *pb.IdentRequest) (*pb.FriendApplyGetReply, error) {
|
||||
return friend.ApplyGet(ctx, in)
|
||||
}
|
||||
|
||||
// 好友申请
|
||||
func (s *FriendServer) ApplyDo(ctx context.Context, in *pb.ApplyDoRequest) (*pb.StatusReply, error) {
|
||||
return friend.ApplyDo(ctx, in)
|
||||
}
|
||||
|
||||
// 好友申请Do:留言
|
||||
func (s *FriendServer) ApplyDoMessage(ctx context.Context, in *pb.ApplyMessageRequest) (*pb.StatusReply, error) {
|
||||
return friend.ApplyDoMessage(ctx, in)
|
||||
}
|
||||
|
||||
// 好友申请Do:确认
|
||||
func (s *FriendServer) ApplyDoPass(ctx context.Context, in *pb.ApplyDoPassRequest) (*pb.StatusReply, error) {
|
||||
return friend.ApplyDoPass(ctx, in)
|
||||
}
|
||||
|
||||
// 好友申请Do:拒绝
|
||||
func (s *FriendServer) ApplyDoReject(ctx context.Context, in *pb.IdentRequest) (*pb.StatusReply, error) {
|
||||
return friend.ApplyDoReject(ctx, in)
|
||||
}
|
||||
|
||||
// 获取标签列表
|
||||
func (s *FriendServer) TagFetch(ctx context.Context, in *pb.Empty) (*pb.FriendTagsReply, error) {
|
||||
return friend.TagFetch(ctx, in)
|
||||
}
|
||||
|
||||
// 获取标签成员
|
||||
func (s *FriendServer) TagMemberFetch(ctx context.Context, in *pb.IdentRequest) (*pb.PartFriendReply, error) {
|
||||
return friend.TagMemberFetch(ctx, in)
|
||||
}
|
||||
|
||||
// 创建标签
|
||||
func (s *FriendServer) TagDoCreate(ctx context.Context, in *pb.TagDoCreateRequest) (*pb.StatusReply, error) {
|
||||
return friend.TagDoCreate(ctx, in)
|
||||
}
|
||||
|
||||
// 更新标签成员
|
||||
func (s *FriendServer) TagDoUpdate(ctx context.Context, in *pb.TagDoUpdateRequest) (*pb.StatusReply, error) {
|
||||
return friend.TagDoUpdate(ctx, in)
|
||||
}
|
||||
36
apps/social/relation/internal/server/match_server.go
Normal file
36
apps/social/relation/internal/server/match_server.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// Code generated by protoc-gen-slc. DO NOT EDIT.
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.apinb.com/bsm-social/relation/internal/logic/match"
|
||||
pb "git.apinb.com/bsm-social/relation/pb"
|
||||
)
|
||||
|
||||
type MatchServer struct {
|
||||
pb.UnimplementedMatchServer
|
||||
}
|
||||
|
||||
func NewMatchServer() *MatchServer {
|
||||
return &MatchServer{}
|
||||
}
|
||||
|
||||
// 获取匹配列表
|
||||
func (s *MatchServer) Fetch(ctx context.Context, in *pb.FetchRequest) (*pb.FetchRelationItemReply, error) {
|
||||
return match.Fetch(ctx, in)
|
||||
}
|
||||
|
||||
// 获取匹配详情
|
||||
func (s *MatchServer) Get(ctx context.Context, in *pb.IdentRequest) (*pb.RelationItem, error) {
|
||||
return match.Get(ctx, in)
|
||||
}
|
||||
|
||||
// 执行通过,加为好友
|
||||
func (s *MatchServer) DoJoin(ctx context.Context, in *pb.IdentRequest) (*pb.StatusReply, error) {
|
||||
return match.DoJoin(ctx, in)
|
||||
}
|
||||
|
||||
// 执行忽略
|
||||
func (s *MatchServer) DoIgnore(ctx context.Context, in *pb.IdentRequest) (*pb.StatusReply, error) {
|
||||
return match.DoIgnore(ctx, in)
|
||||
}
|
||||
75
apps/social/relation/internal/server/new.go
Normal file
75
apps/social/relation/internal/server/new.go
Normal file
@@ -0,0 +1,75 @@
|
||||
// Code generated by protoc-gen-slc. DO NOT EDIT.
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.apinb.com/bsm-sdk/core/vars"
|
||||
pb "git.apinb.com/bsm-social/relation/pb"
|
||||
gwRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
Grpc *grpc.Server
|
||||
Ctx context.Context
|
||||
Mux *gwRuntime.ServeMux
|
||||
}
|
||||
|
||||
func New(addr string) *Server {
|
||||
srv := &Server{Ctx: context.Background(), Grpc: grpc.NewServer(), Mux: gwRuntime.NewServeMux(
|
||||
gwRuntime.WithForwardResponseRewriter(responseEnvelope),
|
||||
)}
|
||||
|
||||
// register service to grpc.Server
|
||||
pb.RegisterFollowServer(srv.Grpc, NewFollowServer())
|
||||
pb.RegisterFriendServer(srv.Grpc, NewFriendServer())
|
||||
pb.RegisterMatchServer(srv.Grpc, NewMatchServer())
|
||||
|
||||
reflection.Register(srv.Grpc)
|
||||
|
||||
// 将服务注册到Gateway
|
||||
opts := []grpc.DialOption{grpc.WithInsecure()}
|
||||
pb.RegisterFollowHandlerFromEndpoint(srv.Ctx, srv.Mux, addr, opts)
|
||||
pb.RegisterFriendHandlerFromEndpoint(srv.Ctx, srv.Mux, addr, opts)
|
||||
pb.RegisterMatchHandlerFromEndpoint(srv.Ctx, srv.Mux, addr, opts)
|
||||
|
||||
// Register services swagger
|
||||
srv.RegisterSwagger()
|
||||
|
||||
return srv
|
||||
}
|
||||
|
||||
// RegisterSwagger 注册swagger
|
||||
func (s *Server) RegisterSwagger() {
|
||||
srvKey := strings.ToLower(vars.ServiceKey)
|
||||
s.Mux.HandlePath("GET", "/"+srvKey+".swagger.json", func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
bytes, err := os.ReadFile("./swagger/" + srvKey + ".swagger.json")
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
w.Write(bytes)
|
||||
return
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
// response envelope
|
||||
func responseEnvelope(_ context.Context, response proto.Message) (interface{}, error) {
|
||||
name := string(response.ProtoReflect().Descriptor().Name())
|
||||
if name == "Status" || name == "Error" || name == "StatusReply" {
|
||||
return response, nil
|
||||
}
|
||||
return map[string]any{
|
||||
"code": 0,
|
||||
"message": "OK",
|
||||
"result": response,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user