plugai_updsrv/pkg/privilege/privileges.go

137 lines
5.1 KiB
Go

package privilege
import (
"intent-system/pkg/dal/models"
"intent-system/pkg/routers"
)
// 固定权限名称列表
const (
Null = "Null" // 无权限校验
UserAccess = "UserAccess" // 账户管理-访问
UserAdd = "UserAdd" // 账户管理-添加
UserEdit = "UserEdit" // 账户管理-编辑
UserDelete = "UserDelete" // 账户管理-删除
RoleAccess = "RoleAccess" // 角色管理-访问
RoleAdd = "RoleAdd" // 角色管理-添加
RoleDelete = "RoleDelete" // 角色管理-删除
RoleEdit = "RoleEdit" // 角色管理-编辑
RoleAuthority = "RoleAuthority" // 角色管理-权限授权
NewsAccess = "NewsAccess" // News数据库-访问
NewsAdd = "NewsAdd" // News数据库-添加
NewsDelete = "NewsDelete" // News数据库-删除
NewsEdit = "NewsEdit" // News数据库-编辑
QA_Access = "QA_Access" // Q&A数据-访问
QA_Add = "QA_Add" // Q&A数据-添加
QA_Delete = "QA_Delete" // Q&A数据-删除
QA_Edit = "QA_Edit" // Q&A数据-编辑
SubAccess = "SubAccess" // 订阅管理-访问
SubAdd = "SubAdd" // 订阅管理-添加
SubEdit = "SubEdit" // 订阅管理-编辑
TagAccess = "TagAccess" // 标签管理-访问
TagAdd = "TagAdd" // 标签管理-添加
TagDelete = "TagDelete" // 标签管理-删除
TagEdit = "TagEdit" // 标签管理-编辑
ModelAccess = "ModelAccess" // 模型管理-访问
ModelAdd = "ModelAdd" // 模型管理-添加
ModelDelete = "ModelDelete" // 模型管理-删除
ModelEdit = "ModelEdit" // 模型管理-编辑
CustomerAccess = "CustomerAccess" // 客户管理-访问
DeployModelApp = "DeployModelApp" // 部署模型或者应用
)
func TotalPrivileges() (tree models.TreePrivilege) {
strPlatformPath := routers.GroupRouterPlatformV1 + "/*"
strNewsPath := routers.GroupRouterNewsV1 + "/*"
strQaPath := routers.GroupRouterQaV1 + "/*"
strTagPath := routers.GroupRouterTagV1 + "/*"
strSubPath := routers.GroupRouterSubV1 + "/*"
strCustomerPath := routers.GroupRouterCustomerV1 + "/*"
strDeployPath := routers.GroupRouterDeployV1 + "/*"
tree = models.TreePrivilege{
{
Label: "账户管理",
Name: "Account manage",
Children: models.TreePrivilege{
{Label: "查看", Name: UserAccess, Path: strPlatformPath},
{Label: "新增", Name: UserAdd, Path: strPlatformPath},
{Label: "删除", Name: UserDelete, Path: strPlatformPath},
{Label: "修改", Name: UserEdit, Path: strPlatformPath},
},
},
{
Label: "角色管理",
Name: "Role manage",
Children: models.TreePrivilege{
{Label: "查看", Name: RoleAccess, Path: strPlatformPath},
{Label: "添加", Name: RoleAdd, Path: strPlatformPath},
{Label: "删除", Name: RoleDelete, Path: strPlatformPath},
{Label: "修改", Name: RoleEdit, Path: strPlatformPath},
{Label: "权限授权", Name: RoleAuthority, Path: strPlatformPath},
},
},
{
Label: "News数据库",
Name: "News DB",
Children: models.TreePrivilege{
{Label: "查看", Name: NewsAccess, Path: strNewsPath},
{Label: "添加", Name: NewsAdd, Path: strNewsPath},
{Label: "删除", Name: NewsDelete, Path: strNewsPath},
{Label: "修改", Name: NewsEdit, Path: strNewsPath},
},
},
{
Label: "Q&A数据",
Name: "Q&A data",
Children: models.TreePrivilege{
{Label: "查看", Name: QA_Access, Path: strQaPath},
{Label: "添加", Name: QA_Add, Path: strQaPath},
{Label: "删除", Name: QA_Delete, Path: strQaPath},
{Label: "修改", Name: QA_Edit, Path: strQaPath},
},
},
{
Label: "订阅",
Name: "Sub manage",
Children: models.TreePrivilege{
{Label: "查看", Name: SubAccess, Path: strSubPath},
{Label: "添加", Name: SubAdd, Path: strSubPath},
{Label: "修改", Name: SubEdit, Path: strSubPath},
//{Label: "删除", Name: SubDelete, Path: strSubPath},
},
},
{
Label: "客户管理",
Name: "Customer manage",
Children: models.TreePrivilege{
{Label: "查看", Name: CustomerAccess, Path: strCustomerPath},
//{Label: "添加", Name: CustomerAdd, Path: strCustomerPath},
//{Label: "删除", Name: CustomerDelete, Path: strCustomerPath},
//{Label: "修改", Name: CustomerEdit, Path: strCustomerPath},
},
},
{
Label: "标签管理",
Name: "Tag manage",
Children: models.TreePrivilege{
{Label: "查看", Name: TagAccess, Path: strTagPath},
{Label: "添加", Name: TagAdd, Path: strTagPath},
{Label: "删除", Name: TagDelete, Path: strTagPath},
{Label: "修改", Name: TagEdit, Path: strTagPath},
},
},
{
Label: "部署模型或应用",
Name: "Deploy ModelApp",
Children: models.TreePrivilege{
{Label: "查看", Name: ModelAccess, Path: strDeployPath},
{Label: "添加", Name: ModelAdd, Path: strDeployPath},
{Label: "删除", Name: ModelDelete, Path: strDeployPath},
{Label: "修改", Name: ModelEdit, Path: strDeployPath},
},
},
}
return tree
}