|
|
@@ -11,7 +11,7 @@ import {
|
|
|
HouseholdDistributionResponseSchema,
|
|
|
JobStatusDistributionResponseSchema,
|
|
|
SalaryDistributionResponseSchema,
|
|
|
- StatisticsQuerySchema
|
|
|
+ EnterpriseStatisticsQuerySchema
|
|
|
} from '../schemas/statistics.schema';
|
|
|
|
|
|
// 获取数据源和统计服务
|
|
|
@@ -25,7 +25,7 @@ const disabilityTypeDistributionRoute = createRoute({
|
|
|
path: '/disability-type-distribution',
|
|
|
middleware: [enterpriseAuthMiddleware],
|
|
|
request: {
|
|
|
- query: StatisticsQuerySchema
|
|
|
+ query: EnterpriseStatisticsQuerySchema
|
|
|
},
|
|
|
responses: {
|
|
|
200: {
|
|
|
@@ -39,7 +39,11 @@ const disabilityTypeDistributionRoute = createRoute({
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
401: {
|
|
|
- description: '认证失败或企业权限不足',
|
|
|
+ description: '认证失败',
|
|
|
+ content: { 'application/json': { schema: ErrorSchema } }
|
|
|
+ },
|
|
|
+ 403: {
|
|
|
+ description: '企业权限不足',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
500: {
|
|
|
@@ -55,7 +59,7 @@ const genderDistributionRoute = createRoute({
|
|
|
path: '/gender-distribution',
|
|
|
middleware: [enterpriseAuthMiddleware],
|
|
|
request: {
|
|
|
- query: StatisticsQuerySchema
|
|
|
+ query: EnterpriseStatisticsQuerySchema
|
|
|
},
|
|
|
responses: {
|
|
|
200: {
|
|
|
@@ -69,7 +73,11 @@ const genderDistributionRoute = createRoute({
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
401: {
|
|
|
- description: '认证失败或企业权限不足',
|
|
|
+ description: '认证失败',
|
|
|
+ content: { 'application/json': { schema: ErrorSchema } }
|
|
|
+ },
|
|
|
+ 403: {
|
|
|
+ description: '企业权限不足',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
500: {
|
|
|
@@ -85,7 +93,7 @@ const ageDistributionRoute = createRoute({
|
|
|
path: '/age-distribution',
|
|
|
middleware: [enterpriseAuthMiddleware],
|
|
|
request: {
|
|
|
- query: StatisticsQuerySchema
|
|
|
+ query: EnterpriseStatisticsQuerySchema
|
|
|
},
|
|
|
responses: {
|
|
|
200: {
|
|
|
@@ -99,7 +107,11 @@ const ageDistributionRoute = createRoute({
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
401: {
|
|
|
- description: '认证失败或企业权限不足',
|
|
|
+ description: '认证失败',
|
|
|
+ content: { 'application/json': { schema: ErrorSchema } }
|
|
|
+ },
|
|
|
+ 403: {
|
|
|
+ description: '企业权限不足',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
500: {
|
|
|
@@ -115,7 +127,7 @@ const householdDistributionRoute = createRoute({
|
|
|
path: '/household-distribution',
|
|
|
middleware: [enterpriseAuthMiddleware],
|
|
|
request: {
|
|
|
- query: StatisticsQuerySchema
|
|
|
+ query: EnterpriseStatisticsQuerySchema
|
|
|
},
|
|
|
responses: {
|
|
|
200: {
|
|
|
@@ -129,7 +141,11 @@ const householdDistributionRoute = createRoute({
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
401: {
|
|
|
- description: '认证失败或企业权限不足',
|
|
|
+ description: '认证失败',
|
|
|
+ content: { 'application/json': { schema: ErrorSchema } }
|
|
|
+ },
|
|
|
+ 403: {
|
|
|
+ description: '企业权限不足',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
500: {
|
|
|
@@ -145,7 +161,7 @@ const jobStatusDistributionRoute = createRoute({
|
|
|
path: '/job-status-distribution',
|
|
|
middleware: [enterpriseAuthMiddleware],
|
|
|
request: {
|
|
|
- query: StatisticsQuerySchema
|
|
|
+ query: EnterpriseStatisticsQuerySchema
|
|
|
},
|
|
|
responses: {
|
|
|
200: {
|
|
|
@@ -159,7 +175,11 @@ const jobStatusDistributionRoute = createRoute({
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
401: {
|
|
|
- description: '认证失败或企业权限不足',
|
|
|
+ description: '认证失败',
|
|
|
+ content: { 'application/json': { schema: ErrorSchema } }
|
|
|
+ },
|
|
|
+ 403: {
|
|
|
+ description: '企业权限不足',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
500: {
|
|
|
@@ -175,7 +195,7 @@ const salaryDistributionRoute = createRoute({
|
|
|
path: '/salary-distribution',
|
|
|
middleware: [enterpriseAuthMiddleware],
|
|
|
request: {
|
|
|
- query: StatisticsQuerySchema
|
|
|
+ query: EnterpriseStatisticsQuerySchema
|
|
|
},
|
|
|
responses: {
|
|
|
200: {
|
|
|
@@ -189,7 +209,11 @@ const salaryDistributionRoute = createRoute({
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
401: {
|
|
|
- description: '认证失败或企业权限不足',
|
|
|
+ description: '认证失败',
|
|
|
+ content: { 'application/json': { schema: ErrorSchema } }
|
|
|
+ },
|
|
|
+ 403: {
|
|
|
+ description: '企业权限不足',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
500: {
|
|
|
@@ -207,11 +231,11 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
const user = c.get('user');
|
|
|
const query = c.req.valid('query');
|
|
|
|
|
|
- // 优先使用查询参数中的companyId,否则使用认证用户的companyId
|
|
|
- const targetCompanyId = query.companyId || user?.companyId;
|
|
|
+ // 企业ID强制从认证token获取
|
|
|
+ const targetCompanyId = user?.companyId;
|
|
|
|
|
|
if (!targetCompanyId) {
|
|
|
- return c.json({ code: 400, message: '企业ID不能为空' }, 400);
|
|
|
+ return c.json({ code: 403, message: '无企业权限' }, 403);
|
|
|
}
|
|
|
|
|
|
const statisticsService = await getStatisticsService();
|
|
|
@@ -242,11 +266,11 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
const user = c.get('user');
|
|
|
const query = c.req.valid('query');
|
|
|
|
|
|
- // 优先使用查询参数中的companyId,否则使用认证用户的companyId
|
|
|
- const targetCompanyId = query.companyId || user?.companyId;
|
|
|
+ // 企业ID强制从认证token获取
|
|
|
+ const targetCompanyId = user?.companyId;
|
|
|
|
|
|
if (!targetCompanyId) {
|
|
|
- return c.json({ code: 400, message: '企业ID不能为空' }, 400);
|
|
|
+ return c.json({ code: 403, message: '无企业权限' }, 403);
|
|
|
}
|
|
|
|
|
|
const statisticsService = await getStatisticsService();
|
|
|
@@ -277,11 +301,11 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
const user = c.get('user');
|
|
|
const query = c.req.valid('query');
|
|
|
|
|
|
- // 优先使用查询参数中的companyId,否则使用认证用户的companyId
|
|
|
- const targetCompanyId = query.companyId || user?.companyId;
|
|
|
+ // 企业ID强制从认证token获取
|
|
|
+ const targetCompanyId = user?.companyId;
|
|
|
|
|
|
if (!targetCompanyId) {
|
|
|
- return c.json({ code: 400, message: '企业ID不能为空' }, 400);
|
|
|
+ return c.json({ code: 403, message: '无企业权限' }, 403);
|
|
|
}
|
|
|
|
|
|
const statisticsService = await getStatisticsService();
|
|
|
@@ -312,11 +336,11 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
const user = c.get('user');
|
|
|
const query = c.req.valid('query');
|
|
|
|
|
|
- // 优先使用查询参数中的companyId,否则使用认证用户的companyId
|
|
|
- const targetCompanyId = query.companyId || user?.companyId;
|
|
|
+ // 企业ID强制从认证token获取
|
|
|
+ const targetCompanyId = user?.companyId;
|
|
|
|
|
|
if (!targetCompanyId) {
|
|
|
- return c.json({ code: 400, message: '企业ID不能为空' }, 400);
|
|
|
+ return c.json({ code: 403, message: '无企业权限' }, 403);
|
|
|
}
|
|
|
|
|
|
const statisticsService = await getStatisticsService();
|
|
|
@@ -347,11 +371,11 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
const user = c.get('user');
|
|
|
const query = c.req.valid('query');
|
|
|
|
|
|
- // 优先使用查询参数中的companyId,否则使用认证用户的companyId
|
|
|
- const targetCompanyId = query.companyId || user?.companyId;
|
|
|
+ // 企业ID强制从认证token获取
|
|
|
+ const targetCompanyId = user?.companyId;
|
|
|
|
|
|
if (!targetCompanyId) {
|
|
|
- return c.json({ code: 400, message: '企业ID不能为空' }, 400);
|
|
|
+ return c.json({ code: 403, message: '无企业权限' }, 403);
|
|
|
}
|
|
|
|
|
|
const statisticsService = await getStatisticsService();
|
|
|
@@ -382,11 +406,11 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
const user = c.get('user');
|
|
|
const query = c.req.valid('query');
|
|
|
|
|
|
- // 优先使用查询参数中的companyId,否则使用认证用户的companyId
|
|
|
- const targetCompanyId = query.companyId || user?.companyId;
|
|
|
+ // 企业ID强制从认证token获取
|
|
|
+ const targetCompanyId = user?.companyId;
|
|
|
|
|
|
if (!targetCompanyId) {
|
|
|
- return c.json({ code: 400, message: '企业ID不能为空' }, 400);
|
|
|
+ return c.json({ code: 403, message: '无企业权限' }, 403);
|
|
|
}
|
|
|
|
|
|
const statisticsService = await getStatisticsService();
|