|
|
@@ -292,16 +292,21 @@ 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);
|
|
|
}
|
|
|
|
|
|
- return c.json(await parseWithAwait(SalaryLevelSchema, result), 200);
|
|
|
+ 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,
|
|
|
@@ -424,17 +429,21 @@ 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,
|