From bcc05bef5890b2eee28a16238d465a7744140aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=A5=E6=B5=B7?= Date: Sat, 9 Dec 2023 21:03:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A5=E5=8F=A3=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E6=80=A7=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- httpd/server.go | 4 ++-- httpd/wcfrest/controller.go | 16 +++++++------- httpd/wcfrest/router.go | 2 +- public/swagger.json | 42 ++++++++++++++++++------------------- wcferry/cmd_client.go | 24 ++++++++++----------- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/httpd/server.go b/httpd/server.go index 72a7c018..28c497f9 100644 --- a/httpd/server.go +++ b/httpd/server.go @@ -9,9 +9,9 @@ import ( ) // @title Wechat Rest API -// @version v0.4.0 +// @version v0.4.1 // @description 基于 WeChatFerry RPC 实现的电脑版微信 REST-API,使用 Go 语言编写,无第三方运行时依赖。基于 HTTP 提供操作接口,轻松对接任意编程语言。 -// @contact.name Github +// @contact.name WeChatRest // @contact.url https://github.com/opentdp/wechat-rest // @license.name Apache 2.0 // @license.url http://www.apache.org/licenses/LICENSE-2.0.html diff --git a/httpd/wcfrest/controller.go b/httpd/wcfrest/controller.go index ca8c47c5..963d63fe 100644 --- a/httpd/wcfrest/controller.go +++ b/httpd/wcfrest/controller.go @@ -199,12 +199,12 @@ func getAliasInChatRoom(c *gin.Context) { } -// @Summary 添加群成员 +// @Summary 邀请群成员 // @Produce json // @Param body body wcferry.MemberMgmt true "增删群成员请求参数" // @Success 200 {object} ActionResponse -// @Router /add_chatroom_members [post] -func addChatRoomMembers(c *gin.Context) { +// @Router /invite_chatroom_members [post] +func inviteChatroomMembers(c *gin.Context) { var req wcferry.MemberMgmt if err := c.ShouldBindJSON(&req); err != nil { @@ -212,7 +212,7 @@ func addChatRoomMembers(c *gin.Context) { return } - status := wc.CmdClient.AddChatRoomMembers(req.Roomid, req.Wxids) + status := wc.CmdClient.InviteChatroomMembers(req.Roomid, req.Wxids) c.Set("Payload", ActionResponse{ Success: status == 1, @@ -220,12 +220,12 @@ func addChatRoomMembers(c *gin.Context) { } -// @Summary 邀请群成员 +// @Summary 添加群成员 // @Produce json // @Param body body wcferry.MemberMgmt true "增删群成员请求参数" // @Success 200 {object} ActionResponse -// @Router /invite_chatroom_members [post] -func inviteChatroomMembers(c *gin.Context) { +// @Router /add_chatroom_members [post] +func addChatRoomMembers(c *gin.Context) { var req wcferry.MemberMgmt if err := c.ShouldBindJSON(&req); err != nil { @@ -233,7 +233,7 @@ func inviteChatroomMembers(c *gin.Context) { return } - status := wc.CmdClient.InviteChatroomMembers(req.Roomid, req.Wxids) + status := wc.CmdClient.AddChatRoomMembers(req.Roomid, req.Wxids) c.Set("Payload", ActionResponse{ Success: status == 1, diff --git a/httpd/wcfrest/router.go b/httpd/wcfrest/router.go index 978b258a..a0dfd895 100644 --- a/httpd/wcfrest/router.go +++ b/httpd/wcfrest/router.go @@ -25,8 +25,8 @@ func Route(rg *gin.RouterGroup) { rg.GET("chatrooms", getChatRooms) rg.GET("chatroom_members/:roomid", getChatRoomMembers) rg.GET("alias_in_chatroom/:wxid/:roomid", getAliasInChatRoom) - rg.POST("add_chatroom_members", addChatRoomMembers) rg.POST("invite_chatroom_members", inviteChatroomMembers) + rg.POST("add_chatroom_members", addChatRoomMembers) rg.POST("del_chatroom_members", delChatRoomMembers) rg.GET("revoke_msg/:msgid", revokeMsg) diff --git a/public/swagger.json b/public/swagger.json index 42338966..cc30dba4 100644 --- a/public/swagger.json +++ b/public/swagger.json @@ -4,14 +4,14 @@ "description": "基于 WeChatFerry RPC 实现的电脑版微信 REST-API,使用 Go 语言编写,无第三方运行时依赖。基于 HTTP 提供操作接口,轻松对接任意编程语言。", "title": "Wechat Rest API", "contact": { - "name": "Github", + "name": "WeChatRest", "url": "https://github.com/opentdp/wechat-rest" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" }, - "version": "v0.4.0" + "version": "v0.4.1" }, "basePath": "/api", "paths": { @@ -377,6 +377,25 @@ } } }, + "/friends": { + "get": { + "produces": [ + "application/json" + ], + "summary": "获取好友列表", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/wcferry.RpcContact" + } + } + } + } + } + }, "/get_audio_msg": { "post": { "produces": [ @@ -431,25 +450,6 @@ } } }, - "/friends": { - "get": { - "produces": [ - "application/json" - ], - "summary": "获取好友列表", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/wcferry.RpcContact" - } - } - } - } - } - }, "/invite_chatroom_members": { "post": { "produces": [ diff --git a/wcferry/cmd_client.go b/wcferry/cmd_client.go index fdeebed8..f1863751 100644 --- a/wcferry/cmd_client.go +++ b/wcferry/cmd_client.go @@ -242,32 +242,32 @@ func (c *CmdClient) GetAliasInChatRoom(wxid, roomid string) string { return nickName } -// 添加群成员 -// param roomid string 待加群的 id -// param wxids string 要加到群里的 wxid,多个用逗号分隔 +// 邀请群成员 +// param roomid string 群的 id +// param wxids string 要邀请成员的 wxid, 多个用逗号`,`分隔 // return int32 1 为成功,其他失败 -func (c *CmdClient) AddChatRoomMembers(roomid, wxIds string) int32 { - req := genFunReq(Functions_FUNC_ADD_ROOM_MEMBERS) +func (c *CmdClient) InviteChatroomMembers(roomid string, wxids string) int32 { + req := genFunReq(Functions_FUNC_INV_ROOM_MEMBERS) req.Msg = &Request_M{ M: &MemberMgmt{ Roomid: roomid, - Wxids: wxIds, + Wxids: strings.ReplaceAll(wxids, " ", ""), }, } recv := c.call(req.build()) return recv.GetStatus() } -// 邀请群成员 -// param roomid string 群的 id -// param wxids string 要邀请成员的 wxid, 多个用逗号`,`分隔 +// 添加群成员 +// param roomid string 待加群的 id +// param wxids string 要加到群里的 wxid,多个用逗号分隔 // return int32 1 为成功,其他失败 -func (c *CmdClient) InviteChatroomMembers(roomid string, wxids string) int32 { - req := genFunReq(Functions_FUNC_INV_ROOM_MEMBERS) +func (c *CmdClient) AddChatRoomMembers(roomid, wxIds string) int32 { + req := genFunReq(Functions_FUNC_ADD_ROOM_MEMBERS) req.Msg = &Request_M{ M: &MemberMgmt{ Roomid: roomid, - Wxids: strings.ReplaceAll(wxids, " ", ""), + Wxids: wxIds, }, } recv := c.call(req.build())