97 lines
3.8 KiB
Go
97 lines
3.8 KiB
Go
package chatrobotctrl
|
|
|
|
import (
|
|
"91porn-server/common"
|
|
"91porn-server/common/stderr"
|
|
"91porn-server/models/v/chatrobotmod"
|
|
"91porn-server/web/service/chatrobotser"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// RobotConfList doc
|
|
// @Summary 机器人配置列表
|
|
// @Description 机器人配置
|
|
// @Tags Robot config
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Param type query string false "机器人类型 COMMENT: 评论机器人 FILM: 影院机器人"
|
|
// @Param pageNumber query integer true "页数"
|
|
// @Param pageSize query integer true "每页条数"
|
|
// @Success 200 {string} json "{"msg": "操作成功" "data": []}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /api/web/admin/robot/conf/list [get]
|
|
func RobotConfList(ctx *gin.Context) {
|
|
var param chatrobotmod.ReqConfList
|
|
if err := ctx.ShouldBind(¶m); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
|
return
|
|
}
|
|
code, data, err := chatrobotser.GetRobotConfList(param)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, code, err)
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, code, data)
|
|
}
|
|
|
|
// AddRobotConf doc
|
|
// @Summary 添加机器人配置
|
|
// @Description 机器人配置
|
|
// @Tags Robot config
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Param type formData string true "机器人类型 COMMENT: 评论机器人 FILM: 影院机器人"
|
|
// @Param from formData string true "机器人类型 HH:SS:MM格式"
|
|
// @Param to formData string true "机器人类型 HH:SS:MM格式"
|
|
// @Param totalLimit formData integer false "机器人每天评论总数"
|
|
// @Param pureLimit formData integer false "单个机器人每天评论数"
|
|
// @Param frequency formData integer false "机器人发表评论频率 单位:秒/条"
|
|
// @Param isActive formData bool false "是否开启"
|
|
// @Success 200 {string} json "{"msg": "操作成功" "data": []}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /api/web/admin/robot/conf/add [post]
|
|
func AddRobotConf(ctx *gin.Context) {
|
|
var param chatrobotmod.ReqAdd
|
|
if err := ctx.ShouldBind(¶m); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
|
return
|
|
}
|
|
code, data, err := chatrobotser.AddRobotConf(param)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, code, err)
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, code, data)
|
|
}
|
|
|
|
// UpdateRobotConf doc
|
|
// @Summary 更新机器人配置
|
|
// @Description 机器人配置
|
|
// @Tags Robot config
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Param type formData string true "机器人类型 COMMENT: 评论机器人 FILM: 影院机器人"
|
|
// @Param from formData string false "机器人类型 HH:SS:MM格式"
|
|
// @Param to formData string false "机器人类型 HH:SS:MM格式"
|
|
// @Param totalLimit formData integer false "机器人每天评论总数"
|
|
// @Param pureLimit formData integer false "单个机器人每天评论数"
|
|
// @Param frequency formData integer false "机器人发表评论频率 单位:秒/条"
|
|
// @Param isActive formData bool false "是否开启"
|
|
// @Success 200 {string} json "{"msg": "操作成功" "data": []}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /api/web/admin/robot/conf/update [post]
|
|
func UpdateRobotConf(ctx *gin.Context) {
|
|
var param chatrobotmod.ReqUpdate
|
|
if err := ctx.ShouldBind(¶m); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
|
return
|
|
}
|
|
code, data, err := chatrobotser.UpdateRobotConf(param)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, code, err)
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, code, data)
|
|
}
|