Files
dify-plus/admin/server/source/system/casbin.go
T
npc0-hue 17832f2424 fix: Dify 1.8.1问题修复
本次提交整合了多个功能改进和问题修复:

主要功能:
- 批量工作流处理功能完善,支持 Excel 上传和进度跟踪
- 管理中心反向代理和转发配置优化
- 用户同步添加互斥锁,防止并发问题
- 计费系统和额度显示优化
- AI 绘图功能扩展

前端改进:
- 文本生成应用显示修复
- 批量任务进度展示优化
- 按钮样式和 CSS 优化,禁止换行
- 多语言支持完善(新增印尼语等)
- 构建镜像逻辑优化
- 批量处理进度管理器实现

后端改进:
- Docker Compose 配置升级
- 队列任务和 Worker Pool 优化
- Admin API 初始化和验证逻辑改进
- 数据库迁移和初始化完善
- 静态变量处理优化
- URL 签名助手实现
- Celery 扩展优化
- 代码和导入包问题修复(idea 自动调整代码位置)

技术改进:
- 兼容性修复 (flask-restx, jschardet)
- 钉钉 Web API 版本更新
- 代码格式化和导入包问题修复
- 日志处理优化
- 工作流循环管理优化

Docker 相关:
- Nginx 配置更新
- 容器启动脚本优化
- 镜像构建流程改进
- docker-compose.dify-plus.yaml 大幅更新

管理后台:
- 工作流批量处理 API 实现
- 工作池初始化
- 批量工作流服务实现
- 转发扩展配置
- 用户服务扩展
2025-10-17 23:04:25 +08:00

357 lines
20 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: "/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: "/gaia/quota/getManagementList", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/gaia/quota/setUserQuota", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/gaia/test/sync/database", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/gaia/test/app/request/batch", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/gaia/test/app/request", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/gaia/test/app/request/list", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/tenants/getAllTenants", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/tenants/getTenantsList", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/tenants/findTenants", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/gaia/dashboard/getAppTokenDailyQuotaData", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/gaia/dashboard/getAppTokenQuotaRankingData", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/gaia/dashboard/getAppQuotaRankingData", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/gaia/dashboard/getAccountQuotaRankingData", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/user/sync", V2: "POST"},
{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"},
// Extend Start: system integration
{Ptype: "p", V0: "888", V1: "/gaia/system/dingtalk", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/gaia/system/dingtalk", V2: "POST"},
// Extend Stop: system integration
// Extend Start: oauth2
{Ptype: "p", V0: "888", V1: "/gaia/system/oauth2", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/gaia/system/oauth2", V2: "POST"},
// Extend Stop: oauth2
// Extend Start: batch workflow
{Ptype: "p", V0: "888", V1: "/gaia/workflow/batch/processing", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/gaia/workflow/batch/:id", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/gaia/workflow/batch/:id/tasks", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/gaia/workflow/batch/:id/progress", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/gaia/workflow/batch/:id/stop", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/gaia/workflow/batch/:id/retry", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/gaia/workflow/batch/:id/retry-failed", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/gaia/workflow/batch/:id/resume", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/gaia/workflow/batch/:id/download", V2: "GET"},
{Ptype: "p", V0: "8881", V1: "/gaia/workflow/batch/processing", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/gaia/workflow/batch/:id", V2: "GET"},
{Ptype: "p", V0: "8881", V1: "/gaia/workflow/batch/:id/tasks", V2: "GET"},
{Ptype: "p", V0: "8881", V1: "/gaia/workflow/batch/:id/progress", V2: "GET"},
{Ptype: "p", V0: "8881", V1: "/gaia/workflow/batch/:id/stop", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/gaia/workflow/batch/:id/retry", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/gaia/workflow/batch/:id/retry-failed", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/gaia/workflow/batch/:id/resume", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/gaia/workflow/batch/:id/download", V2: "GET"},
{Ptype: "p", V0: "9528", V1: "/gaia/workflow/batch/processing", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/gaia/workflow/batch/:id", V2: "GET"},
{Ptype: "p", V0: "9528", V1: "/gaia/workflow/batch/:id/tasks", V2: "GET"},
{Ptype: "p", V0: "9528", V1: "/gaia/workflow/batch/:id/progress", V2: "GET"},
{Ptype: "p", V0: "9528", V1: "/gaia/workflow/batch/:id/stop", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/gaia/workflow/batch/:id/retry", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/gaia/workflow/batch/:id/retry-failed", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/gaia/workflow/batch/:id/resume", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/gaia/workflow/batch/:id/download", V2: "GET"},
{Ptype: "p", V0: "1", V1: "/gaia/workflow/batch/processing", V2: "POST"},
{Ptype: "p", V0: "1", V1: "/gaia/workflow/batch/:id", V2: "GET"},
{Ptype: "p", V0: "1", V1: "/gaia/workflow/batch/:id/tasks", V2: "GET"},
{Ptype: "p", V0: "1", V1: "/gaia/workflow/batch/:id/progress", V2: "GET"},
{Ptype: "p", V0: "1", V1: "/gaia/workflow/batch/:id/stop", V2: "POST"},
{Ptype: "p", V0: "1", V1: "/gaia/workflow/batch/:id/retry", V2: "POST"},
{Ptype: "p", V0: "1", V1: "/gaia/workflow/batch/:id/retry-failed", V2: "POST"},
{Ptype: "p", V0: "1", V1: "/gaia/workflow/batch/:id/resume", V2: "POST"},
{Ptype: "p", V0: "1", V1: "/gaia/workflow/batch/:id/download", V2: "GET"},
// Extend Stop: batch workflow
}
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
}