Skip to content

Commit e18d3d3

Browse files
jimmypaleliljimmypalelil
andauthored
feat: added pdf docs link in maps and location section (#468)
Co-authored-by: jimmypalelil <[email protected]>
1 parent fb672e1 commit e18d3d3

32 files changed

+3162
-846
lines changed

backend/prisma/schema.prisma

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ model recreation_resource {
2727
recreation_fee recreation_fee[]
2828
recreation_map_feature recreation_map_feature[]
2929
recreation_district_code recreation_district_code? @relation(fields: [district_code], references: [district_code], onDelete: NoAction, onUpdate: NoAction)
30+
recreation_resource_docs recreation_resource_docs[]
3031
recreation_resource_images recreation_resource_images[]
3132
recreation_resource_type recreation_resource_type?
3233
recreation_status recreation_status?
@@ -523,3 +524,24 @@ model recreation_resource_images {
523524
524525
@@unique([rec_resource_id, ref_id])
525526
}
527+
528+
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
529+
model recreation_resource_doc_code {
530+
doc_code String @id @db.VarChar
531+
description String? @db.VarChar
532+
recreation_resource_docs recreation_resource_docs[]
533+
}
534+
535+
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
536+
model recreation_resource_docs {
537+
ref_id String @id(map: "recreation_resource_doc_pkey") @db.VarChar
538+
rec_resource_id String? @db.VarChar(10)
539+
title String? @db.VarChar
540+
url String? @db.VarChar
541+
doc_code String? @db.VarChar
542+
extension String? @db.VarChar
543+
recreation_resource_doc_code recreation_resource_doc_code? @relation(fields: [doc_code], references: [doc_code], onDelete: NoAction, onUpdate: NoAction, map: "recreation_resource_doc_doc_code_fkey")
544+
recreation_resource recreation_resource? @relation(fields: [rec_resource_id], references: [rec_resource_id], onDelete: NoAction, onUpdate: NoAction, map: "recreation_resource_doc_rec_resource_id_fkey")
545+
546+
@@unique([rec_resource_id, ref_id], map: "recreation_resource_doc_rec_resource_id_ref_id_key")
547+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {
2+
RecreationResourceDocCode,
3+
RecreationResourceDocDto,
4+
} from "./recreation-resource-doc.dto";
5+
6+
describe("RecreationResourceDocDto", () => {
7+
it("should create a valid DTO instance", () => {
8+
const dto = new RecreationResourceDocDto();
9+
dto.ref_id = "1000";
10+
dto.title = "Campbell river site map";
11+
dto.url = "https://example.com/map.pdf";
12+
dto.doc_code = RecreationResourceDocCode.RM;
13+
dto.doc_code_description = "Recreation Map";
14+
dto.extension = "pdf";
15+
16+
expect(dto).toBeDefined();
17+
expect(dto.ref_id).toBe("1000");
18+
expect(dto.title).toBe("Campbell river site map");
19+
expect(dto.url).toBe("https://example.com/map.pdf");
20+
expect(dto.doc_code).toBe(RecreationResourceDocCode.RM);
21+
expect(dto.doc_code_description).toBe("Recreation Map");
22+
expect(dto.extension).toBe("pdf");
23+
});
24+
25+
it("should validate enum values", () => {
26+
expect(Object.values(RecreationResourceDocCode)).toContain("RM");
27+
expect(Object.keys(RecreationResourceDocCode)).toHaveLength(1);
28+
});
29+
30+
it("should handle empty values", () => {
31+
const dto = new RecreationResourceDocDto();
32+
expect(dto).toBeDefined();
33+
expect(dto.ref_id).toBeUndefined();
34+
expect(dto.title).toBeUndefined();
35+
expect(dto.url).toBeUndefined();
36+
expect(dto.doc_code).toBeUndefined();
37+
expect(dto.doc_code_description).toBeUndefined();
38+
expect(dto.extension).toBeUndefined();
39+
});
40+
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { ApiProperty } from "@nestjs/swagger";
2+
3+
/**
4+
* Enum representing available image size options for the recreation API
5+
*/
6+
export enum RecreationResourceDocCode {
7+
/** Recreation Map */
8+
RM = "RM",
9+
}
10+
11+
export class RecreationResourceDocDto {
12+
@ApiProperty({
13+
description: "Reference ID for the image",
14+
example: "1000",
15+
})
16+
ref_id: string;
17+
18+
@ApiProperty({
19+
description: "Doc title",
20+
example: "Campbell river site map",
21+
})
22+
title: string;
23+
24+
@ApiProperty({
25+
description: "doc link",
26+
})
27+
url: string;
28+
29+
@ApiProperty({
30+
description: "Document code that indicates the type of document",
31+
enum: RecreationResourceDocCode,
32+
})
33+
doc_code: RecreationResourceDocCode;
34+
35+
@ApiProperty({
36+
description: "Description of the document code",
37+
})
38+
doc_code_description: string;
39+
40+
@ApiProperty({
41+
description: "File extension",
42+
})
43+
extension: string;
44+
}

backend/src/recreation-resource/dto/recreation-resource.dto.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ApiProperty } from "@nestjs/swagger";
22
import { RecreationResourceImageDto } from "./recreation-resource-image.dto";
3+
import { RecreationResourceDocDto } from "./recreation-resource-doc.dto";
34

45
export class RecreationActivityDto {
56
@ApiProperty({
@@ -236,6 +237,13 @@ export class RecreationResourceDetailDto extends BaseRecreationResourceDto {
236237
],
237238
})
238239
spatial_feature_geometry?: string[];
240+
241+
@ApiProperty({
242+
description: "List of documents for the recreation resource",
243+
type: [RecreationResourceDocDto],
244+
required: false,
245+
})
246+
recreation_resource_docs?: RecreationResourceDocDto[];
239247
}
240248

241249
/**

backend/src/recreation-resource/recreation-resource.controller.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { Controller, Get, HttpException, Param, Query } from "@nestjs/common";
2-
import { ApiOperation, ApiQuery, ApiResponse, ApiTags } from "@nestjs/swagger";
2+
import {
3+
ApiOperation,
4+
ApiParam,
5+
ApiQuery,
6+
ApiResponse,
7+
ApiTags,
8+
} from "@nestjs/swagger";
39
import { RecreationResourceService } from "./recreation-resource.service";
410
import { PaginatedRecreationResourceDto } from "./dto/paginated-recreation-resource.dto";
511
import { RecreationResourceImageSize } from "./dto/recreation-resource-image.dto";
@@ -116,6 +122,13 @@ export class RecreationResourceController {
116122
summary: "Find recreation resource by ID",
117123
operationId: "getRecreationResourceById",
118124
})
125+
@ApiParam({
126+
name: "id",
127+
required: true,
128+
description: "Resource identifier",
129+
type: "string",
130+
example: "REC204117",
131+
})
119132
@ApiQuery({
120133
name: "imageSizeCodes",
121134
required: false,

0 commit comments

Comments
 (0)