-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from goelsonali/api-create-bookclub-program
Api create bookclub program
- Loading branch information
Showing
22 changed files
with
761 additions
and
30 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/com/wcc/platform/controller/ProgrammeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.wcc.platform.controller; | ||
|
||
import com.wcc.platform.domain.cms.attributes.ProgramType; | ||
import com.wcc.platform.domain.cms.pages.programme.ProgrammePage; | ||
import com.wcc.platform.service.ProgrammeService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** Rest controller for all the programme apis. */ | ||
@RestController | ||
@Tag(name = "APIs relevant Programme pages") | ||
public class ProgrammeController { | ||
|
||
private final ProgrammeService service; | ||
|
||
@Autowired | ||
public ProgrammeController(final ProgrammeService programmeService) { | ||
this.service = programmeService; | ||
} | ||
|
||
@GetMapping("/api/cms/v1/programme") | ||
@Operation(summary = "API to retrieve programme page") | ||
@ResponseStatus(HttpStatus.OK) | ||
public ResponseEntity<ProgrammePage> getProgramme( | ||
@RequestParam(name = "type") final ProgramType programmeType) { | ||
return ResponseEntity.ok(service.getProgramme(programmeType)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/com/wcc/platform/domain/cms/attributes/Card.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.wcc.platform.domain.cms.attributes; | ||
|
||
/** | ||
* Basic card details for a page or section. | ||
* | ||
* @param title of the card | ||
* @param subtitle on the card | ||
* @param description shortened description | ||
* @param link link for any external or internal resource | ||
*/ | ||
public record Card(String title, String subtitle, String description, SimpleLink link) {} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/wcc/platform/domain/cms/pages/programme/ProgrammePage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.wcc.platform.domain.cms.pages.programme; | ||
|
||
import com.wcc.platform.domain.cms.attributes.Contact; | ||
import com.wcc.platform.domain.cms.pages.Page; | ||
import com.wcc.platform.domain.platform.EventSection; | ||
import com.wcc.platform.domain.platform.Programme; | ||
import java.util.List; | ||
|
||
/** | ||
* BookClub programme details. | ||
* | ||
* @param page basic information of the page | ||
* @param contact social network contact information | ||
* @param programmeDetails programme details section | ||
* @param eventSection event details section | ||
*/ | ||
public record ProgrammePage( | ||
Page page, | ||
Contact contact, | ||
List<Programme> programmeDetails, | ||
List<EventSection> eventSection) {} | ||
// TODO Add resources section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/wcc/platform/domain/platform/EventSection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.wcc.platform.domain.platform; | ||
|
||
import com.wcc.platform.domain.cms.attributes.SimpleLink; | ||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
/** EventSection representing list of events {@link Event}. */ | ||
@Data | ||
@Builder | ||
public class EventSection { | ||
private String title; | ||
private SimpleLink link; | ||
private List<Event> events; | ||
|
||
/** | ||
* Builder for the EventSection. | ||
* | ||
* @param title like - "Upcoming Events" or "Past Events" | ||
* @param link link to the Events page | ||
* @param events list of events to show | ||
*/ | ||
public EventSection(final String title, final SimpleLink link, final List<Event> events) { | ||
this.title = title; | ||
this.link = link; | ||
this.events = events; | ||
} | ||
|
||
public EventSection() { | ||
// Necessary constructor for jackson. | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/wcc/platform/domain/platform/Programme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.wcc.platform.domain.platform; | ||
|
||
import com.wcc.platform.domain.cms.attributes.Card; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
/** Programme class representing the structure of any programme section of a programme page. */ | ||
@Data | ||
@Builder | ||
public class Programme { | ||
|
||
private String title; | ||
|
||
private String description; | ||
|
||
private Card card; | ||
|
||
/** | ||
* Programme Builder. | ||
* | ||
* @param title like - heading of the programme | ||
* @param description details co-relating the title | ||
* @param card if any details to be represented in a card | ||
*/ | ||
public Programme(final String title, final String description, final Card card) { | ||
this.title = title; | ||
this.description = description; | ||
this.card = card; | ||
} | ||
|
||
public Programme() { | ||
// Necessary constructor for jackson. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/com/wcc/platform/service/ProgrammeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.wcc.platform.service; | ||
|
||
import static com.wcc.platform.domain.cms.ApiResourcesFile.PROG_BOOK_CLUB; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.wcc.platform.domain.cms.attributes.ProgramType; | ||
import com.wcc.platform.domain.cms.pages.programme.ProgrammePage; | ||
import com.wcc.platform.domain.exceptions.PlatformInternalException; | ||
import com.wcc.platform.utils.FileUtil; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** Programme Service. */ | ||
@Service | ||
public class ProgrammeService { | ||
|
||
private final ObjectMapper objectMapper; | ||
|
||
@Autowired | ||
public ProgrammeService(final ObjectMapper objectMapper) { | ||
this.objectMapper = objectMapper; | ||
} | ||
|
||
/** | ||
* API to fetch details about different type of programmes. | ||
* | ||
* @return Programme Page json response | ||
*/ | ||
public ProgrammePage getProgramme(final ProgramType programType) { | ||
try { | ||
String data = null; | ||
if (ProgramType.BOOK_CLUB.equals(programType)) { | ||
data = FileUtil.readFileAsString(PROG_BOOK_CLUB.getFileName()); | ||
} | ||
return objectMapper.readValue(data, ProgrammePage.class); | ||
} catch (JsonProcessingException e) { | ||
throw new PlatformInternalException(e.getMessage(), e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"page": { | ||
"title": "WCC Book Club", | ||
"subtitle": "", | ||
"description": "What sets our book club apart are the lively conversations, valuable insights and an opportunity to connect with like-minded individuals. The books we read are selected by the community, offering a diverse selection of tech books and essential soft skills topics.The book club meets monthly to share views, exchange ideas, and inspire personal and professional growth." | ||
}, | ||
"contact": { | ||
"title": "Join us in our Study Group Slack channel", | ||
"links": [ | ||
{ | ||
"type": "SLACK", | ||
"link": "http://shortlink_to_slack.com/#prog_book_club" | ||
} | ||
] | ||
}, | ||
"programmeDetails": [ | ||
{ | ||
"title": "How It Works", | ||
"description": "Every month we vote for a book to read, and at the end of the month we review the book together in our bookclub. In order to participate join us n slack.", | ||
"card": null | ||
}, | ||
{ | ||
"title": "Benefits of Joining", | ||
"description": "Dedication, networking and always knowing what is happening in tech market.", | ||
"card": null | ||
}, | ||
{ | ||
"title": "What We Are Reading", | ||
"description": "", | ||
"card": { | ||
"title": "The Pragmatic Programmer From Journeyman to Master", | ||
"subtitle": "Andrew Hunt & David Thomas", | ||
"description": "Essential guide for creating working and maintainable code amidst the complexities of modern software development.", | ||
"link": { | ||
"label": "View Book On GoodReads", | ||
"uri": "http://goodread/book_link" | ||
} | ||
} | ||
} | ||
], | ||
"eventSection": [ | ||
{ | ||
"title": "Upcoming events", | ||
"link": { | ||
"label": "View past events", | ||
"uri": "/eventsPage_link" | ||
}, | ||
"events": [ | ||
{ | ||
"topics": "BOOK_CLUB", | ||
"startDate": "THU, MAY 30, 2024, 8:00 PM CEST", | ||
"endDate": "THU, MAY 30, 2024, 9.30 CEST", | ||
"title": "BOOK MONTH AUG", | ||
"description": "Book description", | ||
"hostProfile": { | ||
"label": "Jane Doe", | ||
"uri": "https://linkedIn/host" | ||
}, | ||
"eventLink": { | ||
"label": "Go to Meetup Event", | ||
"uri": "https://meetup.com/event1" | ||
} | ||
}, | ||
{ | ||
"topics": "BOOK_CLUB", | ||
"startDate": "THU, MAY 30, 2024, 8:00 PM CEST", | ||
"endDate": "THU, MAY 30, 2024, 9.30 CEST", | ||
"title": "BOOK MONTH SEP", | ||
"description": "Book description", | ||
"speakerProfile": { | ||
"label": "Jane Doe", | ||
"uri": "https://linkedIn/host" | ||
}, | ||
"eventLink": { | ||
"label": "Go to Meetup Event", | ||
"uri": "https://meetup.com/event1" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.