Skip to content

Commit

Permalink
add count API
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueHorn07 committed Dec 6, 2023
1 parent e33331e commit cc348ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/popo/setting/setting.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ export class SettingController {
res.send(data);
}

@Get('count-rc-student-list')
@Roles(UserType.admin, UserType.association)
@UseGuards(JwtAuthGuard, RolesGuard)
async countRcStudentList() {
return this.settingService.countRcStduentsList();
}

@Get('get-rc-student-list')
@Roles(UserType.admin, UserType.association)
@UseGuards(JwtAuthGuard, RolesGuard)
Expand Down
8 changes: 6 additions & 2 deletions src/popo/setting/setting.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ export class SettingService {
return this.userRepo.update({userType: UserType.rc_student}, {userType: UserType.student});
}

countRcStduentsList() {
return this.fileService.queryOnS3('popo-rc-students-list.csv', 'SELECT COUNT(*) AS cnt FROM S3Object s');
}

getRcStduentsList() {
return this.fileService.queryOnS3('popo-rc-students-list.csv', 'SELECT * FROM S3Object s');
return this.fileService.queryOnS3('popo-rc-students-list.csv', 'SELECT email FROM S3Object s');
}

async checkRcStudent(email: string) {
const ret = await this.fileService.queryOnS3('popo-rc-students-list.csv', `SELECT * FROM S3Object s WHERE s.email = '${email}'`);
const ret = await this.fileService.queryOnS3('popo-rc-students-list.csv', `SELECT email FROM S3Object s WHERE s.email = '${email}'`);
return ret.length > 0;
}

Expand Down

0 comments on commit cc348ca

Please sign in to comment.