jimmyyem 5 luni în urmă
părinte
comite
0ce51361fd

+ 2 - 1
desc/all.api

@@ -27,4 +27,5 @@ import "./wechat/chat_records.api"
 import "./wechat/chat_session.api"
 import "./wechat/wx_card.api"
 import "./wechat/wx_card_user.api"
-import "./wechat/wx_card_visit.api"
+import "./wechat/wx_card_visit.api"
+import "./wechat/avatar.api"

+ 16 - 1
desc/wechat/avatar.api

@@ -2,7 +2,22 @@ import "../base.api"
 
 type (
 	AvatarInfo {
+		RequestId *string `json:"requestId"`
+		SessionId *string `json:"SessionId"`
+		Token *string  `json:"token"`
+		Channel Channel `json:"channel"`
+	}
 
+	Channel {
+		ChannelId *string `json:"channelId"`
+		Token *string `json:"token"`
+		Type *string `json:"type"`
+		ExpiredTime *string `json:"expiredTime"`
+		Nonce *string `json:"nonce"`
+		UserId *string `json:"userId"`
+		AppId *string `json:"appId"`
+		UserInfoInChannel *string `json:"userInfoInChannel"`
+		Gslb []string `json:"gslb"`
 	}
 
 	// start avatar request | 启动数字人
@@ -22,7 +37,7 @@ type (
 
 @server(
     jwt: Auth
-    group: agent
+    group: avatar
     middleware: Miniprogram
 )
 

+ 1 - 1
desc/wechat/category.api

@@ -54,7 +54,7 @@ type (
 service Wechat {
 	// Get category list | 获取 category 列表
 	@handler getApiCategoryList
-	post /api/category/list () returns (CategoryListResp)
+	post /api/category/list returns (CategoryListResp)
 }
 
 @server(

+ 1 - 1
desc/wechat/chat_records.api

@@ -69,7 +69,7 @@ type (
 service Wechat {
 	// Create chat records information | 创建ChatRecords
 	@handler submitApiChat
-	post /api/chat/create (ChatRecordsInfo) returns ()
+	post /api/chat/create (ChatRecordsInfo)
 
 	// Get chat records list | 获取ChatRecords列表
 	@handler getApiChatList

+ 1 - 3
desc/wechat/user.api

@@ -112,13 +112,11 @@ type (
 service Wechat {
 	// Get user basic information | 获取用户基本信息
 	@handler doApiUserLogin
-	get /api/user/login (UserLoginReq) returns (UserLoginResp)
+	post /api/user/login (UserLoginReq) returns (UserLoginResp)
 }
 
 @server(
-    jwt: Auth
     group: User
-    middleware: Authority
 )
 
 service Wechat {

+ 44 - 0
internal/handler/avatar/get_api_avatar_config_handler.go

@@ -0,0 +1,44 @@
+package avatar
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/avatar"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /api/avatar/config avatar GetApiAvatarConfig
+//
+// get avatar configuration | 获取数字人配置信息
+//
+// get avatar configuration | 获取数字人配置信息
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: AvatarConfigReq
+//
+// Responses:
+//  200: AvatarConfigResp
+
+func GetApiAvatarConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.AvatarConfigReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := avatar.NewGetApiAvatarConfigLogic(r.Context(), svcCtx)
+		resp, err := l.GetApiAvatarConfig(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 23 - 12
internal/handler/routes.go

@@ -13,6 +13,7 @@ import (
 	Wxhook "wechat-api/internal/handler/Wxhook"
 	agent "wechat-api/internal/handler/agent"
 	agent_base "wechat-api/internal/handler/agent_base"
+	avatar "wechat-api/internal/handler/avatar"
 	base "wechat-api/internal/handler/base"
 	batch_msg "wechat-api/internal/handler/batch_msg"
 	category "wechat-api/internal/handler/category"
@@ -625,7 +626,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 	server.AddRoutes(
 		[]rest.Route{
 			{
-				Method:  http.MethodGet,
+				Method:  http.MethodPost,
 				Path:    "/api/user/login",
 				Handler: User.DoApiUserLoginHandler(serverCtx),
 			},
@@ -633,17 +634,13 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 	)
 
 	server.AddRoutes(
-		rest.WithMiddlewares(
-			[]rest.Middleware{serverCtx.Authority},
-			[]rest.Route{
-				{
-					Method:  http.MethodGet,
-					Path:    "/user/info",
-					Handler: User.GetUserInfoHandler(serverCtx),
-				},
-			}...,
-		),
-		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
+		[]rest.Route{
+			{
+				Method:  http.MethodGet,
+				Path:    "/user/info",
+				Handler: User.GetUserInfoHandler(serverCtx),
+			},
+		},
 	)
 
 	server.AddRoutes(
@@ -1285,4 +1282,18 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 		),
 		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
 	)
+
+	server.AddRoutes(
+		rest.WithMiddlewares(
+			[]rest.Middleware{serverCtx.Miniprogram},
+			[]rest.Route{
+				{
+					Method:  http.MethodPost,
+					Path:    "/api/avatar/config",
+					Handler: avatar.GetApiAvatarConfigHandler(serverCtx),
+				},
+			}...,
+		),
+		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
+	)
 }

+ 28 - 0
internal/logic/avatar/get_api_avatar_config_logic.go

@@ -0,0 +1,28 @@
+package avatar
+
+import (
+	"context"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetApiAvatarConfigLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGetApiAvatarConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetApiAvatarConfigLogic {
+	return &GetApiAvatarConfigLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *GetApiAvatarConfigLogic) GetApiAvatarConfig(req *types.AvatarConfigReq) (*types.AvatarConfigResp, error) {
+
+	return &types.AvatarConfigResp{}, nil
+}

+ 35 - 0
internal/types/types.go

@@ -2410,3 +2410,38 @@ type WxCardVisitInfoResp struct {
 	// WxCardVisit information | WxCardVisit数据
 	Data WxCardVisitInfo `json:"data"`
 }
+
+// swagger:model AvatarInfo
+type AvatarInfo struct {
+	RequestId *string `json:"requestId"`
+	SessionId *string `json:"SessionId"`
+	Token     *string `json:"token"`
+	Channel   Channel `json:"channel"`
+}
+
+type Channel struct {
+	ChannelId         *string  `json:"channelId"`
+	Token             *string  `json:"token"`
+	Type              *string  `json:"type"`
+	ExpiredTime       *string  `json:"expiredTime"`
+	Nonce             *string  `json:"nonce"`
+	UserId            *string  `json:"userId"`
+	AppId             *string  `json:"appId"`
+	UserInfoInChannel *string  `json:"userInfoInChannel"`
+	Gslb              []string `json:"gslb"`
+}
+
+// start avatar request | 启动数字人
+// swagger:model AvatarConfigReq
+type AvatarConfigReq struct {
+	// 名片 ID
+	CardId *uint64 `json:"card_id,optional"`
+}
+
+// start avatar response | 启动数字人
+// swagger:model AvatarConfigResp
+type AvatarConfigResp struct {
+	BaseDataInfo
+	// Agent information | Agent数据
+	Data AvatarInfo `json:"data"`
+}