Skip to content

Commit

Permalink
fix: 接口一致性调整
Browse files Browse the repository at this point in the history
  • Loading branch information
rehiy committed Dec 9, 2023
1 parent d960f0f commit bcc05be
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 44 deletions.
4 changes: 2 additions & 2 deletions httpd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions httpd/wcfrest/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,41 +199,41 @@ 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 {
c.Set("Error", err)
return
}

status := wc.CmdClient.AddChatRoomMembers(req.Roomid, req.Wxids)
status := wc.CmdClient.InviteChatroomMembers(req.Roomid, req.Wxids)

c.Set("Payload", ActionResponse{
Success: status == 1,
})

}

// @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 {
c.Set("Error", err)
return
}

status := wc.CmdClient.InviteChatroomMembers(req.Roomid, req.Wxids)
status := wc.CmdClient.AddChatRoomMembers(req.Roomid, req.Wxids)

c.Set("Payload", ActionResponse{
Success: status == 1,
Expand Down
2 changes: 1 addition & 1 deletion httpd/wcfrest/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
42 changes: 21 additions & 21 deletions public/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down
24 changes: 12 additions & 12 deletions wcferry/cmd_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit bcc05be

Please sign in to comment.