feat :参数配置中添加是否前台控制

This commit is contained in:
wenjianzhang
2021-03-17 11:16:53 +08:00
parent 2134d9fa58
commit 6746dbd9cf
4 changed files with 41 additions and 5 deletions
@@ -56,12 +56,16 @@ func (e *SysConfig) GetSysConfigBySysApp(c *gin.Context) {
log.Error(err)
return
}
d.ConfigKey = "sys_app_"
err = d.Bind(c)
if err != nil {
log.Errorf("参数验证失败, error:%s", err)
e.Error(c, 500, err, "参数验证失败")
return
}
// 控制只读前台的数据
d.IsFrontend = 1
list := make([]system.SysConfig, 0)
s := service.SysConfig{}
@@ -73,7 +77,7 @@ func (e *SysConfig) GetSysConfigBySysApp(c *gin.Context) {
e.Error(c, 500, err, "查询失败")
return
}
mp :=make(map[string]string)
mp := make(map[string]string)
for i := 0; i < len(list); i++ {
key := list[i].ConfigKey
if key != "" {
+4 -3
View File
@@ -9,8 +9,9 @@ type SysConfig struct {
ConfigName string `json:"configName" gorm:"type:varchar(128);comment:ConfigName"` //
ConfigKey string `json:"configKey" gorm:"type:varchar(128);comment:ConfigKey"` //
ConfigValue string `json:"configValue" gorm:"type:varchar(255);comment:ConfigValue"` //
ConfigType string `json:"configType" gorm:"type:varchar(64);comment:ConfigType"` //
Remark string `json:"remark" gorm:"type:varchar(128);comment:Remark"` //
ConfigType string `json:"configType" gorm:"type:varchar(64);comment:ConfigType"`
IsFrontend int `json:"isFrontend" gorm:"type:varchar(64);comment:是否前台"` //
Remark string `json:"remark" gorm:"type:varchar(128);comment:Remark"` //
models.ControlBy
models.ModelTime
}
@@ -26,4 +27,4 @@ func (e *SysConfig) Generate() models.ActiveRecord {
func (e *SysConfig) GetId() interface{} {
return e.Id
}
}
+3
View File
@@ -18,6 +18,7 @@ type SysConfigSearch struct {
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:""`
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{} {
@@ -41,6 +42,7 @@ type SysConfigControl struct {
ConfigKey string `uri:"configKey" json:"configKey" comment:""`
ConfigValue string `json:"configValue" comment:""`
ConfigType string `json:"configType" comment:""`
IsFrontend int `json:"isFrontend"`
Remark string `json:"remark" comment:""`
}
@@ -73,6 +75,7 @@ func (s *SysConfigControl) Generate() (*system.SysConfig, error) {
ConfigKey: s.ConfigKey,
ConfigValue: s.ConfigValue,
ConfigType: s.ConfigType,
IsFrontend: s.IsFrontend,
Remark: s.Remark,
}, 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
})
}