Browse Source

fix:save 5

jimmyyem 5 months ago
parent
commit
6d67a08c2a

+ 2 - 2
desc/wechat/chat_records.api

@@ -61,9 +61,9 @@ type (
 )
 
 @server(
-//	jwt: Auth
+	jwt: Auth
 	group: chatrecords
-//	middleware: Miniprogram
+	middleware: Miniprogram
 )
 
 service Wechat {

+ 21 - 17
internal/handler/routes.go

@@ -1011,23 +1011,27 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 	)
 
 	server.AddRoutes(
-		[]rest.Route{
-			{
-				Method:  http.MethodPost,
-				Path:    "/api/chat/create",
-				Handler: chatrecords.SubmitApiChatHandler(serverCtx),
-			},
-			{
-				Method:  http.MethodPost,
-				Path:    "/api/chat/list",
-				Handler: chatrecords.GetApiChatListHandler(serverCtx),
-			},
-			{
-				Method:  http.MethodPost,
-				Path:    "/api/chat/save",
-				Handler: chatrecords.SaveApiChatHandler(serverCtx),
-			},
-		},
+		rest.WithMiddlewares(
+			[]rest.Middleware{serverCtx.Miniprogram},
+			[]rest.Route{
+				{
+					Method:  http.MethodPost,
+					Path:    "/api/chat/create",
+					Handler: chatrecords.SubmitApiChatHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/api/chat/list",
+					Handler: chatrecords.GetApiChatListHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/api/chat/save",
+					Handler: chatrecords.SaveApiChatHandler(serverCtx),
+				},
+			}...,
+		),
+		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
 	)
 
 	server.AddRoutes(

+ 1 - 1
internal/logic/chatrecords/get_api_chat_list_logic.go

@@ -29,7 +29,7 @@ func NewGetApiChatListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
 }
 
 func (l *GetApiChatListLogic) GetApiChatList(req *types.ChatRecordsListReq) (*types.ChatRecordsListResp, error) {
-	userId := uint64(1) //l.ctx.Value("userId").(uint64)
+	userId := l.ctx.Value("userId").(uint64)
 
 	var predicates []predicate.ChatRecords
 	predicates = append(predicates, chatrecords.UserID(userId))