2026-04-09 10:01:23 +08:00
package constants
const (
RoleCodeSuperAdmin = "super_admin" // 超管
RoleCodeAdmin = "admin" // 管理员
RoleCodeCsTeamLeader = "cs_team_leader" // 客服组长
RoleCodeCsUser = "cs_user" // 客服
)
const (
2026-04-30 17:42:24 +08:00
AuthTokenPrefix = "ak_"
2026-04-09 10:01:23 +08:00
)
const (
ClientTypeAdminWeb = "admin_web"
)
const (
BootstrapAdminUsername = "admin"
BootstrapAdminPassword = "ChangeMe123!"
2026-05-31 20:06:44 +08:00
BootstrapAdminNickname = "Super Admin"
2026-04-09 10:01:23 +08:00
)
// Permission 权限结构体
type Permission struct {
Name string
Code string
Type string
GroupName string
Method string
APIPath string
SortNo int
}
// 权限常量定义
var (
// 用户相关权限
2026-04-15 17:12:30 +08:00
PermissionUserView = Permission { Name : "查看用户" , Code : "user.view" , Type : "api" , GroupName : "user" , Method : "ANY" , APIPath : "/api/dashboard/user/list" , SortNo : 10 }
PermissionUserCreate = Permission { Name : "创建用户" , Code : "user.create" , Type : "api" , GroupName : "user" , Method : "POST" , APIPath : "/api/dashboard/user/create" , SortNo : 20 }
PermissionUserUpdate = Permission { Name : "更新用户" , Code : "user.update" , Type : "api" , GroupName : "user" , Method : "POST" , APIPath : "/api/dashboard/user/update" , SortNo : 30 }
PermissionUserDelete = Permission { Name : "删除用户" , Code : "user.delete" , Type : "api" , GroupName : "user" , Method : "POST" , APIPath : "/api/dashboard/user/delete" , SortNo : 40 }
PermissionUserAssignRole = Permission { Name : "分配用户角色" , Code : "user.assignRole" , Type : "api" , GroupName : "user" , Method : "POST" , APIPath : "/api/dashboard/user/assign_role" , SortNo : 50 }
2026-04-09 10:01:23 +08:00
// 角色相关权限
2026-04-15 17:12:30 +08:00
PermissionRoleView = Permission { Name : "查看角色" , Code : "role.view" , Type : "api" , GroupName : "role" , Method : "ANY" , APIPath : "/api/dashboard/role/list" , SortNo : 110 }
PermissionRoleCreate = Permission { Name : "创建角色" , Code : "role.create" , Type : "api" , GroupName : "role" , Method : "POST" , APIPath : "/api/dashboard/role/create" , SortNo : 120 }
PermissionRoleUpdate = Permission { Name : "更新角色" , Code : "role.update" , Type : "api" , GroupName : "role" , Method : "POST" , APIPath : "/api/dashboard/role/update" , SortNo : 130 }
PermissionRoleDelete = Permission { Name : "删除角色" , Code : "role.delete" , Type : "api" , GroupName : "role" , Method : "POST" , APIPath : "/api/dashboard/role/delete" , SortNo : 140 }
PermissionRoleAssignPermission = Permission { Name : "分配角色权限" , Code : "role.assignPermission" , Type : "api" , GroupName : "role" , Method : "POST" , APIPath : "/api/dashboard/role/assign_permission" , SortNo : 150 }
2026-04-09 10:01:23 +08:00
// 权限相关权限
2026-04-15 17:12:30 +08:00
PermissionPermissionView = Permission { Name : "查看权限" , Code : "permission.view" , Type : "api" , GroupName : "permission" , Method : "ANY" , APIPath : "/api/dashboard/permission/list" , SortNo : 210 }
PermissionPermissionSync = Permission { Name : "同步权限" , Code : "permission.sync" , Type : "api" , GroupName : "permission" , Method : "POST" , APIPath : "/api/dashboard/permission/sync" , SortNo : 220 }
2026-04-09 10:01:23 +08:00
// 会话相关权限
2026-04-15 17:12:30 +08:00
PermissionSessionView = Permission { Name : "查看会话" , Code : "session.view" , Type : "api" , GroupName : "session" , Method : "ANY" , APIPath : "/api/dashboard/session/list" , SortNo : 310 }
PermissionSessionRevoke = Permission { Name : "踢除会话" , Code : "session.revoke" , Type : "api" , GroupName : "session" , Method : "POST" , APIPath : "/api/dashboard/session/revoke" , SortNo : 320 }
2026-04-09 10:01:23 +08:00
// 客服会话相关权限
2026-04-15 17:12:30 +08:00
PermissionConversationView = Permission { Name : "查看会话" , Code : "conversation.view" , Type : "api" , GroupName : "conversation" , Method : "ANY" , APIPath : "/api/dashboard/conversation/list" , SortNo : 410 }
PermissionConversationAssign = Permission { Name : "分配会话" , Code : "conversation.assign" , Type : "api" , GroupName : "conversation" , Method : "POST" , APIPath : "/api/dashboard/conversation/assign" , SortNo : 430 }
PermissionConversationTransfer = Permission { Name : "转接会话" , Code : "conversation.transfer" , Type : "api" , GroupName : "conversation" , Method : "POST" , APIPath : "/api/dashboard/conversation/transfer" , SortNo : 440 }
PermissionConversationClose = Permission { Name : "关闭会话" , Code : "conversation.close" , Type : "api" , GroupName : "conversation" , Method : "POST" , APIPath : "/api/dashboard/conversation/close" , SortNo : 450 }
PermissionConversationSend = Permission { Name : "发送会话消息" , Code : "conversation.send" , Type : "api" , GroupName : "conversation" , Method : "POST" , APIPath : "/api/dashboard/conversation/send_message" , SortNo : 460 }
PermissionConversationTag = Permission { Name : "管理会话标签" , Code : "conversation.tag" , Type : "api" , GroupName : "conversation" , Method : "POST" , APIPath : "/api/dashboard/conversation/add_tag" , SortNo : 470 }
PermissionConversationHandover = Permission { Name : "处理会话交接" , Code : "conversation.handover" , Type : "api" , GroupName : "conversation" , Method : "ANY" , APIPath : "/api/dashboard/conversation/handover_list" , SortNo : 480 }
PermissionConversationRecycle = Permission { Name : "回收会话" , Code : "conversation.recycle" , Type : "api" , GroupName : "conversation" , Method : "POST" , APIPath : "/api/dashboard/conversation/recycle" , SortNo : 490 }
PermissionConversationLinkCustomer = Permission { Name : "关联会话客户" , Code : "conversation.linkCustomer" , Type : "api" , GroupName : "conversation" , Method : "POST" , APIPath : "/api/dashboard/conversation/link_customer" , SortNo : 495 }
2026-04-09 10:01:23 +08:00
// 工单相关权限
2026-05-02 18:57:40 +08:00
PermissionTicketView = Permission { Name : "查看工单" , Code : "ticket.view" , Type : "api" , GroupName : "ticket" , Method : "ANY" , APIPath : "/api/dashboard/ticket/list" , SortNo : 500 }
PermissionTicketCreate = Permission { Name : "创建工单" , Code : "ticket.create" , Type : "api" , GroupName : "ticket" , Method : "POST" , APIPath : "/api/dashboard/ticket/create" , SortNo : 510 }
PermissionTicketUpdate = Permission { Name : "更新工单" , Code : "ticket.update" , Type : "api" , GroupName : "ticket" , Method : "POST" , APIPath : "/api/dashboard/ticket/update" , SortNo : 520 }
PermissionTicketAssign = Permission { Name : "指派工单" , Code : "ticket.assign" , Type : "api" , GroupName : "ticket" , Method : "POST" , APIPath : "/api/dashboard/ticket/assign" , SortNo : 530 }
PermissionTicketChangeStatus = Permission { Name : "变更工单状态" , Code : "ticket.changeStatus" , Type : "api" , GroupName : "ticket" , Method : "POST" , APIPath : "/api/dashboard/ticket/change_status" , SortNo : 540 }
2026-05-02 21:05:11 +08:00
PermissionTicketProgress = Permission { Name : "更新工单进展" , Code : "ticket.progress" , Type : "api" , GroupName : "ticket" , Method : "POST" , APIPath : "/api/dashboard/ticket/progress/create" , SortNo : 550 }
2026-04-09 10:01:23 +08:00
2026-04-28 19:20:38 +08:00
// 通知相关权限
PermissionNotificationView = Permission { Name : "查看通知" , Code : "notification.view" , Type : "api" , GroupName : "notification" , Method : "ANY" , APIPath : "/api/dashboard/notification/list" , SortNo : 680 }
PermissionNotificationUpdate = Permission { Name : "更新通知" , Code : "notification.update" , Type : "api" , GroupName : "notification" , Method : "POST" , APIPath : "/api/dashboard/notification/mark_read" , SortNo : 690 }
2026-04-09 10:01:23 +08:00
// 快捷回复相关权限
2026-04-15 17:12:30 +08:00
PermissionQuickReplyView = Permission { Name : "查看快捷回复" , Code : "quickReply.view" , Type : "api" , GroupName : "quickReply" , Method : "ANY" , APIPath : "/api/dashboard/quick-reply/list" , SortNo : 610 }
PermissionQuickReplyCreate = Permission { Name : "创建快捷回复" , Code : "quickReply.create" , Type : "api" , GroupName : "quickReply" , Method : "POST" , APIPath : "/api/dashboard/quick-reply/create" , SortNo : 620 }
PermissionQuickReplyUpdate = Permission { Name : "更新快捷回复" , Code : "quickReply.update" , Type : "api" , GroupName : "quickReply" , Method : "POST" , APIPath : "/api/dashboard/quick-reply/update" , SortNo : 630 }
PermissionQuickReplyDelete = Permission { Name : "删除快捷回复" , Code : "quickReply.delete" , Type : "api" , GroupName : "quickReply" , Method : "POST" , APIPath : "/api/dashboard/quick-reply/delete" , SortNo : 640 }
2026-04-09 10:01:23 +08:00
// 标签相关权限
2026-04-15 17:12:30 +08:00
PermissionTagView = Permission { Name : "查看标签" , Code : "tag.view" , Type : "api" , GroupName : "tag" , Method : "ANY" , APIPath : "/api/dashboard/tag/list" , SortNo : 550 }
PermissionTagCreate = Permission { Name : "创建标签" , Code : "tag.create" , Type : "api" , GroupName : "tag" , Method : "POST" , APIPath : "/api/dashboard/tag/create" , SortNo : 560 }
PermissionTagUpdate = Permission { Name : "更新标签" , Code : "tag.update" , Type : "api" , GroupName : "tag" , Method : "POST" , APIPath : "/api/dashboard/tag/update" , SortNo : 570 }
PermissionTagDelete = Permission { Name : "删除标签" , Code : "tag.delete" , Type : "api" , GroupName : "tag" , Method : "POST" , APIPath : "/api/dashboard/tag/delete" , SortNo : 580 }
2026-04-09 10:01:23 +08:00
// 公司相关权限
2026-04-15 17:12:30 +08:00
PermissionCompanyView = Permission { Name : "查看公司" , Code : "company.view" , Type : "api" , GroupName : "company" , Method : "ANY" , APIPath : "/api/dashboard/company/list" , SortNo : 590 }
PermissionCompanyCreate = Permission { Name : "创建公司" , Code : "company.create" , Type : "api" , GroupName : "company" , Method : "POST" , APIPath : "/api/dashboard/company/create" , SortNo : 600 }
PermissionCompanyUpdate = Permission { Name : "更新公司" , Code : "company.update" , Type : "api" , GroupName : "company" , Method : "POST" , APIPath : "/api/dashboard/company/update" , SortNo : 610 }
PermissionCompanyDelete = Permission { Name : "删除公司" , Code : "company.delete" , Type : "api" , GroupName : "company" , Method : "POST" , APIPath : "/api/dashboard/company/delete" , SortNo : 620 }
2026-04-09 10:01:23 +08:00
// 接入渠道相关权限
2026-04-15 17:12:30 +08:00
PermissionChannelView = Permission { Name : "查看接入渠道" , Code : "channel.view" , Type : "api" , GroupName : "channel" , Method : "ANY" , APIPath : "/api/dashboard/channel/list" , SortNo : 625 }
PermissionChannelCreate = Permission { Name : "创建接入渠道" , Code : "channel.create" , Type : "api" , GroupName : "channel" , Method : "POST" , APIPath : "/api/dashboard/channel/create" , SortNo : 626 }
PermissionChannelUpdate = Permission { Name : "更新接入渠道" , Code : "channel.update" , Type : "api" , GroupName : "channel" , Method : "POST" , APIPath : "/api/dashboard/channel/update" , SortNo : 627 }
PermissionChannelDelete = Permission { Name : "删除接入渠道" , Code : "channel.delete" , Type : "api" , GroupName : "channel" , Method : "POST" , APIPath : "/api/dashboard/channel/delete" , SortNo : 628 }
2026-04-09 10:01:23 +08:00
2026-08-02 14:03:23 +08:00
// 企微 Outbox 相关权限
PermissionWxWorkOutboxView = Permission { Name : "查看企微 Outbox" , Code : "wxworkOutbox.view" , Type : "api" , GroupName : "wxworkOutbox" , Method : "ANY" , APIPath : "/api/dashboard/channel/wxwork/outbox/failed/list" , SortNo : 629 }
PermissionWxWorkOutboxUpdate = Permission { Name : "处置企微 Outbox" , Code : "wxworkOutbox.update" , Type : "api" , GroupName : "wxworkOutbox" , Method : "POST" , APIPath : "/api/dashboard/channel/wxwork/outbox/retry" , SortNo : 630 }
2026-04-09 10:01:23 +08:00
// 客户相关权限
2026-04-15 17:12:30 +08:00
PermissionCustomerView = Permission { Name : "查看客户" , Code : "customer.view" , Type : "api" , GroupName : "customer" , Method : "POST" , APIPath : "/api/dashboard/customer/list" , SortNo : 630 }
PermissionCustomerCreate = Permission { Name : "创建客户" , Code : "customer.create" , Type : "api" , GroupName : "customer" , Method : "POST" , APIPath : "/api/dashboard/customer/create" , SortNo : 640 }
PermissionCustomerUpdate = Permission { Name : "更新客户" , Code : "customer.update" , Type : "api" , GroupName : "customer" , Method : "POST" , APIPath : "/api/dashboard/customer/update" , SortNo : 650 }
PermissionCustomerDelete = Permission { Name : "删除客户" , Code : "customer.delete" , Type : "api" , GroupName : "customer" , Method : "POST" , APIPath : "/api/dashboard/customer/delete" , SortNo : 660 }
2026-04-09 10:01:23 +08:00
// 客服相关权限
2026-04-15 17:12:30 +08:00
PermissionAgentView = Permission { Name : "查看客服" , Code : "agent.view" , Type : "api" , GroupName : "agent" , Method : "ANY" , APIPath : "/api/dashboard/agent/list" , SortNo : 610 }
PermissionAgentCreate = Permission { Name : "创建客服" , Code : "agent.create" , Type : "api" , GroupName : "agent" , Method : "POST" , APIPath : "/api/dashboard/agent/create" , SortNo : 620 }
PermissionAgentUpdate = Permission { Name : "更新客服" , Code : "agent.update" , Type : "api" , GroupName : "agent" , Method : "POST" , APIPath : "/api/dashboard/agent/update" , SortNo : 630 }
PermissionAgentDelete = Permission { Name : "删除客服" , Code : "agent.delete" , Type : "api" , GroupName : "agent" , Method : "POST" , APIPath : "/api/dashboard/agent/delete" , SortNo : 640 }
PermissionAgentUpdateStatus = Permission { Name : "更新客服状态" , Code : "agent.updateStatus" , Type : "api" , GroupName : "agent" , Method : "POST" , APIPath : "/api/dashboard/agent/update_status" , SortNo : 650 }
PermissionAgentConfig = Permission { Name : "配置客服服务规则" , Code : "agent.config" , Type : "api" , GroupName : "agent" , Method : "POST" , APIPath : "/api/dashboard/agent/update_service_config" , SortNo : 660 }
2026-04-09 10:01:23 +08:00
// 客服组相关权限
2026-04-15 17:12:30 +08:00
PermissionAgentTeamView = Permission { Name : "查看客服组" , Code : "agentTeam.view" , Type : "api" , GroupName : "agentTeam" , Method : "ANY" , APIPath : "/api/dashboard/agent-team/list" , SortNo : 710 }
PermissionAgentTeamCreate = Permission { Name : "创建客服组" , Code : "agentTeam.create" , Type : "api" , GroupName : "agentTeam" , Method : "POST" , APIPath : "/api/dashboard/agent-team/create" , SortNo : 720 }
PermissionAgentTeamUpdate = Permission { Name : "更新客服组" , Code : "agentTeam.update" , Type : "api" , GroupName : "agentTeam" , Method : "POST" , APIPath : "/api/dashboard/agent-team/update" , SortNo : 730 }
PermissionAgentTeamDelete = Permission { Name : "删除客服组" , Code : "agentTeam.delete" , Type : "api" , GroupName : "agentTeam" , Method : "POST" , APIPath : "/api/dashboard/agent-team/delete" , SortNo : 740 }
2026-04-09 10:01:23 +08:00
// 客服组排班相关权限
2026-04-15 17:12:30 +08:00
PermissionAgentTeamScheduleView = Permission { Name : "查看客服组排班" , Code : "agentTeamSchedule.view" , Type : "api" , GroupName : "agentTeamSchedule" , Method : "ANY" , APIPath : "/api/dashboard/agent-team-schedule/list" , SortNo : 810 }
PermissionAgentTeamScheduleCreate = Permission { Name : "创建客服组排班" , Code : "agentTeamSchedule.create" , Type : "api" , GroupName : "agentTeamSchedule" , Method : "POST" , APIPath : "/api/dashboard/agent-team-schedule/create" , SortNo : 820 }
PermissionAgentTeamScheduleUpdate = Permission { Name : "更新客服组排班" , Code : "agentTeamSchedule.update" , Type : "api" , GroupName : "agentTeamSchedule" , Method : "POST" , APIPath : "/api/dashboard/agent-team-schedule/update" , SortNo : 830 }
PermissionAgentTeamScheduleDelete = Permission { Name : "删除客服组排班" , Code : "agentTeamSchedule.delete" , Type : "api" , GroupName : "agentTeamSchedule" , Method : "POST" , APIPath : "/api/dashboard/agent-team-schedule/delete" , SortNo : 840 }
PermissionAgentTeamScheduleBatchGenerate = Permission { Name : "批量生成客服组排班" , Code : "agentTeamSchedule.batchGenerate" , Type : "api" , GroupName : "agentTeamSchedule" , Method : "POST" , APIPath : "/api/dashboard/agent-team-schedule/batch_generate" , SortNo : 850 }
2026-04-09 10:01:23 +08:00
// 文件资源相关权限
2026-04-15 17:12:30 +08:00
PermissionAssetView = Permission { Name : "查看文件资源" , Code : "asset.view" , Type : "api" , GroupName : "asset" , Method : "ANY" , APIPath : "/api/dashboard/asset/list" , SortNo : 1210 }
PermissionAssetCreate = Permission { Name : "上传文件资源" , Code : "asset.create" , Type : "api" , GroupName : "asset" , Method : "POST" , APIPath : "/api/dashboard/asset/create" , SortNo : 1220 }
PermissionAssetDelete = Permission { Name : "删除文件资源" , Code : "asset.delete" , Type : "api" , GroupName : "asset" , Method : "POST" , APIPath : "/api/dashboard/asset/delete" , SortNo : 1230 }
2026-04-09 10:01:23 +08:00
2026-04-23 14:26:10 +08:00
// AI Agent 相关权限
PermissionAIAgentView = Permission { Name : "查看 AI Agent" , Code : "aiAgent.view" , Type : "api" , GroupName : "aiAgent" , Method : "ANY" , APIPath : "/api/dashboard/ai-agent/list" , SortNo : 1310 }
PermissionAIAgentCreate = Permission { Name : "创建 AI Agent" , Code : "aiAgent.create" , Type : "api" , GroupName : "aiAgent" , Method : "POST" , APIPath : "/api/dashboard/ai-agent/create" , SortNo : 1320 }
PermissionAIAgentUpdate = Permission { Name : "更新 AI Agent" , Code : "aiAgent.update" , Type : "api" , GroupName : "aiAgent" , Method : "POST" , APIPath : "/api/dashboard/ai-agent/update" , SortNo : 1330 }
PermissionAIAgentDelete = Permission { Name : "删除 AI Agent" , Code : "aiAgent.delete" , Type : "api" , GroupName : "aiAgent" , Method : "POST" , APIPath : "/api/dashboard/ai-agent/delete" , SortNo : 1340 }
2026-04-09 10:01:23 +08:00
// AI 配置相关权限
2026-04-15 17:12:30 +08:00
PermissionAIConfigView = Permission { Name : "查看 AI 配置" , Code : "aiConfig.view" , Type : "api" , GroupName : "aiConfig" , Method : "ANY" , APIPath : "/api/dashboard/ai-config/list" , SortNo : 1390 }
PermissionAIConfigCreate = Permission { Name : "创建 AI 配置" , Code : "aiConfig.create" , Type : "api" , GroupName : "aiConfig" , Method : "POST" , APIPath : "/api/dashboard/ai-config/create" , SortNo : 1400 }
PermissionAIConfigUpdate = Permission { Name : "更新 AI 配置" , Code : "aiConfig.update" , Type : "api" , GroupName : "aiConfig" , Method : "POST" , APIPath : "/api/dashboard/ai-config/update" , SortNo : 1410 }
PermissionAIConfigDelete = Permission { Name : "删除 AI 配置" , Code : "aiConfig.delete" , Type : "api" , GroupName : "aiConfig" , Method : "POST" , APIPath : "/api/dashboard/ai-config/delete" , SortNo : 1420 }
2026-04-09 10:01:23 +08:00
// 知识库相关权限
2026-04-15 17:12:30 +08:00
PermissionKnowledgeBaseView = Permission { Name : "查看知识库" , Code : "knowledgeBase.view" , Type : "api" , GroupName : "knowledgeBase" , Method : "ANY" , APIPath : "/api/dashboard/knowledge-base/list" , SortNo : 1410 }
PermissionKnowledgeBaseCreate = Permission { Name : "创建知识库" , Code : "knowledgeBase.create" , Type : "api" , GroupName : "knowledgeBase" , Method : "POST" , APIPath : "/api/dashboard/knowledge-base/create" , SortNo : 1420 }
PermissionKnowledgeBaseUpdate = Permission { Name : "更新知识库" , Code : "knowledgeBase.update" , Type : "api" , GroupName : "knowledgeBase" , Method : "POST" , APIPath : "/api/dashboard/knowledge-base/update" , SortNo : 1430 }
PermissionKnowledgeBaseDelete = Permission { Name : "删除知识库" , Code : "knowledgeBase.delete" , Type : "api" , GroupName : "knowledgeBase" , Method : "POST" , APIPath : "/api/dashboard/knowledge-base/delete" , SortNo : 1440 }
2026-04-09 10:01:23 +08:00
// 知识文档相关权限
2026-04-15 17:12:30 +08:00
PermissionKnowledgeDocumentView = Permission { Name : "查看知识文档" , Code : "knowledgeDocument.view" , Type : "api" , GroupName : "knowledgeDocument" , Method : "ANY" , APIPath : "/api/dashboard/knowledge-document/list" , SortNo : 1510 }
PermissionKnowledgeDocumentCreate = Permission { Name : "创建知识文档" , Code : "knowledgeDocument.create" , Type : "api" , GroupName : "knowledgeDocument" , Method : "POST" , APIPath : "/api/dashboard/knowledge-document/create" , SortNo : 1520 }
PermissionKnowledgeDocumentUpdate = Permission { Name : "更新知识文档" , Code : "knowledgeDocument.update" , Type : "api" , GroupName : "knowledgeDocument" , Method : "POST" , APIPath : "/api/dashboard/knowledge-document/update" , SortNo : 1530 }
PermissionKnowledgeDocumentDelete = Permission { Name : "删除知识文档" , Code : "knowledgeDocument.delete" , Type : "api" , GroupName : "knowledgeDocument" , Method : "POST" , APIPath : "/api/dashboard/knowledge-document/delete" , SortNo : 1540 }
PermissionKnowledgeFAQView = Permission { Name : "查看知识FAQ" , Code : "knowledgeFAQ.view" , Type : "api" , GroupName : "knowledgeFAQ" , Method : "ANY" , APIPath : "/api/dashboard/knowledge-faq/list" , SortNo : 1550 }
PermissionKnowledgeFAQCreate = Permission { Name : "创建知识FAQ" , Code : "knowledgeFAQ.create" , Type : "api" , GroupName : "knowledgeFAQ" , Method : "POST" , APIPath : "/api/dashboard/knowledge-faq/create" , SortNo : 1560 }
PermissionKnowledgeFAQUpdate = Permission { Name : "更新知识FAQ" , Code : "knowledgeFAQ.update" , Type : "api" , GroupName : "knowledgeFAQ" , Method : "POST" , APIPath : "/api/dashboard/knowledge-faq/update" , SortNo : 1570 }
PermissionKnowledgeFAQDelete = Permission { Name : "删除知识FAQ" , Code : "knowledgeFAQ.delete" , Type : "api" , GroupName : "knowledgeFAQ" , Method : "POST" , APIPath : "/api/dashboard/knowledge-faq/delete" , SortNo : 1580 }
2026-04-09 10:01:23 +08:00
// Skill 定义相关权限
2026-04-15 17:12:30 +08:00
PermissionSkillDefinitionView = Permission { Name : "查看技能定义" , Code : "skillDefinition.view" , Type : "api" , GroupName : "skillDefinition" , Method : "ANY" , APIPath : "/api/dashboard/skill-definition/list" , SortNo : 1610 }
PermissionSkillDefinitionCreate = Permission { Name : "创建技能定义" , Code : "skillDefinition.create" , Type : "api" , GroupName : "skillDefinition" , Method : "POST" , APIPath : "/api/dashboard/skill-definition/create" , SortNo : 1620 }
PermissionSkillDefinitionUpdate = Permission { Name : "更新技能定义" , Code : "skillDefinition.update" , Type : "api" , GroupName : "skillDefinition" , Method : "POST" , APIPath : "/api/dashboard/skill-definition/update" , SortNo : 1630 }
PermissionSkillDefinitionDelete = Permission { Name : "删除技能定义" , Code : "skillDefinition.delete" , Type : "api" , GroupName : "skillDefinition" , Method : "POST" , APIPath : "/api/dashboard/skill-definition/delete" , SortNo : 1640 }
2026-04-09 10:01:23 +08:00
// MCP 调试相关权限
2026-04-15 17:12:30 +08:00
PermissionMCPView = Permission { Name : "查看MCP调试信息" , Code : "mcp.view" , Type : "api" , GroupName : "mcp" , Method : "POST" , APIPath : "/api/dashboard/mcp/list_tools" , SortNo : 1710 }
PermissionMCPCall = Permission { Name : "调用MCP工具" , Code : "mcp.call" , Type : "api" , GroupName : "mcp" , Method : "POST" , APIPath : "/api/dashboard/mcp/call_tool" , SortNo : 1720 }
2026-04-09 10:01:23 +08:00
)
// Permissions 内置权限列表
var Permissions = [] Permission {
PermissionUserView ,
PermissionUserCreate ,
PermissionUserUpdate ,
PermissionUserDelete ,
PermissionUserAssignRole ,
PermissionRoleView ,
PermissionRoleCreate ,
PermissionRoleUpdate ,
PermissionRoleDelete ,
PermissionRoleAssignPermission ,
PermissionPermissionView ,
PermissionPermissionSync ,
PermissionSessionView ,
PermissionSessionRevoke ,
PermissionConversationView ,
PermissionConversationAssign ,
PermissionConversationTransfer ,
PermissionConversationClose ,
PermissionConversationSend ,
PermissionConversationTag ,
PermissionConversationHandover ,
PermissionConversationRecycle ,
PermissionConversationLinkCustomer ,
PermissionTicketView ,
PermissionTicketCreate ,
PermissionTicketUpdate ,
PermissionTicketAssign ,
PermissionTicketChangeStatus ,
2026-05-02 18:57:40 +08:00
PermissionTicketProgress ,
2026-04-28 19:20:38 +08:00
PermissionNotificationView ,
PermissionNotificationUpdate ,
2026-04-09 10:01:23 +08:00
PermissionQuickReplyView ,
PermissionQuickReplyCreate ,
PermissionQuickReplyUpdate ,
PermissionQuickReplyDelete ,
PermissionTagView ,
PermissionTagCreate ,
PermissionTagUpdate ,
PermissionTagDelete ,
PermissionCompanyView ,
PermissionCompanyCreate ,
PermissionCompanyUpdate ,
PermissionCompanyDelete ,
PermissionChannelView ,
PermissionChannelCreate ,
PermissionChannelUpdate ,
PermissionChannelDelete ,
2026-08-02 14:03:23 +08:00
PermissionWxWorkOutboxView ,
PermissionWxWorkOutboxUpdate ,
2026-04-09 10:01:23 +08:00
PermissionCustomerView ,
PermissionCustomerCreate ,
PermissionCustomerUpdate ,
PermissionCustomerDelete ,
PermissionAgentView ,
PermissionAgentCreate ,
PermissionAgentUpdate ,
PermissionAgentDelete ,
PermissionAgentUpdateStatus ,
PermissionAgentConfig ,
PermissionAgentTeamView ,
PermissionAgentTeamCreate ,
PermissionAgentTeamUpdate ,
PermissionAgentTeamDelete ,
PermissionAgentTeamScheduleView ,
PermissionAgentTeamScheduleCreate ,
PermissionAgentTeamScheduleUpdate ,
PermissionAgentTeamScheduleDelete ,
PermissionAgentTeamScheduleBatchGenerate ,
PermissionAssetView ,
PermissionAssetCreate ,
PermissionAssetDelete ,
2026-04-23 14:26:10 +08:00
PermissionAIAgentView ,
PermissionAIAgentCreate ,
PermissionAIAgentUpdate ,
PermissionAIAgentDelete ,
2026-04-09 10:01:23 +08:00
PermissionAIConfigView ,
PermissionAIConfigCreate ,
PermissionAIConfigUpdate ,
PermissionAIConfigDelete ,
PermissionKnowledgeBaseView ,
PermissionKnowledgeBaseCreate ,
PermissionKnowledgeBaseUpdate ,
PermissionKnowledgeBaseDelete ,
PermissionKnowledgeDocumentView ,
PermissionKnowledgeDocumentCreate ,
PermissionKnowledgeDocumentUpdate ,
PermissionKnowledgeDocumentDelete ,
PermissionKnowledgeFAQView ,
PermissionKnowledgeFAQCreate ,
PermissionKnowledgeFAQUpdate ,
PermissionKnowledgeFAQDelete ,
PermissionSkillDefinitionView ,
PermissionSkillDefinitionCreate ,
PermissionSkillDefinitionUpdate ,
PermissionSkillDefinitionDelete ,
PermissionMCPView ,
PermissionMCPCall ,
}
// PermissionMap 权限映射,用于通过 Code 查找 Permission
var PermissionMap = make ( map [ string ] Permission )
// init 初始化 PermissionMap
func init () {
2026-05-31 20:06:44 +08:00
normalizeBuiltinPermissionNames ()
2026-04-09 10:01:23 +08:00
for _ , permission := range Permissions {
PermissionMap [ permission . Code ] = permission
}
}
2026-05-31 20:06:44 +08:00
func normalizeBuiltinPermissionNames () {
for i := range Permissions {
Permissions [ i ]. Name = builtinPermissionName ( Permissions [ i ]. Code , Permissions [ i ]. Name )
}
}
func builtinPermissionName ( code string , fallback string ) string {
if name , ok := builtinPermissionNameOverrides [ code ]; ok {
return name
}
resourceKey , actionKey , ok := splitPermissionCode ( code )
if ! ok {
return fallback
}
action , ok := builtinPermissionActionLabels [ actionKey ]
if ! ok {
return fallback
}
resource , ok := builtinPermissionResourceLabels [ resourceKey ]
if ! ok {
return fallback
}
return action + " " + resource
}
func splitPermissionCode ( code string ) ( string , string , bool ) {
for i := 0 ; i < len ( code ); i ++ {
if code [ i ] == '.' {
return code [: i ], code [ i + 1 :], i > 0 && i < len ( code ) - 1
}
}
return "" , "" , false
}
var builtinPermissionActionLabels = map [ string ] string {
"view" : "View" ,
"create" : "Create" ,
"update" : "Update" ,
"delete" : "Delete" ,
"assignRole" : "Assign roles to" ,
"assignPermission" : "Assign permissions to" ,
"sync" : "Sync" ,
"revoke" : "Revoke" ,
"assign" : "Assign" ,
"transfer" : "Transfer" ,
"close" : "Close" ,
"send" : "Send" ,
"tag" : "Manage tags for" ,
"handover" : "Handle handoffs for" ,
"recycle" : "Recycle" ,
"linkCustomer" : "Link customers to" ,
"changeStatus" : "Change status for" ,
"progress" : "Update progress for" ,
"updateStatus" : "Update status for" ,
"config" : "Configure service rules for" ,
"batchGenerate" : "Batch generate" ,
"call" : "Call" ,
}
var builtinPermissionResourceLabels = map [ string ] string {
"user" : "users" ,
"role" : "roles" ,
"permission" : "permissions" ,
"session" : "sessions" ,
"conversation" : "conversations" ,
"ticket" : "tickets" ,
"notification" : "notifications" ,
"quickReply" : "quick replies" ,
"tag" : "tags" ,
"company" : "companies" ,
"channel" : "channels" ,
2026-08-02 14:03:23 +08:00
"wxworkOutbox" : "WeCom outbox records" ,
2026-05-31 20:06:44 +08:00
"customer" : "customers" ,
"agent" : "agents" ,
"agentTeam" : "agent teams" ,
"agentTeamSchedule" : "agent team schedules" ,
"asset" : "file assets" ,
"aiAgent" : "AI Agents" ,
"aiConfig" : "AI configurations" ,
"knowledgeBase" : "knowledge bases" ,
"knowledgeDocument" : "knowledge documents" ,
"knowledgeFAQ" : "knowledge FAQs" ,
"skillDefinition" : "Skill definitions" ,
"mcp" : "MCP tools" ,
}
var builtinPermissionNameOverrides = map [ string ] string {
"user.assignRole" : "Assign user roles" ,
"role.assignPermission" : "Assign role permissions" ,
"session.revoke" : "Revoke sessions" ,
"conversation.send" : "Send conversation messages" ,
"conversation.linkCustomer" : "Link conversation customer" ,
"ticket.changeStatus" : "Change ticket status" ,
"ticket.progress" : "Update ticket progress" ,
"agent.config" : "Configure agent service rules" ,
"agentTeamSchedule.batchGenerate" : "Batch generate agent team schedules" ,
2026-08-02 14:03:23 +08:00
"wxworkOutbox.update" : "Handle WeCom outbox records" ,
2026-05-31 20:06:44 +08:00
"mcp.view" : "View MCP debug information" ,
"mcp.call" : "Call MCP tools" ,
}
2026-04-09 10:01:23 +08:00
type RoleSpec struct {
Name string
Code string
SortNo int
}
var Roles = [] RoleSpec {
2026-05-31 20:06:44 +08:00
{ Name : "Super Admin" , Code : RoleCodeSuperAdmin , SortNo : 1 },
{ Name : "Admin" , Code : RoleCodeAdmin , SortNo : 2 },
{ Name : "Support Team Lead" , Code : RoleCodeCsTeamLeader , SortNo : 3 },
{ Name : "Support Agent" , Code : RoleCodeCsUser , SortNo : 4 },
2026-04-09 10:01:23 +08:00
}
var RolePermissions = map [ string ][] Permission {
RoleCodeSuperAdmin : Permissions ,
RoleCodeAdmin : {
PermissionUserView , PermissionUserCreate , PermissionUserUpdate , PermissionUserAssignRole ,
PermissionRoleView , PermissionRoleCreate , PermissionRoleUpdate , PermissionRoleAssignPermission ,
PermissionPermissionView , PermissionPermissionSync ,
PermissionSessionView , PermissionSessionRevoke ,
PermissionConversationView , PermissionConversationAssign , PermissionConversationTransfer , PermissionConversationClose , PermissionConversationSend , PermissionConversationTag , PermissionConversationHandover , PermissionConversationRecycle , PermissionConversationLinkCustomer ,
2026-05-02 18:57:40 +08:00
PermissionTicketView , PermissionTicketCreate , PermissionTicketUpdate , PermissionTicketAssign , PermissionTicketChangeStatus , PermissionTicketProgress ,
2026-04-28 19:20:38 +08:00
PermissionNotificationView , PermissionNotificationUpdate ,
2026-04-09 10:01:23 +08:00
PermissionQuickReplyView , PermissionQuickReplyCreate , PermissionQuickReplyUpdate , PermissionQuickReplyDelete ,
PermissionTagView , PermissionTagCreate , PermissionTagUpdate , PermissionTagDelete ,
PermissionCompanyView , PermissionCompanyCreate , PermissionCompanyUpdate , PermissionCompanyDelete ,
2026-08-02 14:03:23 +08:00
PermissionChannelView , PermissionChannelCreate , PermissionChannelUpdate , PermissionChannelDelete , PermissionWxWorkOutboxView , PermissionWxWorkOutboxUpdate ,
2026-04-09 10:01:23 +08:00
PermissionCustomerView , PermissionCustomerCreate , PermissionCustomerUpdate , PermissionCustomerDelete ,
PermissionAgentView , PermissionAgentCreate , PermissionAgentUpdate , PermissionAgentDelete , PermissionAgentUpdateStatus , PermissionAgentConfig ,
PermissionAgentTeamView , PermissionAgentTeamCreate , PermissionAgentTeamUpdate , PermissionAgentTeamDelete ,
PermissionAgentTeamScheduleView , PermissionAgentTeamScheduleCreate , PermissionAgentTeamScheduleUpdate , PermissionAgentTeamScheduleDelete , PermissionAgentTeamScheduleBatchGenerate ,
PermissionAssetView , PermissionAssetCreate , PermissionAssetDelete ,
2026-04-23 14:26:10 +08:00
PermissionAIAgentView , PermissionAIAgentCreate , PermissionAIAgentUpdate , PermissionAIAgentDelete ,
2026-04-09 10:01:23 +08:00
PermissionAIConfigView , PermissionAIConfigCreate , PermissionAIConfigUpdate , PermissionAIConfigDelete ,
PermissionSkillDefinitionView , PermissionSkillDefinitionCreate , PermissionSkillDefinitionUpdate , PermissionSkillDefinitionDelete ,
},
RoleCodeCsTeamLeader : {
PermissionUserView ,
PermissionRoleView ,
PermissionPermissionView ,
PermissionSessionView ,
PermissionConversationView , PermissionConversationClose , PermissionConversationSend , PermissionConversationTag , PermissionConversationHandover , PermissionConversationRecycle , PermissionConversationLinkCustomer ,
2026-05-02 18:57:40 +08:00
PermissionTicketView , PermissionTicketCreate , PermissionTicketUpdate , PermissionTicketAssign , PermissionTicketChangeStatus , PermissionTicketProgress ,
2026-04-28 19:20:38 +08:00
PermissionNotificationView , PermissionNotificationUpdate ,
2026-04-09 10:01:23 +08:00
PermissionQuickReplyView , PermissionQuickReplyCreate , PermissionQuickReplyUpdate , PermissionQuickReplyDelete ,
PermissionTagView , PermissionTagCreate , PermissionTagUpdate , PermissionTagDelete ,
PermissionCompanyView ,
PermissionChannelView , PermissionChannelCreate , PermissionChannelUpdate ,
PermissionCustomerView , PermissionCustomerCreate , PermissionCustomerUpdate ,
PermissionAgentView , PermissionAgentUpdate ,
PermissionAgentTeamView ,
PermissionAgentTeamScheduleView , PermissionAgentTeamScheduleCreate , PermissionAgentTeamScheduleUpdate , PermissionAgentTeamScheduleDelete , PermissionAgentTeamScheduleBatchGenerate ,
PermissionAssetView , PermissionAssetCreate , PermissionAssetDelete ,
2026-04-23 14:26:10 +08:00
PermissionAIAgentView , PermissionAIAgentCreate , PermissionAIAgentUpdate ,
2026-04-09 10:01:23 +08:00
PermissionAIConfigView ,
PermissionSkillDefinitionView , PermissionSkillDefinitionCreate , PermissionSkillDefinitionUpdate ,
},
RoleCodeCsUser : {
PermissionUserView ,
PermissionRoleView ,
PermissionPermissionView ,
PermissionConversationView ,
2026-05-02 21:00:00 +08:00
PermissionTicketView , PermissionTicketCreate , PermissionTicketAssign , PermissionTicketChangeStatus , PermissionTicketProgress ,
2026-04-28 19:20:38 +08:00
PermissionNotificationView , PermissionNotificationUpdate ,
2026-04-09 10:01:23 +08:00
PermissionQuickReplyView ,
PermissionTagView ,
PermissionCompanyView ,
PermissionChannelView ,
PermissionCustomerView ,
PermissionAssetView ,
PermissionAgentView ,
PermissionAgentTeamView ,
PermissionAgentTeamScheduleView ,
2026-04-23 14:26:10 +08:00
PermissionAIAgentView ,
2026-04-09 10:01:23 +08:00
PermissionAIConfigView ,
PermissionSkillDefinitionView ,
},
}
func PermissionCodes () [] string {
ret := make ([] string , 0 , len ( Permissions ))
for _ , permission := range Permissions {
ret = append ( ret , permission . Code )
}
return ret
}