完善保险前后端、养殖端小程序
This commit is contained in:
222
insurance_backend/routes/dashboard.js
Normal file
222
insurance_backend/routes/dashboard.js
Normal file
@@ -0,0 +1,222 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const dashboardController = require('../controllers/dashboardController');
|
||||
const { jwtAuth, checkPermission } = require('../middleware/auth');
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Dashboard
|
||||
* description: 仪表板相关接口
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/dashboard/stats:
|
||||
* get:
|
||||
* summary: 获取仪表板统计数据
|
||||
* tags: [Dashboard]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 成功获取统计数据
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* data:
|
||||
* type: object
|
||||
* properties:
|
||||
* totalApplications:
|
||||
* type: integer
|
||||
* description: 总申请数
|
||||
* todayApplications:
|
||||
* type: integer
|
||||
* description: 今日申请数
|
||||
* monthApplications:
|
||||
* type: integer
|
||||
* description: 本月申请数
|
||||
* applicationGrowthRate:
|
||||
* type: number
|
||||
* description: 申请增长率
|
||||
* totalPolicies:
|
||||
* type: integer
|
||||
* description: 总保单数
|
||||
* activePolicies:
|
||||
* type: integer
|
||||
* description: 有效保单数
|
||||
* policyGrowthRate:
|
||||
* type: number
|
||||
* description: 保单增长率
|
||||
* totalClaims:
|
||||
* type: integer
|
||||
* description: 总理赔数
|
||||
* pendingClaims:
|
||||
* type: integer
|
||||
* description: 待处理理赔数
|
||||
* claimProcessingRate:
|
||||
* type: string
|
||||
* description: 理赔处理率
|
||||
* totalUsers:
|
||||
* type: integer
|
||||
* description: 总用户数
|
||||
* quickStats:
|
||||
* type: object
|
||||
* properties:
|
||||
* newApplicationsToday:
|
||||
* type: integer
|
||||
* pendingReviews:
|
||||
* type: integer
|
||||
* activeUsers:
|
||||
* type: integer
|
||||
* systemAlerts:
|
||||
* type: integer
|
||||
* message:
|
||||
* type: string
|
||||
* example: 获取仪表板统计数据成功
|
||||
* timestamp:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* 401:
|
||||
* description: 未授权
|
||||
* 500:
|
||||
* description: 服务器内部错误
|
||||
*/
|
||||
router.get('/stats', jwtAuth, checkPermission('dashboard', 'read'), dashboardController.getStats);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/dashboard/recent-activities:
|
||||
* get:
|
||||
* summary: 获取最近活动
|
||||
* tags: [Dashboard]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: limit
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 20
|
||||
* description: 返回记录数量限制
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 成功获取最近活动
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* data:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* type:
|
||||
* type: string
|
||||
* description: 活动类型
|
||||
* title:
|
||||
* type: string
|
||||
* description: 活动标题
|
||||
* description:
|
||||
* type: string
|
||||
* description: 活动描述
|
||||
* timestamp:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* user:
|
||||
* type: string
|
||||
* description: 操作用户
|
||||
* level:
|
||||
* type: string
|
||||
* description: 日志级别
|
||||
* message:
|
||||
* type: string
|
||||
* example: 获取最近活动成功
|
||||
* timestamp:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* 401:
|
||||
* description: 未授权
|
||||
* 500:
|
||||
* description: 服务器内部错误
|
||||
*/
|
||||
router.get('/recent-activities', jwtAuth, checkPermission('dashboard', 'read'), dashboardController.getRecentActivities);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/dashboard/chart-data:
|
||||
* get:
|
||||
* summary: 获取图表数据
|
||||
* tags: [Dashboard]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: type
|
||||
* schema:
|
||||
* type: string
|
||||
* enum: [applications, policies, claims]
|
||||
* default: applications
|
||||
* description: 图表数据类型
|
||||
* - in: query
|
||||
* name: period
|
||||
* schema:
|
||||
* type: string
|
||||
* enum: [7d, 30d, 90d]
|
||||
* default: 7d
|
||||
* description: 时间周期
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 成功获取图表数据
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* data:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* date:
|
||||
* type: string
|
||||
* format: date
|
||||
* value:
|
||||
* type: integer
|
||||
* message:
|
||||
* type: string
|
||||
* example: 获取图表数据成功
|
||||
* timestamp:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* 401:
|
||||
* description: 未授权
|
||||
* 500:
|
||||
* description: 服务器内部错误
|
||||
*/
|
||||
router.get('/chart-data', jwtAuth, checkPermission('dashboard', 'read'), dashboardController.getChartData);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,6 +1,7 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const installationTaskController = require('../controllers/installationTaskController');
|
||||
const { jwtAuth, requirePermission } = require('../middleware/auth');
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -59,7 +60,7 @@ const installationTaskController = require('../controllers/installationTaskContr
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
*/
|
||||
router.get('/', installationTaskController.getInstallationTasks);
|
||||
router.get('/', jwtAuth, requirePermission('installation_tasks:read'), installationTaskController.getInstallationTasks);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -115,13 +116,13 @@ router.get('/', installationTaskController.getInstallationTasks);
|
||||
* 201:
|
||||
* description: 创建成功
|
||||
*/
|
||||
router.post('/', installationTaskController.createInstallationTask);
|
||||
router.post('/', jwtAuth, requirePermission('installation_tasks:create'), installationTaskController.createInstallationTask);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/installation-tasks/{id}:
|
||||
* get:
|
||||
* summary: 获取待安装任务详情
|
||||
* summary: 根据ID获取待安装任务详情
|
||||
* tags: [InstallationTasks]
|
||||
* parameters:
|
||||
* - in: path
|
||||
@@ -133,8 +134,10 @@ router.post('/', installationTaskController.createInstallationTask);
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
* 404:
|
||||
* description: 任务不存在
|
||||
*/
|
||||
router.get('/:id', installationTaskController.getInstallationTaskById);
|
||||
router.get('/:id', jwtAuth, requirePermission('installation_tasks:read'), installationTaskController.getInstallationTaskById);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -142,12 +145,14 @@ router.get('/:id', installationTaskController.getInstallationTaskById);
|
||||
* put:
|
||||
* summary: 更新待安装任务
|
||||
* tags: [InstallationTasks]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* type: string
|
||||
* description: 任务ID
|
||||
* requestBody:
|
||||
* required: true
|
||||
@@ -162,16 +167,13 @@ router.get('/:id', installationTaskController.getInstallationTaskById);
|
||||
* priority:
|
||||
* type: string
|
||||
* enum: [低, 中, 高, 紧急]
|
||||
* assignedTo:
|
||||
* type: integer
|
||||
* installationCompletedAt:
|
||||
* notes:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 更新成功
|
||||
*/
|
||||
router.put('/:id', installationTaskController.updateInstallationTask);
|
||||
router.put('/:id', jwtAuth, requirePermission('installation_tasks:update'), installationTaskController.updateInstallationTask);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -189,8 +191,10 @@ router.put('/:id', installationTaskController.updateInstallationTask);
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 删除成功
|
||||
* 404:
|
||||
* description: 任务不存在
|
||||
*/
|
||||
router.delete('/:id', installationTaskController.deleteInstallationTask);
|
||||
router.delete('/:id', jwtAuth, requirePermission('installation_tasks:delete'), installationTaskController.deleteInstallationTask);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -224,7 +228,7 @@ router.delete('/:id', installationTaskController.deleteInstallationTask);
|
||||
* 200:
|
||||
* description: 操作成功
|
||||
*/
|
||||
router.post('/batch/operate', installationTaskController.batchOperateInstallationTasks);
|
||||
router.post('/batch/operate', jwtAuth, requirePermission('installation_tasks:update'), installationTaskController.batchOperateInstallationTasks);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -232,6 +236,8 @@ router.post('/batch/operate', installationTaskController.batchOperateInstallatio
|
||||
* get:
|
||||
* summary: 导出待安装任务数据
|
||||
* tags: [InstallationTasks]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: ids
|
||||
@@ -242,7 +248,7 @@ router.post('/batch/operate', installationTaskController.batchOperateInstallatio
|
||||
* 200:
|
||||
* description: 导出成功
|
||||
*/
|
||||
router.get('/export', installationTaskController.exportInstallationTasks);
|
||||
router.get('/export', jwtAuth, requirePermission('installation_tasks:read'), installationTaskController.exportInstallationTasks);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -250,10 +256,12 @@ router.get('/export', installationTaskController.exportInstallationTasks);
|
||||
* get:
|
||||
* summary: 获取安装任务统计数据
|
||||
* tags: [InstallationTasks]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
*/
|
||||
router.get('/stats', installationTaskController.getInstallationTaskStats);
|
||||
router.get('/stats', jwtAuth, requirePermission('installation_tasks:read'), installationTaskController.getInstallationTaskStats);
|
||||
|
||||
module.exports = router;
|
||||
@@ -10,37 +10,7 @@ const { jwtAuth } = require('../middleware/auth');
|
||||
* description: 菜单管理相关接口
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/menus/public:
|
||||
* get:
|
||||
* summary: 获取公开菜单列表(无需认证)
|
||||
* tags: [Menus]
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 成功获取菜单列表
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* data:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/Menu'
|
||||
* message:
|
||||
* type: string
|
||||
* example: 获取菜单成功
|
||||
* 500:
|
||||
* description: 服务器内部错误
|
||||
*/
|
||||
router.get('/public', menuController.getMenus);
|
||||
// 移除了公共API路径,所有菜单API都需要认证
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
|
||||
542
insurance_backend/routes/permissions.js
Normal file
542
insurance_backend/routes/permissions.js
Normal file
@@ -0,0 +1,542 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const permissionController = require('../controllers/permissionController');
|
||||
const { jwtAuth } = require('../middleware/auth');
|
||||
|
||||
// 所有权限管理路由都需要认证
|
||||
router.use(jwtAuth);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* components:
|
||||
* schemas:
|
||||
* Permission:
|
||||
* type: object
|
||||
* required:
|
||||
* - name
|
||||
* - code
|
||||
* - module
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* description: 权限ID
|
||||
* name:
|
||||
* type: string
|
||||
* description: 权限名称
|
||||
* code:
|
||||
* type: string
|
||||
* description: 权限代码
|
||||
* description:
|
||||
* type: string
|
||||
* description: 权限描述
|
||||
* module:
|
||||
* type: string
|
||||
* description: 所属模块
|
||||
* type:
|
||||
* type: string
|
||||
* enum: [menu, operation]
|
||||
* description: 权限类型
|
||||
* parent_id:
|
||||
* type: integer
|
||||
* description: 父权限ID
|
||||
* status:
|
||||
* type: string
|
||||
* enum: [active, inactive]
|
||||
* description: 状态
|
||||
* sort_order:
|
||||
* type: integer
|
||||
* description: 排序
|
||||
* created_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* description: 创建时间
|
||||
* updated_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* description: 更新时间
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/permissions:
|
||||
* get:
|
||||
* summary: 获取权限列表
|
||||
* tags: [权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: page
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 1
|
||||
* description: 页码
|
||||
* - in: query
|
||||
* name: limit
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 10
|
||||
* description: 每页数量
|
||||
* - in: query
|
||||
* name: module
|
||||
* schema:
|
||||
* type: string
|
||||
* description: 模块筛选
|
||||
* - in: query
|
||||
* name: type
|
||||
* schema:
|
||||
* type: string
|
||||
* enum: [menu, operation]
|
||||
* description: 类型筛选
|
||||
* - in: query
|
||||
* name: status
|
||||
* schema:
|
||||
* type: string
|
||||
* enum: [active, inactive]
|
||||
* default: active
|
||||
* description: 状态筛选
|
||||
* - in: query
|
||||
* name: keyword
|
||||
* schema:
|
||||
* type: string
|
||||
* description: 关键词搜索
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* message:
|
||||
* type: string
|
||||
* example: 获取权限列表成功
|
||||
* data:
|
||||
* type: object
|
||||
* properties:
|
||||
* permissions:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/Permission'
|
||||
* pagination:
|
||||
* type: object
|
||||
* properties:
|
||||
* total:
|
||||
* type: integer
|
||||
* page:
|
||||
* type: integer
|
||||
* limit:
|
||||
* type: integer
|
||||
* pages:
|
||||
* type: integer
|
||||
*/
|
||||
router.get('/', permissionController.getPermissions);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/permissions/tree:
|
||||
* get:
|
||||
* summary: 获取权限树形结构
|
||||
* tags: [权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: module
|
||||
* schema:
|
||||
* type: string
|
||||
* description: 模块筛选
|
||||
* - in: query
|
||||
* name: type
|
||||
* schema:
|
||||
* type: string
|
||||
* enum: [menu, operation]
|
||||
* description: 类型筛选
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* message:
|
||||
* type: string
|
||||
* example: 获取权限树成功
|
||||
* data:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/Permission'
|
||||
*/
|
||||
router.get('/tree', permissionController.getPermissionTree);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/permissions/modules:
|
||||
* get:
|
||||
* summary: 获取模块列表
|
||||
* tags: [权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* message:
|
||||
* type: string
|
||||
* example: 获取模块列表成功
|
||||
* data:
|
||||
* type: array
|
||||
* items:
|
||||
* type: string
|
||||
*/
|
||||
router.get('/modules', permissionController.getModules);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/permissions/{id}:
|
||||
* get:
|
||||
* summary: 获取权限详情
|
||||
* tags: [权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 权限ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* message:
|
||||
* type: string
|
||||
* example: 获取权限详情成功
|
||||
* data:
|
||||
* $ref: '#/components/schemas/Permission'
|
||||
* 404:
|
||||
* description: 权限不存在
|
||||
*/
|
||||
router.get('/:id', permissionController.getPermissionById);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/permissions:
|
||||
* post:
|
||||
* summary: 创建权限
|
||||
* tags: [权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - name
|
||||
* - code
|
||||
* - module
|
||||
* properties:
|
||||
* name:
|
||||
* type: string
|
||||
* description: 权限名称
|
||||
* code:
|
||||
* type: string
|
||||
* description: 权限代码
|
||||
* description:
|
||||
* type: string
|
||||
* description: 权限描述
|
||||
* module:
|
||||
* type: string
|
||||
* description: 所属模块
|
||||
* type:
|
||||
* type: string
|
||||
* enum: [menu, operation]
|
||||
* default: operation
|
||||
* description: 权限类型
|
||||
* parent_id:
|
||||
* type: integer
|
||||
* description: 父权限ID
|
||||
* sort_order:
|
||||
* type: integer
|
||||
* default: 0
|
||||
* description: 排序
|
||||
* responses:
|
||||
* 201:
|
||||
* description: 创建成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* message:
|
||||
* type: string
|
||||
* example: 创建权限成功
|
||||
* data:
|
||||
* $ref: '#/components/schemas/Permission'
|
||||
* 400:
|
||||
* description: 请求参数错误
|
||||
*/
|
||||
router.post('/', permissionController.createPermission);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/permissions/{id}:
|
||||
* put:
|
||||
* summary: 更新权限
|
||||
* tags: [权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 权限ID
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* name:
|
||||
* type: string
|
||||
* description: 权限名称
|
||||
* code:
|
||||
* type: string
|
||||
* description: 权限代码
|
||||
* description:
|
||||
* type: string
|
||||
* description: 权限描述
|
||||
* module:
|
||||
* type: string
|
||||
* description: 所属模块
|
||||
* type:
|
||||
* type: string
|
||||
* enum: [menu, operation]
|
||||
* description: 权限类型
|
||||
* parent_id:
|
||||
* type: integer
|
||||
* description: 父权限ID
|
||||
* sort_order:
|
||||
* type: integer
|
||||
* description: 排序
|
||||
* status:
|
||||
* type: string
|
||||
* enum: [active, inactive]
|
||||
* description: 状态
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 更新成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* message:
|
||||
* type: string
|
||||
* example: 更新权限成功
|
||||
* data:
|
||||
* $ref: '#/components/schemas/Permission'
|
||||
* 404:
|
||||
* description: 权限不存在
|
||||
*/
|
||||
router.put('/:id', permissionController.updatePermission);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/permissions/{id}:
|
||||
* delete:
|
||||
* summary: 删除权限
|
||||
* tags: [权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 权限ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 删除成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* message:
|
||||
* type: string
|
||||
* example: 删除权限成功
|
||||
* 404:
|
||||
* description: 权限不存在
|
||||
* 400:
|
||||
* description: 权限正在使用中,无法删除
|
||||
*/
|
||||
router.delete('/:id', permissionController.deletePermission);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/permissions/roles/{roleId}:
|
||||
* get:
|
||||
* summary: 获取角色权限
|
||||
* tags: [权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: roleId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 角色ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* message:
|
||||
* type: string
|
||||
* example: 获取角色权限成功
|
||||
* data:
|
||||
* type: object
|
||||
* properties:
|
||||
* role:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* name:
|
||||
* type: string
|
||||
* description:
|
||||
* type: string
|
||||
* permissions:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/Permission'
|
||||
* 404:
|
||||
* description: 角色不存在
|
||||
*/
|
||||
router.get('/roles/:roleId', permissionController.getRolePermissions);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/permissions/roles/{roleId}/assign:
|
||||
* post:
|
||||
* summary: 分配角色权限
|
||||
* tags: [权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: roleId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 角色ID
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - permissionIds
|
||||
* properties:
|
||||
* permissionIds:
|
||||
* type: array
|
||||
* items:
|
||||
* type: integer
|
||||
* description: 权限ID列表
|
||||
* example:
|
||||
* permissionIds: [1, 2, 3, 4]
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 分配成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* message:
|
||||
* type: string
|
||||
* example: 分配角色权限成功
|
||||
* 404:
|
||||
* description: 角色不存在
|
||||
* 400:
|
||||
* description: 请求参数错误
|
||||
*/
|
||||
router.post('/roles/:roleId/assign', permissionController.assignRolePermissions);
|
||||
|
||||
module.exports = router;
|
||||
384
insurance_backend/routes/rolePermissions.js
Normal file
384
insurance_backend/routes/rolePermissions.js
Normal file
@@ -0,0 +1,384 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const rolePermissionController = require('../controllers/rolePermissionController');
|
||||
const { jwtAuth } = require('../middleware/auth');
|
||||
|
||||
// 应用认证中间件
|
||||
router.use(jwtAuth);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* components:
|
||||
* schemas:
|
||||
* RolePermissionAssignment:
|
||||
* type: object
|
||||
* properties:
|
||||
* roleId:
|
||||
* type: integer
|
||||
* description: 角色ID
|
||||
* permissionIds:
|
||||
* type: array
|
||||
* items:
|
||||
* type: integer
|
||||
* description: 权限ID列表
|
||||
* operation:
|
||||
* type: string
|
||||
* enum: [replace, add, remove]
|
||||
* default: replace
|
||||
* description: 操作类型
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/role-permissions:
|
||||
* get:
|
||||
* summary: 获取所有角色及其权限
|
||||
* tags: [角色权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* message:
|
||||
* type: string
|
||||
* example: 获取角色权限列表成功
|
||||
* data:
|
||||
* type: object
|
||||
* properties:
|
||||
* roles:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* name:
|
||||
* type: string
|
||||
* description:
|
||||
* type: string
|
||||
* permissions:
|
||||
* type: array
|
||||
* permissionCount:
|
||||
* type: integer
|
||||
* total:
|
||||
* type: integer
|
||||
*/
|
||||
router.get('/', rolePermissionController.getAllRolesWithPermissions);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/role-permissions/permissions:
|
||||
* get:
|
||||
* summary: 获取所有权限
|
||||
* tags: [角色权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
*/
|
||||
router.get('/permissions', rolePermissionController.getAllPermissions);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/role-permissions/roles:
|
||||
* get:
|
||||
* summary: 获取所有角色及其权限
|
||||
* tags: [角色权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
*/
|
||||
router.get('/roles', rolePermissionController.getAllRolesWithPermissions);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/role-permissions/roles/{roleId}/permissions:
|
||||
* get:
|
||||
* summary: 获取指定角色的权限详情
|
||||
* tags: [角色权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: roleId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 角色ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
* 404:
|
||||
* description: 角色不存在
|
||||
*/
|
||||
router.get('/roles/:roleId/permissions', rolePermissionController.getRolePermissionDetail);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/role-permissions/stats:
|
||||
* get:
|
||||
* summary: 获取权限统计信息
|
||||
* tags: [角色权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
*/
|
||||
router.get('/stats', rolePermissionController.getPermissionStats);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/role-permissions/{roleId}:
|
||||
* get:
|
||||
* summary: 获取指定角色的权限详情
|
||||
* tags: [角色权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: roleId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 角色ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
* 404:
|
||||
* description: 角色不存在
|
||||
*/
|
||||
router.get('/:roleId', rolePermissionController.getRolePermissionDetail);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/role-permissions/{roleId}/assign:
|
||||
* post:
|
||||
* summary: 批量分配角色权限
|
||||
* tags: [角色权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: roleId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 角色ID
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - permissionIds
|
||||
* properties:
|
||||
* permissionIds:
|
||||
* type: array
|
||||
* items:
|
||||
* type: integer
|
||||
* description: 权限ID列表
|
||||
* operation:
|
||||
* type: string
|
||||
* enum: [replace, add, remove]
|
||||
* default: replace
|
||||
* description: 操作类型
|
||||
* examples:
|
||||
* replace:
|
||||
* summary: 替换权限
|
||||
* value:
|
||||
* permissionIds: [1, 2, 3, 4]
|
||||
* operation: "replace"
|
||||
* add:
|
||||
* summary: 添加权限
|
||||
* value:
|
||||
* permissionIds: [5, 6]
|
||||
* operation: "add"
|
||||
* remove:
|
||||
* summary: 移除权限
|
||||
* value:
|
||||
* permissionIds: [1, 2]
|
||||
* operation: "remove"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 分配成功
|
||||
* 400:
|
||||
* description: 请求参数错误
|
||||
* 404:
|
||||
* description: 角色不存在
|
||||
*/
|
||||
router.post('/:roleId/assign', rolePermissionController.batchAssignPermissions);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/role-permissions/copy:
|
||||
* post:
|
||||
* summary: 复制角色权限
|
||||
* tags: [角色权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - sourceRoleId
|
||||
* - targetRoleId
|
||||
* properties:
|
||||
* sourceRoleId:
|
||||
* type: integer
|
||||
* description: 源角色ID
|
||||
* targetRoleId:
|
||||
* type: integer
|
||||
* description: 目标角色ID
|
||||
* example:
|
||||
* sourceRoleId: 1
|
||||
* targetRoleId: 2
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 复制成功
|
||||
* 400:
|
||||
* description: 请求参数错误
|
||||
* 404:
|
||||
* description: 角色不存在
|
||||
*/
|
||||
router.post('/copy', rolePermissionController.copyRolePermissions);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/role-permissions/check/{userId}/{permissionCode}:
|
||||
* get:
|
||||
* summary: 检查用户权限
|
||||
* tags: [角色权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: userId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 用户ID
|
||||
* - in: path
|
||||
* name: permissionCode
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: 权限代码
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 检查完成
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* message:
|
||||
* type: string
|
||||
* example: 权限检查完成
|
||||
* data:
|
||||
* type: object
|
||||
* properties:
|
||||
* userId:
|
||||
* type: integer
|
||||
* username:
|
||||
* type: string
|
||||
* roleName:
|
||||
* type: string
|
||||
* permissionCode:
|
||||
* type: string
|
||||
* hasPermission:
|
||||
* type: boolean
|
||||
* checkTime:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* 404:
|
||||
* description: 用户不存在
|
||||
*/
|
||||
router.get('/check/:userId/:permissionCode', rolePermissionController.checkUserPermission);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/role-permissions/stats:
|
||||
* get:
|
||||
* summary: 获取权限统计信息
|
||||
* tags: [角色权限管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* message:
|
||||
* type: string
|
||||
* example: 获取权限统计成功
|
||||
* data:
|
||||
* type: object
|
||||
* properties:
|
||||
* overview:
|
||||
* type: object
|
||||
* properties:
|
||||
* totalRoles:
|
||||
* type: integer
|
||||
* totalPermissions:
|
||||
* type: integer
|
||||
* totalAssignments:
|
||||
* type: integer
|
||||
* averagePermissionsPerRole:
|
||||
* type: integer
|
||||
* moduleDistribution:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* module:
|
||||
* type: string
|
||||
* count:
|
||||
* type: integer
|
||||
* roleDistribution:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* roleId:
|
||||
* type: integer
|
||||
* roleName:
|
||||
* type: string
|
||||
* permissionCount:
|
||||
* type: integer
|
||||
*/
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,7 +1,7 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const SupervisoryTaskController = require('../controllers/supervisoryTaskController');
|
||||
const auth = require('../middleware/auth');
|
||||
const { jwtAuth, requirePermission } = require('../middleware/auth');
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -62,7 +62,7 @@ const auth = require('../middleware/auth');
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
*/
|
||||
router.get('/', SupervisoryTaskController.getList);
|
||||
router.get('/', jwtAuth, requirePermission('supervision_tasks:read'), SupervisoryTaskController.getList);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -131,7 +131,7 @@ router.get('/', SupervisoryTaskController.getList);
|
||||
* 201:
|
||||
* description: 创建成功
|
||||
*/
|
||||
router.post('/', SupervisoryTaskController.create);
|
||||
router.post('/', jwtAuth, requirePermission('supervision_tasks:create'), SupervisoryTaskController.create);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -152,7 +152,7 @@ router.post('/', SupervisoryTaskController.create);
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
*/
|
||||
router.get('/:id', SupervisoryTaskController.getById);
|
||||
router.get('/:id', jwtAuth, requirePermission('supervision_tasks:read'), SupervisoryTaskController.getById);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -167,8 +167,8 @@ router.get('/:id', SupervisoryTaskController.getById);
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 监管任务ID
|
||||
* type: string
|
||||
* description: 任务ID
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
@@ -179,18 +179,22 @@ router.get('/:id', SupervisoryTaskController.getById);
|
||||
* status:
|
||||
* type: string
|
||||
* enum: [pending, processing, completed, rejected]
|
||||
* description: 状态
|
||||
* assignedTo:
|
||||
* type: integer
|
||||
* type: string
|
||||
* description: 分配给
|
||||
* priority:
|
||||
* type: string
|
||||
* enum: [low, medium, high, urgent]
|
||||
* remarks:
|
||||
* description: 优先级
|
||||
* notes:
|
||||
* type: string
|
||||
* description: 备注
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 更新成功
|
||||
*/
|
||||
router.put('/:id', SupervisoryTaskController.update);
|
||||
router.put('/:id', jwtAuth, requirePermission('supervision_tasks:update'), SupervisoryTaskController.update);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -205,13 +209,13 @@ router.put('/:id', SupervisoryTaskController.update);
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 监管任务ID
|
||||
* type: string
|
||||
* description: 任务ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 删除成功
|
||||
*/
|
||||
router.delete('/:id', SupervisoryTaskController.delete);
|
||||
router.delete('/:id', jwtAuth, requirePermission('supervision_tasks:delete'), SupervisoryTaskController.delete);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -247,13 +251,13 @@ router.delete('/:id', SupervisoryTaskController.delete);
|
||||
* 200:
|
||||
* description: 操作成功
|
||||
*/
|
||||
router.post('/batch/operate', SupervisoryTaskController.bulkCreate);
|
||||
router.post('/batch/operate', jwtAuth, requirePermission('supervision_tasks:create'), SupervisoryTaskController.bulkCreate);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/supervision-tasks/stats:
|
||||
* get:
|
||||
* summary: 获取监管任务统计数据
|
||||
* summary: 获取监管任务统计信息
|
||||
* tags: [SupervisionTasks]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
@@ -261,6 +265,6 @@ router.post('/batch/operate', SupervisoryTaskController.bulkCreate);
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
*/
|
||||
router.get('/stats', SupervisoryTaskController.getStatistics);
|
||||
router.get('/stats', jwtAuth, requirePermission('supervision_tasks:read'), SupervisoryTaskController.getStatistics);
|
||||
|
||||
module.exports = router;
|
||||
@@ -34,4 +34,172 @@ router.put('/change-password', jwtAuth, userController.changePassword);
|
||||
// 上传头像(不需要特殊权限,用户可以上传自己的头像)
|
||||
router.post('/avatar', jwtAuth, userController.uploadAvatar);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /users/{id}/fixed-token:
|
||||
* get:
|
||||
* summary: 获取用户固定令牌信息
|
||||
* description: 获取指定用户的固定令牌信息,包括是否已生成令牌、令牌预览等
|
||||
* tags: [用户管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* - fixedTokenAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 用户ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 获取成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* data:
|
||||
* $ref: '#/components/schemas/FixedTokenInfo'
|
||||
* 401:
|
||||
* $ref: '#/components/responses/UnauthorizedError'
|
||||
* 403:
|
||||
* $ref: '#/components/responses/ForbiddenError'
|
||||
* 404:
|
||||
* $ref: '#/components/responses/NotFoundError'
|
||||
* post:
|
||||
* summary: 生成用户固定令牌
|
||||
* description: 为指定用户生成新的固定令牌,用于API访问验证
|
||||
* tags: [用户管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* - fixedTokenAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 用户ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 生成成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* data:
|
||||
* $ref: '#/components/schemas/FixedTokenGenerated'
|
||||
* 400:
|
||||
* description: 用户已有固定令牌
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 401:
|
||||
* $ref: '#/components/responses/UnauthorizedError'
|
||||
* 403:
|
||||
* $ref: '#/components/responses/ForbiddenError'
|
||||
* 404:
|
||||
* $ref: '#/components/responses/NotFoundError'
|
||||
* put:
|
||||
* summary: 重新生成用户固定令牌
|
||||
* description: 重新生成指定用户的固定令牌,原令牌将失效
|
||||
* tags: [用户管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* - fixedTokenAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 用户ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 重新生成成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* data:
|
||||
* $ref: '#/components/schemas/FixedTokenGenerated'
|
||||
* 401:
|
||||
* $ref: '#/components/responses/UnauthorizedError'
|
||||
* 403:
|
||||
* $ref: '#/components/responses/ForbiddenError'
|
||||
* 404:
|
||||
* $ref: '#/components/responses/NotFoundError'
|
||||
* delete:
|
||||
* summary: 删除用户固定令牌
|
||||
* description: 删除指定用户的固定令牌,令牌将立即失效
|
||||
* tags: [用户管理]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* - fixedTokenAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: 用户ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 删除成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* message:
|
||||
* type: string
|
||||
* example: 固定令牌删除成功
|
||||
* 401:
|
||||
* $ref: '#/components/responses/UnauthorizedError'
|
||||
* 403:
|
||||
* $ref: '#/components/responses/ForbiddenError'
|
||||
* 404:
|
||||
* $ref: '#/components/responses/NotFoundError'
|
||||
*/
|
||||
// 固定Token管理路由(需要管理员权限)
|
||||
// 获取用户固定Token信息
|
||||
router.get('/:id/fixed-token', jwtAuth, checkPermission('user', 'read'), userController.getFixedTokenInfo);
|
||||
|
||||
// 生成用户固定Token
|
||||
router.post('/:id/fixed-token', jwtAuth, checkPermission('user', 'update'), userController.generateFixedToken);
|
||||
|
||||
// 重新生成用户固定Token
|
||||
router.put('/:id/fixed-token', jwtAuth, checkPermission('user', 'update'), userController.regenerateFixedToken);
|
||||
|
||||
// 删除用户固定Token
|
||||
router.delete('/:id/fixed-token', jwtAuth, checkPermission('user', 'delete'), userController.deleteFixedToken);
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user