-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Grad2-3181 V2 for Mincode and District Reports (#162)
* Part 1 - V2 endpoints for School report by mincode and district code. * Part 2 - V2 endpoints for School report by district code is completed. * Part 3 - Test cases done. * Part 4 - corrections. * Part 5 - Files structure Changes after review. * Part 6 - Fixed Test cases failures * Part 7 - Updated API responses * Part 8 - Renamed the file * Part 9 - corrected response code.
- Loading branch information
1 parent
0345668
commit 4944430
Showing
14 changed files
with
382 additions
and
16 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...ava/ca/bc/gov/educ/api/gradbusiness/controller/v2/SchoolAndDistrictReportsController.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,54 @@ | ||
package ca.bc.gov.educ.api.gradbusiness.controller.v2; | ||
|
||
import ca.bc.gov.educ.api.gradbusiness.service.GradBusinessService; | ||
import ca.bc.gov.educ.api.gradbusiness.util.EducGradBusinessApiConstants; | ||
import ca.bc.gov.educ.api.gradbusiness.util.EducGraduationApiConstants; | ||
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.info.Info; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
|
||
@CrossOrigin | ||
@RestController | ||
@RequestMapping(EducGraduationApiConstants.GRAD_BUSINESS_API_ROOT_MAPPING) | ||
@Slf4j | ||
@OpenAPIDefinition(info = @Info(title = "API for School and District reports.", description = "This Read API is for Reading school and district data from TRAX.", version = "2"), | ||
security = {@SecurityRequirement(name = "OAUTH2", scopes = {"GET_GRADUATION_DATA"})}) | ||
public class SchoolAndDistrictReportsController { | ||
|
||
private final GradBusinessService gardBusinessService; | ||
|
||
@Autowired | ||
public SchoolAndDistrictReportsController(GradBusinessService gardBusinessService) { | ||
this.gardBusinessService = gardBusinessService; | ||
} | ||
|
||
@GetMapping(EducGradBusinessApiConstants.SCHOOL_REPORT_PDF_MINCODE_V2) | ||
@PreAuthorize("hasAuthority('SCOPE_GET_GRADUATION_DATA')") | ||
@Operation(summary = "Get School Report pdf from graduation by mincode and report type", description = "Get School Report pdf from graduation by mincode and report type", tags = { "Graduation Data" }) | ||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), | ||
@ApiResponse(responseCode = "404", description = "NOT FOUND"), | ||
@ApiResponse(responseCode = "500", description = "INTERNAL SERVER ERROR.")}) | ||
public ResponseEntity<byte[]> schoolReportByMincode(@PathVariable String mincode,@RequestParam(name = "type") String type) { | ||
return gardBusinessService.getSchoolReportPDFByMincode(mincode, type); | ||
} | ||
|
||
@GetMapping(EducGradBusinessApiConstants.DISTRICT_REPORT_PDF_DISTCODE_V2) | ||
@PreAuthorize("hasAuthority('SCOPE_GET_GRADUATION_DATA')") | ||
@Operation(summary = "Get District Report pdf from graduation by distcode and report type", description = "Get District Report pdf from graduation by distcode and report type", tags = { "Graduation Data" }) | ||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), | ||
@ApiResponse(responseCode = "404", description = "NOT FOUND"), | ||
@ApiResponse(responseCode = "500", description = "INTERNAL SERVER ERROR.")}) | ||
public ResponseEntity<byte[]> districtReportByDistrictCode(@PathVariable String distcode, @RequestParam(name = "type") String type) { | ||
return gardBusinessService.getDistrictReportPDFByDistcode(distcode, type); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
api/src/main/java/ca/bc/gov/educ/api/gradbusiness/model/dto/BaseModel.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,13 @@ | ||
package ca.bc.gov.educ.api.gradbusiness.model.dto; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class BaseModel { | ||
private String createUser; | ||
private String createDate; | ||
@NotBlank(message = "updateUser must not be null or empty") | ||
private String updateUser; | ||
private String updateDate; | ||
} |
25 changes: 25 additions & 0 deletions
25
api/src/main/java/ca/bc/gov/educ/api/gradbusiness/model/dto/District.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,25 @@ | ||
package ca.bc.gov.educ.api.gradbusiness.model.dto; | ||
|
||
import lombok.*; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Data | ||
@Builder | ||
@EqualsAndHashCode(callSuper = true) | ||
@Component | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class District extends BaseModel { | ||
|
||
private String districtId; | ||
private String districtNumber; | ||
private String faxNumber; | ||
private String phoneNumber; | ||
private String email; | ||
private String website; | ||
private String displayName; | ||
private String districtRegionCode; | ||
private String districtStatusCode; | ||
|
||
|
||
} |
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
36 changes: 36 additions & 0 deletions
36
api/src/main/java/ca/bc/gov/educ/api/gradbusiness/service/DistrictService.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,36 @@ | ||
package ca.bc.gov.educ.api.gradbusiness.service; | ||
|
||
import ca.bc.gov.educ.api.gradbusiness.model.dto.District; | ||
import ca.bc.gov.educ.api.gradbusiness.util.EducGraduationApiConstants; | ||
import ca.bc.gov.educ.api.gradbusiness.util.JsonTransformer; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@Service | ||
public class DistrictService { | ||
|
||
EducGraduationApiConstants educGraduationApiConstants; | ||
final RESTService restService; | ||
JsonTransformer jsonTransformer; | ||
|
||
private static Logger logger = LoggerFactory.getLogger(DistrictService.class); | ||
|
||
@Autowired | ||
public DistrictService(RESTService restService, JsonTransformer jsonTransformer, EducGraduationApiConstants educGraduationApiConstants) { | ||
this.restService = restService; | ||
this.jsonTransformer = jsonTransformer; | ||
this.educGraduationApiConstants = educGraduationApiConstants; | ||
} | ||
|
||
public District getDistrictDetails(String distNo) { | ||
var response = this.restService.get(String.format(educGraduationApiConstants.getDistrictDetails(),distNo), District.class); | ||
return jsonTransformer.convertValue(response, new TypeReference<>() {}); | ||
} | ||
} |
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
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
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
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
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
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.