Files
gin-vue-admin/server/plugin/plugin-tool/utils/check.go
PiexlMax(奇淼 2242f5d6e1 public: 发布v2.8.8 (#2167)
* refactor: 移除冗余的工具名称和描述,简化代码生成器的文档

* Add Content-Type to S3 upload input

Add Content-Type to S3 upload input

* style: 优化仪表盘组件样式,调整各个子组件的布局和样式,提升视觉效果

* fix: 更新插件链接

* 优化角色配置-首页配置相关内容

* feat: 默认首页只允许选择已选中的菜单

* feat: 更新样式和优化组件,调整背景色及文本颜色

* feat: 清理无用的右侧边线

* feat: 增加了导入导出模板的自定义sql能力,方便灵活化扩展导入导出

* feat: 优化日志输出,增加插件字典定义

* feat: 增加插件字典定义前端相关

* feat: 增加插件自定义字典方法

* feat: 增加文件名和路径合法性检查

* feat: 修复暗黑模式和亮色模式logo路径定义

* feat: 移除未使用的defineEmits导入

* feat: 更新授权链接至新地址

* feat: 移除菜单组件背景色

* feat: 更新导出和导入SQL语句的示例占位符

* feat: 错误日志必须有数据库链接才会存储

* feat: 移除仪表板中公告卡片的高度限制

* feat: 添加插件列表接口,更新插件表格组件,移除不必要的注释

* feat: 更新版本号至v2.8.8,调整插件表格组件的请求参数

---------

Co-authored-by: piexlMax(奇淼 <qimiaojiangjizhao@gmail.com>
Co-authored-by: Yexk_M <yexk@yexk.cn>
Co-authored-by: Azir-11 <2075125282@qq.com>
2026-01-11 14:41:19 +08:00

84 lines
2.5 KiB
Go

package utils
import (
"github.com/pkg/errors"
"go.uber.org/zap"
"gorm.io/gorm"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
)
func RegisterApis(apis ...system.SysApi) {
err := global.GVA_DB.Transaction(func(tx *gorm.DB) error {
for _, api := range apis {
err := tx.Model(system.SysApi{}).Where("path = ? AND method = ? AND api_group = ? ", api.Path, api.Method, api.ApiGroup).FirstOrCreate(&api).Error
if err != nil {
zap.L().Error("注册API失败", zap.Error(err), zap.String("api", api.Path), zap.String("method", api.Method), zap.String("apiGroup", api.ApiGroup))
return err
}
}
return nil
})
if err != nil {
zap.L().Error("注册API失败", zap.Error(err))
}
}
func RegisterMenus(menus ...system.SysBaseMenu) {
parentMenu := menus[0]
otherMenus := menus[1:]
err := global.GVA_DB.Transaction(func(tx *gorm.DB) error {
err := tx.Model(system.SysBaseMenu{}).Where("name = ? ", parentMenu.Name).FirstOrCreate(&parentMenu).Error
if err != nil {
zap.L().Error("注册菜单失败", zap.Error(err))
return errors.Wrap(err, "注册菜单失败")
}
pid := parentMenu.ID
for i := range otherMenus {
otherMenus[i].ParentId = pid
err = tx.Model(system.SysBaseMenu{}).Where("name = ? ", otherMenus[i].Name).FirstOrCreate(&otherMenus[i]).Error
if err != nil {
zap.L().Error("注册菜单失败", zap.Error(err))
return errors.Wrap(err, "注册菜单失败")
}
}
return nil
})
if err != nil {
zap.L().Error("注册菜单失败", zap.Error(err))
}
}
func RegisterDictionaries(dictionaries ...system.SysDictionary) {
err := global.GVA_DB.Transaction(func(tx *gorm.DB) error {
for _, dict := range dictionaries {
details := dict.SysDictionaryDetails
dict.SysDictionaryDetails = nil
err := tx.Model(system.SysDictionary{}).Where("type = ?", dict.Type).FirstOrCreate(&dict).Error
if err != nil {
zap.L().Error("注册字典失败", zap.Error(err), zap.String("type", dict.Type))
return err
}
for _, detail := range details {
detail.SysDictionaryID = int(dict.ID)
err = tx.Model(system.SysDictionaryDetail{}).Where("sys_dictionary_id = ? AND value = ?", dict.ID, detail.Value).FirstOrCreate(&detail).Error
if err != nil {
zap.L().Error("注册字典详情失败", zap.Error(err), zap.String("value", detail.Value))
return err
}
}
}
return nil
})
if err != nil {
zap.L().Error("注册字典失败", zap.Error(err))
}
}
func Pointer[T any](in T) *T {
return &in
}