Resolved conflicts
This commit is contained in:
@@ -369,6 +369,8 @@ public class GepafinConstant {
|
||||
public static final String HUB="hub";
|
||||
public static final String NAME="name";
|
||||
|
||||
public static final String USER_ACTION_FETCHED_SUCCESSFULLY = "user.action.fetched.successfully";
|
||||
public static final String ACTION_CONTEXT_LABELS_FETCHED_SUCCESSFULLY = "action.context.labels.fetched.successfully";
|
||||
//action log response
|
||||
public static final String STATUS_CODE_STRING = "statusCode";
|
||||
public static final String GET_STATUS_CODE_STRING = "status";
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.entities.RoleActionContextEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserActionEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
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.response.UserActionResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||
import net.gepafin.tendermanagement.repositories.RoleActionContextRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserActionsRepository;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class UserActionDao {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private UserActionsRepository userActionsRepository;
|
||||
|
||||
@Autowired
|
||||
private AssignedApplicationsRepository assignedApplicationsRepository;
|
||||
|
||||
@Autowired
|
||||
private RoleActionContextRepository roleActionContextRepository;
|
||||
|
||||
public SummaryPageResponseBean getUserAction(HttpServletRequest request, UserEntity userEntity, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext){
|
||||
Long numberOfLoginAttempts = userActionsRepository.countUserLoginAttempts(userEntity.getId());
|
||||
Long applicationsProcessed = assignedApplicationsRepository.countAssignedApplicationsByUserId(userEntity.getId());
|
||||
|
||||
List<UserActionEntity> userActions = getFilterUserActions(userEntity.getId(),timeFilter,actionContext);
|
||||
|
||||
return createSummaryPageResponse(userEntity,numberOfLoginAttempts,applicationsProcessed,userActions);
|
||||
}
|
||||
|
||||
public SummaryPageResponseBean createSummaryPageResponse(UserEntity user, Long numberOfLoginAttempts, Long applicationsProcessed, List<UserActionEntity> userActions){
|
||||
SummaryPageResponseBean response = new SummaryPageResponseBean();
|
||||
response.setRole(user.getRoleEntity().getRoleName());
|
||||
response.setLastLogin(user.getLastLogin());
|
||||
response.setRegistrationDate(user.getCreatedDate());
|
||||
response.setUsername(user.getFirstName());
|
||||
response.setEmail(user.getEmail());
|
||||
response.setNumberOfLoginAttempts(numberOfLoginAttempts);
|
||||
response.setApplicationsProcessed(applicationsProcessed);
|
||||
|
||||
List<UserActionResponseBean> userAction = convertEntityToResponse(userActions);
|
||||
response.setUserActions(userAction);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public List<UserActionEntity> getFilterUserActions(Long userId ,TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContextList) {
|
||||
LocalDateTime endDate = LocalDateTime.now();
|
||||
LocalDateTime startDate = (timeFilter != null) ? getStartTimeFromFilter(timeFilter) : null;
|
||||
Pageable pageable = PageRequest.of(0, 25);
|
||||
|
||||
// String actionContextLabel = (actionContext != null) ? actionContext.toString() : null;
|
||||
List<String> actionContextLabels = (actionContextList != null && !actionContextList.isEmpty())
|
||||
? actionContextList.stream().map(Enum::toString).collect(Collectors.toList())
|
||||
: null;
|
||||
|
||||
Specification<UserActionEntity> spec = getUserActionsSpecification(userId, startDate, endDate, actionContextLabels);
|
||||
Page<UserActionEntity> pageResult = userActionsRepository.findAll(spec, pageable);
|
||||
|
||||
return pageResult.getContent();
|
||||
}
|
||||
|
||||
private LocalDateTime getStartTimeFromFilter(TimePeriodEnum timeFilter) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
if (timeFilter.equals(TimePeriodEnum.LAST_WEEK)) {
|
||||
return now.minusDays(7);
|
||||
} else if (timeFilter.equals(TimePeriodEnum.LAST_QUARTER)) {
|
||||
return now.minusMonths(4);
|
||||
} else if (timeFilter.equals(TimePeriodEnum.LAST_SEMESTER)) {
|
||||
return now.minusMonths(6);
|
||||
} else if (timeFilter.equals(TimePeriodEnum.LAST_YEAR)) {
|
||||
return now.minusYears(1);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Specification<UserActionEntity> getUserActionsSpecification(Long userId, LocalDateTime startDate, LocalDateTime endDate, List<String> actionContextList) {
|
||||
return (root, query, builder) -> {
|
||||
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
||||
|
||||
predicate = builder.and(predicate, builder.equal(root.get("userId"), userId));
|
||||
|
||||
if (startDate != null && endDate != null) {
|
||||
predicate = builder.and(predicate, builder.between(root.get("createdDate"), startDate, endDate));
|
||||
}
|
||||
|
||||
|
||||
if (actionContextList != null && !actionContextList.isEmpty()) {
|
||||
CriteriaBuilder.In<Object> inClause = builder.in(root.get("actionContext"));
|
||||
for (String actionContext : actionContextList) {
|
||||
inClause.value(actionContext);
|
||||
}
|
||||
predicate = builder.and(predicate, inClause);
|
||||
}
|
||||
query.orderBy(builder.desc(root.get("createdDate")));
|
||||
|
||||
return predicate;
|
||||
};
|
||||
}
|
||||
|
||||
private List<UserActionResponseBean> convertEntityToResponse(List<UserActionEntity> userActions) {
|
||||
return userActions.stream().map(action -> {
|
||||
UserActionResponseBean responseBean = new UserActionResponseBean();
|
||||
responseBean.setId(action.getId());
|
||||
responseBean.setUserId(action.getUserId());
|
||||
responseBean.setActionType(action.getActionType());
|
||||
responseBean.setRequestBody(action.getRequestBody());
|
||||
responseBean.setLoginAttemptId(action.getLoginAttemptId());
|
||||
responseBean.setIpAddress(action.getIpAddress());
|
||||
responseBean.setActionContext(action.getActionContext());
|
||||
responseBean.setHubId(action.getHubId());
|
||||
responseBean.setUrl(action.getUrl());
|
||||
responseBean.setResponse(action.getResponse());
|
||||
responseBean.setCreatedDate(action.getCreatedDate());
|
||||
responseBean.setUpdatedDate(action.getUpdatedDate());
|
||||
return responseBean;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<ActionContextLabelResponse> getActionContextLabels(HttpServletRequest request, UserEntity userEntity){
|
||||
List<RoleActionContextEntity> actionContextLabel = roleActionContextRepository.findActionContextLabel(userEntity.getRoleEntity().getId());
|
||||
return convertRoleContextEntityToResponse(actionContextLabel);
|
||||
}
|
||||
|
||||
private List<ActionContextLabelResponse> convertRoleContextEntityToResponse(List<RoleActionContextEntity> actionContextEntities){
|
||||
return actionContextEntities.stream().map(actionContext -> {
|
||||
ActionContextLabelResponse responseBean = new ActionContextLabelResponse();
|
||||
responseBean.setId(actionContext.getId());
|
||||
responseBean.setActionContext(UserActionContextEnum.valueOf(actionContext.getActionContext()));
|
||||
responseBean.setRoleId(actionContext.getRoleId());
|
||||
responseBean.setDescription(actionContext.getDescription());
|
||||
responseBean.setIsViewed(actionContext.getIsViewed());
|
||||
return responseBean;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name ="role_action_context")
|
||||
public class RoleActionContextEntity extends BaseEntity {
|
||||
|
||||
@Column(name = "action_context")
|
||||
private String actionContext;
|
||||
|
||||
@Column(name = "role_id")
|
||||
private Long roleId;
|
||||
|
||||
@Column(name="is_deleted")
|
||||
private Boolean isDeleted;
|
||||
|
||||
@Column(name = "is_viewed")
|
||||
private Boolean isViewed;
|
||||
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.gepafin.tendermanagement.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum TimePeriodEnum {
|
||||
|
||||
LAST_WEEK ("LAST_WEEK"),
|
||||
LAST_QUARTER("LAST_QUARTER"),
|
||||
LAST_SEMESTER("LAST_SEMESTER"),
|
||||
LAST_YEAR("LAST_YEAR");
|
||||
|
||||
private String value;
|
||||
|
||||
TimePeriodEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -168,9 +168,11 @@ public enum UserActionContextEnum {
|
||||
|
||||
GET_ALL_NOTIFICATION_BY_PAGINATION("GET_ALL_NOTIFICATION_BY_PAGINATION"),
|
||||
GET_ALL_CALL_BY_PAGINATION("GET_ALL_CALL_BY_PAGINATION"),
|
||||
GET_ALL_APPLICATION_BY_PAGINATION("GET_ALL_APPLICATION_BY_PAGINATION");
|
||||
GET_ALL_APPLICATION_BY_PAGINATION("GET_ALL_APPLICATION_BY_PAGINATION"),
|
||||
|
||||
|
||||
GET_USER_ACTION("GET_USER_ACTION"),
|
||||
GET_ACTION_CONTEXT_LABELS("GET_ACTION_CONTEXT_LABELS");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
|
||||
@Data
|
||||
public class ActionContextLabelResponse {
|
||||
private Long id;
|
||||
private UserActionContextEnum actionContext;
|
||||
private Long roleId;
|
||||
private Boolean isViewed;
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SummaryPageResponseBean {
|
||||
private String username;
|
||||
private String email;
|
||||
private String role;
|
||||
private LocalDateTime lastLogin;
|
||||
private LocalDateTime registrationDate;
|
||||
private Long numberOfLoginAttempts;
|
||||
private Long applicationsProcessed;
|
||||
private List<UserActionResponseBean> userActions;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class UserActionResponseBean {
|
||||
private Long id;
|
||||
private Long userId;
|
||||
private String actionType;
|
||||
private String requestBody;
|
||||
private Long loginAttemptId;
|
||||
private String actionContext;
|
||||
private String ipAddress;
|
||||
private String methodType;
|
||||
private Long hubId;
|
||||
private String url;
|
||||
private String response;
|
||||
private LocalDateTime createdDate;
|
||||
private LocalDateTime updatedDate;
|
||||
}
|
||||
@@ -20,6 +20,6 @@ public interface AssignedApplicationsRepository extends JpaRepository<AssignedAp
|
||||
@Param("applicationId") Long applicationId,
|
||||
@Param("id") Long id);
|
||||
|
||||
|
||||
|
||||
@Query("SELECT COUNT(aa) FROM AssignedApplicationsEntity aa WHERE aa.isDeleted = false AND aa.userId = :userId AND aa.status <> 'CLOSE'")
|
||||
Long countAssignedApplicationsByUserId(@Param("userId") Long userId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.RoleActionContextEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface RoleActionContextRepository extends JpaRepository<RoleActionContextEntity,Long>, JpaSpecificationExecutor<RoleActionContextEntity> {
|
||||
|
||||
@Query("SELECT r FROM RoleActionContextEntity r WHERE r.roleId = :roleId AND r.isDeleted = false AND r.isViewed = true")
|
||||
List<RoleActionContextEntity> findActionContextLabel(@Param("roleId") Long roleId);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,18 +1,22 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.UserActionEntity;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface UserActionsRepository extends JpaRepository<UserActionEntity, Long> {
|
||||
public interface UserActionsRepository extends JpaRepository<UserActionEntity, Long> , JpaSpecificationExecutor<UserActionEntity> {
|
||||
UserActionEntity findUserActionById(Long id);
|
||||
|
||||
|
||||
@Query("SELECT COUNT(u) FROM UserActionEntity u " +
|
||||
"WHERE u.userId = :userId " +
|
||||
"AND u.actionContext = 'USER_LOGIN' " +
|
||||
"AND u.isDeleted = false")
|
||||
Long countUserLoginAttempts(@Param("userId") Long userId);
|
||||
|
||||
UserActionEntity findUserActionByIdAndIsDeletedFalse(Long id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
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 java.util.List;
|
||||
|
||||
public interface UserActionService {
|
||||
public SummaryPageResponseBean getUserAction(HttpServletRequest request, Long userId, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext);
|
||||
|
||||
public List<ActionContextLabelResponse> getActionContextLabels(HttpServletRequest request, Long userId);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.UserActionDao;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
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.service.UserActionService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserActionServiceImpl implements UserActionService {
|
||||
|
||||
@Autowired
|
||||
private UserActionDao userActionDao;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
|
||||
@Override
|
||||
public SummaryPageResponseBean getUserAction(HttpServletRequest request, Long userId, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext) {
|
||||
UserEntity user = validator.validateUserId(request, userId);
|
||||
return userActionDao.getUserAction(request,user,timeFilter,actionContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActionContextLabelResponse> getActionContextLabels(HttpServletRequest request, Long userId) {
|
||||
UserEntity user = validator.validateUserId(request, userId);
|
||||
return userActionDao.getActionContextLabels(request,user);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
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 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;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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 = {
|
||||
@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}", 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) 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);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
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.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;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.web.rest.api.UserActionApi;
|
||||
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/userAction}")
|
||||
public class UserActionApiController implements UserActionApi {
|
||||
|
||||
@Autowired
|
||||
private UserActionService userActionService;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@Override
|
||||
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)
|
||||
.actionContext(UserActionContextEnum.GET_USER_ACTION).build());
|
||||
SummaryPageResponseBean userActionResponse= userActionService.getUserAction(request,userId,timeFilter,actionContext);
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user