mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 02:04:09 +00:00
feat✨ :参数配置中添加是否前台控制
This commit is contained in:
@@ -56,12 +56,16 @@ func (e *SysConfig) GetSysConfigBySysApp(c *gin.Context) {
|
|||||||
log.Error(err)
|
log.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
d.ConfigKey = "sys_app_"
|
err = d.Bind(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("参数验证失败, error:%s", err)
|
log.Errorf("参数验证失败, error:%s", err)
|
||||||
e.Error(c, 500, err, "参数验证失败")
|
e.Error(c, 500, err, "参数验证失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 控制只读前台的数据
|
||||||
|
d.IsFrontend = 1
|
||||||
|
|
||||||
|
|
||||||
list := make([]system.SysConfig, 0)
|
list := make([]system.SysConfig, 0)
|
||||||
s := service.SysConfig{}
|
s := service.SysConfig{}
|
||||||
@@ -73,7 +77,7 @@ func (e *SysConfig) GetSysConfigBySysApp(c *gin.Context) {
|
|||||||
e.Error(c, 500, err, "查询失败")
|
e.Error(c, 500, err, "查询失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mp :=make(map[string]string)
|
mp := make(map[string]string)
|
||||||
for i := 0; i < len(list); i++ {
|
for i := 0; i < len(list); i++ {
|
||||||
key := list[i].ConfigKey
|
key := list[i].ConfigKey
|
||||||
if key != "" {
|
if key != "" {
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ type SysConfig struct {
|
|||||||
ConfigName string `json:"configName" gorm:"type:varchar(128);comment:ConfigName"` //
|
ConfigName string `json:"configName" gorm:"type:varchar(128);comment:ConfigName"` //
|
||||||
ConfigKey string `json:"configKey" gorm:"type:varchar(128);comment:ConfigKey"` //
|
ConfigKey string `json:"configKey" gorm:"type:varchar(128);comment:ConfigKey"` //
|
||||||
ConfigValue string `json:"configValue" gorm:"type:varchar(255);comment:ConfigValue"` //
|
ConfigValue string `json:"configValue" gorm:"type:varchar(255);comment:ConfigValue"` //
|
||||||
ConfigType string `json:"configType" gorm:"type:varchar(64);comment:ConfigType"` //
|
ConfigType string `json:"configType" gorm:"type:varchar(64);comment:ConfigType"`
|
||||||
Remark string `json:"remark" gorm:"type:varchar(128);comment:Remark"` //
|
IsFrontend int `json:"isFrontend" gorm:"type:varchar(64);comment:是否前台"` //
|
||||||
|
Remark string `json:"remark" gorm:"type:varchar(128);comment:Remark"` //
|
||||||
models.ControlBy
|
models.ControlBy
|
||||||
models.ModelTime
|
models.ModelTime
|
||||||
}
|
}
|
||||||
@@ -26,4 +27,4 @@ func (e *SysConfig) Generate() models.ActiveRecord {
|
|||||||
|
|
||||||
func (e *SysConfig) GetId() interface{} {
|
func (e *SysConfig) GetId() interface{} {
|
||||||
return e.Id
|
return e.Id
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,7 @@ type SysConfigSearch struct {
|
|||||||
ConfigName string `form:"configName" search:"type:contains;column:config_name;table:sys_config" comment:""`
|
ConfigName string `form:"configName" search:"type:contains;column:config_name;table:sys_config" comment:""`
|
||||||
ConfigKey string `form:"configKey" search:"type:contains;column:config_key;table:sys_config" comment:""`
|
ConfigKey string `form:"configKey" search:"type:contains;column:config_key;table:sys_config" comment:""`
|
||||||
ConfigType string `form:"configType" search:"type:exact;column:config_type;table:sys_config" comment:""`
|
ConfigType string `form:"configType" search:"type:exact;column:config_type;table:sys_config" comment:""`
|
||||||
|
IsFrontend int `json:"isFrontend" search:"type:exact;column:is_frontend;table:sys_config" comment:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SysConfigSearch) GetNeedSearch() interface{} {
|
func (m *SysConfigSearch) GetNeedSearch() interface{} {
|
||||||
@@ -41,6 +42,7 @@ type SysConfigControl struct {
|
|||||||
ConfigKey string `uri:"configKey" json:"configKey" comment:""`
|
ConfigKey string `uri:"configKey" json:"configKey" comment:""`
|
||||||
ConfigValue string `json:"configValue" comment:""`
|
ConfigValue string `json:"configValue" comment:""`
|
||||||
ConfigType string `json:"configType" comment:""`
|
ConfigType string `json:"configType" comment:""`
|
||||||
|
IsFrontend int `json:"isFrontend"`
|
||||||
Remark string `json:"remark" comment:""`
|
Remark string `json:"remark" comment:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +75,7 @@ func (s *SysConfigControl) Generate() (*system.SysConfig, error) {
|
|||||||
ConfigKey: s.ConfigKey,
|
ConfigKey: s.ConfigKey,
|
||||||
ConfigValue: s.ConfigValue,
|
ConfigValue: s.ConfigValue,
|
||||||
ConfigType: s.ConfigType,
|
ConfigType: s.ConfigType,
|
||||||
|
IsFrontend: s.IsFrontend,
|
||||||
Remark: s.Remark,
|
Remark: s.Remark,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package version
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
|
"go-admin/cmd/migrate/migration"
|
||||||
|
common "go-admin/common/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
_, fileName, _, _ := runtime.Caller(0)
|
||||||
|
migration.Migrate.SetVersion(migration.GetFilename(fileName), _1615948084336Test)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _1615948084336Test(db *gorm.DB, version string) error {
|
||||||
|
return db.Transaction(func(tx *gorm.DB) error {
|
||||||
|
|
||||||
|
err := tx.Exec("alter table sys_config add is_frontend int default 1 null comment '是否前台参数' after config_type").Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return tx.Create(&common.Migration{
|
||||||
|
Version: version,
|
||||||
|
}).Error
|
||||||
|
})
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user