
* fix(style): 修复 border 额外的 reset 导致 tailwind border 属性生效异常的问题 * feat: 添加错误预览组件并优化请求错误处理逻辑 * optimize: select and update necessary fields in `ChangePassword` method - Simplify `ChangePassword` method signature by removing unnecessary return type. - Use `Select()` to fetch only the necessary fields (`id` and `password`) from the database. - Replace `Save()` with `Update()` for more efficient password update operation. Note: use `Save(&user)` to update the whole user record, which will cover other unchanged fields as well, causing data inconsistency when data race conditions. * feat(menu): 版本更新为2.8.4,给菜单增加按钮和参数的预制打包 * feat(menu): 恢复空白的配置文件 * Remove unused `SideMode` field from `ChangeUserInfo` struct Remove unused and deprecated `SideMode` field from user request model. * feat(automation): 增加可以自动生成CURD和续写方法的MCP * fix(mcp): 确保始终返回目录结构信息 * fix(mcp): 当不需要创建模块时提前返回目录结构信息 * feat(automation): 增加可以自动生成CURD和续写方法的MCP * feat(mcp): 添加GAG工具用户确认流程和自动字典创建功能 实现三步工作流程:分析、确认、执行 新增自动字典创建功能,当字段使用字典类型时自动检查并创建字典 添加用户确认机制,确保创建操作前获得用户明确确认 * feat(version): 新增版本管理功能,支持创建、导入、导出和下载版本数据 新增版本管理模块,包含以下功能: 1. 版本数据的增删改查 2. 版本创建功能,可选择关联菜单和API 3. 版本导入导出功能 4. 版本JSON数据下载 5. 相关前端页面和接口实现 * refactor(version): 简化版本管理删除逻辑并移除无用字段 移除版本管理中的状态、创建者、更新者和删除者字段 简化删除和批量删除方法的实现,去除事务和用户ID参数 更新自动生成配置的默认值说明 * feat(版本管理): 新增版本管理功能模块 * fix(menu): 修复递归创建菜单时关联数据未正确处理的问题 * feat(mcp): 添加预设计模块扫描功能以支持代码自动生成 在自动化模块分析器中添加对预设计模块的扫描功能,包括: - 新增PredesignedModuleInfo结构体存储模块信息 - 实现scanPredesignedModules方法扫描plugin和model目录 - 在分析响应中添加predesignedModules字段 - 更新帮助文档说明预设计模块的使用方式 这些修改使系统能够识别并利用现有的预设计模块,提高代码生成效率并减少重复工作。 * feat(mcp): 新增API、菜单和字典生成工具并优化自动生成模块 * docs(mcp): 更新菜单和API创建工具的描述信息 * feat(mcp): 添加字典查询工具用于AI生成逻辑时了解可用字典选项 * feat: 在创建菜单/API/模块结果中添加权限分配提醒 为菜单创建、API创建和模块创建的结果消息添加权限分配提醒,帮助用户了解后续需要进行的权限配置步骤 * refactor(mcp): 统一使用WithBoolean替换WithBool并优化错误处理 * docs(mcp): 更新API创建工具的说明和错误处理日志 * feat(mcp): 添加插件意图检测功能并增强验证逻辑 --------- Co-authored-by: Azir <2075125282@qq.com> Co-authored-by: Feng.YJ <jxfengyijie@gmail.com> Co-authored-by: piexlMax(奇淼 <qimiaojiangjizhao@gmail.com>
304 lines
16 KiB
Go
304 lines
16 KiB
Go
package system
|
|
|
|
import (
|
|
"context"
|
|
|
|
adapter "github.com/casbin/gorm-adapter/v3"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/service/system"
|
|
"github.com/pkg/errors"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
const initOrderCasbin = initOrderApiIgnore + 1
|
|
|
|
type initCasbin struct{}
|
|
|
|
// auto run
|
|
func init() {
|
|
system.RegisterInit(initOrderCasbin, &initCasbin{})
|
|
}
|
|
|
|
func (i *initCasbin) MigrateTable(ctx context.Context) (context.Context, error) {
|
|
db, ok := ctx.Value("db").(*gorm.DB)
|
|
if !ok {
|
|
return ctx, system.ErrMissingDBContext
|
|
}
|
|
return ctx, db.AutoMigrate(&adapter.CasbinRule{})
|
|
}
|
|
|
|
func (i *initCasbin) TableCreated(ctx context.Context) bool {
|
|
db, ok := ctx.Value("db").(*gorm.DB)
|
|
if !ok {
|
|
return false
|
|
}
|
|
return db.Migrator().HasTable(&adapter.CasbinRule{})
|
|
}
|
|
|
|
func (i *initCasbin) InitializerName() string {
|
|
var entity adapter.CasbinRule
|
|
return entity.TableName()
|
|
}
|
|
|
|
func (i *initCasbin) InitializeData(ctx context.Context) (context.Context, error) {
|
|
db, ok := ctx.Value("db").(*gorm.DB)
|
|
if !ok {
|
|
return ctx, system.ErrMissingDBContext
|
|
}
|
|
entities := []adapter.CasbinRule{
|
|
{Ptype: "p", V0: "888", V1: "/user/admin_register", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/api/createApi", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/api/getApiList", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/api/getApiById", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/api/deleteApi", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/api/updateApi", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/api/getAllApis", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/api/deleteApisByIds", V2: "DELETE"},
|
|
{Ptype: "p", V0: "888", V1: "/api/syncApi", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/api/getApiGroups", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/api/enterSyncApi", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/api/ignoreApi", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/authority/copyAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/authority/updateAuthority", V2: "PUT"},
|
|
{Ptype: "p", V0: "888", V1: "/authority/createAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/authority/deleteAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/authority/getAuthorityList", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/authority/setDataAuthority", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/menu/getMenu", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/menu/getMenuList", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/menu/addBaseMenu", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/menu/getBaseMenuTree", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/menu/addMenuAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/menu/getMenuAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/menu/deleteBaseMenu", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/menu/updateBaseMenu", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/menu/getBaseMenuById", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/user/getUserInfo", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/user/setUserInfo", V2: "PUT"},
|
|
{Ptype: "p", V0: "888", V1: "/user/setSelfInfo", V2: "PUT"},
|
|
{Ptype: "p", V0: "888", V1: "/user/getUserList", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/user/deleteUser", V2: "DELETE"},
|
|
{Ptype: "p", V0: "888", V1: "/user/changePassword", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/user/setUserAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/user/setUserAuthorities", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/user/resetPassword", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/user/setSelfSetting", V2: "PUT"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/findFile", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/breakpointContinueFinish", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/breakpointContinue", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/removeChunk", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/upload", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/editFileName", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/importURL", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/casbin/updateCasbin", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/jwt/jsonInBlacklist", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/system/getSystemConfig", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/system/setSystemConfig", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/system/getServerInfo", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/customer/customer", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/customer/customer", V2: "PUT"},
|
|
{Ptype: "p", V0: "888", V1: "/customer/customer", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/customer/customer", V2: "DELETE"},
|
|
{Ptype: "p", V0: "888", V1: "/customer/customerList", V2: "GET"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/getDB", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/getMeta", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/preview", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/getTables", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/getColumn", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/rollback", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/createTemp", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/delSysHistory", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/getSysHistory", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/createPackage", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/getTemplates", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/getPackage", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/delPackage", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/createPlug", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/installPlugin", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/pubPlug", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/addFunc", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/mcp", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/mcpTest", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/autoCode/mcpList", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/findSysDictionaryDetail", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/updateSysDictionaryDetail", V2: "PUT"},
|
|
{Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/createSysDictionaryDetail", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/getSysDictionaryDetailList", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/deleteSysDictionaryDetail", V2: "DELETE"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/sysDictionary/findSysDictionary", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysDictionary/updateSysDictionary", V2: "PUT"},
|
|
{Ptype: "p", V0: "888", V1: "/sysDictionary/getSysDictionaryList", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysDictionary/createSysDictionary", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/sysDictionary/deleteSysDictionary", V2: "DELETE"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/sysOperationRecord/findSysOperationRecord", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysOperationRecord/updateSysOperationRecord", V2: "PUT"},
|
|
{Ptype: "p", V0: "888", V1: "/sysOperationRecord/createSysOperationRecord", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/sysOperationRecord/getSysOperationRecordList", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysOperationRecord/deleteSysOperationRecord", V2: "DELETE"},
|
|
{Ptype: "p", V0: "888", V1: "/sysOperationRecord/deleteSysOperationRecordByIds", V2: "DELETE"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/email/emailTest", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/email/sendEmail", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/simpleUploader/upload", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/simpleUploader/checkFileMd5", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/simpleUploader/mergeFileMd5", V2: "GET"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/authorityBtn/setAuthorityBtn", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/authorityBtn/getAuthorityBtn", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/authorityBtn/canRemoveAuthorityBtn", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/sysExportTemplate/createSysExportTemplate", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/sysExportTemplate/deleteSysExportTemplate", V2: "DELETE"},
|
|
{Ptype: "p", V0: "888", V1: "/sysExportTemplate/deleteSysExportTemplateByIds", V2: "DELETE"},
|
|
{Ptype: "p", V0: "888", V1: "/sysExportTemplate/updateSysExportTemplate", V2: "PUT"},
|
|
{Ptype: "p", V0: "888", V1: "/sysExportTemplate/findSysExportTemplate", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysExportTemplate/getSysExportTemplateList", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysExportTemplate/exportExcel", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysExportTemplate/exportTemplate", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysExportTemplate/importExcel", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/info/createInfo", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/info/deleteInfo", V2: "DELETE"},
|
|
{Ptype: "p", V0: "888", V1: "/info/deleteInfoByIds", V2: "DELETE"},
|
|
{Ptype: "p", V0: "888", V1: "/info/updateInfo", V2: "PUT"},
|
|
{Ptype: "p", V0: "888", V1: "/info/findInfo", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/info/getInfoList", V2: "GET"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/sysParams/createSysParams", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/sysParams/deleteSysParams", V2: "DELETE"},
|
|
{Ptype: "p", V0: "888", V1: "/sysParams/deleteSysParamsByIds", V2: "DELETE"},
|
|
{Ptype: "p", V0: "888", V1: "/sysParams/updateSysParams", V2: "PUT"},
|
|
{Ptype: "p", V0: "888", V1: "/sysParams/findSysParams", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysParams/getSysParamsList", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysParams/getSysParam", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/attachmentCategory/getCategoryList", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/attachmentCategory/addCategory", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/attachmentCategory/deleteCategory", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "888", V1: "/sysVersion/findSysVersion", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysVersion/getSysVersionList", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysVersion/downloadVersionJson", V2: "GET"},
|
|
{Ptype: "p", V0: "888", V1: "/sysVersion/exportVersion", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/sysVersion/importVersion", V2: "POST"},
|
|
{Ptype: "p", V0: "888", V1: "/sysVersion/deleteSysVersion", V2: "DELETE"},
|
|
{Ptype: "p", V0: "888", V1: "/sysVersion/deleteSysVersionByIds", V2: "DELETE"},
|
|
|
|
{Ptype: "p", V0: "8881", V1: "/user/admin_register", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/api/createApi", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/api/getApiList", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/api/getApiById", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/api/deleteApi", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/api/updateApi", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/api/getAllApis", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/authority/createAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/authority/deleteAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/authority/getAuthorityList", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/authority/setDataAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/menu/getMenu", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/menu/getMenuList", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/menu/addBaseMenu", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/menu/getBaseMenuTree", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/menu/addMenuAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/menu/getMenuAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/menu/deleteBaseMenu", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/menu/updateBaseMenu", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/menu/getBaseMenuById", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/user/changePassword", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/user/getUserList", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/user/setUserAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/fileUploadAndDownload/upload", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/fileUploadAndDownload/editFileName", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/fileUploadAndDownload/importURL", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/casbin/updateCasbin", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/jwt/jsonInBlacklist", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/system/getSystemConfig", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/system/setSystemConfig", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/customer/customer", V2: "POST"},
|
|
{Ptype: "p", V0: "8881", V1: "/customer/customer", V2: "PUT"},
|
|
{Ptype: "p", V0: "8881", V1: "/customer/customer", V2: "DELETE"},
|
|
{Ptype: "p", V0: "8881", V1: "/customer/customer", V2: "GET"},
|
|
{Ptype: "p", V0: "8881", V1: "/customer/customerList", V2: "GET"},
|
|
{Ptype: "p", V0: "8881", V1: "/user/getUserInfo", V2: "GET"},
|
|
|
|
{Ptype: "p", V0: "9528", V1: "/user/admin_register", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/api/createApi", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/api/getApiList", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/api/getApiById", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/api/deleteApi", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/api/updateApi", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/api/getAllApis", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "9528", V1: "/authority/createAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/authority/deleteAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/authority/getAuthorityList", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/authority/setDataAuthority", V2: "POST"},
|
|
|
|
{Ptype: "p", V0: "9528", V1: "/menu/getMenu", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/menu/getMenuList", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/menu/addBaseMenu", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/menu/getBaseMenuTree", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/menu/addMenuAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/menu/getMenuAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/menu/deleteBaseMenu", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/menu/updateBaseMenu", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/menu/getBaseMenuById", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/user/changePassword", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/user/getUserList", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/user/setUserAuthority", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/fileUploadAndDownload/upload", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/fileUploadAndDownload/editFileName", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/fileUploadAndDownload/importURL", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/casbin/updateCasbin", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/jwt/jsonInBlacklist", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/system/getSystemConfig", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/system/setSystemConfig", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/customer/customer", V2: "PUT"},
|
|
{Ptype: "p", V0: "9528", V1: "/customer/customer", V2: "GET"},
|
|
{Ptype: "p", V0: "9528", V1: "/customer/customer", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/customer/customer", V2: "DELETE"},
|
|
{Ptype: "p", V0: "9528", V1: "/customer/customerList", V2: "GET"},
|
|
{Ptype: "p", V0: "9528", V1: "/autoCode/createTemp", V2: "POST"},
|
|
{Ptype: "p", V0: "9528", V1: "/user/getUserInfo", V2: "GET"},
|
|
}
|
|
if err := db.Create(&entities).Error; err != nil {
|
|
return ctx, errors.Wrap(err, "Casbin 表 ("+i.InitializerName()+") 数据初始化失败!")
|
|
}
|
|
next := context.WithValue(ctx, i.InitializerName(), entities)
|
|
return next, nil
|
|
}
|
|
|
|
func (i *initCasbin) DataInserted(ctx context.Context) bool {
|
|
db, ok := ctx.Value("db").(*gorm.DB)
|
|
if !ok {
|
|
return false
|
|
}
|
|
if errors.Is(db.Where(adapter.CasbinRule{Ptype: "p", V0: "9528", V1: "/user/getUserInfo", V2: "GET"}).
|
|
First(&adapter.CasbinRule{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
|
|
return false
|
|
}
|
|
return true
|
|
}
|