mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 10:58:35 +08:00
[优化]base模块提出
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/biz"
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
"github.com/XM-GO/PandaKit/utils"
|
||||
entity "pandax/apps/system/entity"
|
||||
services "pandax/apps/system/services"
|
||||
"pandax/base/biz"
|
||||
"pandax/base/ginx"
|
||||
"pandax/base/utils"
|
||||
)
|
||||
|
||||
type ConfigApi struct {
|
||||
@@ -23,9 +23,9 @@ type ConfigApi struct {
|
||||
// @Success 200 {string} string "{"code": 200, "data": [...]}"
|
||||
// @Router /system/config [get]
|
||||
// @Security
|
||||
func (p *ConfigApi) GetConfigList(rc *ginx.ReqCtx) {
|
||||
pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1)
|
||||
pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10)
|
||||
func (p *ConfigApi) GetConfigList(rc *restfulx.ReqCtx) {
|
||||
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
|
||||
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
|
||||
configName := rc.GinCtx.Query("configName")
|
||||
configKey := rc.GinCtx.Query("configKey")
|
||||
configType := rc.GinCtx.Query("configType")
|
||||
@@ -47,7 +47,7 @@ func (p *ConfigApi) GetConfigList(rc *ginx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 200, "data": [...]}"
|
||||
// @Router /system/config/configKey [get]
|
||||
// @Security
|
||||
func (p *ConfigApi) GetConfigListByKey(rc *ginx.ReqCtx) {
|
||||
func (p *ConfigApi) GetConfigListByKey(rc *restfulx.ReqCtx) {
|
||||
configKey := rc.GinCtx.Query("configKey")
|
||||
biz.IsTrue(configKey != "", "请传入配置Key")
|
||||
rc.ResData = p.ConfigApp.FindList(entity.SysConfig{ConfigKey: configKey})
|
||||
@@ -60,8 +60,8 @@ func (p *ConfigApi) GetConfigListByKey(rc *ginx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 200, "data": [...]}"
|
||||
// @Router /system/config/{configId} [get]
|
||||
// @Security
|
||||
func (p *ConfigApi) GetConfig(rc *ginx.ReqCtx) {
|
||||
id := ginx.PathParamInt(rc.GinCtx, "configId")
|
||||
func (p *ConfigApi) GetConfig(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParamInt(rc.GinCtx, "configId")
|
||||
p.ConfigApp.FindOne(int64(id))
|
||||
}
|
||||
|
||||
@@ -75,9 +75,9 @@ func (p *ConfigApi) GetConfig(rc *ginx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
|
||||
// @Router /system/config [post]
|
||||
// @Security X-TOKEN
|
||||
func (p *ConfigApi) InsertConfig(rc *ginx.ReqCtx) {
|
||||
func (p *ConfigApi) InsertConfig(rc *restfulx.ReqCtx) {
|
||||
var config entity.SysConfig
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &config)
|
||||
restfulx.BindJsonAndValid(rc.GinCtx, &config)
|
||||
|
||||
p.ConfigApp.Insert(config)
|
||||
}
|
||||
@@ -92,9 +92,9 @@ func (p *ConfigApi) InsertConfig(rc *ginx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
|
||||
// @Router /system/config [put]
|
||||
// @Security X-TOKEN
|
||||
func (p *ConfigApi) UpdateConfig(rc *ginx.ReqCtx) {
|
||||
func (p *ConfigApi) UpdateConfig(rc *restfulx.ReqCtx) {
|
||||
var post entity.SysConfig
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &post)
|
||||
restfulx.BindJsonAndValid(rc.GinCtx, &post)
|
||||
p.ConfigApp.Update(post)
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func (p *ConfigApi) UpdateConfig(rc *ginx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
|
||||
// @Router /system/config/{configId} [delete]
|
||||
func (p *ConfigApi) DeleteConfig(rc *ginx.ReqCtx) {
|
||||
func (p *ConfigApi) DeleteConfig(rc *restfulx.ReqCtx) {
|
||||
configId := rc.GinCtx.Param("configId")
|
||||
p.ConfigApp.Delete(utils.IdsStrToIdsIntGroup(configId))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user