feat: 等级配置
This commit is contained in:
@@ -9,13 +9,15 @@ type ApiGroup struct {
|
||||
WikiClassApi
|
||||
WikiApi
|
||||
OcrApi
|
||||
LevelConfigApi
|
||||
}
|
||||
|
||||
var (
|
||||
plantService = service.GroupApp.PlantServiceGroup.MyPlantService
|
||||
topicService = service.GroupApp.PlantServiceGroup.TopicService
|
||||
postService = service.GroupApp.PlantServiceGroup.PostService
|
||||
wikiClassService = service.GroupApp.PlantServiceGroup.WikiClassService
|
||||
wikiService = service.GroupApp.PlantServiceGroup.WikiService
|
||||
ocrService = service.GroupApp.PlantServiceGroup.OcrService
|
||||
plantService = service.GroupApp.PlantServiceGroup.MyPlantService
|
||||
topicService = service.GroupApp.PlantServiceGroup.TopicService
|
||||
postService = service.GroupApp.PlantServiceGroup.PostService
|
||||
wikiClassService = service.GroupApp.PlantServiceGroup.WikiClassService
|
||||
wikiService = service.GroupApp.PlantServiceGroup.WikiService
|
||||
ocrService = service.GroupApp.PlantServiceGroup.OcrService
|
||||
levelConfigService = service.GroupApp.PlantServiceGroup.LevelConfigService
|
||||
)
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package plant
|
||||
|
||||
import (
|
||||
"sundynix-go/global"
|
||||
"sundynix-go/model/commom/response"
|
||||
plantReq "sundynix-go/model/plant/request"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type LevelConfigApi struct{}
|
||||
|
||||
// AddLevelConfig 添加等级配置
|
||||
// @Tags 等级配置
|
||||
// @Summary 添加等级配置
|
||||
// @Security BearerAuth
|
||||
// @accept json
|
||||
// @Produce application/json
|
||||
// @Param data body plantReq.CreateLevelConf true "添加等级配置"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
|
||||
// @Router /config/level/add [post]
|
||||
func (a *LevelConfigApi) AddLevelConfig(c *gin.Context) {
|
||||
var req plantReq.CreateLevelConf
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
response.FailWithMsg("请求参数错误", c)
|
||||
return
|
||||
}
|
||||
err = levelConfigService.AddLevelConfig(req)
|
||||
if err != nil {
|
||||
global.Logger.Error("添加等级配置失败", zap.Error(err))
|
||||
response.FailWithMsg("添加等级配置失败", c)
|
||||
return
|
||||
}
|
||||
response.OkWithMsg("添加等级配置成功", c)
|
||||
}
|
||||
|
||||
// UpdateLevelConfig 修改等级配置
|
||||
// @Tags 等级配置
|
||||
// @Summary 修改等级配置
|
||||
// @Security BearerAuth
|
||||
// @accept json
|
||||
// @Produce application/json
|
||||
// @Param data body plantReq.UpdateLevelConf true "修改等级配置"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
|
||||
// @Router /config/level/update [post]
|
||||
func (a *LevelConfigApi) UpdateLevelConfig(c *gin.Context) {
|
||||
var req plantReq.UpdateLevelConf
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
response.FailWithMsg("请求参数错误", c)
|
||||
return
|
||||
}
|
||||
err = levelConfigService.UpdateLevelConfig(req)
|
||||
if err != nil {
|
||||
global.Logger.Error("修改等级配置失败", zap.Error(err))
|
||||
response.FailWithMsg("修改等级配置失败", c)
|
||||
return
|
||||
}
|
||||
response.OkWithMsg("修改等级配置成功", c)
|
||||
}
|
||||
|
||||
// LevelConfigList 等级配置列表
|
||||
// @Tags 等级配置
|
||||
// @Summary 等级配置列表
|
||||
// @Security BearerAuth
|
||||
// @Produce application/json
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
|
||||
// @Router /config/level/list [get]
|
||||
func (a *LevelConfigApi) LevelConfigList(c *gin.Context) {
|
||||
list, err := levelConfigService.LevelConfigList()
|
||||
if err != nil {
|
||||
global.Logger.Error("查询等级配置列表失败", zap.Error(err))
|
||||
response.FailWithMsg("查询等级配置列表失败", c)
|
||||
return
|
||||
}
|
||||
response.OkWithData(response.ListResult{
|
||||
List: list,
|
||||
}, c)
|
||||
|
||||
}
|
||||
|
||||
// LevelConfigDetail 等级配置详情
|
||||
// @Tags 等级配置
|
||||
// @Summary 等级配置详情
|
||||
// @Security BearerAuth
|
||||
// @Produce application/json
|
||||
// @Param id query string true "等级配置id"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
|
||||
// @Router /config/level/detail [get]
|
||||
func (a *LevelConfigApi) LevelConfigDetail(c *gin.Context) {
|
||||
id := c.Query("id")
|
||||
levelConfig, err := levelConfigService.LevelConfigDetail(id)
|
||||
if err != nil {
|
||||
global.Logger.Error("查询等级配置详情失败", zap.Error(err))
|
||||
response.FailWithMsg("查询等级配置详情失败", c)
|
||||
return
|
||||
}
|
||||
response.OkWithData(levelConfig, c)
|
||||
}
|
||||
Reference in New Issue
Block a user