提交 316832fd 编写于 作者: Sliver_Horn's avatar Sliver_Horn

fixed:

- casbin 数据问题
- AuthoritiesMenus 问题修复
- DataAuthorities 问题修复
- File 问题修复
- 初始化表 add CasbinRule
- ViewAuthorityMenuMysql 问题修复
上级 6f0a8b95
package system
import (
adapter "github.com/casbin/gorm-adapter/v3"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/example"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
_ "github.com/jackc/pgx/v4"
)
type InitDBService struct{}
......@@ -40,6 +40,8 @@ func (initDBService *InitDBService) initTables() error {
system.SysDictionaryDetail{},
system.SysBaseMenuParameter{},
adapter.CasbinRule{},
example.ExaFile{},
example.ExaCustomer{},
example.ExaFileChunk{},
......
......@@ -27,7 +27,7 @@ func (f *file) Initialize() error {
}
func (f *file) CheckDataExist() bool {
if errors.Is(global.GVA_DB.Where("name = ? AND key = ?", "logo.png", "1587973709logo.png").First(&example.ExaFileUploadAndDownload{}).Error, gorm.ErrRecordNotFound) {
if errors.Is(global.GVA_DB.Where("`name` = ? AND `key` = ?", "logo.png", "1587973709logo.png").First(&example.ExaFileUploadAndDownload{}).Error, gorm.ErrRecordNotFound) {
return false
}
return true
......
......@@ -73,7 +73,7 @@ func (a *authoritiesMenus) Initialize() error {
}
func (a *authoritiesMenus) CheckDataExist() bool {
if errors.Is(global.GVA_DB.Where("menu_id = ? AND authority_id = ?", 17, "9528").First(&AuthorityMenus{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
if errors.Is(global.GVA_DB.Where("sys_base_menu_id = ? AND sys_authority_authority_id = ?", 17, "9528").First(&AuthorityMenus{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
return false
}
return true
......
此差异已折叠。
......@@ -33,7 +33,7 @@ func (a *dataAuthorities) Initialize() error {
}
func (a *dataAuthorities) CheckDataExist() bool {
if errors.Is(global.GVA_DB.Where("authority_id = ? AND resources_id = ?", "9528", "9528").First(&AuthoritiesResources{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
if errors.Is(global.GVA_DB.Where("sys_authority_authority_id = ? AND data_authority_id_authority_id = ?", "9528", "9528").First(&AuthoritiesResources{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
return false
}
return true
......@@ -41,8 +41,8 @@ func (a *dataAuthorities) CheckDataExist() bool {
// AuthoritiesResources 角色资源表
type AuthoritiesResources struct {
AuthorityId string `gorm:"column:authority_id"`
ResourcesId string `gorm:"column:resources_id"`
AuthorityId string `gorm:"column:sys_authority_authority_id"`
ResourcesId string `gorm:"column:data_authority_id_authority_id"`
}
func (a *AuthoritiesResources) TableName() string {
......
......@@ -19,7 +19,28 @@ func (v *viewAuthorityMenuMysql) TableName() string {
func (v *viewAuthorityMenuMysql) Initialize() error {
var entity AuthorityMenus
sql := "CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `@table_name` AS select `@menus`.id AS id, `@menus`.path AS path, `@menus`.icon AS icon, `@menus`.name AS name, `@menus`.sort AS sort, `@menus`.title AS title, `@menus`.hidden AS hidden, `@menus`.component AS component, `@menus`.parent_id AS parent_id, `@menus`.created_at AS created_at, `@menus`.updated_at AS updated_at, `@menus`.deleted_at AS deleted_at, `@menus`.keep_alive AS keep_alive, `@menus`.menu_level AS menu_level, `@menus`.default_menu AS default_menu, `@authorities_menus`.menu_id AS menu_id, `@authorities_menus`.authority_id AS authority_id from (`@authorities_menus` join `@menus` on ((`@authorities_menus`.menu_id = `@menus`.id)));"
sql := `
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW @table_name AS
select @menus.id AS id,
@menus.path AS path,
@menus.icon AS icon,
@menus.name AS name,
@menus.sort AS sort,
@menus.title AS title,
@menus.hidden AS hidden,
@menus.component AS component,
@menus.parent_id AS parent_id,
@menus.created_at AS created_at,
@menus.updated_at AS updated_at,
@menus.deleted_at AS deleted_at,
@menus.keep_alive AS keep_alive,
@menus.menu_level AS menu_level,
@menus.default_menu AS default_menu,
@authorities_menus.sys_base_menu_id AS menu_id,
@authorities_menus.sys_authority_authority_id AS authority_id
from (@authorities_menus
join @menus on ((@authorities_menus.sys_base_menu_id = @menus.id)));
`
sql = strings.ReplaceAll(sql, "@table_name", v.TableName())
sql = strings.ReplaceAll(sql, "@menus", "sys_base_menus")
sql = strings.ReplaceAll(sql, "@authorities_menus", entity.TableName())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册