Skip to content

Commit

Permalink
fix: 修复返回值类型
Browse files Browse the repository at this point in the history
  • Loading branch information
rehiy committed Mar 9, 2024
1 parent e6283fb commit 9007a4f
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 45 deletions.
2 changes: 1 addition & 1 deletion httpd/wrobot/chatroom.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Chatroom struct{}
// @Produce json
// @Tags BOT::群聊配置
// @Param body body chatroom.FetchAllParam true "获取群聊配置列表参数"
// @Success 200 {object} []tables.Chatroom
// @Success 200 {array} tables.Chatroom
// @Router /bot/chatroom/list [post]
func (*Chatroom) list(c *gin.Context) {

Expand Down
2 changes: 1 addition & 1 deletion httpd/wrobot/keyword.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Keyword struct{}
// @Produce json
// @Tags BOT::关键字
// @Param body body keyword.FetchAllParam true "获取关键字列表参数"
// @Success 200 {object} []tables.Keyword
// @Success 200 {array} tables.Keyword
// @Router /bot/keyword/list [post]
func (*Keyword) list(c *gin.Context) {

Expand Down
2 changes: 1 addition & 1 deletion httpd/wrobot/llmodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type LLModel struct{}
// @Produce json
// @Tags BOT::大语言模型
// @Param body body llmodel.FetchAllParam true "获取模型列表参数"
// @Success 200 {object} []tables.LLModel
// @Success 200 {array} tables.LLModel
// @Router /bot/llmodel/list [post]
func (*LLModel) list(c *gin.Context) {

Expand Down
2 changes: 1 addition & 1 deletion httpd/wrobot/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Profile struct{}
// @Produce json
// @Tags BOT::用户配置
// @Param body body profile.FetchAllParam true "获取用户配置列表参数"
// @Success 200 {object} []tables.Profile
// @Success 200 {array} tables.Profile
// @Router /bot/profile/list [post]
func (*Profile) list(c *gin.Context) {

Expand Down
2 changes: 1 addition & 1 deletion httpd/wrobot/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ func Route() {

// sundry

rg.POST("handlers", handlers)
rg.POST("handlers", robotHandlers)

}
2 changes: 1 addition & 1 deletion httpd/wrobot/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Setting struct{}
// @Produce json
// @Tags BOT::全局配置
// @Param body body setting.FetchAllParam true "获取全局配置列表参数"
// @Success 200 {object} []tables.Setting
// @Success 200 {array} tables.Setting
// @Router /bot/setting/list [post]
func (*Setting) list(c *gin.Context) {

Expand Down
28 changes: 25 additions & 3 deletions httpd/wrobot/sundry.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,32 @@ import (

// @Summary 机器人指令集
// @Tags BOT::杂项
// @Success 200 {object} []robot.Handler
// @Success 200 {array} RobotHandler
// @Router /bot/handlers [post]
func handlers(c *gin.Context) {
func robotHandlers(c *gin.Context) {

c.Set("Payload", robot.Handlers)
items := []RobotHandler{}

for _, v := range robot.Handlers {
items = append(items, RobotHandler{
Level: v.Level,
Order: v.Order,
ChatAble: v.ChatAble,
RoomAble: v.RoomAble,
Command: v.Command,
Describe: v.Describe,
})
}

c.Set("Payload", items)

}

type RobotHandler struct {
Level int32 `json:"level"` // 0:不限制 7:群管理 9:创始人
Order int32 `json:"order"` // 排序,越小越靠前
ChatAble bool `json:"chat_able"` // 是否允许在私聊使用
RoomAble bool `json:"room_able"` // 是否允许在群聊使用
Command string `json:"command"` // 指令
Describe string `json:"describe"` // 指令的描述信息
}
60 changes: 30 additions & 30 deletions public/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/robot.Handler"
"$ref": "#/definitions/wrobot.RobotHandler"
}
}
}
Expand Down Expand Up @@ -2449,35 +2449,6 @@
}
}
},
"robot.Handler": {
"type": "object",
"properties": {
"chat_able": {
"description": "是否允许在私聊使用",
"type": "boolean"
},
"command": {
"description": "指令",
"type": "string"
},
"describe": {
"description": "指令的描述信息",
"type": "string"
},
"level": {
"description": "0:不限制 7:群管理 9:创始人",
"type": "integer"
},
"order": {
"description": "排序,越小越靠前",
"type": "integer"
},
"room_able": {
"description": "是否允许在群聊使用",
"type": "boolean"
}
}
},
"setting.CreateParam": {
"type": "object",
"required": [
Expand Down Expand Up @@ -3269,6 +3240,35 @@
"type": "string"
}
}
},
"wrobot.RobotHandler": {
"type": "object",
"properties": {
"chat_able": {
"description": "是否允许在私聊使用",
"type": "boolean"
},
"command": {
"description": "指令",
"type": "string"
},
"describe": {
"description": "指令的描述信息",
"type": "string"
},
"level": {
"description": "0:不限制 7:群管理 9:创始人",
"type": "integer"
},
"order": {
"description": "排序,越小越靠前",
"type": "integer"
},
"room_able": {
"description": "是否允许在群聊使用",
"type": "boolean"
}
}
}
}
}
12 changes: 6 additions & 6 deletions wclient/robot/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ var Handlers = []*Handler{}
var HandlerMap = map[string]*Handler{}

type Handler struct {
Level int32 `json:"level"` // 0:不限制 7:群管理 9:创始人
Order int32 `json:"order"` // 排序,越小越靠前
ChatAble bool `json:"chat_able"` // 是否允许在私聊使用
RoomAble bool `json:"room_able"` // 是否允许在群聊使用
Command string `json:"command"` // 指令
Describe string `json:"describe"` // 指令的描述信息
Level int32 // 0:不限制 7:群管理 9:创始人
Order int32 // 排序,越小越靠前
ChatAble bool // 是否允许在私聊使用
RoomAble bool // 是否允许在群聊使用
Command string // 指令
Describe string // 指令的描述信息
PreCheck func(*wcferry.WxMsg) string // 前置检查,可拦截文本聊天内容
Callback func(*wcferry.WxMsg) string // 指令回调,返回回复内容
}
Expand Down

0 comments on commit 9007a4f

Please sign in to comment.