Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

Commit fa901c0

Browse files
committed
feat: Update findAll methods across services to exclude records marked as 'DELETED'
1 parent 13939c3 commit fa901c0

8 files changed

Lines changed: 30 additions & 14 deletions

File tree

src/achievement/achievement.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ export class AchievementService {
3838
}
3939

4040
async findAll() {
41-
return this.db.select().from(achievements);
41+
return this.db
42+
.select()
43+
.from(achievements)
44+
.where(ne(achievements.recordStatus, 'DELETED'));
4245
}
4346

4447
async findOne(id: number) {

src/category/category.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ export class CategoryService {
3535
}
3636

3737
async findAll() {
38-
return this.db.select().from(categories);
38+
return this.db
39+
.select()
40+
.from(categories)
41+
.where(ne(categories.recordStatus, 'DELETED'));
3942
}
4043

4144
async findOne(id: number) {

src/city/city.service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class CityService {
4040
}
4141

4242
async findAll(regionId?: number) {
43-
const baseConditions = [];
43+
const baseConditions = [ne(cities.recordStatus, 'DELETED')];
4444

4545
if (regionId) {
4646
baseConditions.push(eq(cities.regionId, regionId));
@@ -62,8 +62,11 @@ export class CityService {
6262
updatedAt: cities.updatedAt,
6363
})
6464
.from(cities)
65-
.leftJoin(regions, eq(cities.regionId, regions.id))
66-
.where(baseConditions.length > 0 ? and(...baseConditions) : undefined);
65+
.leftJoin(regions, and(
66+
eq(cities.regionId, regions.id),
67+
ne(regions.recordStatus, 'DELETED')
68+
))
69+
.where(and(...baseConditions));
6770
}
6871

6972
async findOne(id: number) {

src/help-type/help-type.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ export class HelpTypeService {
3434
}
3535

3636
async findAll() {
37-
return this.db.select().from(helpTypes);
37+
return this.db
38+
.select()
39+
.from(helpTypes)
40+
.where(ne(helpTypes.recordStatus, 'DELETED'));
3841
}
3942

4043
async findOne(id: number) {

src/organization-type/organization-type.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ export class OrganizationTypeService {
3434
}
3535

3636
async findAll() {
37-
return this.db.select().from(organizationTypes);
37+
return this.db
38+
.select()
39+
.from(organizationTypes)
40+
.where(ne(organizationTypes.recordStatus, 'DELETED'));
3841
}
3942

4043
async findOne(id: number) {

src/quest-update/quest-update.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ export class QuestUpdateService {
4444
}
4545

4646
async findAll(questId?: number) {
47-
const conditions = [];
47+
const conditions = [ne(questUpdates.recordStatus, 'DELETED')];
4848
if (questId) {
4949
conditions.push(eq(questUpdates.questId, questId));
5050
}
5151
return this.db
5252
.select()
5353
.from(questUpdates)
54-
.where(conditions.length > 0 ? and(...conditions) : undefined);
54+
.where(and(...conditions));
5555
}
5656

5757
async findOne(id: number) {

src/quest/quest.repository.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,15 @@ export class QuestRepository {
258258
ne(organizationTypes.recordStatus, 'DELETED')
259259
));
260260

261-
const conditions = [];
261+
const conditions = [ne(quests.recordStatus, 'DELETED')];
262262
if (cityId) {
263263
conditions.push(eq(quests.cityId, cityId));
264264
}
265265
if (categoryId) {
266266
query = query.innerJoin(questCategories, eq(quests.id, questCategories.questId)) as any;
267267
conditions.push(eq(questCategories.categoryId, categoryId));
268268
}
269-
if (conditions.length > 0) {
270-
query = query.where(and(...conditions)) as any;
271-
}
269+
query = query.where(and(...conditions)) as any;
272270

273271
return await query as QuestWithRelations[];
274272
} catch (error: any) {

src/region/region.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ export class RegionService {
2222
}
2323

2424
async findAll() {
25-
return this.db.select().from(regions);
25+
return this.db
26+
.select()
27+
.from(regions)
28+
.where(ne(regions.recordStatus, 'DELETED'));
2629
}
2730

2831
async findOne(id: number) {

0 commit comments

Comments
 (0)