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';
|
2025-01-06 08:45:23 +08:00
|
|
|
import { db } from '@nice/common';
|
2024-12-30 08:26:40 +08:00
|
|
|
|
|
|
|
@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(
|
2025-04-06 19:44:22 +08:00
|
|
|
@Query('dept-id') deptId: string | null,
|
2024-12-30 08:26:40 +08:00
|
|
|
@Query('domain-id') domainId: string,
|
|
|
|
) {
|
|
|
|
try {
|
2025-04-06 19:44:22 +08:00
|
|
|
const result = await this.staffService.findByDept({
|
|
|
|
deptId: deptId || null,
|
|
|
|
domainId: domainId,
|
|
|
|
});
|
2024-12-30 08:26:40 +08:00
|
|
|
return {
|
|
|
|
data: result,
|
|
|
|
errmsg: 'success',
|
|
|
|
errno: 0,
|
|
|
|
};
|
|
|
|
} catch (e) {
|
|
|
|
return {
|
|
|
|
data: {},
|
|
|
|
errmsg: (e as any)?.message || 'error',
|
|
|
|
errno: 1,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|