Skip to content

Commit f6d45c5

Browse files
Merge pull request #758 from authenticeasy-sys/main
Implemented Member Stats Provider & Endpoint
2 parents 54bdc82 + 1b83ec7 commit f6d45c5

13 files changed

+309
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Body, Controller, Delete, Get, Param, Patch, Post, UseGuards } from '@nestjs/common';
2+
import { AdminModeratorAccountSettingsService } from './admin-moderator-account-settings.service';
3+
import { CreateAdminModeratorAccountSettingsDto } from './dto/create-admin-moderator-account-settings.dto';
4+
import { UpdateAdminModeratorAccountSettingsDto } from './dto/update-admin-moderator-account-settings.dto';
5+
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
6+
import { RolesGuard } from '../common/guards/roles.guard';
7+
import { Role } from '../common/enums/role.enum';
8+
import { Roles } from '../common/decorators/roles.decorator';
9+
10+
@Controller('admin-moderator/account-settings')
11+
export class AdminModeratorAccountSettingsController {
12+
constructor(private readonly service: AdminModeratorAccountSettingsService) {}
13+
14+
@Get()
15+
findAll() {
16+
return this.service.findAll();
17+
}
18+
19+
@Get(':id')
20+
findOne(@Param('id') id: string) {
21+
return this.service.findOne(id);
22+
}
23+
24+
@Post()
25+
@UseGuards(JwtAuthGuard, RolesGuard)
26+
@Roles(Role.ADMIN, Role.MODERATOR, Role.TUTOR)
27+
create(@Body() payload: CreateAdminModeratorAccountSettingsDto) {
28+
return this.service.create(payload);
29+
}
30+
31+
@Patch(':id')
32+
@UseGuards(JwtAuthGuard, RolesGuard)
33+
@Roles(Role.ADMIN, Role.MODERATOR, Role.TUTOR)
34+
update(@Param('id') id: string, @Body() payload: UpdateAdminModeratorAccountSettingsDto) {
35+
return this.service.update(id, payload);
36+
}
37+
38+
@Delete(':id')
39+
@UseGuards(JwtAuthGuard, RolesGuard)
40+
@Roles(Role.ADMIN, Role.MODERATOR)
41+
remove(@Param('id') id: string) {
42+
return this.service.remove(id);
43+
}
44+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Module } from '@nestjs/common';
2+
import { AdminModeratorAccountSettingsController } from './admin-moderator-account-settings.controller';
3+
import { AdminModeratorAccountSettingsService } from './admin-moderator-account-settings.service';
4+
5+
@Module({
6+
controllers: [AdminModeratorAccountSettingsController],
7+
providers: [AdminModeratorAccountSettingsService],
8+
})
9+
export class AdminModeratorAccountSettingsModule {}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Injectable, NotFoundException } from '@nestjs/common';
2+
import { CreateAdminModeratorAccountSettingsDto } from './dto/create-admin-moderator-account-settings.dto';
3+
import { UpdateAdminModeratorAccountSettingsDto } from './dto/update-admin-moderator-account-settings.dto';
4+
5+
@Injectable()
6+
export class AdminModeratorAccountSettingsService {
7+
private readonly items: Array<{ id: string } & CreateAdminModeratorAccountSettingsDto> = [];
8+
9+
findAll() {
10+
return this.items;
11+
}
12+
13+
findOne(id: string) {
14+
const item = this.items.find((entry) => entry.id === id);
15+
if (!item) {
16+
throw new NotFoundException('AdminModeratorAccountSettings item not found');
17+
}
18+
return item;
19+
}
20+
21+
create(payload: CreateAdminModeratorAccountSettingsDto) {
22+
const created = { id: crypto.randomUUID(), ...payload };
23+
this.items.push(created);
24+
return created;
25+
}
26+
27+
update(id: string, payload: UpdateAdminModeratorAccountSettingsDto) {
28+
const item = this.findOne(id);
29+
Object.assign(item, payload);
30+
return item;
31+
}
32+
33+
remove(id: string) {
34+
const index = this.items.findIndex((entry) => entry.id === id);
35+
if (index === -1) {
36+
throw new NotFoundException('AdminModeratorAccountSettings item not found');
37+
}
38+
this.items.splice(index, 1);
39+
return { id, deleted: true };
40+
}
41+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Body, Controller, Delete, Get, Param, Patch, Post, UseGuards } from '@nestjs/common';
2+
import { BadgesNftService } from './badges-nft.service';
3+
import { CreateBadgesNftDto } from './dto/create-badges-nft.dto';
4+
import { UpdateBadgesNftDto } from './dto/update-badges-nft.dto';
5+
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
6+
import { RolesGuard } from '../common/guards/roles.guard';
7+
import { Role } from '../common/enums/role.enum';
8+
import { Roles } from '../common/decorators/roles.decorator';
9+
10+
@Controller('badges-nft')
11+
export class BadgesNftController {
12+
constructor(private readonly service: BadgesNftService) {}
13+
14+
@Get()
15+
findAll() {
16+
return this.service.findAll();
17+
}
18+
19+
@Get(':id')
20+
findOne(@Param('id') id: string) {
21+
return this.service.findOne(id);
22+
}
23+
24+
@Post()
25+
@UseGuards(JwtAuthGuard, RolesGuard)
26+
@Roles(Role.ADMIN, Role.MODERATOR, Role.TUTOR)
27+
create(@Body() payload: CreateBadgesNftDto) {
28+
return this.service.create(payload);
29+
}
30+
31+
@Patch(':id')
32+
@UseGuards(JwtAuthGuard, RolesGuard)
33+
@Roles(Role.ADMIN, Role.MODERATOR, Role.TUTOR)
34+
update(@Param('id') id: string, @Body() payload: UpdateBadgesNftDto) {
35+
return this.service.update(id, payload);
36+
}
37+
38+
@Delete(':id')
39+
@UseGuards(JwtAuthGuard, RolesGuard)
40+
@Roles(Role.ADMIN, Role.MODERATOR)
41+
remove(@Param('id') id: string) {
42+
return this.service.remove(id);
43+
}
44+
}

backend/menu/badges-nft.module.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Module } from '@nestjs/common';
2+
import { BadgesNftController } from './badges-nft.controller';
3+
import { BadgesNftService } from './badges-nft.service';
4+
5+
@Module({
6+
controllers: [BadgesNftController],
7+
providers: [BadgesNftService],
8+
})
9+
export class BadgesNftModule {}

backend/menu/badges-nft.service.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Injectable, NotFoundException } from '@nestjs/common';
2+
import { CreateBadgesNftDto } from './dto/create-badges-nft.dto';
3+
import { UpdateBadgesNftDto } from './dto/update-badges-nft.dto';
4+
5+
@Injectable()
6+
export class BadgesNftService {
7+
private readonly items: Array<{ id: string } & CreateBadgesNftDto> = [];
8+
9+
findAll() {
10+
return this.items;
11+
}
12+
13+
findOne(id: string) {
14+
const item = this.items.find((entry) => entry.id === id);
15+
if (!item) {
16+
throw new NotFoundException('BadgesNft item not found');
17+
}
18+
return item;
19+
}
20+
21+
create(payload: CreateBadgesNftDto) {
22+
const created = { id: crypto.randomUUID(), ...payload };
23+
this.items.push(created);
24+
return created;
25+
}
26+
27+
update(id: string, payload: UpdateBadgesNftDto) {
28+
const item = this.findOne(id);
29+
Object.assign(item, payload);
30+
return item;
31+
}
32+
33+
remove(id: string) {
34+
const index = this.items.findIndex((entry) => entry.id === id);
35+
if (index === -1) {
36+
throw new NotFoundException('BadgesNft item not found');
37+
}
38+
this.items.splice(index, 1);
39+
return { id, deleted: true };
40+
}
41+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Body, Controller, Delete, Get, Param, Patch, Post, UseGuards } from '@nestjs/common';
2+
import { CertificateDownloadService } from './certificate-download.service';
3+
import { CreateCertificateDownloadDto } from './dto/create-certificate-download.dto';
4+
import { UpdateCertificateDownloadDto } from './dto/update-certificate-download.dto';
5+
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
6+
import { RolesGuard } from '../common/guards/roles.guard';
7+
import { Role } from '../common/enums/role.enum';
8+
import { Roles } from '../common/decorators/roles.decorator';
9+
10+
@Controller('certificates/download')
11+
export class CertificateDownloadController {
12+
constructor(private readonly service: CertificateDownloadService) {}
13+
14+
@Get()
15+
findAll() {
16+
return this.service.findAll();
17+
}
18+
19+
@Get(':id')
20+
findOne(@Param('id') id: string) {
21+
return this.service.findOne(id);
22+
}
23+
24+
@Post()
25+
@UseGuards(JwtAuthGuard, RolesGuard)
26+
@Roles(Role.ADMIN, Role.MODERATOR, Role.TUTOR)
27+
create(@Body() payload: CreateCertificateDownloadDto) {
28+
return this.service.create(payload);
29+
}
30+
31+
@Patch(':id')
32+
@UseGuards(JwtAuthGuard, RolesGuard)
33+
@Roles(Role.ADMIN, Role.MODERATOR, Role.TUTOR)
34+
update(@Param('id') id: string, @Body() payload: UpdateCertificateDownloadDto) {
35+
return this.service.update(id, payload);
36+
}
37+
38+
@Delete(':id')
39+
@UseGuards(JwtAuthGuard, RolesGuard)
40+
@Roles(Role.ADMIN, Role.MODERATOR)
41+
remove(@Param('id') id: string) {
42+
return this.service.remove(id);
43+
}
44+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Module } from '@nestjs/common';
2+
import { CertificateDownloadController } from './certificate-download.controller';
3+
import { CertificateDownloadService } from './certificate-download.service';
4+
5+
@Module({
6+
controllers: [CertificateDownloadController],
7+
providers: [CertificateDownloadService],
8+
})
9+
export class CertificateDownloadModule {}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Injectable, NotFoundException } from '@nestjs/common';
2+
import { CreateCertificateDownloadDto } from './dto/create-certificate-download.dto';
3+
import { UpdateCertificateDownloadDto } from './dto/update-certificate-download.dto';
4+
5+
@Injectable()
6+
export class CertificateDownloadService {
7+
private readonly items: Array<{ id: string } & CreateCertificateDownloadDto> = [];
8+
9+
findAll() {
10+
return this.items;
11+
}
12+
13+
findOne(id: string) {
14+
const item = this.items.find((entry) => entry.id === id);
15+
if (!item) {
16+
throw new NotFoundException('CertificateDownload item not found');
17+
}
18+
return item;
19+
}
20+
21+
create(payload: CreateCertificateDownloadDto) {
22+
const created = { id: crypto.randomUUID(), ...payload };
23+
this.items.push(created);
24+
return created;
25+
}
26+
27+
update(id: string, payload: UpdateCertificateDownloadDto) {
28+
const item = this.findOne(id);
29+
Object.assign(item, payload);
30+
return item;
31+
}
32+
33+
remove(id: string) {
34+
const index = this.items.findIndex((entry) => entry.id === id);
35+
if (index === -1) {
36+
throw new NotFoundException('CertificateDownload item not found');
37+
}
38+
this.items.splice(index, 1);
39+
return { id, deleted: true };
40+
}
41+
}

backend/menu/controller.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const { createIssueController } = require('../../../common/create-issue-module');
2+
const { issue_5_course_performance_leaderboardService } = require('./service');
3+
4+
const issue_5_course_performance_leaderboardController = createIssueController(issue_5_course_performance_leaderboardService);
5+
6+
module.exports = { issue_5_course_performance_leaderboardController };

0 commit comments

Comments
 (0)