updated code

This commit is contained in:
rajesh
2025-01-14 13:13:39 +05:30
parent efcf8e7755
commit e9df9cdb44
14 changed files with 325 additions and 238 deletions

View File

@@ -7,6 +7,8 @@ import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.enums.TimePeriodEnum;
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
@@ -16,6 +18,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
public interface UserActionApi {
@Operation(summary = "Api to get user action",
responses = {
@@ -26,8 +30,20 @@ public interface UserActionApi {
@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 = "/{userId}", produces = { "application/json" })
@GetMapping(value = "/user/{userId}", produces = { "application/json" })
ResponseEntity<Response<SummaryPageResponseBean>> getUserAction(HttpServletRequest request, @Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
@Parameter(description = "Time Filter") @RequestParam(value = "timeFilter", required = false) TimePeriodEnum timeFilter,
@Parameter(description = "Action Context") @RequestParam(value = "actionContext", required = false) String actionContext);
@Parameter(description = "Action Context") @RequestParam(value = "actionContext", required = false) List<UserActionContextEnum> actionContext);
@Operation(summary = "Api to get action context label",
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 = "/user/{userId}/action-context", produces = { "application/json" })
ResponseEntity<Response<List<ActionContextLabelResponse>>> getActionContextLabels(HttpServletRequest request, @Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId);
}

View File

@@ -7,6 +7,7 @@ import net.gepafin.tendermanagement.enums.TimePeriodEnum;
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
import net.gepafin.tendermanagement.model.request.UserActionRequest;
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.UserActionService;
@@ -19,6 +20,8 @@ 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/userAction}")
public class UserActionApiController implements UserActionApi {
@@ -30,7 +33,7 @@ public class UserActionApiController implements UserActionApi {
private LoggingUtil loggingUtil;
@Override
public ResponseEntity<Response<SummaryPageResponseBean>> getUserAction(HttpServletRequest request, Long userId, TimePeriodEnum timeFilter, String actionContext) {
public ResponseEntity<Response<SummaryPageResponseBean>> getUserAction(HttpServletRequest request, Long userId, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext) {
/** This code is responsible for creating user action logs for the "get user action" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
@@ -39,5 +42,17 @@ public class UserActionApiController implements UserActionApi {
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(userActionResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_ACTION_FETCHED_SUCCESSFULLY)));
}
@Override
public ResponseEntity<Response<List<ActionContextLabelResponse>>> getActionContextLabels(HttpServletRequest request, Long userId) {
/** This code is responsible for creating user action logs for the "get user action context labels" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
.actionContext(UserActionContextEnum.GET_ACTION_CONTEXT_LABELS).build());
List<ActionContextLabelResponse> actionContextResponse= userActionService.getActionContextLabels(request,userId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(actionContextResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.ACTION_CONTEXT_LABELS_FETCHED_SUCCESSFULLY)));
}
}