Merge branch 'feature-auth-daiyb' into dev
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
commit
ce36b30e00
@ -184,3 +184,26 @@ func (a *AyrshareProvider) GenerateJWT(_ context.Context, req *aryshare.Generate
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnlinkSocialNetwork 解除社交网络连接
|
||||||
|
func (a *AyrshareProvider) UnlinkSocialNetwork(_ context.Context, req *aryshare.UnlinkSocialNetworkRequest) (res *aryshare.UnlinkSocialNetworkResponse, err error) {
|
||||||
|
res = new(aryshare.UnlinkSocialNetworkResponse)
|
||||||
|
|
||||||
|
// 将 proto 请求转换为 DTO
|
||||||
|
dtoReq := &dto.UnlinkSocialNetworkRequest{
|
||||||
|
Platform: req.Platform,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 调用 logic 层
|
||||||
|
dtoRes, err := a.aryshareProfileLogic.UnlinkSocialNetwork(dtoReq, req.ProfileKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将 DTO 响应转换为 proto 响应
|
||||||
|
res.Status = dtoRes.Status
|
||||||
|
res.Platform = dtoRes.Platform
|
||||||
|
res.RefId = dtoRes.RefId
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@ -85,3 +85,15 @@ type GenerateJWTResponse struct {
|
|||||||
EmailSent bool `json:"emailSent"`
|
EmailSent bool `json:"emailSent"`
|
||||||
ExpiresIn string `json:"expiresIn"`
|
ExpiresIn string `json:"expiresIn"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnlinkSocialNetworkRequest 解除社交网络连接请求
|
||||||
|
type UnlinkSocialNetworkRequest struct {
|
||||||
|
Platform string `json:"platform"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnlinkSocialNetworkResponse 解除社交网络连接响应
|
||||||
|
type UnlinkSocialNetworkResponse struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
Platform string `json:"platform"`
|
||||||
|
RefId string `json:"refId"`
|
||||||
|
}
|
||||||
@ -19,6 +19,7 @@ type IAryshareProfile interface {
|
|||||||
CreateProfile(req *dto.CreateProfileRequest) (res *dto.CreateProfileResponse, err error)
|
CreateProfile(req *dto.CreateProfileRequest) (res *dto.CreateProfileResponse, err error)
|
||||||
GetProfiles(req *dto.GetProfilesRequest) (res *dto.GetProfilesResponse, err error)
|
GetProfiles(req *dto.GetProfilesRequest) (res *dto.GetProfilesResponse, err error)
|
||||||
GenerateJWT(req *dto.GenerateJWTRequest) (res *dto.GenerateJWTResponse, err error)
|
GenerateJWT(req *dto.GenerateJWTRequest) (res *dto.GenerateJWTResponse, err error)
|
||||||
|
UnlinkSocialNetwork(req *dto.UnlinkSocialNetworkRequest, profileKey string) (res *dto.UnlinkSocialNetworkResponse, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type AyrshareProfile struct {
|
type AyrshareProfile struct {
|
||||||
@ -209,3 +210,57 @@ func (a *AyrshareProfile) GenerateJWT(req *dto.GenerateJWTRequest) (res *dto.Gen
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnlinkSocialNetwork 解除社交网络连接
|
||||||
|
func (a *AyrshareProfile) UnlinkSocialNetwork(req *dto.UnlinkSocialNetworkRequest, profileKey string) (res *dto.UnlinkSocialNetworkResponse, err error) {
|
||||||
|
errCommon.NoReturnInfo(req, "解除社交网络连接 参数信息: ")
|
||||||
|
|
||||||
|
res = new(dto.UnlinkSocialNetworkResponse)
|
||||||
|
|
||||||
|
// 验证必填参数
|
||||||
|
if req.Platform == "" {
|
||||||
|
return nil, errCommon.ReturnError(fmt.Errorf(msg.ErrPlatformEmpty), msg.ErrPlatformEmpty, "解除社交网络连接 失败: ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建请求URL
|
||||||
|
url := fmt.Sprintf("%s/api/profiles/social", app.ModuleClients.AryshareClient.Config.Endpoint)
|
||||||
|
|
||||||
|
// 准备请求体
|
||||||
|
reqBody, err := json.Marshal(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errCommon.ReturnError(err, msg.ErrorJSONMarshal, "解除社交网络连接失败: ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 准备请求头
|
||||||
|
headers := make(map[string]string)
|
||||||
|
headers["Authorization"] = fmt.Sprintf("Bearer %s", app.ModuleClients.AryshareClient.Config.ApiKey)
|
||||||
|
headers["Content-Type"] = "application/json"
|
||||||
|
|
||||||
|
// 如果提供了 profileKey,添加到请求头
|
||||||
|
if profileKey != "" {
|
||||||
|
headers["Profile-Key"] = profileKey
|
||||||
|
}
|
||||||
|
|
||||||
|
// 调用 HTTP DELETE 方法
|
||||||
|
statusCode, result, err := utils.DeleteWithHeaders(url, reqBody, headers)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errCommon.ReturnError(err, "解除社交网络连接失败", "解除社交网络连接失败: ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查状态码
|
||||||
|
if statusCode != http.StatusOK {
|
||||||
|
return nil, errCommon.ReturnError(fmt.Errorf("接口返回状态码: %d, 响应结果: %s", statusCode, result), "解除社交网络连接失败", "解除社交网络连接 失败: ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析响应
|
||||||
|
var unlinkResp dto.UnlinkSocialNetworkResponse
|
||||||
|
if err := json.Unmarshal([]byte(result), &unlinkResp); err != nil {
|
||||||
|
return nil, errCommon.ReturnError(err, msg.ErrorJSONParse, "解除社交网络连接失败: ")
|
||||||
|
}
|
||||||
|
|
||||||
|
errCommon.NoReturnInfo(&unlinkResp, "解除社交网络连接 成功: ")
|
||||||
|
|
||||||
|
res = &unlinkResp
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -206,6 +206,15 @@ func (this *GenerateJWTRequest) Validate() error {
|
|||||||
func (this *GenerateJWTResponse) Validate() error {
|
func (this *GenerateJWTResponse) Validate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (this *UnlinkSocialNetworkRequest) Validate() error {
|
||||||
|
if this.Platform == "" {
|
||||||
|
return github_com_mwitkow_go_proto_validators.FieldError("Platform", fmt.Errorf(`platform不能为空`))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *UnlinkSocialNetworkResponse) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
func (this *HistoryPostId) Validate() error {
|
func (this *HistoryPostId) Validate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
|
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// - protoc-gen-go-triple v1.0.8
|
// - protoc-gen-go-triple v1.0.8
|
||||||
// - protoc v3.21.1
|
// - protoc v6.32.0--rc2
|
||||||
// source: pb/ayrshare.proto
|
// source: pb/ayrshare.proto
|
||||||
|
|
||||||
package aryshare
|
package aryshare
|
||||||
@ -37,6 +37,7 @@ type AyrshareClient interface {
|
|||||||
CreateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc_go.CallOption) (*CreateProfileResponse, common.ErrorWithAttachment)
|
CreateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc_go.CallOption) (*CreateProfileResponse, common.ErrorWithAttachment)
|
||||||
GetProfiles(ctx context.Context, in *GetProfilesRequest, opts ...grpc_go.CallOption) (*GetProfilesResponse, common.ErrorWithAttachment)
|
GetProfiles(ctx context.Context, in *GetProfilesRequest, opts ...grpc_go.CallOption) (*GetProfilesResponse, common.ErrorWithAttachment)
|
||||||
GenerateJWT(ctx context.Context, in *GenerateJWTRequest, opts ...grpc_go.CallOption) (*GenerateJWTResponse, common.ErrorWithAttachment)
|
GenerateJWT(ctx context.Context, in *GenerateJWTRequest, opts ...grpc_go.CallOption) (*GenerateJWTResponse, common.ErrorWithAttachment)
|
||||||
|
UnlinkSocialNetwork(ctx context.Context, in *UnlinkSocialNetworkRequest, opts ...grpc_go.CallOption) (*UnlinkSocialNetworkResponse, common.ErrorWithAttachment)
|
||||||
// 历史记录相关 api
|
// 历史记录相关 api
|
||||||
GetHistory(ctx context.Context, in *GetHistoryRequest, opts ...grpc_go.CallOption) (*GetHistoryResponse, common.ErrorWithAttachment)
|
GetHistory(ctx context.Context, in *GetHistoryRequest, opts ...grpc_go.CallOption) (*GetHistoryResponse, common.ErrorWithAttachment)
|
||||||
GetHistoryById(ctx context.Context, in *GetHistoryByIdRequest, opts ...grpc_go.CallOption) (*GetHistoryByIdResponse, common.ErrorWithAttachment)
|
GetHistoryById(ctx context.Context, in *GetHistoryByIdRequest, opts ...grpc_go.CallOption) (*GetHistoryByIdResponse, common.ErrorWithAttachment)
|
||||||
@ -71,6 +72,7 @@ type AyrshareClientImpl struct {
|
|||||||
CreateProfile func(ctx context.Context, in *CreateProfileRequest) (*CreateProfileResponse, error)
|
CreateProfile func(ctx context.Context, in *CreateProfileRequest) (*CreateProfileResponse, error)
|
||||||
GetProfiles func(ctx context.Context, in *GetProfilesRequest) (*GetProfilesResponse, error)
|
GetProfiles func(ctx context.Context, in *GetProfilesRequest) (*GetProfilesResponse, error)
|
||||||
GenerateJWT func(ctx context.Context, in *GenerateJWTRequest) (*GenerateJWTResponse, error)
|
GenerateJWT func(ctx context.Context, in *GenerateJWTRequest) (*GenerateJWTResponse, error)
|
||||||
|
UnlinkSocialNetwork func(ctx context.Context, in *UnlinkSocialNetworkRequest) (*UnlinkSocialNetworkResponse, error)
|
||||||
GetHistory func(ctx context.Context, in *GetHistoryRequest) (*GetHistoryResponse, error)
|
GetHistory func(ctx context.Context, in *GetHistoryRequest) (*GetHistoryResponse, error)
|
||||||
GetHistoryById func(ctx context.Context, in *GetHistoryByIdRequest) (*GetHistoryByIdResponse, error)
|
GetHistoryById func(ctx context.Context, in *GetHistoryByIdRequest) (*GetHistoryByIdResponse, error)
|
||||||
GetHistoryByPlatform func(ctx context.Context, in *GetHistoryByPlatformRequest) (*GetHistoryByPlatformResponse, error)
|
GetHistoryByPlatform func(ctx context.Context, in *GetHistoryByPlatformRequest) (*GetHistoryByPlatformResponse, error)
|
||||||
@ -137,6 +139,12 @@ func (c *ayrshareClient) GenerateJWT(ctx context.Context, in *GenerateJWTRequest
|
|||||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/GenerateJWT", in, out)
|
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/GenerateJWT", in, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ayrshareClient) UnlinkSocialNetwork(ctx context.Context, in *UnlinkSocialNetworkRequest, opts ...grpc_go.CallOption) (*UnlinkSocialNetworkResponse, common.ErrorWithAttachment) {
|
||||||
|
out := new(UnlinkSocialNetworkResponse)
|
||||||
|
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||||
|
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UnlinkSocialNetwork", in, out)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *ayrshareClient) GetHistory(ctx context.Context, in *GetHistoryRequest, opts ...grpc_go.CallOption) (*GetHistoryResponse, common.ErrorWithAttachment) {
|
func (c *ayrshareClient) GetHistory(ctx context.Context, in *GetHistoryRequest, opts ...grpc_go.CallOption) (*GetHistoryResponse, common.ErrorWithAttachment) {
|
||||||
out := new(GetHistoryResponse)
|
out := new(GetHistoryResponse)
|
||||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||||
@ -246,6 +254,7 @@ type AyrshareServer interface {
|
|||||||
CreateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error)
|
CreateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error)
|
||||||
GetProfiles(context.Context, *GetProfilesRequest) (*GetProfilesResponse, error)
|
GetProfiles(context.Context, *GetProfilesRequest) (*GetProfilesResponse, error)
|
||||||
GenerateJWT(context.Context, *GenerateJWTRequest) (*GenerateJWTResponse, error)
|
GenerateJWT(context.Context, *GenerateJWTRequest) (*GenerateJWTResponse, error)
|
||||||
|
UnlinkSocialNetwork(context.Context, *UnlinkSocialNetworkRequest) (*UnlinkSocialNetworkResponse, error)
|
||||||
// 历史记录相关 api
|
// 历史记录相关 api
|
||||||
GetHistory(context.Context, *GetHistoryRequest) (*GetHistoryResponse, error)
|
GetHistory(context.Context, *GetHistoryRequest) (*GetHistoryResponse, error)
|
||||||
GetHistoryById(context.Context, *GetHistoryByIdRequest) (*GetHistoryByIdResponse, error)
|
GetHistoryById(context.Context, *GetHistoryByIdRequest) (*GetHistoryByIdResponse, error)
|
||||||
@ -293,6 +302,9 @@ func (UnimplementedAyrshareServer) GetProfiles(context.Context, *GetProfilesRequ
|
|||||||
func (UnimplementedAyrshareServer) GenerateJWT(context.Context, *GenerateJWTRequest) (*GenerateJWTResponse, error) {
|
func (UnimplementedAyrshareServer) GenerateJWT(context.Context, *GenerateJWTRequest) (*GenerateJWTResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method GenerateJWT not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method GenerateJWT not implemented")
|
||||||
}
|
}
|
||||||
|
func (UnimplementedAyrshareServer) UnlinkSocialNetwork(context.Context, *UnlinkSocialNetworkRequest) (*UnlinkSocialNetworkResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method UnlinkSocialNetwork not implemented")
|
||||||
|
}
|
||||||
func (UnimplementedAyrshareServer) GetHistory(context.Context, *GetHistoryRequest) (*GetHistoryResponse, error) {
|
func (UnimplementedAyrshareServer) GetHistory(context.Context, *GetHistoryRequest) (*GetHistoryResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method GetHistory not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method GetHistory not implemented")
|
||||||
}
|
}
|
||||||
@ -543,6 +555,35 @@ func _Ayrshare_GenerateJWT_Handler(srv interface{}, ctx context.Context, dec fun
|
|||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _Ayrshare_UnlinkSocialNetwork_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(UnlinkSocialNetworkRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
base := srv.(dubbo3.Dubbo3GrpcService)
|
||||||
|
args := []interface{}{}
|
||||||
|
args = append(args, in)
|
||||||
|
md, _ := metadata.FromIncomingContext(ctx)
|
||||||
|
invAttachment := make(map[string]interface{}, len(md))
|
||||||
|
for k, v := range md {
|
||||||
|
invAttachment[k] = v
|
||||||
|
}
|
||||||
|
invo := invocation.NewRPCInvocation("UnlinkSocialNetwork", args, invAttachment)
|
||||||
|
if interceptor == nil {
|
||||||
|
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||||
|
return result, result.Error()
|
||||||
|
}
|
||||||
|
info := &grpc_go.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||||
|
return result, result.Error()
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
func _Ayrshare_GetHistory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
func _Ayrshare_GetHistory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(GetHistoryRequest)
|
in := new(GetHistoryRequest)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
@ -1038,6 +1079,10 @@ var Ayrshare_ServiceDesc = grpc_go.ServiceDesc{
|
|||||||
MethodName: "GenerateJWT",
|
MethodName: "GenerateJWT",
|
||||||
Handler: _Ayrshare_GenerateJWT_Handler,
|
Handler: _Ayrshare_GenerateJWT_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "UnlinkSocialNetwork",
|
||||||
|
Handler: _Ayrshare_UnlinkSocialNetwork_Handler,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
MethodName: "GetHistory",
|
MethodName: "GetHistory",
|
||||||
Handler: _Ayrshare_GetHistory_Handler,
|
Handler: _Ayrshare_GetHistory_Handler,
|
||||||
|
|||||||
@ -18,6 +18,7 @@ service Ayrshare {
|
|||||||
rpc CreateProfile(CreateProfileRequest) returns (CreateProfileResponse);
|
rpc CreateProfile(CreateProfileRequest) returns (CreateProfileResponse);
|
||||||
rpc GetProfiles(GetProfilesRequest) returns (GetProfilesResponse);
|
rpc GetProfiles(GetProfilesRequest) returns (GetProfilesResponse);
|
||||||
rpc GenerateJWT(GenerateJWTRequest) returns (GenerateJWTResponse);
|
rpc GenerateJWT(GenerateJWTRequest) returns (GenerateJWTResponse);
|
||||||
|
rpc UnlinkSocialNetwork(UnlinkSocialNetworkRequest) returns (UnlinkSocialNetworkResponse);
|
||||||
|
|
||||||
// 历史记录相关 api
|
// 历史记录相关 api
|
||||||
rpc GetHistory(GetHistoryRequest) returns (GetHistoryResponse);
|
rpc GetHistory(GetHistoryRequest) returns (GetHistoryResponse);
|
||||||
@ -350,6 +351,19 @@ message GenerateJWTResponse {
|
|||||||
string expiresIn = 6 [json_name = "expiresIn"];
|
string expiresIn = 6 [json_name = "expiresIn"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 解除社交网络连接请求
|
||||||
|
message UnlinkSocialNetworkRequest {
|
||||||
|
string platform = 1 [json_name = "platform", (validator.field) = {string_not_empty: true, human_error: "platform不能为空"}];
|
||||||
|
string profileKey = 2 [json_name = "profileKey"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解除社交网络连接响应
|
||||||
|
message UnlinkSocialNetworkResponse {
|
||||||
|
string status = 1 [json_name = "status"];
|
||||||
|
string platform = 2 [json_name = "platform"];
|
||||||
|
string refId = 3 [json_name = "refId"];
|
||||||
|
}
|
||||||
|
|
||||||
// 历史记录中的帖子 ID
|
// 历史记录中的帖子 ID
|
||||||
message HistoryPostId {
|
message HistoryPostId {
|
||||||
string status = 1 [json_name = "status"];
|
string status = 1 [json_name = "status"];
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package msg
|
|||||||
const (
|
const (
|
||||||
ErrProfileTitleEmpty = "用户配置标题不能为空"
|
ErrProfileTitleEmpty = "用户配置标题不能为空"
|
||||||
ErrProfileEmailRequiredWhenTeamTrue = "当team为true时,email不能为空"
|
ErrProfileEmailRequiredWhenTeamTrue = "当team为true时,email不能为空"
|
||||||
|
ErrPlatformEmpty = "平台名称不能为空"
|
||||||
ErrorCreateProfileFailed = "创建用户配置失败"
|
ErrorCreateProfileFailed = "创建用户配置失败"
|
||||||
ErrorGetProfilesFailed = "获取用户配置列表失败"
|
ErrorGetProfilesFailed = "获取用户配置列表失败"
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user