-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 媒体库增加 普通上传、压缩上传按钮,方便媒体库直接上传图片 * 增加数据类型切换后的的校验,避免使用错误的查询条件和字典条件。 * refactor: 重构初始化逻辑 * 媒体库功能丰富 * 修复注入漏洞和路径穿越 * 修复自动化接口获取数据库表失败后未能终止的bug * 微调媒体库样式 Co-authored-by: bypanghu <bypanghu@163.com> Co-authored-by: tesun <36953434+tesun@users.noreply.github.com> Co-authored-by: pnck <hio131@gmail.com> Co-authored-by: task <121913992@qq.com>
- Loading branch information
1 parent
4d43583
commit 954859b
Showing
40 changed files
with
1,352 additions
and
778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package initialize | ||
|
||
import ( | ||
"context" | ||
adapter "github.com/casbin/gorm-adapter/v3" | ||
"github.com/flipped-aurora/gin-vue-admin/server/model/example" | ||
sysModel "github.com/flipped-aurora/gin-vue-admin/server/model/system" | ||
"github.com/flipped-aurora/gin-vue-admin/server/service/system" | ||
"gorm.io/gorm" | ||
) | ||
|
||
const initOrderEnsureTables = system.InitOrderExternal - 1 | ||
|
||
type ensureTables struct{} | ||
|
||
// auto run | ||
func init() { | ||
system.RegisterInit(initOrderEnsureTables, &ensureTables{}) | ||
} | ||
|
||
func (ensureTables) InitializerName() string { | ||
return "ensure_tables_created" | ||
} | ||
func (e *ensureTables) InitializeData(ctx context.Context) (next context.Context, err error) { | ||
return ctx, nil | ||
} | ||
|
||
func (e *ensureTables) DataInserted(ctx context.Context) bool { | ||
return true | ||
} | ||
|
||
func (e *ensureTables) MigrateTable(ctx context.Context) (context.Context, error) { | ||
db, ok := ctx.Value("db").(*gorm.DB) | ||
if !ok { | ||
return ctx, system.ErrMissingDBContext | ||
} | ||
tables := []interface{}{ | ||
sysModel.SysApi{}, | ||
sysModel.SysUser{}, | ||
sysModel.SysBaseMenu{}, | ||
sysModel.SysAuthority{}, | ||
sysModel.JwtBlacklist{}, | ||
sysModel.SysDictionary{}, | ||
sysModel.SysAutoCodeHistory{}, | ||
sysModel.SysOperationRecord{}, | ||
sysModel.SysDictionaryDetail{}, | ||
sysModel.SysBaseMenuParameter{}, | ||
sysModel.SysBaseMenuBtn{}, | ||
sysModel.SysAuthorityBtn{}, | ||
sysModel.SysAutoCode{}, | ||
|
||
adapter.CasbinRule{}, | ||
|
||
example.ExaFile{}, | ||
example.ExaCustomer{}, | ||
example.ExaFileChunk{}, | ||
example.ExaFileUploadAndDownload{}, | ||
} | ||
for _, t := range tables { | ||
_ = db.AutoMigrate(&t) | ||
// 视图 authority_menu 会被当成表来创建,引发冲突错误(更新版本的gorm似乎不会) | ||
// 由于 AutoMigrate() 基本无需考虑错误,因此显式忽略 | ||
} | ||
return ctx, nil | ||
} | ||
|
||
func (e *ensureTables) TableCreated(ctx context.Context) bool { | ||
db, ok := ctx.Value("db").(*gorm.DB) | ||
if !ok { | ||
return false | ||
} | ||
tables := []interface{}{ | ||
sysModel.SysApi{}, | ||
sysModel.SysUser{}, | ||
sysModel.SysBaseMenu{}, | ||
sysModel.SysAuthority{}, | ||
sysModel.JwtBlacklist{}, | ||
sysModel.SysDictionary{}, | ||
sysModel.SysAutoCodeHistory{}, | ||
sysModel.SysOperationRecord{}, | ||
sysModel.SysDictionaryDetail{}, | ||
sysModel.SysBaseMenuParameter{}, | ||
sysModel.SysBaseMenuBtn{}, | ||
sysModel.SysAuthorityBtn{}, | ||
sysModel.SysAutoCode{}, | ||
|
||
adapter.CasbinRule{}, | ||
|
||
example.ExaFile{}, | ||
example.ExaCustomer{}, | ||
example.ExaFileChunk{}, | ||
example.ExaFileUploadAndDownload{}, | ||
} | ||
yes := true | ||
for _, t := range tables { | ||
yes = yes && db.Migrator().HasTable(t) | ||
} | ||
return yes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package initialize | ||
|
||
import ( | ||
_ "github.com/flipped-aurora/gin-vue-admin/server/source/example" | ||
_ "github.com/flipped-aurora/gin-vue-admin/server/source/system" | ||
) | ||
|
||
func init() { | ||
// do nothing,only import source package so that inits can be registered | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.