Skip to content

Commit

Permalink
feature[Staff]add role staff for list staff
Browse files Browse the repository at this point in the history
  • Loading branch information
MinhhTien committed Mar 7, 2024
1 parent 704e71d commit ed3b73c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/staff/controllers/staff.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ export class StaffController {
@ApiOperation({
summary: 'Paginate list staff'
})
@Roles(UserRole.ADMIN)
@Roles(UserRole.ADMIN, UserRole.STAFF)
@UseGuards(RolesGuard)
@ApiOkResponse({ type: StaffPaginateResponseDto })
@ApiQuery({ type: PaginationQuery })
getListStaff(@Req() req, @Pagination() paginationParams: PaginationParams, @Query() filterStaffDto: FilterStaffDto) {
const { _id: adminId } = _.get(req, 'user')
return this.staffService.paginate(filterStaffDto, paginationParams, adminId)
const { _id } = _.get(req, 'user')
return this.staffService.paginate(filterStaffDto, paginationParams, _id)
}

@Get('consultant')
Expand All @@ -85,12 +85,12 @@ export class StaffController {
@ApiOperation({
summary: 'View staff detail'
})
@Roles(UserRole.ADMIN)
@Roles(UserRole.ADMIN, UserRole.STAFF)
@UseGuards(RolesGuard)
@ApiOkResponse({ type: StaffResponseDto })
getStaffDetail(@Req() req, @Param('staffId', ParseObjectIdPipe) staffId: string) {
const { _id: adminId } = _.get(req, 'user')
return this.staffService.getOne({ _id: staffId }, adminId)
const { _id } = _.get(req, 'user')
return this.staffService.getOne({ _id: staffId }, _id)
}

@Delete(':staffId/deactivate')
Expand Down
8 changes: 4 additions & 4 deletions src/staff/services/staff.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ export class StaffService {
return new SuccessResponse(true)
}

public async paginate(filter: FilterQuery<Staff>, paginationParams: PaginationParams, adminId: string) {
public async paginate(filter: FilterQuery<Staff>, paginationParams: PaginationParams, staffId: string) {
const { providerId } = await this.staffRepository.findOne({
conditions: { _id: adminId }
conditions: { _id: staffId }
})

const result = await this.staffRepository.paginate(
Expand Down Expand Up @@ -141,9 +141,9 @@ export class StaffService {
return result
}

public async getOne(filter: FilterQuery<Staff>, adminId: string) {
public async getOne(filter: FilterQuery<Staff>, staffId: string) {
const { providerId } = await this.staffRepository.findOne({
conditions: { _id: adminId }
conditions: { _id: staffId }
})

const staff = await this.staffRepository.findOne({
Expand Down

0 comments on commit ed3b73c

Please sign in to comment.