training_data/apps/server/src/models/staff/staff.controller.ts

49 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-12-30 08:26:40 +08:00
import { Controller, Get, Query, UseGuards } from '@nestjs/common';
import { StaffService } from './staff.service';
import { AuthGuard } from '@server/auth/auth.guard';
import { db } from '@nicestack/common';
@Controller('staff')
export class StaffController {
constructor(private readonly staffService: StaffService) {}
@UseGuards(AuthGuard)
@Get('find-by-id')
async findById(@Query('id') id: string) {
try {
const result = await this.staffService.findById(id);
return {
data: result,
errmsg: 'success',
errno: 0,
};
} catch (e) {
return {
data: {},
errmsg: (e as any)?.message || 'error',
errno: 1,
};
}
}
@Get('find-by-dept')
async findByDept(
@Query('dept-id') deptId: string,
@Query('domain-id') domainId: string,
) {
try {
const result = await this.staffService.findByDept({ deptId, domainId });
return {
data: result,
errmsg: 'success',
errno: 0,
};
} catch (e) {
return {
data: {},
errmsg: (e as any)?.message || 'error',
errno: 1,
};
}
}
}