Skip to content

Commit 181e084

Browse files
feat: implement core services, controllers, and repositories for user, veil, gallery, and treatment modules
1 parent 10f19d3 commit 181e084

20 files changed

Lines changed: 114 additions & 8 deletions

File tree

backend/src/modules/gallery/application/gallery.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { GalleryRepository } from '../infrastructure/repositories/gallery.reposi
66
export class GalleryService {
77
constructor(private readonly galleryRepository: GalleryRepository) {}
88

9+
async count(): Promise<number> {
10+
return this.galleryRepository.count();
11+
}
12+
913
async findAll(): Promise<Gallery[]> {
1014
return this.galleryRepository.findAll();
1115
}

backend/src/modules/gallery/infrastructure/repositories/gallery.repository.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export class GalleryRepository {
1414
private readonly galleryModel: Model<GalleryDocument>,
1515
) {}
1616

17+
async count(): Promise<number> {
18+
return this.galleryModel.countDocuments().exec();
19+
}
20+
1721
async findAll(): Promise<Gallery[]> {
1822
const docs = await this.galleryModel.find().exec();
1923
const doc = docs.map((doc) => this.toDomain(doc));

backend/src/modules/gallery/presentation/gallery.controller.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ import { UpdateGalleryDto } from './dto/update-gallery.dto';
2121
export class GalleryController {
2222
constructor(private readonly galleryService: GalleryService) {}
2323

24+
@Get('count')
25+
async count(): Promise<number> {
26+
return this.galleryService.count();
27+
}
28+
2429
@Get()
2530
async findAll(): Promise<Gallery[]> {
2631
return this.galleryService.findAll();

backend/src/modules/treatments/application/treatments.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { deleteFileSafe } from '@common/utils';
77
export class TreatmentsService {
88
constructor(private readonly treatmentsRepository: TreatmentsRepository) {}
99

10+
async count(): Promise<number> {
11+
return this.treatmentsRepository.count();
12+
}
13+
1014
async findAll(): Promise<Treatments[]> {
1115
return this.treatmentsRepository.findAll();
1216
}

backend/src/modules/treatments/infrastructure/repositories/treatments.repository.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export class TreatmentsRepository {
1414
private readonly treatmentsModel: Model<TreatmentsDocument>,
1515
) {}
1616

17+
async count(): Promise<number> {
18+
return this.treatmentsModel.countDocuments().exec();
19+
}
20+
1721
async findAll(): Promise<Treatments[]> {
1822
const docs = await this.treatmentsModel.find().exec();
1923
return docs.map((doc) => this.toDomain(doc));

backend/src/modules/treatments/presentation/treatments.controller.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ import { extname } from 'path';
2323
export class TreatmentsController {
2424
constructor(private readonly treatmentsService: TreatmentsService) {}
2525

26+
@Get('count')
27+
async count(): Promise<number> {
28+
return this.treatmentsService.count();
29+
}
30+
2631
@Get()
2732
async findAll(): Promise<Treatments[]> {
2833
return this.treatmentsService.findAll();

backend/src/modules/user/application/user.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { UserRepository } from '../infrastructure/repositories/user.repository';
77
export class UserService {
88
constructor(private readonly userRepository: UserRepository) {}
99

10+
async count(): Promise<number> {
11+
return await this.userRepository.count();
12+
}
13+
1014
async findAll(): Promise<User[]> {
1115
return await this.userRepository.findAll();
1216
}

backend/src/modules/user/infrastructure/repositories/user.repository.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export class UserRepository {
1010
@InjectModel(UserSchemaEntity.name) private userModel: Model<UserDocument>,
1111
) {}
1212

13+
async count(): Promise<number> {
14+
return this.userModel.countDocuments().exec();
15+
}
16+
1317
async findAll(): Promise<User[]> {
1418
const docs = await this.userModel.find().exec();
1519
return docs.map((doc) => this.toDomain(doc));

backend/src/modules/user/presentation/user.controller.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export class UserController {
4949
);
5050
}
5151

52+
@Get('count')
53+
async count(): Promise<number> {
54+
return this.userService.count();
55+
}
56+
5257
@Get()
5358
async findAll(): Promise<User[]> {
5459
return this.userService.findAll();

backend/src/modules/veil/application/veil.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { VeilRepository } from '../infrastructure/repositories/veil.repository';
66
export class VeilService {
77
constructor(private readonly veilRepository: VeilRepository) {}
88

9+
async count(): Promise<number> {
10+
return this.veilRepository.count();
11+
}
12+
913
async findAll(): Promise<Veil[]> {
1014
return this.veilRepository.findAll();
1115
}

0 commit comments

Comments
 (0)