- pgsql 修复初始化数据失败的bug
- pgsql 获取角色菜单时 报错
- SysOperationRecord longtext 改为 text
This commit is contained in:
SliverHorn
2021-11-18 23:13:17 +08:00
parent b8698cdcff
commit 8ef9e19a64
8 changed files with 76 additions and 58 deletions

View File

@@ -7,15 +7,15 @@ import (
"gorm.io/gorm"
)
var File = new(file)
var FileMysql = new(fileMysql)
type file struct{}
type fileMysql struct{}
func (f *file) TableName() string {
func (f *fileMysql) TableName() string {
return "exa_file_upload_and_downloads"
}
func (f *file) Initialize() error {
func (f *fileMysql) Initialize() error {
entities := []example.ExaFileUploadAndDownload{
{Name: "10.png", Url: "https://qmplusimg.henrongyi.top/gvalogo.png", Tag: "png", Key: "158787308910.png"},
{Name: "logo.png", Url: "https://qmplusimg.henrongyi.top/1576554439myAvatar.png", Tag: "png", Key: "1587973709logo.png"},
@@ -26,7 +26,7 @@ func (f *file) Initialize() error {
return nil
}
func (f *file) CheckDataExist() bool {
func (f *fileMysql) CheckDataExist() bool {
if errors.Is(global.GVA_DB.Where("`name` = ? AND `key` = ?", "logo.png", "1587973709logo.png").First(&example.ExaFileUploadAndDownload{}).Error, gorm.ErrRecordNotFound) {
return false
}

View File

@@ -0,0 +1,34 @@
package example
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/example"
"github.com/pkg/errors"
"gorm.io/gorm"
)
var FilePgsql = new(fileMysql)
type filePgsql struct{}
func (f *filePgsql) TableName() string {
return "exa_file_upload_and_downloads"
}
func (f *filePgsql) Initialize() error {
entities := []example.ExaFileUploadAndDownload{
{Name: "10.png", Url: "https://qmplusimg.henrongyi.top/gvalogo.png", Tag: "png", Key: "158787308910.png"},
{Name: "logo.png", Url: "https://qmplusimg.henrongyi.top/1576554439myAvatar.png", Tag: "png", Key: "1587973709logo.png"},
}
if err := global.GVA_DB.Create(&entities).Error; err != nil {
return errors.Wrap(err, f.TableName()+"表数据初始化失败!")
}
return nil
}
func (f *filePgsql) CheckDataExist() bool {
if errors.Is(global.GVA_DB.Where("name = ? AND key = ?", "logo.png", "1587973709logo.png").First(&example.ExaFileUploadAndDownload{}).Error, gorm.ErrRecordNotFound) {
return false
}
return true
}

View File

@@ -36,9 +36,9 @@ func (a *viewAuthorityMenuPostgres) Initialize() error {
@menus.deleted_at as deleted_at,
@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)));`
@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", a.TableName())
sql = strings.ReplaceAll(sql, "@menus", "sys_base_menus")
sql = strings.ReplaceAll(sql, "@authorities_menus", entity.TableName())