Skip to content

system 模块

管理核心模块。承担用户 / 角色 / 菜单 / 部门 / 岗位 / 字典(数据 + 类型)/ 公告 / 客户端 / 参数配置的 CRUD,以及个人资料自服务、社交绑定列表、角色 / 用户授权、消息箱读取。每条写路径均由 CheckPermission(菜单超管操作用 CheckRole)守护,并包裹 oplog.Log(...) + repeatsubmit.RepeatSubmit(0,"")。通过 POST /export 导出。登录信息 / 操作日志的 记录服务在此,但其 监控(list/delete)在 monitor 模块。

前缀:standalone /system,modular ""。探针:GET /system/ping(注册在裸 engine 上,受保护组之外)。

中间件图例:OP=oplog.Log(title,type)RS=repeatsubmit.RepeatSubmit(0,"")ENC=encrypt.ApiEncrypt()

user + profile(前缀 /user

方法路径鉴权中间件Handler
GET/user/getInfoCheckLoginUserApiApp.GetInfo
GET/user/profileCheckLoginProfileApiApp.Profile
PUT/user/profileCheckLoginOP(profile,Update) RSProfileApiApp.UpdateProfile
PUT/user/profile/updatePwdCheckLoginENC, OP(profile,Update) RSProfileApiApp.UpdatePwd
GET/user/listsystem:user:listUserApiApp.List
GET/user/list/dept/:deptIdsystem:user:listUserApiApp.ListByDept
GET/user/deptTreesystem:user:listUserApiApp.DeptTree
GET/user/optionselectsystem:user:queryUserApiApp.OptionSelect
GET/user/authRole/:userIdsystem:user:queryUserApiApp.AuthRole
GET/user/unlock/:userIdsystem:user:editOP(user,Other) RSUserApiApp.Unlock
POST/user/exportsystem:user:exportOP(user,Export)UserApiApp.Export
POST/user/importDatasystem:user:importOP(user,Import)UserApiApp.ImportData
POST/user/importTemplateCheckLoginUserApiApp.ImportTemplate
POST/usersystem:user:addOP(user,Insert) RSUserApiApp.Add
PUT/usersystem:user:editOP(user,Update) RSUserApiApp.Edit
PUT/user/resetPwdsystem:user:resetPwdENC, OP(user,Update) RSUserApiApp.ResetPwd
PUT/user/changeStatussystem:user:editOP(user,Update) RSUserApiApp.ChangeStatus
PUT/user/authRolesystem:user:editOP(user,Grant) RSUserApiApp.InsertAuthRole
GET/usersystem:user:queryUserApiApp.GetInfoByID
GET/user/:userIdsystem:user:queryUserApiApp.GetInfoByID
DELETE/user/:userIdssystem:user:removeOP(user,Delete)UserApiApp.Remove
方法路径鉴权中间件Handler
GET/menu/getRoutersCheckLoginMenuApiApp.GetRouters
GET/menu/listCheckRole(superAdmin) AND system:menu:listMenuApiApp.List
GET/menu/treeselectsystem:menu:queryMenuApiApp.TreeSelect
GET/menu/roleMenuTreeselect/:roleIdsystem:menu:queryMenuApiApp.RoleMenuTreeSelect
GET/menu/:menuIdCheckRole(superAdmin) AND system:menu:queryMenuApiApp.GetInfo
POST/menuCheckRole(superAdmin) AND system:menu:addOP(menu,Insert) RSMenuApiApp.Add
PUT/menuCheckRole(superAdmin) AND system:menu:editOP(menu,Update) RSMenuApiApp.Edit
DELETE/menu/cascade/:menuIdsCheckRole(superAdmin) AND system:menu:removeOP(menu,Delete)MenuApiApp.CascadeRemove
DELETE/menu/:menuIdCheckRole(superAdmin) AND system:menu:removeOP(menu,Delete)MenuApiApp.Remove

client(前缀 /client

方法路径鉴权中间件Handler
GET/client/listsystem:client:listClientApiApp.List
GET/client/:idsystem:client:queryClientApiApp.GetInfo
POST/client/exportsystem:client:exportOP(client,Export)ClientApiApp.Export
POST/clientsystem:client:addOP(client,Insert) RSClientApiApp.Add
PUT/clientsystem:client:editOP(client,Update) RSClientApiApp.Edit
PUT/client/changeStatussystem:client:editOP(client,Update)(无 RS——幂等)ClientApiApp.ChangeStatus
DELETE/client/:idssystem:client:removeOP(client,Delete)ClientApiApp.Remove

config(前缀 /config

方法路径鉴权中间件Handler
GET/config/listsystem:config:listConfigApiApp.List
GET/config/configKey/:configKeyCheckLoginConfigApiApp.GetConfigKey
GET/config/:configIdsystem:config:queryConfigApiApp.GetInfo
POST/config/exportsystem:config:exportOP(config,Export)ConfigApiApp.Export
POST/configsystem:config:addOP(config,Insert) RSConfigApiApp.Add
PUT/configsystem:config:editOP(config,Update) RSConfigApiApp.Edit
PUT/config/updateByKeysystem:config:editOP(config,Update) RSConfigApiApp.UpdateByKey
DELETE/config/refreshCachesystem:config:removeOP(config,Clean)ConfigApiApp.RefreshCache
DELETE/config/:configIdssystem:config:removeOP(config,Delete)ConfigApiApp.Remove

dept(前缀 /dept

方法路径鉴权中间件Handler
GET/dept/listsystem:dept:listDeptApiApp.List
GET/dept/list/exclude/:deptIdsystem:dept:listDeptApiApp.ExcludeChild
GET/dept/optionselectsystem:dept:queryDeptApiApp.OptionSelect
GET/dept/:deptIdsystem:dept:queryDeptApiApp.GetInfo
POST/deptsystem:dept:addOP(dept,Insert) RSDeptApiApp.Add
PUT/deptsystem:dept:editOP(dept,Update) RSDeptApiApp.Edit
DELETE/dept/:deptIdsystem:dept:removeOP(dept,Delete)DeptApiApp.Remove(仅单删——保树完整性)

dict data(前缀 /dict/data

方法路径鉴权中间件Handler
GET/dict/data/listsystem:dict:listDictDataApiApp.List
GET/dict/data/type/:dictTypeCheckLoginDictDataApiApp.DictType
GET/dict/data/:dictCodesystem:dict:queryDictDataApiApp.GetInfo
POST/dict/data/exportsystem:dict:exportOP(dictData,Export)DictDataApiApp.Export
POST/dict/datasystem:dict:addOP(dictData,Insert) RSDictDataApiApp.Add
PUT/dict/datasystem:dict:editOP(dictData,Update) RSDictDataApiApp.Edit
DELETE/dict/data/:dictCodessystem:dict:removeOP(dictData,Delete)DictDataApiApp.Remove

dict type(前缀 /dict/type

方法路径鉴权中间件Handler
GET/dict/type/listsystem:dict:listDictTypeApiApp.List
GET/dict/type/optionselectCheckLoginDictTypeApiApp.OptionSelect
GET/dict/type/:dictIdsystem:dict:queryDictTypeApiApp.GetInfo
POST/dict/type/exportsystem:dict:exportOP(dictType,Export)DictTypeApiApp.Export
POST/dict/typesystem:dict:addOP(dictType,Insert) RSDictTypeApiApp.Add
PUT/dict/typesystem:dict:editOP(dictType,Update) RSDictTypeApiApp.Edit
DELETE/dict/type/refreshCachesystem:dict:removeOP(dictType,Clean)DictTypeApiApp.RefreshCache
DELETE/dict/type/:dictIdssystem:dict:removeOP(dictType,Delete)DictTypeApiApp.Remove

notice(前缀 /notice

方法路径鉴权中间件Handler
GET/notice/listsystem:notice:listNoticeApiApp.List
GET/notice/:noticeIdsystem:notice:queryNoticeApiApp.GetInfo
POST/noticesystem:notice:addOP(notice,Insert) RSNoticeApiApp.Add
PUT/noticesystem:notice:editOP(notice,Update) RSNoticeApiApp.Edit
DELETE/notice/:noticeIdssystem:notice:removeOP(notice,Delete)NoticeApiApp.Remove

post(前缀 /post

方法路径鉴权中间件Handler
GET/post/listsystem:post:listPostApiApp.List
GET/post/optionselectsystem:post:queryPostApiApp.OptionSelect
GET/post/deptTreesystem:post:listPostApiApp.DeptTree
GET/post/:postIdsystem:post:queryPostApiApp.GetInfo
POST/post/exportsystem:post:exportOP(post,Export)PostApiApp.Export
POST/postsystem:post:addOP(post,Insert) RSPostApiApp.Add
PUT/postsystem:post:editOP(post,Update) RSPostApiApp.Edit
DELETE/post/:postIdssystem:post:removeOP(post,Delete)PostApiApp.Remove

social(前缀 /social

方法路径鉴权中间件Handler
GET/social/listCheckLoginSocialApiApp.List

role(前缀 /role

方法路径鉴权中间件Handler
GET/role/listsystem:role:listRoleApiApp.List
GET/role/optionselectsystem:role:queryRoleApiApp.OptionSelect
GET/role/authUser/allocatedListsystem:role:listRoleApiApp.AllocatedList
GET/role/authUser/unallocatedListsystem:role:listRoleApiApp.UnallocatedList
GET/role/deptTree/:roleIdsystem:role:listRoleApiApp.DeptTreeSelect
POST/role/exportsystem:role:exportOP(role,Export)RoleApiApp.Export
POST/rolesystem:role:addOP(role,Insert) RSRoleApiApp.Add
PUT/rolesystem:role:editOP(role,Update) RSRoleApiApp.Edit
PUT/role/permissionsystem:role:editOP(role,Update) RSRoleApiApp.EditPermission
PUT/role/changeStatussystem:role:editOP(role,Update) RSRoleApiApp.ChangeStatus
PUT/role/authUser/cancelsystem:role:editOP(role,Grant) RSRoleApiApp.CancelAuthUser
PUT/role/authUser/cancelAllsystem:role:editOP(role,Grant) RSRoleApiApp.CancelAuthUserAll
PUT/role/authUser/selectAllsystem:role:editOP(role,Grant) RSRoleApiApp.SelectAuthUserAll
GET/role/:roleIdsystem:role:queryRoleApiApp.GetInfo
DELETE/role/:roleIdssystem:role:removeOP(role,Delete)RoleApiApp.Remove

Services

位于 internal/system/service/

Service(单例)职责
ClientServiceClientSvcAppOAuth 客户端 CRUD + 按 clientID 查找;key 唯一性校验。
ConfigServiceConfigSvcApp参数配置 CRUD、分页查询、configKey 查找、updateByKey、缓存刷新。
DeptServiceDeptSvcApp部门树 CRUD,校验父子关系 / 名称唯一性。
DictDataServiceDictDataSvcApp字典数据 CRUD,类型内 value 唯一性,缓存。
DictTypeServiceDictTypeSvcApp字典类型 CRUD,type 唯一性,缓存刷新。
LoginInfoServiceLoginInfoSvcApp登录事件异步记录(UA 解析、客户端查找、IP 定位、落库)——仅记录;list/delete 在 monitor。
MenuServiceMenuSvcApp菜单 CRUD、路由树构建、treeselect、按用户取权限;超管短路返回。
MessageServiceMessageSvcApp消息箱读取——system/notice/workflow 三类,各 100 条 / 最近 30 天;经 pkg/push 推送公告。
NoticeServiceNoticeSvcApp公告 CRUD,按类型标签生成推送文案;创建者未知时 create-by 哨兵值 -1。
OperLogServiceOperLogSvcApp操作日志异步持久化oplog.Recorder 实现,由 main 注册进 pkg/oplog)。
PermissionServicePermissionSvcApp角色-权限 / 菜单-权限解析;超管拿固定角色 key / *:*:*
PostServicePostSvcApp岗位 CRUD,名称 / 编码唯一性校验,且在岗用户存在时禁止停用。
RoleServiceRoleSvcApp角色 CRUD、授权用户列表、部门树选择、权限编辑、状态切换、授权 / 取消授权。
SocialServiceSocialSvcApp社交绑定 CRUD,每 authId 加 10s 互斥锁串行化 bind/unbind 竞态。
UserServiceUserSvcApp用户 CRUD、导入导出、重置密码、authRole 授权、解锁、部门树;bcrypt + 雪花 ID。

设计要点

中间件顺序 顺序刻意为之:鉴权先于 repeat-submit;oplog 先于 repeat-submit;resetPwd / updatePwd 上 encrypt 先于

oplog + repeat-submit,使指纹落在解密后的明文上。

权限与角色语义:多个中间件串联 = AND;单个 CheckPermission 内多值 = OR。菜单 list / get / add / edit / remove 额外要求 CheckRole(SuperAdminRoleKey)

公开但需登录的端点(CheckLogin、无权限码):profile 读取 / 更新、importTemplate、configKey、dict/data/type、dict/type/optionselect、social/list、menu/getRouters。

静态段优先注册。集合根路径写作 "" 而非 "/"。部门仅支持单删。导出走 POST。refreshCache 复用 remove 权限码。

相关文档

基于 MIT 协议开源