diff --git a/app/admin/apis/sys_config.go b/app/admin/apis/sys_config.go index e4886bce..0a95c8b4 100644 --- a/app/admin/apis/sys_config.go +++ b/app/admin/apis/sys_config.go @@ -198,7 +198,7 @@ func (e SysConfig) Get2SysApp(c *gin.Context) { return } // 控制只读前台的数据 - req.IsFrontend = 1 + req.IsFrontend = "1" list := make([]models.SysConfig, 0) err = s.GetWithKeyList(&req, &list) if err != nil { @@ -310,4 +310,4 @@ func (e SysConfig) GetSysConfigByKEYForService(c *gin.Context) { return } e.OK(resp, s.Msg) -} \ No newline at end of file +} diff --git a/app/admin/models/sys_config.go b/app/admin/models/sys_config.go index 8bd07275..beb656be 100644 --- a/app/admin/models/sys_config.go +++ b/app/admin/models/sys_config.go @@ -10,7 +10,7 @@ type SysConfig struct { ConfigKey string `json:"configKey" gorm:"size:128;comment:ConfigKey"` // ConfigValue string `json:"configValue" gorm:"size:255;comment:ConfigValue"` // ConfigType string `json:"configType" gorm:"size:64;comment:ConfigType"` - IsFrontend int `json:"isFrontend" gorm:"size:64;comment:是否前台"` // + IsFrontend string `json:"isFrontend" gorm:"size:64;comment:是否前台"` // Remark string `json:"remark" gorm:"size:128;comment:Remark"` // models.ControlBy models.ModelTime diff --git a/app/admin/service/dto/sys_config.go b/app/admin/service/dto/sys_config.go index cbc03656..06f7467f 100644 --- a/app/admin/service/dto/sys_config.go +++ b/app/admin/service/dto/sys_config.go @@ -12,7 +12,7 @@ type SysConfigGetPageReq struct { ConfigName string `form:"configName" search:"type:contains;column:config_name;table:sys_config"` ConfigKey string `form:"configKey" search:"type:contains;column:config_key;table:sys_config"` ConfigType string `form:"configType" search:"type:exact;column:config_type;table:sys_config"` - IsFrontend int `form:"isFrontend" search:"type:exact;column:is_frontend;table:sys_config"` + IsFrontend string `form:"isFrontend" search:"type:exact;column:is_frontend;table:sys_config"` SysConfigOrder } @@ -29,7 +29,7 @@ func (m *SysConfigGetPageReq) GetNeedSearch() interface{} { } type SysConfigGetToSysAppReq struct { - IsFrontend int `form:"isFrontend" search:"type:exact;column:is_frontend;table:sys_config"` + IsFrontend string `form:"isFrontend" search:"type:exact;column:is_frontend;table:sys_config"` } func (m *SysConfigGetToSysAppReq) GetNeedSearch() interface{} { @@ -43,7 +43,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"` + IsFrontend string `json:"isFrontend"` Remark string `json:"remark" comment:""` common.ControlBy } diff --git a/cmd/migrate/migration/models/initdb.go b/cmd/migrate/migration/models/initdb.go index a9345031..ba7f4ca7 100644 --- a/cmd/migrate/migration/models/initdb.go +++ b/cmd/migrate/migration/models/initdb.go @@ -13,6 +13,10 @@ import ( func InitDb(db *gorm.DB) (err error) { filePath := "config/db.sql" if global.Driver == "postgres" { + filePath := "config/db.sql" + if err = ExecSql(db, filePath); err != nil { + return err + } filePath = "config/pg.sql" err = ExecSql(db, filePath) } else if global.Driver == "mysql" { diff --git a/common/middleware/handler/login.go b/common/middleware/handler/login.go index 619ac0f5..d17626c0 100644 --- a/common/middleware/handler/login.go +++ b/common/middleware/handler/login.go @@ -14,7 +14,7 @@ type Login struct { } func (u *Login) GetUser(tx *gorm.DB) (user SysUser, role SysRole, err error) { - err = tx.Table("sys_user").Where("username = ? and status = 2", u.Username).First(&user).Error + err = tx.Table("sys_user").Where("username = ? and status = '2'", u.Username).First(&user).Error if err != nil { log.Errorf("get user error, %s", err.Error()) return diff --git a/config/pg.sql b/config/pg.sql index 1c6836ea..ba3c0c82 100644 --- a/config/pg.sql +++ b/config/pg.sql @@ -1,11 +1,21 @@ -- 开始初始化数据 ; +create sequence if not exists sys_role_role_id_seq; +create sequence if not exists sys_user_user_id_seq; +create sequence if not exists sys_post_post_id_seq; +create sequence if not exists sys_menu_menu_id_seq; +create sequence if not exists sys_dict_type_dict_id_seq; +create sequence if not exists sys_dict_data_dict_code_seq; +create sequence if not exists sys_dept_dept_id_seq; +create sequence if not exists sys_config_config_id_seq; +create sequence if not exists sys_job_id_seq; + select setval('sys_role_role_id_seq',4); select setval('sys_user_user_id_seq',5); select setval('sys_post_post_id_seq',4); -select setval('sys_menu_menu_id_seq',268); +select setval('sys_menu_menu_id_seq',543); select setval('sys_dict_type_dict_id_seq',12); -select setval('sys_dict_data_dict_code_seq',32); +select setval('sys_dict_data_dict_code_seq',34); select setval('sys_dept_dept_id_seq',11); -select setval('sys_config_config_id_seq',4); +select setval('sys_config_config_id_seq',6); select setval('sys_job_id_seq',3); --- 数据完成 ; \ No newline at end of file +-- 数据完成 ;