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/getInfo | CheckLogin | — | UserApiApp.GetInfo |
| GET | /user/profile | CheckLogin | — | ProfileApiApp.Profile |
| PUT | /user/profile | CheckLogin | OP(profile,Update) RS | ProfileApiApp.UpdateProfile |
| PUT | /user/profile/updatePwd | CheckLogin | ENC, OP(profile,Update) RS | ProfileApiApp.UpdatePwd |
| GET | /user/list | system:user:list | — | UserApiApp.List |
| GET | /user/list/dept/:deptId | system:user:list | — | UserApiApp.ListByDept |
| GET | /user/deptTree | system:user:list | — | UserApiApp.DeptTree |
| GET | /user/optionselect | system:user:query | — | UserApiApp.OptionSelect |
| GET | /user/authRole/:userId | system:user:query | — | UserApiApp.AuthRole |
| GET | /user/unlock/:userId | system:user:edit | OP(user,Other) RS | UserApiApp.Unlock |
| POST | /user/export | system:user:export | OP(user,Export) | UserApiApp.Export |
| POST | /user/importData | system:user:import | OP(user,Import) | UserApiApp.ImportData |
| POST | /user/importTemplate | CheckLogin | — | UserApiApp.ImportTemplate |
| POST | /user | system:user:add | OP(user,Insert) RS | UserApiApp.Add |
| PUT | /user | system:user:edit | OP(user,Update) RS | UserApiApp.Edit |
| PUT | /user/resetPwd | system:user:resetPwd | ENC, OP(user,Update) RS | UserApiApp.ResetPwd |
| PUT | /user/changeStatus | system:user:edit | OP(user,Update) RS | UserApiApp.ChangeStatus |
| PUT | /user/authRole | system:user:edit | OP(user,Grant) RS | UserApiApp.InsertAuthRole |
| GET | /user | system:user:query | — | UserApiApp.GetInfoByID |
| GET | /user/:userId | system:user:query | — | UserApiApp.GetInfoByID |
| DELETE | /user/:userIds | system:user:remove | OP(user,Delete) | UserApiApp.Remove |
menu(前缀 /menu)
| 方法 | 路径 | 鉴权 | 中间件 | Handler |
|---|---|---|---|---|
| GET | /menu/getRouters | CheckLogin | — | MenuApiApp.GetRouters |
| GET | /menu/list | CheckRole(superAdmin) AND system:menu:list | — | MenuApiApp.List |
| GET | /menu/treeselect | system:menu:query | — | MenuApiApp.TreeSelect |
| GET | /menu/roleMenuTreeselect/:roleId | system:menu:query | — | MenuApiApp.RoleMenuTreeSelect |
| GET | /menu/:menuId | CheckRole(superAdmin) AND system:menu:query | — | MenuApiApp.GetInfo |
| POST | /menu | CheckRole(superAdmin) AND system:menu:add | OP(menu,Insert) RS | MenuApiApp.Add |
| PUT | /menu | CheckRole(superAdmin) AND system:menu:edit | OP(menu,Update) RS | MenuApiApp.Edit |
| DELETE | /menu/cascade/:menuIds | CheckRole(superAdmin) AND system:menu:remove | OP(menu,Delete) | MenuApiApp.CascadeRemove |
| DELETE | /menu/:menuId | CheckRole(superAdmin) AND system:menu:remove | OP(menu,Delete) | MenuApiApp.Remove |
client(前缀 /client)
| 方法 | 路径 | 鉴权 | 中间件 | Handler |
|---|---|---|---|---|
| GET | /client/list | system:client:list | — | ClientApiApp.List |
| GET | /client/:id | system:client:query | — | ClientApiApp.GetInfo |
| POST | /client/export | system:client:export | OP(client,Export) | ClientApiApp.Export |
| POST | /client | system:client:add | OP(client,Insert) RS | ClientApiApp.Add |
| PUT | /client | system:client:edit | OP(client,Update) RS | ClientApiApp.Edit |
| PUT | /client/changeStatus | system:client:edit | OP(client,Update)(无 RS——幂等) | ClientApiApp.ChangeStatus |
| DELETE | /client/:ids | system:client:remove | OP(client,Delete) | ClientApiApp.Remove |
config(前缀 /config)
| 方法 | 路径 | 鉴权 | 中间件 | Handler |
|---|---|---|---|---|
| GET | /config/list | system:config:list | — | ConfigApiApp.List |
| GET | /config/configKey/:configKey | CheckLogin | — | ConfigApiApp.GetConfigKey |
| GET | /config/:configId | system:config:query | — | ConfigApiApp.GetInfo |
| POST | /config/export | system:config:export | OP(config,Export) | ConfigApiApp.Export |
| POST | /config | system:config:add | OP(config,Insert) RS | ConfigApiApp.Add |
| PUT | /config | system:config:edit | OP(config,Update) RS | ConfigApiApp.Edit |
| PUT | /config/updateByKey | system:config:edit | OP(config,Update) RS | ConfigApiApp.UpdateByKey |
| DELETE | /config/refreshCache | system:config:remove | OP(config,Clean) | ConfigApiApp.RefreshCache |
| DELETE | /config/:configIds | system:config:remove | OP(config,Delete) | ConfigApiApp.Remove |
dept(前缀 /dept)
| 方法 | 路径 | 鉴权 | 中间件 | Handler |
|---|---|---|---|---|
| GET | /dept/list | system:dept:list | — | DeptApiApp.List |
| GET | /dept/list/exclude/:deptId | system:dept:list | — | DeptApiApp.ExcludeChild |
| GET | /dept/optionselect | system:dept:query | — | DeptApiApp.OptionSelect |
| GET | /dept/:deptId | system:dept:query | — | DeptApiApp.GetInfo |
| POST | /dept | system:dept:add | OP(dept,Insert) RS | DeptApiApp.Add |
| PUT | /dept | system:dept:edit | OP(dept,Update) RS | DeptApiApp.Edit |
| DELETE | /dept/:deptId | system:dept:remove | OP(dept,Delete) | DeptApiApp.Remove(仅单删——保树完整性) |
dict data(前缀 /dict/data)
| 方法 | 路径 | 鉴权 | 中间件 | Handler |
|---|---|---|---|---|
| GET | /dict/data/list | system:dict:list | — | DictDataApiApp.List |
| GET | /dict/data/type/:dictType | CheckLogin | — | DictDataApiApp.DictType |
| GET | /dict/data/:dictCode | system:dict:query | — | DictDataApiApp.GetInfo |
| POST | /dict/data/export | system:dict:export | OP(dictData,Export) | DictDataApiApp.Export |
| POST | /dict/data | system:dict:add | OP(dictData,Insert) RS | DictDataApiApp.Add |
| PUT | /dict/data | system:dict:edit | OP(dictData,Update) RS | DictDataApiApp.Edit |
| DELETE | /dict/data/:dictCodes | system:dict:remove | OP(dictData,Delete) | DictDataApiApp.Remove |
dict type(前缀 /dict/type)
| 方法 | 路径 | 鉴权 | 中间件 | Handler |
|---|---|---|---|---|
| GET | /dict/type/list | system:dict:list | — | DictTypeApiApp.List |
| GET | /dict/type/optionselect | CheckLogin | — | DictTypeApiApp.OptionSelect |
| GET | /dict/type/:dictId | system:dict:query | — | DictTypeApiApp.GetInfo |
| POST | /dict/type/export | system:dict:export | OP(dictType,Export) | DictTypeApiApp.Export |
| POST | /dict/type | system:dict:add | OP(dictType,Insert) RS | DictTypeApiApp.Add |
| PUT | /dict/type | system:dict:edit | OP(dictType,Update) RS | DictTypeApiApp.Edit |
| DELETE | /dict/type/refreshCache | system:dict:remove | OP(dictType,Clean) | DictTypeApiApp.RefreshCache |
| DELETE | /dict/type/:dictIds | system:dict:remove | OP(dictType,Delete) | DictTypeApiApp.Remove |
notice(前缀 /notice)
| 方法 | 路径 | 鉴权 | 中间件 | Handler |
|---|---|---|---|---|
| GET | /notice/list | system:notice:list | — | NoticeApiApp.List |
| GET | /notice/:noticeId | system:notice:query | — | NoticeApiApp.GetInfo |
| POST | /notice | system:notice:add | OP(notice,Insert) RS | NoticeApiApp.Add |
| PUT | /notice | system:notice:edit | OP(notice,Update) RS | NoticeApiApp.Edit |
| DELETE | /notice/:noticeIds | system:notice:remove | OP(notice,Delete) | NoticeApiApp.Remove |
post(前缀 /post)
| 方法 | 路径 | 鉴权 | 中间件 | Handler |
|---|---|---|---|---|
| GET | /post/list | system:post:list | — | PostApiApp.List |
| GET | /post/optionselect | system:post:query | — | PostApiApp.OptionSelect |
| GET | /post/deptTree | system:post:list | — | PostApiApp.DeptTree |
| GET | /post/:postId | system:post:query | — | PostApiApp.GetInfo |
| POST | /post/export | system:post:export | OP(post,Export) | PostApiApp.Export |
| POST | /post | system:post:add | OP(post,Insert) RS | PostApiApp.Add |
| PUT | /post | system:post:edit | OP(post,Update) RS | PostApiApp.Edit |
| DELETE | /post/:postIds | system:post:remove | OP(post,Delete) | PostApiApp.Remove |
social(前缀 /social)
| 方法 | 路径 | 鉴权 | 中间件 | Handler |
|---|---|---|---|---|
| GET | /social/list | CheckLogin | — | SocialApiApp.List |
role(前缀 /role)
| 方法 | 路径 | 鉴权 | 中间件 | Handler |
|---|---|---|---|---|
| GET | /role/list | system:role:list | — | RoleApiApp.List |
| GET | /role/optionselect | system:role:query | — | RoleApiApp.OptionSelect |
| GET | /role/authUser/allocatedList | system:role:list | — | RoleApiApp.AllocatedList |
| GET | /role/authUser/unallocatedList | system:role:list | — | RoleApiApp.UnallocatedList |
| GET | /role/deptTree/:roleId | system:role:list | — | RoleApiApp.DeptTreeSelect |
| POST | /role/export | system:role:export | OP(role,Export) | RoleApiApp.Export |
| POST | /role | system:role:add | OP(role,Insert) RS | RoleApiApp.Add |
| PUT | /role | system:role:edit | OP(role,Update) RS | RoleApiApp.Edit |
| PUT | /role/permission | system:role:edit | OP(role,Update) RS | RoleApiApp.EditPermission |
| PUT | /role/changeStatus | system:role:edit | OP(role,Update) RS | RoleApiApp.ChangeStatus |
| PUT | /role/authUser/cancel | system:role:edit | OP(role,Grant) RS | RoleApiApp.CancelAuthUser |
| PUT | /role/authUser/cancelAll | system:role:edit | OP(role,Grant) RS | RoleApiApp.CancelAuthUserAll |
| PUT | /role/authUser/selectAll | system:role:edit | OP(role,Grant) RS | RoleApiApp.SelectAuthUserAll |
| GET | /role/:roleId | system:role:query | — | RoleApiApp.GetInfo |
| DELETE | /role/:roleIds | system:role:remove | OP(role,Delete) | RoleApiApp.Remove |
Services
位于 internal/system/service/:
| Service(单例) | 职责 |
|---|---|
ClientService(ClientSvcApp) | OAuth 客户端 CRUD + 按 clientID 查找;key 唯一性校验。 |
ConfigService(ConfigSvcApp) | 参数配置 CRUD、分页查询、configKey 查找、updateByKey、缓存刷新。 |
DeptService(DeptSvcApp) | 部门树 CRUD,校验父子关系 / 名称唯一性。 |
DictDataService(DictDataSvcApp) | 字典数据 CRUD,类型内 value 唯一性,缓存。 |
DictTypeService(DictTypeSvcApp) | 字典类型 CRUD,type 唯一性,缓存刷新。 |
LoginInfoService(LoginInfoSvcApp) | 登录事件异步记录(UA 解析、客户端查找、IP 定位、落库)——仅记录;list/delete 在 monitor。 |
MenuService(MenuSvcApp) | 菜单 CRUD、路由树构建、treeselect、按用户取权限;超管短路返回。 |
MessageService(MessageSvcApp) | 消息箱读取——system/notice/workflow 三类,各 100 条 / 最近 30 天;经 pkg/push 推送公告。 |
NoticeService(NoticeSvcApp) | 公告 CRUD,按类型标签生成推送文案;创建者未知时 create-by 哨兵值 -1。 |
OperLogService(OperLogSvcApp) | 操作日志异步持久化(oplog.Recorder 实现,由 main 注册进 pkg/oplog)。 |
PermissionService(PermissionSvcApp) | 角色-权限 / 菜单-权限解析;超管拿固定角色 key / *:*:*。 |
PostService(PostSvcApp) | 岗位 CRUD,名称 / 编码唯一性校验,且在岗用户存在时禁止停用。 |
RoleService(RoleSvcApp) | 角色 CRUD、授权用户列表、部门树选择、权限编辑、状态切换、授权 / 取消授权。 |
SocialService(SocialSvcApp) | 社交绑定 CRUD,每 authId 加 10s 互斥锁串行化 bind/unbind 竞态。 |
UserService(UserSvcApp) | 用户 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 权限码。