chore: add more openai

This commit is contained in:
engigu
2026-03-11 10:59:25 +08:00
parent 735b798bd7
commit deae554620
8 changed files with 121 additions and 5 deletions
+53
View File
@@ -17,6 +17,16 @@ func NewScriptController(scriptService *services.ScriptService) *ScriptControlle
return &ScriptController{scriptService: scriptService}
}
// CreateScript 创建脚本
// @Summary 创建脚本
// @Description 创建一个新的脚本
// @Tags 脚本管理
// @Accept json
// @Produce json
// @Security BearerAuth
// @Param body body object true "脚本信息"
// @Success 200 {object} utils.Response{data=vo.ScriptVO}
// @Router /scripts [post]
func (sc *ScriptController) CreateScript(c *gin.Context) {
userID := c.GetString("userID")
@@ -34,6 +44,15 @@ func (sc *ScriptController) CreateScript(c *gin.Context) {
utils.Success(c, vo.ToScriptVO(script))
}
// GetScripts 获取脚本列表
// @Summary 获取脚本列表
// @Description 获取当前用户的所有脚本(内容字段为空)
// @Tags 脚本管理
// @Accept json
// @Produce json
// @Security BearerAuth
// @Success 200 {object} utils.Response{data=[]vo.ScriptVO}
// @Router /scripts [get]
func (sc *ScriptController) GetScripts(c *gin.Context) {
userID := c.GetString("userID")
scripts := sc.scriptService.GetScriptsByUserID(userID)
@@ -44,6 +63,17 @@ func (sc *ScriptController) GetScripts(c *gin.Context) {
utils.Success(c, vos)
}
// GetScript 获取脚本详情
// @Summary 获取脚本详情
// @Description 根据 ID 获取脚本详情
// @Tags 脚本管理
// @Accept json
// @Produce json
// @Security BearerAuth
// @Param id path string true "脚本ID"
// @Success 200 {object} utils.Response{data=vo.ScriptVO}
// @Failure 404 {object} utils.Response
// @Router /scripts/{id} [get]
func (sc *ScriptController) GetScript(c *gin.Context) {
id := c.Param("id")
if id == "" {
@@ -60,6 +90,18 @@ func (sc *ScriptController) GetScript(c *gin.Context) {
utils.Success(c, vo.ToScriptVO(script))
}
// UpdateScript 更新脚本
// @Summary 更新脚本
// @Description 根据 ID 更新脚本信息
// @Tags 脚本管理
// @Accept json
// @Produce json
// @Security BearerAuth
// @Param id path string true "脚本ID"
// @Param body body object true "脚本更新信息"
// @Success 200 {object} utils.Response{data=vo.ScriptVO}
// @Failure 404 {object} utils.Response
// @Router /scripts/{id} [put]
func (sc *ScriptController) UpdateScript(c *gin.Context) {
id := c.Param("id")
if id == "" {
@@ -86,6 +128,17 @@ func (sc *ScriptController) UpdateScript(c *gin.Context) {
utils.Success(c, vo.ToScriptVO(script))
}
// DeleteScript 删除脚本
// @Summary 删除脚本
// @Description 根据 ID 删除脚本
// @Tags 脚本管理
// @Accept json
// @Produce json
// @Security BearerAuth
// @Param id path string true "脚本ID"
// @Success 200 {object} utils.Response
// @Failure 404 {object} utils.Response
// @Router /scripts/{id} [delete]
func (sc *ScriptController) DeleteScript(c *gin.Context) {
id := c.Param("id")
if id == "" {