|
|
@@ -241,18 +241,14 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
// 创建薪资
|
|
|
.openapi(createSalaryRoute, async (c) => {
|
|
|
try {
|
|
|
- console.debug('收到创建薪资请求,原始body:', await c.req.text());
|
|
|
const data = c.req.valid('json');
|
|
|
- console.debug('验证后的数据:', JSON.stringify(data, null, 2));
|
|
|
const salaryService = new SalaryService(AppDataSource);
|
|
|
|
|
|
const result = await salaryService.create(data);
|
|
|
|
|
|
return c.json(await parseWithAwait(SalaryLevelSchema, result), 200);
|
|
|
} catch (error) {
|
|
|
- console.debug('创建薪资捕获到错误:', error);
|
|
|
if (error instanceof z.ZodError) {
|
|
|
- console.debug('ZodError详情:', JSON.stringify(error.issues, null, 2));
|
|
|
return c.json({
|
|
|
code: 400,
|
|
|
message: '参数错误',
|
|
|
@@ -292,21 +288,17 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
try {
|
|
|
const { id } = c.req.valid('param');
|
|
|
const data = c.req.valid('json');
|
|
|
- console.debug('更新薪资,ID:', id, '数据:', JSON.stringify(data, null, 2));
|
|
|
const salaryService = new SalaryService(AppDataSource);
|
|
|
|
|
|
const result = await salaryService.update(id, data);
|
|
|
- console.debug('更新结果:', result);
|
|
|
|
|
|
if (!result) {
|
|
|
return c.json({ code: 404, message: '薪资记录不存在' }, 404);
|
|
|
}
|
|
|
|
|
|
const validatedResult = await parseWithAwait(SalaryLevelSchema, result);
|
|
|
- console.debug('验证后的更新结果:', validatedResult);
|
|
|
return c.json(validatedResult, 200);
|
|
|
} catch (error) {
|
|
|
- console.debug('更新薪资错误:', error);
|
|
|
if (error instanceof z.ZodError) {
|
|
|
return c.json({
|
|
|
code: 400,
|
|
|
@@ -404,21 +396,17 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
.openapi(getSalaryByIdRoute, async (c) => {
|
|
|
try {
|
|
|
const { id } = c.req.valid('param');
|
|
|
- console.debug('获取薪资详情,ID:', id);
|
|
|
const salaryService = new SalaryService(AppDataSource);
|
|
|
|
|
|
const result = await salaryService.findOne(id);
|
|
|
- console.debug('查询结果:', result);
|
|
|
|
|
|
if (!result) {
|
|
|
return c.json({ code: 404, message: '薪资记录不存在' }, 404);
|
|
|
}
|
|
|
|
|
|
const validatedResult = await parseWithAwait(SalaryLevelSchema, result);
|
|
|
- console.debug('验证后的结果:', validatedResult);
|
|
|
return c.json(validatedResult, 200);
|
|
|
} catch (error) {
|
|
|
- console.debug('获取薪资详情错误:', error);
|
|
|
return c.json({
|
|
|
code: 500,
|
|
|
message: error instanceof Error ? error.message : '获取薪资详情失败'
|
|
|
@@ -429,21 +417,17 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
.openapi(getSalaryByProvinceCityRoute, async (c) => {
|
|
|
try {
|
|
|
const { provinceId, cityId } = c.req.valid('query');
|
|
|
- console.debug('按省份城市查询薪资,provinceId:', provinceId, 'cityId:', cityId);
|
|
|
const salaryService = new SalaryService(AppDataSource);
|
|
|
|
|
|
const result = await salaryService.findByProvinceCity(provinceId, cityId);
|
|
|
- console.debug('查询结果:', result);
|
|
|
|
|
|
if (!result) {
|
|
|
return c.json({ code: 404, message: '该省份城市的薪资记录不存在' }, 404);
|
|
|
}
|
|
|
|
|
|
const validatedResult = await parseWithAwait(SalaryLevelSchema, result);
|
|
|
- console.debug('验证后的结果:', validatedResult);
|
|
|
return c.json(validatedResult, 200);
|
|
|
} catch (error) {
|
|
|
- console.debug('按省份城市查询薪资错误:', error);
|
|
|
if (error instanceof Error && error.message.includes('该省份城市的薪资记录不存在')) {
|
|
|
return c.json({
|
|
|
code: 404,
|