Updated code

This commit is contained in:
nisha
2025-02-17 15:42:11 +05:30
parent 48b6b148c0
commit 2304e1cc72
8 changed files with 29 additions and 28 deletions

View File

@@ -47,17 +47,14 @@ public class UserActionDao {
@Autowired @Autowired
private RoleActionContextRepository roleActionContextRepository; private RoleActionContextRepository roleActionContextRepository;
public SummaryPageResponseBean getUserAction(HttpServletRequest request, UserEntity userEntity, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext){ public SummaryPageResponseBean getUserAction(HttpServletRequest request, UserEntity userEntity){
Long numberOfLoginAttempts = userActionsRepository.countUserLoginAttempts(userEntity.getId()); Long numberOfLoginAttempts = userActionsRepository.countUserLoginAttempts(userEntity.getId());
Long applicationsProcessed = assignedApplicationsRepository.countAssignedApplicationsByUserId(userEntity.getId()); Long applicationsProcessed = assignedApplicationsRepository.countAssignedApplicationsByUserId(userEntity.getId());
List<UserActionEntity> userActions = getFilterUserActions(userEntity.getId(),timeFilter,actionContext); return createSummaryPageResponse(userEntity,numberOfLoginAttempts,applicationsProcessed);
return null;
// createSummaryPageResponse(userEntity,numberOfLoginAttempts,applicationsProcessed,userActions);
} }
public SummaryPageResponseBean createSummaryPageResponse(UserEntity user, Long numberOfLoginAttempts, Long applicationsProcessed,PageableResponseBean<List<UserActionResponseBean>> userActions){ public SummaryPageResponseBean createSummaryPageResponse(UserEntity user, Long numberOfLoginAttempts, Long applicationsProcessed){
SummaryPageResponseBean response = new SummaryPageResponseBean(); SummaryPageResponseBean response = new SummaryPageResponseBean();
response.setRole(user.getRoleEntity().getRoleName()); response.setRole(user.getRoleEntity().getRoleName());
response.setLastLogin(user.getLastLogin()); response.setLastLogin(user.getLastLogin());
@@ -66,7 +63,6 @@ public class UserActionDao {
response.setEmail(user.getEmail()); response.setEmail(user.getEmail());
response.setNumberOfLoginAttempts(numberOfLoginAttempts); response.setNumberOfLoginAttempts(numberOfLoginAttempts);
response.setApplicationsProcessed(applicationsProcessed); response.setApplicationsProcessed(applicationsProcessed);
response.setUserActions(userActions);
return response; return response;
} }
@@ -162,7 +158,7 @@ public class UserActionDao {
return responseBean; return responseBean;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
public SummaryPageResponseBean getUserActionByPagination(UserEntity user, UserActionPaginationRequest userActionPaginationRequest) { public PageableResponseBean<List<UserActionResponseBean>> getUserActionByPagination(UserEntity user, UserActionPaginationRequest userActionPaginationRequest) {
Integer pageNo = null; Integer pageNo = null;
Integer pageLimit = null; Integer pageLimit = null;
if (userActionPaginationRequest.getGlobalFilters() != null) { if (userActionPaginationRequest.getGlobalFilters() != null) {
@@ -192,7 +188,7 @@ public class UserActionDao {
pageableResponseBean.setTotalRecords(entityPage.getTotalElements()); pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
pageableResponseBean.setPageSize(entityPage.getSize()); pageableResponseBean.setPageSize(entityPage.getSize());
return createSummaryPageResponse(user,numberOfLoginAttempts,applicationsProcessed,pageableResponseBean); return pageableResponseBean;
} }
public Specification<UserActionEntity> search(UserActionPaginationRequest userActionPaginationRequest,UserEntity userEntity) { public Specification<UserActionEntity> search(UserActionPaginationRequest userActionPaginationRequest,UserEntity userEntity) {
return (root, query, criteriaBuilder) -> { return (root, query, criteriaBuilder) -> {

View File

@@ -14,5 +14,4 @@ public class SummaryPageResponseBean {
private LocalDateTime registrationDate; private LocalDateTime registrationDate;
private Long numberOfLoginAttempts; private Long numberOfLoginAttempts;
private Long applicationsProcessed; private Long applicationsProcessed;
private PageableResponseBean<List<UserActionResponseBean>> userActions;
} }

View File

@@ -5,15 +5,17 @@ import net.gepafin.tendermanagement.enums.TimePeriodEnum;
import net.gepafin.tendermanagement.enums.UserActionContextEnum; import net.gepafin.tendermanagement.enums.UserActionContextEnum;
import net.gepafin.tendermanagement.model.request.UserActionPaginationRequest; import net.gepafin.tendermanagement.model.request.UserActionPaginationRequest;
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse; import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean; import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
import net.gepafin.tendermanagement.model.response.UserActionResponseBean;
import java.util.List; import java.util.List;
public interface UserActionService { public interface UserActionService {
public SummaryPageResponseBean getUserAction(HttpServletRequest request, Long userId, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext); public SummaryPageResponseBean getUserAction(HttpServletRequest request, Long userId);
public List<ActionContextLabelResponse> getActionContextLabels(HttpServletRequest request, Long userId); public List<ActionContextLabelResponse> getActionContextLabels(HttpServletRequest request, Long userId);
public SummaryPageResponseBean getUserActionByPagination(HttpServletRequest request, Long userId, UserActionPaginationRequest userActionPaginationRequest); public PageableResponseBean<List<UserActionResponseBean>> getUserActionByPagination(HttpServletRequest request, Long userId, UserActionPaginationRequest userActionPaginationRequest);
} }

View File

@@ -7,7 +7,9 @@ import net.gepafin.tendermanagement.enums.TimePeriodEnum;
import net.gepafin.tendermanagement.enums.UserActionContextEnum; import net.gepafin.tendermanagement.enums.UserActionContextEnum;
import net.gepafin.tendermanagement.model.request.UserActionPaginationRequest; import net.gepafin.tendermanagement.model.request.UserActionPaginationRequest;
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse; import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean; import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
import net.gepafin.tendermanagement.model.response.UserActionResponseBean;
import net.gepafin.tendermanagement.service.UserActionService; import net.gepafin.tendermanagement.service.UserActionService;
import net.gepafin.tendermanagement.util.Validator; import net.gepafin.tendermanagement.util.Validator;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -26,9 +28,9 @@ public class UserActionServiceImpl implements UserActionService {
@Override @Override
public SummaryPageResponseBean getUserAction(HttpServletRequest request, Long userId, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext) { public SummaryPageResponseBean getUserAction(HttpServletRequest request, Long userId) {
UserEntity user = validator.validateUserId(request, userId); UserEntity user = validator.validateUserId(request, userId);
return userActionDao.getUserAction(request,user,timeFilter,actionContext); return userActionDao.getUserAction(request,user);
} }
@Override @Override
@@ -38,7 +40,7 @@ public class UserActionServiceImpl implements UserActionService {
} }
@Override @Override
public SummaryPageResponseBean getUserActionByPagination(HttpServletRequest request, Long userId, UserActionPaginationRequest userActionPaginationRequest) { public PageableResponseBean<List<UserActionResponseBean>> getUserActionByPagination(HttpServletRequest request, Long userId, UserActionPaginationRequest userActionPaginationRequest) {
UserEntity user = validator.validateUserId(request, userId); UserEntity user = validator.validateUserId(request, userId);
return userActionDao.getUserActionByPagination(user,userActionPaginationRequest); return userActionDao.getUserActionByPagination(user,userActionPaginationRequest);
} }

View File

@@ -76,7 +76,7 @@ public interface ApplicationAmendmentRequestApi {
@GetMapping(value = "", produces = "application/json") @GetMapping(value = "", produces = "application/json")
ResponseEntity<Response<ApplicationAmendmentRequestResponse>> getApplicationAmendmentRequestById(HttpServletRequest request,@Parameter(description = "The application amendment id", required = true) @RequestParam(value = "id", required = true) Long id); ResponseEntity<Response<ApplicationAmendmentRequestResponse>> getApplicationAmendmentRequestById(HttpServletRequest request,@Parameter(description = "The application amendment id", required = true) @RequestParam(value = "id", required = true) Long id);
@Operation(summary = "Api to get all applications amendment request by preInstructor user Id", @Operation(summary = "Api to get all applications amendment request by preInstructor user Id (deprecated)",
responses = { responses = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@@ -104,7 +104,7 @@ public interface ApplicationAmendmentRequestApi {
@Parameter(description = "The Application Amendment id", required = true) @PathVariable("id") Long id, @Parameter(description = "The Application Amendment id", required = true) @PathVariable("id") Long id,
@Parameter(description = "Assigned Application request object", required = true) @Valid @RequestBody ApplicationAmendmentRequestBean applicationAmendmentRequestBean); @Parameter(description = "Assigned Application request object", required = true) @Valid @RequestBody ApplicationAmendmentRequestBean applicationAmendmentRequestBean);
@Operation(summary = "Api to get all applications amendment request by beneficary user Id", @Operation(summary = "Api to get all applications amendment request by beneficary user Id (deprecated)",
responses = { responses = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {

View File

@@ -10,7 +10,9 @@ import net.gepafin.tendermanagement.enums.TimePeriodEnum;
import net.gepafin.tendermanagement.enums.UserActionContextEnum; import net.gepafin.tendermanagement.enums.UserActionContextEnum;
import net.gepafin.tendermanagement.model.request.UserActionPaginationRequest; import net.gepafin.tendermanagement.model.request.UserActionPaginationRequest;
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse; import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean; import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
import net.gepafin.tendermanagement.model.response.UserActionResponseBean;
import net.gepafin.tendermanagement.model.util.Response; import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants; import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
@@ -20,7 +22,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
public interface UserActionApi { public interface UserActionApi {
@Operation(summary = "Api to get user action", @Operation(summary = "Api to get user summary ",
responses = { responses = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@@ -30,9 +32,7 @@ public interface UserActionApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "/user/{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, 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) List<UserActionContextEnum> actionContext);
@Operation(summary = "Api to get action context label", @Operation(summary = "Api to get action context label",
responses = { responses = {
@@ -56,7 +56,7 @@ public interface UserActionApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@PostMapping(value = "/user/{userId}/pagination", produces = { "application/json" }) @PostMapping(value = "/user/{userId}/pagination", produces = { "application/json" })
ResponseEntity<Response<SummaryPageResponseBean>> getUserActionByPaginnation(HttpServletRequest request, @Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId, ResponseEntity<Response<PageableResponseBean<List<UserActionResponseBean>>>> getUserActionByPaginnation(HttpServletRequest request, @Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
@RequestBody UserActionPaginationRequest userActionPaginationRequest); @RequestBody UserActionPaginationRequest userActionPaginationRequest);
} }

View File

@@ -227,7 +227,7 @@ public interface UserApi {
ResponseEntity<Response<UserSamlResponse>> validateNewUserToken(HttpServletRequest request, ResponseEntity<Response<UserSamlResponse>> validateNewUserToken(HttpServletRequest request,
@Parameter(description = "The spid token", required = true) @PathVariable("token") String token); @Parameter(description = "The spid token", required = true) @PathVariable("token") String token);
@Operation(summary = "Api to get all users", @Operation(summary = "Api to get all users (deprecated)",
responses = { responses = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {

View File

@@ -9,7 +9,9 @@ import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
import net.gepafin.tendermanagement.model.request.UserActionPaginationRequest; import net.gepafin.tendermanagement.model.request.UserActionPaginationRequest;
import net.gepafin.tendermanagement.model.request.UserActionRequest; import net.gepafin.tendermanagement.model.request.UserActionRequest;
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse; import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean; import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
import net.gepafin.tendermanagement.model.response.UserActionResponseBean;
import net.gepafin.tendermanagement.model.util.Response; import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.UserActionService; import net.gepafin.tendermanagement.service.UserActionService;
import net.gepafin.tendermanagement.util.LoggingUtil; import net.gepafin.tendermanagement.util.LoggingUtil;
@@ -34,12 +36,12 @@ public class UserActionApiController implements UserActionApi {
private LoggingUtil loggingUtil; private LoggingUtil loggingUtil;
@Override @Override
public ResponseEntity<Response<SummaryPageResponseBean>> getUserAction(HttpServletRequest request, Long userId, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext) { public ResponseEntity<Response<SummaryPageResponseBean>> getUserAction(HttpServletRequest request, Long userId) {
/** This code is responsible for creating user action logs for the "get user action" operation. **/ /** This code is responsible for creating user action logs for the "get user action" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW) loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
.actionContext(UserActionContextEnum.GET_USER_ACTION).build()); .actionContext(UserActionContextEnum.GET_USER_ACTION).build());
SummaryPageResponseBean userActionResponse= userActionService.getUserAction(request,userId,timeFilter,actionContext); SummaryPageResponseBean userActionResponse= userActionService.getUserAction(request,userId);
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(userActionResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_ACTION_FETCHED_SUCCESSFULLY))); .body(new Response<>(userActionResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_ACTION_FETCHED_SUCCESSFULLY)));
} }
@@ -57,11 +59,11 @@ public class UserActionApiController implements UserActionApi {
} }
@Override @Override
public ResponseEntity<Response<SummaryPageResponseBean>> getUserActionByPaginnation(HttpServletRequest request, Long userId, UserActionPaginationRequest userActionPaginationRequest) { public ResponseEntity<Response<PageableResponseBean<List<UserActionResponseBean>>>> getUserActionByPaginnation(HttpServletRequest request, Long userId, UserActionPaginationRequest userActionPaginationRequest) {
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW) loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
.actionContext(UserActionContextEnum.GET_ALL_USER_ACTION_BY_PAGINATION).build()); .actionContext(UserActionContextEnum.GET_ALL_USER_ACTION_BY_PAGINATION).build());
SummaryPageResponseBean userActionResponse= userActionService.getUserActionByPagination(request,userId,userActionPaginationRequest); PageableResponseBean<List<UserActionResponseBean>> userActionResponse= userActionService.getUserActionByPagination(request,userId,userActionPaginationRequest);
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(userActionResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_ACTION_FETCHED_SUCCESSFULLY))); .body(new Response<>(userActionResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_ACTION_FETCHED_SUCCESSFULLY)));