Added get all document category api
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jdk.jfr.Category;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.DocumentCategoryEntity;
|
||||
@@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@@ -108,4 +110,11 @@ public class DocumentCategoryDao {
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<DocumentCategoryResponse> getAllDocumentCategory(){
|
||||
List<DocumentCategoryEntity> documentCategoryEntityList = categoryRepository.findAll();
|
||||
return documentCategoryEntityList.stream()
|
||||
.map(this::convertToResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,6 +207,7 @@ public enum UserActionContextEnum {
|
||||
DELETE_DOCUMENT_CATEGORY("DELETE_DOCUMENT_CATEGORY"),
|
||||
UPDATE_DOCUMENT_CATEGORY("UPDATE_DOCUMENT_CATEGORY"),
|
||||
COMPANY_DOCUMENT_EXPIRATION_SCHEDULER("COMPANY_DOCUMENT_EXPIRATION_SCHEDULER"),
|
||||
GET_ALL_DOCUMENT_CATEGORY("GET_ALL_DOCUMENT_CATEGORY"),
|
||||
|
||||
GET_ALL_ASSIGNED_APPLICATION_BY_PAGINATION("GET_ALL_ASSIGNED_APPLICATION_BY_PAGINATION"),
|
||||
GET_ALL_APPLICATION_AMENDMENT_BY_PAGINATION("GET_ALL_APPLICATION_AMENDMENT_BY_PAGINATION"),
|
||||
|
||||
@@ -4,10 +4,13 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.model.request.DocumentCategoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentCategoryResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DocumentCategoryService {
|
||||
|
||||
DocumentCategoryResponse createDocumentCategory(HttpServletRequest request, DocumentCategoryRequest categoryRequest);
|
||||
DocumentCategoryResponse getDocumentCategoryById(HttpServletRequest request, Long id);
|
||||
void deleteDocumentCategory(HttpServletRequest request,Long id);
|
||||
DocumentCategoryResponse updateDocumentCategory(HttpServletRequest request, Long id, DocumentCategoryRequest categoryRequest);
|
||||
List<DocumentCategoryResponse> getAllDocumentCategory(HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DocumentCategoryServiceImpl implements DocumentCategoryService {
|
||||
|
||||
@@ -47,5 +49,11 @@ public class DocumentCategoryServiceImpl implements DocumentCategoryService {
|
||||
return categoryDao.updateDocumentCategory(request,id,categoryRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DocumentCategoryResponse> getAllDocumentCategory(HttpServletRequest request) {
|
||||
validator.validateUser(request);
|
||||
return categoryDao.getAllDocumentCategory();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Validated
|
||||
public interface DocumentCategoryApi {
|
||||
|
||||
@@ -79,4 +81,16 @@ public interface DocumentCategoryApi {
|
||||
@PathVariable("id") Long id,
|
||||
@Parameter(description = "Category request object", required = true)
|
||||
@Valid @RequestBody DocumentCategoryRequest categoryRequest);
|
||||
|
||||
@Operation(summary = "Api to get all document category",
|
||||
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<DocumentCategoryResponse>>> getAllDocumentCategory(HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
@@ -20,8 +21,11 @@ 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/documentCategory}")
|
||||
@Log4j2
|
||||
public class DocumentCategoryApiController implements DocumentCategoryApi {
|
||||
|
||||
@Autowired
|
||||
@@ -79,4 +83,18 @@ public class DocumentCategoryApiController implements DocumentCategoryApi {
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(categoryResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_CATEGORY_UPDATE_SUCCESS)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<List<DocumentCategoryResponse>>> getAllDocumentCategory(HttpServletRequest request) {
|
||||
log.info("Get All Document Category");
|
||||
|
||||
/** This code is responsible for creating user action logs for the "get all document category" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_ALL_DOCUMENT_CATEGORY).build());
|
||||
|
||||
List<DocumentCategoryResponse> documentCategoryResponseList = categoryService.getAllDocumentCategory(request);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(documentCategoryResponseList, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_CATEGORY_GET_SUCCESS)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user