forked from lxh/go-wxhelper
✨ 完成 AI 助手相关接口
This commit is contained in:
parent
9b3f1bb488
commit
08821977b4
25
api/admin/aiassistant/delete.go
Normal file
25
api/admin/aiassistant/delete.go
Normal file
@ -0,0 +1,25 @@
|
||||
package aiassistant
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"unicode/utf8"
|
||||
"wechat-robot/pkg/response"
|
||||
aiAssistantService "wechat-robot/service/aiassistant"
|
||||
)
|
||||
|
||||
// DeleteById
|
||||
// @description: 删除AI助手
|
||||
// @param ctx
|
||||
func DeleteById(ctx *gin.Context) {
|
||||
var id = ctx.Param("id")
|
||||
if utf8.RuneCountInString(id) != 32 {
|
||||
response.New(ctx).SetMsg("参数错误").Fail()
|
||||
return
|
||||
}
|
||||
// 删除数据
|
||||
if err := aiAssistantService.DeleteById(id); err != nil {
|
||||
response.New(ctx).SetMsg("删除失败").SetError(err).Fail()
|
||||
} else {
|
||||
response.New(ctx).SetMsg("删除成功").Success()
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import (
|
||||
// @description: AI助手相关
|
||||
// @param g
|
||||
func aiAssistant(g *gin.RouterGroup) {
|
||||
g.POST("", aiassistantApi.Save) // 保存AI助手
|
||||
g.GET("", aiassistantApi.GetAll) // 获取所有AI助手
|
||||
g.POST("", aiassistantApi.Save) // 保存AI助手
|
||||
g.GET("", aiassistantApi.GetAll) // 获取所有AI助手
|
||||
g.DELETE("/:id", aiassistantApi.DeleteById) // 删除AI助手
|
||||
}
|
||||
|
16
service/aiassistant/delete.go
Normal file
16
service/aiassistant/delete.go
Normal file
@ -0,0 +1,16 @@
|
||||
package aiassistant
|
||||
|
||||
import (
|
||||
"wechat-robot/internal/database"
|
||||
"wechat-robot/model/entity"
|
||||
)
|
||||
|
||||
// DeleteById
|
||||
// @description: 删除AI助手
|
||||
// @param id string id
|
||||
// @return err error 错误
|
||||
func DeleteById(id string) (err error) {
|
||||
// 删除数据
|
||||
err = database.Client.Where("id = ?", id).Delete(&entity.AiAssistant{}).Error
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue
Block a user