Skip to content

Commit c22fbd5

Browse files
authored
Feat: Create get all programs page (#594)
1 parent 4626d1e commit c22fbd5

11 files changed

Lines changed: 485 additions & 8 deletions

File tree

src/main/java/com/wcc/platform/controller/ProgrammeController.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.wcc.platform.controller;
22

33
import com.wcc.platform.domain.cms.pages.programme.ProgrammePage;
4+
import com.wcc.platform.domain.cms.pages.programme.ProgrammesPage;
45
import com.wcc.platform.domain.platform.type.ProgramType;
56
import com.wcc.platform.service.ProgrammeService;
67
import io.swagger.v3.oas.annotations.Operation;
@@ -45,7 +46,17 @@ public ResponseEntity<ProgrammePage> getProgramme(
4546
return ResponseEntity.ok(service.getProgramme(programType));
4647
}
4748

48-
/** Create Program Page Content and store into a database. */
49+
/** Get all programmes API. */
50+
@Tag(name = "Pages: Programmes", description = "API to retrieve Page with all programmes")
51+
@GetMapping("/api/cms/v1/programmes")
52+
@Operation(summary = "API to retrieve page with all programmes")
53+
@ResponseStatus(HttpStatus.OK)
54+
public ResponseEntity<ProgrammesPage> getAllProgrammes() {
55+
56+
return ResponseEntity.ok(service.getAllProgrammes());
57+
}
58+
59+
/** Create Programme Page Content and store into database. */
4960
@Tag(name = "Platform: Pages", description = "Platform Internal Pages APIs")
5061
@PostMapping("/api/platform/v1/program")
5162
@Operation(
@@ -60,8 +71,8 @@ public ResponseEntity<Object> createPage(
6071
return ResponseEntity.ok(service.create(type, page));
6172
}
6273

63-
/** Update Program Page and store into a database. */
64-
@Tag(name = "Platform: Pages", description = "Platform Internal Pages APIs")
74+
/** Update Program Page and store into database. */
75+
@Tag(name = "Platform: Program", description = "Program Internal APIs")
6576
@PutMapping("/api/platform/v1/program")
6677
@Operation(
6778
summary = "Update program page content by program type",

src/main/java/com/wcc/platform/domain/cms/PageType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public enum PageType {
3030
TEAM("init-data/teamPage.json", "page:TEAM"),
3131
COLLABORATOR("init-data/collaboratorPage.json", "page:COLLABORATORS"),
3232
CODE_OF_CONDUCT("init-data/codeOfConductPage.json", "page:CODE_OF_CONDUCT"),
33-
PARTNERS("init-data/partnersPage.json", "page:PARTNERS");
33+
PARTNERS("init-data/partnersPage.json", "page:PARTNERS"),
34+
PROGRAMMES("init-data/programmesPage.json", "page:PROGRAMMES");
3435

3536
public static final String ID_PREFIX = "page:";
3637

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
package com.wcc.platform.domain.cms.attributes.style;
22

3+
import com.wcc.platform.domain.cms.attributes.CmsIcon;
4+
35
/** Custom frontend styles. */
4-
public record CustomStyle(BackgroundColourStyle backgroundColour) {}
6+
public record CustomStyle(BackgroundColourStyle backgroundColour, CmsIcon icon) {}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.wcc.platform.domain.cms.pages.programme;
2+
3+
import com.wcc.platform.domain.cms.attributes.Image;
4+
import com.wcc.platform.domain.cms.attributes.LabelLink;
5+
import com.wcc.platform.domain.cms.attributes.style.CustomStyle;
6+
import jakarta.validation.constraints.NotBlank;
7+
import jakarta.validation.constraints.NotNull;
8+
import java.util.List;
9+
import lombok.AllArgsConstructor;
10+
import lombok.Builder;
11+
import lombok.EqualsAndHashCode;
12+
import lombok.Getter;
13+
import lombok.NoArgsConstructor;
14+
import lombok.ToString;
15+
16+
/** Programme item to be listed in the landing page. */
17+
@Getter
18+
@AllArgsConstructor
19+
@NoArgsConstructor
20+
@ToString
21+
@EqualsAndHashCode
22+
@Builder
23+
@SuppressWarnings("checkstyle:Indentation")
24+
public class ProgrammeCardItem {
25+
@NotBlank private String title;
26+
@NotBlank private String description;
27+
private List<Image> images;
28+
@NotNull private LabelLink link;
29+
private CustomStyle customStyle;
30+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.wcc.platform.domain.cms.pages.programme;
2+
3+
import com.wcc.platform.domain.cms.attributes.CommonSection;
4+
import com.wcc.platform.domain.cms.attributes.HeroSection;
5+
import com.wcc.platform.domain.cms.attributes.ListSection;
6+
import jakarta.validation.constraints.NotBlank;
7+
import jakarta.validation.constraints.NotNull;
8+
import lombok.AllArgsConstructor;
9+
import lombok.Builder;
10+
import lombok.EqualsAndHashCode;
11+
import lombok.Getter;
12+
import lombok.NoArgsConstructor;
13+
import lombok.ToString;
14+
15+
/** Programmes landing page with all programmes. */
16+
@Getter
17+
@AllArgsConstructor
18+
@NoArgsConstructor
19+
@ToString
20+
@EqualsAndHashCode
21+
@Builder
22+
public class ProgrammesPage {
23+
@NotBlank private String id;
24+
@NotNull private HeroSection heroSection;
25+
@NotNull private CommonSection section;
26+
@NotNull private ListSection<ProgrammeCardItem> programmesSection;
27+
}

src/main/java/com/wcc/platform/service/ProgrammeService.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package com.wcc.platform.service;
22

3+
import static com.wcc.platform.domain.cms.PageType.PROGRAMMES;
4+
35
import com.fasterxml.jackson.databind.ObjectMapper;
46
import com.wcc.platform.domain.cms.pages.programme.ProgrammePage;
7+
import com.wcc.platform.domain.cms.pages.programme.ProgrammesPage;
58
import com.wcc.platform.domain.exceptions.ContentNotFoundException;
69
import com.wcc.platform.domain.exceptions.PlatformInternalException;
710
import com.wcc.platform.domain.platform.type.ProgramType;
@@ -27,7 +30,7 @@ public ProgrammeService(final PageRepository pageRepository, final ObjectMapper
2730
}
2831

2932
/**
30-
* API to fetch details about different type of programmes.
33+
* API to fetch details about different types of programmes.
3134
*
3235
* @return Programme Page json response
3336
*/
@@ -63,4 +66,17 @@ public Object create(final ProgramType programType, final Object page) {
6366
throw new PlatformInternalException(programType, e);
6467
}
6568
}
69+
70+
/** Get the page with all programmes. */
71+
public ProgrammesPage getAllProgrammes() {
72+
final var page = pageRepository.findById(PROGRAMMES.getId());
73+
if (page.isPresent()) {
74+
try {
75+
return objectMapper.convertValue(page.get(), ProgrammesPage.class);
76+
} catch (IllegalArgumentException e) {
77+
throw new PlatformInternalException(e.getMessage(), e);
78+
}
79+
}
80+
return pageRepository.getFallback(PROGRAMMES, ProgrammesPage.class, objectMapper);
81+
}
6682
}
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
{
2+
"id": "page:PROGRAMMES",
3+
"heroSection": {
4+
"title": "WCC Programmes",
5+
"images": [
6+
{
7+
"path": "https://drive.google.com/uc?id=1efbBcw8yaASbSx3pgqcj06tIN-P2Wf55&export=download",
8+
"alt": "There is a group of women showing WCC logo",
9+
"type": "desktop"
10+
}
11+
],
12+
"customStyle": {
13+
"backgroundColour": {
14+
"color": "PRIMARY",
15+
"shade": {
16+
"name": "LIGHT",
17+
"value": 90
18+
}
19+
}
20+
}
21+
},
22+
"section": {
23+
"description": "Here you will find the list of available WCC programmes."
24+
},
25+
"programmesSection": {
26+
"items": [
27+
{
28+
"title": "Code Club",
29+
"description": "Code club is a series of short workshops that teach basic coding skills to young people.",
30+
"images": [
31+
{
32+
"path": "https://drive.google.com/uc?id=1efbBcw8yaASbSx3pgqcj06tIN-P2Wf55&export=download",
33+
"alt": "There is a group of women showing WCC logo",
34+
"type": "desktop"
35+
}
36+
],
37+
"link": {
38+
"label": "program page",
39+
"uri": "/programmes/code-club"
40+
},
41+
"customStyle": {
42+
"icon": "code_blocks",
43+
"backgroundColour": {
44+
"color": "secondary",
45+
"shade": {
46+
"name": "LIGHT",
47+
"value": 90
48+
}
49+
}
50+
}
51+
},
52+
{
53+
"title": "Book Club",
54+
"description": "The study group focuses on mastering API testing using Postman, a popular API development and testing tool. Sessions feature hands-on exercises and real-world scenarios to deepen understanding of testing techniques and gain practical knowledge on API automation.",
55+
"images": [
56+
{
57+
"path": "https://drive.google.com/uc?id=1efbBcw8yaASbSx3pgqcj06tIN-P2Wf55&export=download",
58+
"alt": "There is a group of women showing WCC logo",
59+
"type": "desktop"
60+
}
61+
],
62+
"link": {
63+
"label": "program page",
64+
"uri": "programmes/book-club"
65+
},
66+
"customStyle": {
67+
"icon": "book_2",
68+
"backgroundColour": {
69+
"color": "tertiary",
70+
"shade": {
71+
"name": "main",
72+
"value": 90
73+
}
74+
}
75+
}
76+
},
77+
{
78+
"title": "Writing Club",
79+
"description": "Writing club is a series of short workshops that teach basic coding skills to young people.",
80+
"link": {
81+
"label": "program page",
82+
"uri": "/programmes/writing-club"
83+
},
84+
"customStyle": {
85+
"icon": "group",
86+
"backgroundColour": {
87+
"color": "secondary",
88+
"shade": {
89+
"name": "dark",
90+
"value": 90
91+
}
92+
}
93+
}
94+
},
95+
{
96+
"title": "Speaking Club",
97+
"description": "Speaking club is a series of short workshops that teach basic coding skills to young people.",
98+
"link": {
99+
"label": "program page",
100+
"uri": "/programmes/speaking-club"
101+
},
102+
"customStyle": {
103+
"icon": "calendar_month",
104+
"backgroundColour": {
105+
"color": "tertiary",
106+
"shade": {
107+
"name": "main",
108+
"value": 90
109+
}
110+
}
111+
}
112+
},
113+
{
114+
"title": "CV Clinic Programme",
115+
"description": "CV Clinic Program is a series of short workshops that teach basic coding skills to young people.",
116+
"link": {
117+
"label": "program page",
118+
"uri": "/programmes/cv-clinic-programme"
119+
},
120+
"customStyle": {
121+
"icon": "calendar_month",
122+
"backgroundColour": {
123+
"color": "tertiary",
124+
"shade": {
125+
"name": "main",
126+
"value": 90
127+
}
128+
}
129+
}
130+
},
131+
{
132+
"title": "Java Track",
133+
"description": "Java Track is a series of short workshops that teach basic coding skills.",
134+
"link": {
135+
"label": "program page",
136+
"uri": "/programmes/java-track"
137+
},
138+
"customStyle": {
139+
"icon": "calendar_month",
140+
"backgroundColour": {
141+
"color": "tertiary",
142+
"shade": {
143+
"name": "main",
144+
"value": 90
145+
}
146+
}
147+
}
148+
},
149+
{
150+
"title": "Leetcode Programme",
151+
"description": "Leetcode Programme is a series of short workshops that teach basic coding skills to young people.",
152+
"link": {
153+
"label": "program page",
154+
"uri": "/programmes/leetcode-programme"
155+
},
156+
"customStyle": {
157+
"icon": "calendar_month",
158+
"backgroundColour": {
159+
"color": "tertiary",
160+
"shade": {
161+
"name": "main",
162+
"value": 90
163+
}
164+
}
165+
}
166+
},
167+
{
168+
"title": "Machine Learning",
169+
"description": "Machine Learning Programme is a series of short workshops that teach basic coding skills to young people.",
170+
"link": {
171+
"label": "program page",
172+
"uri": "/programmes/machine-learning"
173+
},
174+
"customStyle": {
175+
"icon": "calendar_month",
176+
"backgroundColour": {
177+
"color": "tertiary",
178+
"shade": {
179+
"name": "main",
180+
"value": 90
181+
}
182+
}
183+
}
184+
},
185+
{
186+
"title": "Mock Interview Programme",
187+
"description": "Mock Interview Programme is a series of short workshops that teach basic coding skills to young people.",
188+
"link": {
189+
"label": "program page",
190+
"uri": "/programmes/mock-interview-programme"
191+
},
192+
"customStyle": {
193+
"icon": "calendar_month",
194+
"backgroundColour": {
195+
"color": "tertiary",
196+
"shade": {
197+
"name": "main",
198+
"value": 90
199+
}
200+
}
201+
}
202+
},
203+
{
204+
"title": "QA Track",
205+
"description": "QA Track is a series of short workshops that teach basic coding skills to young people.",
206+
"link": {
207+
"label": "program page",
208+
"uri": "/programmes/qa-track"
209+
},
210+
"customStyle": {
211+
"icon": "calendar_month",
212+
"backgroundColour": {
213+
"color": "tertiary",
214+
"shade": {
215+
"name": "main",
216+
"value": 90
217+
}
218+
}
219+
}
220+
},
221+
{
222+
"title": "System Design Track",
223+
"description": "System Design Track is a series of short workshops that teach basic coding skills to young people.",
224+
"link": {
225+
"label": "program page",
226+
"uri": "/programmes/system-design-track"
227+
},
228+
"customStyle": {
229+
"icon": "calendar_month",
230+
"backgroundColour": {
231+
"color": "tertiary",
232+
"shade": {
233+
"name": "main",
234+
"value": 90
235+
}
236+
}
237+
}
238+
}
239+
]
240+
}
241+
}

0 commit comments

Comments
 (0)