Resolved conflicts

This commit is contained in:
rajesh
2024-08-28 15:38:56 +05:30
85 changed files with 2713 additions and 578 deletions

View File

@@ -1,5 +1,17 @@
package net.gepafin.tendermanagement.web.rest.api;
import java.util.List;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
@@ -9,15 +21,11 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
import net.gepafin.tendermanagement.model.response.CreateCallResponseBean;
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
import net.gepafin.tendermanagement.model.response.CallDetailsResponseBean;
import net.gepafin.tendermanagement.model.response.CallResponse;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@Validated
public interface CallApi {
@@ -34,7 +42,7 @@ public interface CallApi {
})
@PostMapping(value = "/step1", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep1(HttpServletRequest request,
public ResponseEntity<Response<CallResponse>> createCallStep1(HttpServletRequest request,
@Parameter(description = "Call request object", required = true)
@Valid @RequestBody CreateCallRequestStep1 createCallRequest);
@@ -48,10 +56,69 @@ public interface CallApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
})
@PostMapping(value = "/step2", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@PutMapping(value = "/step2/{callId}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep2(HttpServletRequest request,
@Parameter(description = "Call request object", required = true)
@Valid @RequestBody CreateCallRequestStep2 createCallRequest);
public ResponseEntity<Response<CallResponse>> createCallStep2(HttpServletRequest request,
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId,
@Parameter(description = "Call request object", required = true) @Valid @RequestBody CreateCallRequestStep2 createCallRequest);
@Operation(summary = "Api to update call step 1",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
})
@PutMapping(value = "/step1/{callId}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
public ResponseEntity<Response<CallResponse>> updateCallStep1(HttpServletRequest request,
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId,
@Parameter(description = "Call request object", required = true) @Valid @RequestBody UpdateCallRequestStep1 updateCallRequest);
@Operation(summary = "Api to get call by id",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "/{callId}",
produces = { "application/json" })
ResponseEntity<Response<CallResponse>> getCallById(
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);
@Operation(summary = "Api to get all calls",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "",
produces = { "application/json" })
ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls();
@Operation(summary = "Api to validate call",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
})
@PostMapping(value = "/validate/{callId}", produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
public ResponseEntity<Response<CallResponse>> validateCall(HttpServletRequest request,
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId);
}

View File

@@ -1,6 +1,7 @@
package net.gepafin.tendermanagement.web.rest.api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
@@ -27,14 +28,12 @@ public interface DocumentApi {
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
})
@PostMapping(value = "/uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
default ResponseEntity<Response<List<DocumentResponseBean>>> uploadFile(HttpServletRequest httpServletRequest,
@RequestParam("file") List<MultipartFile> files,
@RequestParam("documentType") DocumentTypeEnum documentTypeEnum) {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))})
@PostMapping(value = "/uploadFile/call/{callId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
default ResponseEntity<Response<List<DocumentResponseBean>>> uploadFile(HttpServletRequest httpServletRequest, @Parameter(description = "call id", required = true) @PathVariable Long callId, @RequestParam("file") List<MultipartFile> files, @RequestParam("documentType") DocumentTypeEnum documentTypeEnum) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
@Operation(summary = "API to delete a file by document id",
responses = {
@ApiResponse(responseCode = "200", description = "File deleted successfully"),
@@ -50,4 +49,30 @@ public interface DocumentApi {
@RequestParam( "id") Long id) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
@Operation(summary = "Api to update document",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))})
@PutMapping(value = "/{id}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
default ResponseEntity<Response<DocumentResponseBean>> updateDocument(HttpServletRequest httpServletRequest, @Parameter(description = "document id", required = true) @PathVariable Long documentId, @RequestParam("file") MultipartFile file, @RequestParam("documentType") DocumentTypeEnum documentTypeEnum) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
@Operation(summary = "API to get document by id",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) }))
})
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<DocumentResponseBean>> getDocumentById(HttpServletRequest request,
@Parameter(description = "document id", required = true)
@PathVariable Long id);
}

View File

@@ -0,0 +1,78 @@
package net.gepafin.tendermanagement.web.rest.api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import net.gepafin.tendermanagement.model.request.EvaluationCriteriaRequest;
import net.gepafin.tendermanagement.model.response.EvaluationCriteriaResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
public interface EvaluationCriteriaApi {
@Operation(summary = "Api to create evaluation criteria",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
})
@PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<EvaluationCriteriaResponseBean>> createEvaluationCriteria(HttpServletRequest request,
@Parameter(description = "Evaluation criteria request object", required = true)
@Valid @RequestBody EvaluationCriteriaRequest createCallRequest);
@Operation(summary = "Api to get evaluation criteria by id",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) }))
})
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<EvaluationCriteriaResponseBean>> getEvaluationCriteriaById(HttpServletRequest request,
@Parameter(description = "evaluation criteria id", required = true)
@PathVariable Long id);
@Operation(summary = "API to update evaluation criteria",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
})
@PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<EvaluationCriteriaResponseBean>> updateEvaluationCriteria(HttpServletRequest request,
@Parameter(description = "evaluation criteria id", required = true)
@PathVariable Long id,
@Parameter(description = "Evaluation criteria request object", required = true)
@Valid @RequestBody EvaluationCriteriaRequest evaluationCriteriaRequest);
@Operation(summary = "API to delete evaluation criteria",
responses = {
@ApiResponse(responseCode = "204", description = "No Content"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) }))
})
@DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Void> deleteEvaluationCriteria(HttpServletRequest request,
@Parameter(description = "evaluation criteria id", required = true)
@PathVariable Long id);
}

View File

@@ -0,0 +1,57 @@
package net.gepafin.tendermanagement.web.rest.api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import net.gepafin.tendermanagement.model.request.FaqReq;
import net.gepafin.tendermanagement.model.response.FaqResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import jakarta.servlet.http.HttpServletRequest;
import javax.validation.Valid;
public interface FaqApi {
@Operation(summary = "API to create FAQ",
responses = {
@ApiResponse(responseCode = "201", description = "Created"),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Bad Request\" }"))),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Unauthorized\" }"))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Not Found\" }")))
})
@PostMapping(value = "/call/{callId}", consumes = "application/json", produces = "application/json")
ResponseEntity<Response<FaqResponseBean>> createFaq(HttpServletRequest request, @Parameter(description = "evaluation criteria id", required = true)
@PathVariable Long id, @Valid @RequestBody FaqReq faqRequest);
@Operation(summary = "API to get FAQ by id",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Not Found\" }")))
})
@GetMapping(value = "/{id}", produces = "application/json")
ResponseEntity<Response<FaqResponseBean>> getFaqById(HttpServletRequest request,
@PathVariable Long id);
@Operation(summary = "API to update FAQ",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Not Found\" }"))),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Bad Request\" }")))
})
@PutMapping(value = "/{id}", consumes = "application/json", produces = "application/json")
ResponseEntity<Response<FaqResponseBean>> updateFaq(HttpServletRequest request,
@PathVariable Long id,
@Valid @RequestBody FaqReq faqRequest);
@Operation(summary = "API to delete FAQ",
responses = {
@ApiResponse(responseCode = "204", description = "No Content"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Not Found\" }")))
})
@DeleteMapping(value = "/{id}")
ResponseEntity<Response<Void>> deleteFaq(HttpServletRequest request,
@PathVariable Long id);
}

View File

@@ -0,0 +1,81 @@
package net.gepafin.tendermanagement.web.rest.api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
import net.gepafin.tendermanagement.model.request.LookUpDataRequest;
import net.gepafin.tendermanagement.model.response.LookUpDataResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import jakarta.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
public interface LookUpDataApi {
@Operation(summary = "Api to create LookUp Data",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
@PostMapping(value = "", consumes = "application/json", produces = "application/json")
ResponseEntity<Response<LookUpDataResponseBean>> createLookUpData(HttpServletRequest request, @Valid @RequestBody LookUpDataRequest lookUpDataReq);
@Operation(summary = "Api to get LookUp Data by id",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
@GetMapping(value = "/{id}", produces = "application/json")
ResponseEntity<Response<LookUpDataResponseBean>> getLookUpDataById(HttpServletRequest request, @PathVariable Long id);
@Operation(summary = "Api to update LookUp Data",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
@PutMapping(value = "/{id}", consumes = "application/json", produces = "application/json")
ResponseEntity<Response<LookUpDataResponseBean>> updateLookUpData(HttpServletRequest request, @PathVariable Long id, @Valid @RequestBody LookUpDataRequest lookUpDataReq);
@Operation(summary = "Api to delete LookUp Data",
responses = {
@ApiResponse(responseCode = "204", description = "No Content"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
@DeleteMapping(value = "/{id}")
ResponseEntity<Response<Void>> deleteLookUpData(HttpServletRequest request, @PathVariable Long id);
@Operation(summary = "Api to get LookUp Data by type",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
@GetMapping(value = "/type", produces = "application/json")
ResponseEntity<Response<List<LookUpDataResponseBean>>> getLookUpDataByType(HttpServletRequest request, @RequestParam LookUpDataTypeEnum type);
}

View File

@@ -61,7 +61,7 @@ public interface RegionApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "/{regionId}", produces = "application/json")
ResponseEntity<Response<RegionEntity>> getRegionById(
ResponseEntity<Response<RegionResponseBean>> getRegionById(
@Parameter(description = "The region id", required = true) @PathVariable("regionId") Long regionId);
@Operation(summary = "Api to get all regions",

View File

@@ -62,7 +62,7 @@ public interface RoleApi {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "/{roleId}",
produces = { "application/json" })
ResponseEntity<Response<RoleEntity>> getRoleById(
ResponseEntity<Response<RoleResponseBean>> getRoleById(
@Parameter(description = "The role ID", required = true) @PathVariable("roleId") Long roleId);
@Operation(summary = "Api to get all roles",

View File

@@ -5,10 +5,12 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import net.gepafin.tendermanagement.model.request.LoginReq;
import net.gepafin.tendermanagement.model.request.UpdateUserReq;
import net.gepafin.tendermanagement.model.request.UserReq;
import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.enums.UserStatusEnum;
import net.gepafin.tendermanagement.model.request.*;
import net.gepafin.tendermanagement.model.response.UserResponseBean;
import net.gepafin.tendermanagement.model.util.JWTToken;
import net.gepafin.tendermanagement.model.util.Response;
@@ -18,10 +20,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.*;
@Validated
public interface UserApi {
@@ -105,4 +104,77 @@ public interface UserApi {
method = RequestMethod.POST)
ResponseEntity<Response<JWTToken>> login(
@Parameter(description = "Login request object", required = true) @Valid @RequestBody LoginReq loginReq);
@Operation(summary = "Api to initiate password reset request",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
@RequestMapping(value = "/reset-password/initiate",
produces = {"application/json"},
method = RequestMethod.POST)
ResponseEntity<Response<String>> initiatePasswordReset(
@Parameter(description = "Initiate password reset request object", required = true) @Valid @RequestBody InitiatePasswordResetReq initiatePasswordResetReq);
@Operation(summary = "Api to reset password",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
@RequestMapping(value = "/reset-password",
produces = {"application/json"},
method = RequestMethod.POST)
ResponseEntity<Response<Boolean>> resetPassword(
@Parameter(description = "Reset password request object", required = true) @Valid @RequestBody ResetPasswordReq resetPasswordReq);
@Operation(summary = "Api to change user password",
responses = {
@ApiResponse(responseCode = "200", description = "Password Changed Successfully", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = "{ \"message\": \"Password changed successfully.\" }")})),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
@RequestMapping(value = "/change-password",
produces = {"application/json"},
method = RequestMethod.POST)
ResponseEntity<Response<Boolean>> changePassword(
@Parameter(description = "Change password request object", required = true) @Valid @RequestBody ChangePasswordRequest changePasswordRequest); @Operation(summary = "Api to logout user",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
@RequestMapping(value = "/logout",
method = RequestMethod.POST)
ResponseEntity<Response<Void>> logoutUser(
@Parameter(description = "The request object is not needed for logout", required = false) HttpServletRequest request,
@Parameter(description = "The response object is not needed for logout", required = false) HttpServletResponse response);
@Operation(summary = "Api to update user active/deactive status",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))
})
@RequestMapping(value = "/{userId}/status",
produces = {"application/json"},
method = RequestMethod.PUT)
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
default ResponseEntity<Response<UserResponseBean>> updateUserStatus(
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) UserStatusEnum status) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
}

View File

@@ -0,0 +1,27 @@
package net.gepafin.tendermanagement.web.rest.api.errors;
import java.util.List;
public class ValidationException extends CustomValidationException {
private final Status status;
private static final long serialVersionUID = 1L;
private final List<String> errors;
public ValidationException(Status status, List<String> errors) {
super(status, errors.toString());
this.errors = errors;
this.status = status;
}
public List<String> getErrors() {
return errors;
}
public Status getStatus() {
return status;
}
}

View File

@@ -1,15 +1,7 @@
package net.gepafin.tendermanagement.web.rest.api.impl;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
import net.gepafin.tendermanagement.model.response.CreateCallResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.CallService;
import net.gepafin.tendermanagement.web.rest.api.CallApi;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -17,6 +9,19 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
import net.gepafin.tendermanagement.model.response.CallDetailsResponseBean;
import net.gepafin.tendermanagement.model.response.CallResponse;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.CallService;
import net.gepafin.tendermanagement.web.rest.api.CallApi;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
@RestController
@RequestMapping("${openapi.gepafin.base-path:/v1/call}")
@@ -28,17 +33,49 @@ public class CallApiController implements CallApi {
@Override
@Transactional(rollbackFor=Exception.class)
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest) {
CreateCallResponseBean createCallResponseBean = callService.createCallStep1(request, createCallRequest);
public ResponseEntity<Response<CallResponse>> createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest) {
CallResponse createCallResponseBean = callService.createCallStep1(request, createCallRequest);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(createCallResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_CREATED_SUCCESSFULLY_MSG)));
}
@Override
@Transactional(rollbackFor=Exception.class)
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep2(HttpServletRequest request, CreateCallRequestStep2 createCallRequest) {
CreateCallResponseBean createCallResponseBean = callService.createCallStep2(request, createCallRequest);
public ResponseEntity<Response<CallResponse>> createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest) {
CallResponse createCallResponseBean = callService.createCallStep2(request, callId, createCallRequest);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(createCallResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_CREATED_SUCCESSFULLY_MSG)));
}
@Override
@Transactional(rollbackFor=Exception.class)
public ResponseEntity<Response<CallResponse>> updateCallStep1(HttpServletRequest request, Long callId, UpdateCallRequestStep1 updateCallRequest) {
CallResponse createCallResponseBean = callService.updateCallStep1(request, callId, updateCallRequest);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(createCallResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_UPDATE_SUCCESSFULLY_MSG)));
}
@Override
@Transactional(readOnly = true)
public ResponseEntity<Response<CallResponse>> getCallById(Long callId) {
CallResponse createCallResponseBean = callService.getCallById(callId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(createCallResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));
}
@Override
@Transactional(readOnly = true)
public ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls() {
List<CallDetailsResponseBean> calls = callService.getAllCalls();
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(calls, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));
}
@Override
public ResponseEntity<Response<CallResponse>> validateCall(HttpServletRequest request, Long callId) {
CallResponse call = callService.validateCall(callId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(call, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));
}
}

View File

@@ -20,16 +20,17 @@ import java.util.List;
@RestController
@RequestMapping("${openapi.swaggerBflowsMiddleware.base-path:/v1/document}")
public class DocumentApiController implements DocumentApi {
public class
DocumentApiController implements DocumentApi {
@Autowired
private DocumentService fileService;
private DocumentService documentService;
@Override
public ResponseEntity<Response<List<DocumentResponseBean>>> uploadFile(HttpServletRequest httpServletRequest,
List<MultipartFile> files, DocumentTypeEnum fileType) {
public ResponseEntity<Response<List<DocumentResponseBean>>> uploadFile(HttpServletRequest httpServletRequest, Long callId,
List<MultipartFile> files, DocumentTypeEnum fileType) {
try {
List<DocumentResponseBean> responseBeans=fileService.uploadFile(files,fileType);
List<DocumentResponseBean> responseBeans = documentService.uploadFile(files, callId, fileType);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<List<DocumentResponseBean>>(responseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.FILES_UPLOADED_MSG)));
} catch (CustomValidationException ex) {
@@ -38,8 +39,22 @@ public class DocumentApiController implements DocumentApi {
}
@Override
public ResponseEntity<Response<Void>> deleteFile(HttpServletRequest httpServletRequest, Long documentId) {
fileService.deleteFile(documentId);
documentService.deleteFile(documentId);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<Void>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.FILE_DELETED_SUCCESSFULLY_MSG)));
}
}
@Override
public ResponseEntity<Response<DocumentResponseBean>> updateDocument(HttpServletRequest httpServletRequest, Long documentId, MultipartFile file, DocumentTypeEnum documentTypeEnum) {
DocumentResponseBean responseBeans = documentService.updateDocument(httpServletRequest, documentId, file, documentTypeEnum);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<DocumentResponseBean>(responseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_UPDATED_SUCCESSFULLY)));
}
@Override
public ResponseEntity<Response<DocumentResponseBean>> getDocumentById(HttpServletRequest request, Long id) {
DocumentResponseBean documentResponseBean= documentService.getDocument(request,id);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<DocumentResponseBean>(documentResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_FETCHED_SUCCESSFULLY)));
}
}

View File

@@ -0,0 +1,66 @@
package net.gepafin.tendermanagement.web.rest.api.impl;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.model.request.EvaluationCriteriaRequest;
import net.gepafin.tendermanagement.model.response.EvaluationCriteriaResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.EvaluationCriteriaService;
import net.gepafin.tendermanagement.web.rest.api.EvaluationCriteriaApi;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("${openapi.gepafin.base-path:/v1/evaluationCriteria}")
public class EvaluationCriteriaApiController implements EvaluationCriteriaApi {
@Autowired
private EvaluationCriteriaService service;
@Override
public ResponseEntity<Response<EvaluationCriteriaResponseBean>> createEvaluationCriteria(HttpServletRequest request, EvaluationCriteriaRequest evaluationCriteriaRequest) {
EvaluationCriteriaResponseBean responseBean = service.createEvaluationCriteria(request,evaluationCriteriaRequest);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_CREATED_SUCCESSFULLY)));
}
@Override
public ResponseEntity<Response<EvaluationCriteriaResponseBean>> getEvaluationCriteriaById(HttpServletRequest request, Long id) {
EvaluationCriteriaResponseBean responseBean = service.getEvaluationCriteria(request,id);
if (responseBean != null) {
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_FETCH_SUCCESSFULLY)));
} else {
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Response<>(null, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_NOT_FOUND)));
}
}
@Override
@Transactional(rollbackFor=Exception.class)
public ResponseEntity<Response<EvaluationCriteriaResponseBean>> updateEvaluationCriteria(HttpServletRequest request, Long id, EvaluationCriteriaRequest evaluationCriteriaRequest) {
EvaluationCriteriaResponseBean responseBean = service.updateEvaluationCriteria(request,id, evaluationCriteriaRequest);
if (responseBean != null) {
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_UPDATED_SUCCESSFULLY)));
} else {
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Response<>(null, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_NOT_FOUND)));
}
}
@Override
public ResponseEntity<Void> deleteEvaluationCriteria(HttpServletRequest request, Long id) {
service.deleteEvaluationCriteria(request,id);
return ResponseEntity.status(HttpStatus.OK)
.header("Message", Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_DELETED_SUCCESSFULLY))
.build();
}
}

View File

@@ -0,0 +1,61 @@
package net.gepafin.tendermanagement.web.rest.api.impl;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.model.request.FaqReq;
import net.gepafin.tendermanagement.model.response.FaqResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.FaqService;
import net.gepafin.tendermanagement.web.rest.api.FaqApi;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("${openapi.gepafin.base-path:/v1/faq}")
public class FaqApiController implements FaqApi {
@Autowired
private FaqService faqService;
@Override
public ResponseEntity<Response<FaqResponseBean>> createFaq(HttpServletRequest request, Long callId,FaqReq faqRequest) {
FaqResponseBean response = faqService.createFaq(request,callId, faqRequest);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.FAQ_CREATED_SUCCESSFULLY)));
}
@Override
public ResponseEntity<Response<FaqResponseBean>> getFaqById(HttpServletRequest request, Long id) {
FaqResponseBean response = faqService.getFaqById(request, id);
if (response != null) {
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.FAQ_FETCHED_SUCCESSFULLY)));
} else {
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Response<>(null, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.FAQ_NOT_FOUND)));
}
}
@Override
public ResponseEntity<Response<FaqResponseBean>> updateFaq(HttpServletRequest request, Long id, FaqReq faqRequest) {
FaqResponseBean response = faqService.updateFaq(request, id, faqRequest);
if (response != null) {
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.FAQ_UPDATED_SUCCESSFULLY)));
} else {
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Response<>(null, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.FAQ_NOT_FOUND)));
}
}
@Override
public ResponseEntity<Response<Void>> deleteFaq(HttpServletRequest request, Long id) {
faqService.deleteFaq(request, id);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.FAQ_DELETED_SUCCESSFULLY)));
}
}

View File

@@ -0,0 +1,76 @@
package net.gepafin.tendermanagement.web.rest.api.impl;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
import net.gepafin.tendermanagement.model.request.LookUpDataRequest;
import net.gepafin.tendermanagement.model.response.LookUpDataResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.LookUpDataService;
import net.gepafin.tendermanagement.web.rest.api.LookUpDataApi;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("${openapi.gepafin.base-path:/v1/lookUpData}")
public class LookUpDataApiController implements LookUpDataApi {
@Autowired
private LookUpDataService lookUpDataService;
@Override
public ResponseEntity<Response<LookUpDataResponseBean>> createLookUpData(HttpServletRequest request, LookUpDataRequest lookUpDataReq) {
LookUpDataResponseBean responseBean = lookUpDataService.createLookUpData(lookUpDataReq);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<LookUpDataResponseBean>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOOKUP_DATA_CREATED_SUCCESSFULLY)));
}
@Override
public ResponseEntity<Response<LookUpDataResponseBean>> getLookUpDataById(HttpServletRequest request, Long id) {
LookUpDataResponseBean responseBean = lookUpDataService.getLookUpDataById(id);
if (responseBean != null) {
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<LookUpDataResponseBean>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOOKUP_DATA_FETCHED_SUCCESSFULLY)));
} else {
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Response<LookUpDataResponseBean>(responseBean, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.LOOKUP_DATA_NOT_FOUND)));
}
}
@Override
public ResponseEntity<Response<LookUpDataResponseBean>> updateLookUpData(HttpServletRequest request, Long id, LookUpDataRequest lookUpDataReq) {
LookUpDataResponseBean responseBean = lookUpDataService.updateLookUpData(id, lookUpDataReq);
if (responseBean != null) {
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<LookUpDataResponseBean>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOOKUP_DATA_UPDATED_SUCCESSFULLY)));
} else {
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Response<LookUpDataResponseBean>(responseBean, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.LOOKUP_DATA_NOT_FOUND)));
}
}
@Override
public ResponseEntity<Response<Void>> deleteLookUpData(HttpServletRequest request, Long id) {
lookUpDataService.deleteLookUpData(id);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOOKUP_DATA_DELETED_SUCCESSFULLY)));
}
@Override
public ResponseEntity<Response<List<LookUpDataResponseBean>>> getLookUpDataByType(HttpServletRequest request, LookUpDataTypeEnum type) {
List<LookUpDataResponseBean> responseBean = lookUpDataService.getLookUpDataByType(type);
if (responseBean != null) {
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<List<LookUpDataResponseBean>>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOOKUP_DATA_FETCHED_SUCCESSFULLY)));
} else {
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Response<List<LookUpDataResponseBean>>(responseBean, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.LOOKUP_DATA_NOT_FOUND)));
}
}
}

View File

@@ -52,10 +52,10 @@ public class RegionApiController implements RegionApi {
}
@Override
public ResponseEntity<Response<RegionEntity>> getRegionById(
public ResponseEntity<Response<RegionResponseBean>> getRegionById(
@PathVariable("regionId") Long regionId) {
log.info("Get Region by ID - Region ID: {}", regionId);
RegionEntity region = regionService.getRegionById(regionId);
RegionResponseBean region = regionService.getRegionById(regionId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(region, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_REGION_SUCCESS_MSG)));
}

View File

@@ -57,11 +57,11 @@ public class RoleApiController implements RoleApi {
}
@Override
public ResponseEntity<Response<RoleEntity>> getRoleById(Long roleId) {
public ResponseEntity<Response<RoleResponseBean>> getRoleById(Long roleId) {
log.info("Get Role by ID - Role ID: {}", roleId);
RoleEntity roleEntity = roleService.getRoleById(roleId);
RoleResponseBean roleResponseBean = roleService.getRoleById(roleId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(roleEntity, Status.SUCCESS, Translator.toLocale(GepafinConstant.ROLE_FETCH_SUCCESS_MSG)));
.body(new Response<>(roleResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.ROLE_FETCH_SUCCESS_MSG)));
}
@Override

View File

@@ -1,17 +1,19 @@
package net.gepafin.tendermanagement.web.rest.api.impl;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.config.jwt.TokenProvider;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.model.request.LoginReq;
import net.gepafin.tendermanagement.model.request.UpdateUserReq;
import net.gepafin.tendermanagement.model.request.UserReq;
import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.enums.UserStatusEnum;
import net.gepafin.tendermanagement.model.request.*;
import net.gepafin.tendermanagement.model.response.UserResponseBean;
import net.gepafin.tendermanagement.model.util.JWTToken;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.UserService;
import net.gepafin.tendermanagement.web.rest.api.UserApi;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -27,7 +29,8 @@ import org.springframework.web.bind.annotation.*;
public class UserApiController implements UserApi {
private final Logger log = LoggerFactory.getLogger(UserApiController.class);
@Autowired
private TokenProvider tokenProvider;
@Autowired
private UserService userService;
@@ -74,4 +77,46 @@ public class UserApiController implements UserApi {
JWTToken jwtToken = userService.login(loginReq);
return ResponseEntity.ok(new Response<>(jwtToken, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOGIN_SUCCESS_MSG)));
}
}
@Override
public ResponseEntity<Response<Boolean>> changePassword(@Valid @RequestBody ChangePasswordRequest request) {
log.info("Change Password attempt for email: {}", request.getEmail());
userService.changePassword(request);
return ResponseEntity.ok(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.SUCCESS_PASSWORD_CHANGED)));
}
@Override
public ResponseEntity<Response<String>> initiatePasswordReset(InitiatePasswordResetReq request) {
log.info("Initiating password reset for email: {}", request.getEmail());
String resetToken = userService.initiatePasswordReset(request);
log.info("Password reset token generated for email: {}", request.getEmail());
return ResponseEntity.ok(new Response<>(resetToken, Status.SUCCESS, Translator.toLocale(GepafinConstant.RESET_PASSWORD_INITIATED)));
}
@Override
public ResponseEntity<Response<Boolean>> resetPassword(ResetPasswordReq request) {
log.info("Resetting password for username: {}", request.getEmail());
Boolean success = userService.resetPassword(request);
if (success) {
log.info("Password reset successfully for username: {}", request.getEmail());
} else {
log.error("Password reset failed for username: {}", request.getEmail());
}
return ResponseEntity.ok(new Response<>(success, Status.SUCCESS, Translator.toLocale(GepafinConstant.PASSWORD_RESET_SUCCESS)));
}
@Override
public ResponseEntity<Response<Void>> logoutUser(HttpServletRequest request, HttpServletResponse response) {
userService.logoutUser(request, response);
log.info("User has successfully logged");
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOGOUT_SUCCESSFUL_MSG)));
}
@Override
public ResponseEntity<Response<UserResponseBean>> updateUserStatus(@PathVariable Long userId, @RequestParam UserStatusEnum status) {
log.info("Update User Status for- User ID: {}, Request Body: {}", userId, status);
UserResponseBean updatedUser = userService.updateUserStatus(userId, status);
return ResponseEntity.ok(new Response<>(updatedUser, Status.SUCCESS, Translator.toLocale(GepafinConstant.UPDATE_USER_STATUS_SUCCESS_MSG)));
}
}