resolved conflicts
This commit is contained in:
@@ -47,6 +47,7 @@ public class GepafinConstant {
|
||||
public static final String STEP_2 = "STEP_2";
|
||||
public static final String CALL_UPDATE_SUCCESSFULLY_MSG = "call.update.successfully";
|
||||
public static final String CALL_NOT_FOUND = "call.not.found";
|
||||
public static final String CALL_FETCH_SUCCESS_MSG = "call.fetch.success";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -32,11 +33,6 @@ import net.gepafin.tendermanagement.model.request.EvaluationCriteriaReq;
|
||||
import net.gepafin.tendermanagement.model.request.FaqReq;
|
||||
import net.gepafin.tendermanagement.model.request.LookUpDataReq;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.model.response.CreateCallResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.EvaluationCriteriaResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.FaqResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.LookUpDataResponse;
|
||||
import net.gepafin.tendermanagement.repositories.CallRepository;
|
||||
import net.gepafin.tendermanagement.repositories.CallTargetAudienceChecklistRepository;
|
||||
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||
@@ -273,7 +269,8 @@ public class CallDao {
|
||||
CreateCallResponseBean createCallResponseBean = new CreateCallResponseBean();
|
||||
createCallResponseBean.setId(callEntity.getId());
|
||||
createCallResponseBean.setName(callEntity.getName());
|
||||
createCallResponseBean.setDates(List.of(callEntity.getStartDate(), callEntity.getEndDate()));
|
||||
createCallResponseBean.setStartDate(callEntity.getStartDate());
|
||||
createCallResponseBean.setEndDate(callEntity.getEndDate());
|
||||
createCallResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
|
||||
createCallResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
|
||||
createCallResponseBean.setStatus(CallTypeEnum.valueOf(callEntity.getStatus()));
|
||||
@@ -403,13 +400,19 @@ public class CallDao {
|
||||
return lookUpDataResponse;
|
||||
}
|
||||
|
||||
private CallEntity getCallById(Long callId) {
|
||||
public CallEntity validateCall(Long callId) {
|
||||
return callRepository.findById(callId).orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
}
|
||||
public CreateCallResponseBean getCallById(Long callId) {
|
||||
CallEntity callEntity = callRepository.findById(callId)
|
||||
.orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
return getCallResponseBean(callEntity);
|
||||
}
|
||||
|
||||
public CreateCallResponseBean createCallStep2(CreateCallRequestStep2 createCallRequest, Long userId) {
|
||||
CallEntity callEntity = callRepository.findById(createCallRequest.getCallId())
|
||||
public CreateCallResponseBean createCallStep2(Long callId, CreateCallRequestStep2 createCallRequest, Long userId) {
|
||||
CallEntity callEntity = callRepository.findById(callId)
|
||||
.orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
|
||||
@@ -459,7 +462,7 @@ public class CallDao {
|
||||
}
|
||||
|
||||
public CreateCallResponseBean updateCallStep1(Long callId, UpdateCallRequestStep1 updateCallRequest, Long userId) {
|
||||
CallEntity callEntity = getCallById(callId);
|
||||
CallEntity callEntity = validateCall(callId);
|
||||
UserEntity userEntity = userService.validateUser(userId);
|
||||
isValidDateRange(updateCallRequest, callEntity);
|
||||
setIfUpdated(callEntity::getName, callEntity::setName, updateCallRequest.getName());
|
||||
@@ -567,6 +570,26 @@ public class CallDao {
|
||||
callTargetAudienceChecklistRepository.save(callTargetAudienceChecklistEntity);
|
||||
}
|
||||
|
||||
public CallDetailsResponseBean convertToCallDetailsResponseBean(CallEntity callEntity) {
|
||||
CallDetailsResponseBean callDetailsResponseBean = new CallDetailsResponseBean();
|
||||
callDetailsResponseBean.setId(callEntity.getId());
|
||||
callDetailsResponseBean.setName(callEntity.getName());
|
||||
callDetailsResponseBean.setDates(List.of(callEntity.getStartDate(), callEntity.getEndDate()));
|
||||
callDetailsResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
|
||||
callDetailsResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
|
||||
callDetailsResponseBean.setStatus(CallTypeEnum.valueOf(callEntity.getStatus()));
|
||||
callDetailsResponseBean.setRegionId(callEntity.getRegion().getId());
|
||||
callDetailsResponseBean.setAmount(callEntity.getAmount());
|
||||
callDetailsResponseBean.setAmountMax(callEntity.getAmountMax());
|
||||
callDetailsResponseBean.setContactInfo(callEntity.getContactInfo());
|
||||
callDetailsResponseBean.setSubmissionMethod(callEntity.getSubmissionMethod());
|
||||
callDetailsResponseBean.setThreshold(callEntity.getThreshold());
|
||||
callDetailsResponseBean.setDocumentationReqested(callEntity.getDocumentationRequested());
|
||||
callDetailsResponseBean.setPriorityArea(callEntity.getPriorityArea());
|
||||
callDetailsResponseBean.setCreatedDate(callEntity.getCreatedDate());
|
||||
callDetailsResponseBean.setUpdatedDate(callEntity.getUpdatedDate());
|
||||
return callDetailsResponseBean;
|
||||
}
|
||||
private CreateCallResponseBean getCallResponseBean(CallEntity callEntity) {
|
||||
List<DocumentEntity> documentEntities = documentRepository.findByCallIdAndTypeAndIsDeletedFalse(callEntity.getId(),
|
||||
DocumentTypeEnum.DOCUMENT.getValue());
|
||||
@@ -589,4 +612,10 @@ public class CallDao {
|
||||
createCallResponseBean.setCheckList(checkList);
|
||||
return createCallResponseBean;
|
||||
}
|
||||
public List<CallDetailsResponseBean> getAllCalls() {
|
||||
return callRepository.findAll()
|
||||
.stream()
|
||||
.map(this::convertToCallDetailsResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class RegionDao {
|
||||
|
||||
public RegionResponseBean updateRegion(Long id, RegionReq regionReq) {
|
||||
log.info("Updating region with ID: {}", id);
|
||||
RegionEntity existingRegion = getRegionById(id);
|
||||
RegionEntity existingRegion = validateRegion(id);
|
||||
log.info("Current region details: {}", existingRegion);
|
||||
log.info("New region details: {}", regionReq);
|
||||
String newStatus = regionReq.getStatus() != null ? regionReq.getStatus().getValue() : null;
|
||||
@@ -102,14 +102,19 @@ public class RegionDao {
|
||||
return Utils.convertObject(existingRegion, RegionResponseBean.class);
|
||||
}
|
||||
|
||||
public RegionEntity getRegionById(Long id) {
|
||||
public RegionEntity validateRegion(Long id) {
|
||||
log.info("Fetching region with ID: {}", id);
|
||||
RegionEntity regionEntity = regionRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.REGION_NOT_FOUND_MSG)));
|
||||
log.info("Region found: {}", regionEntity);
|
||||
return regionEntity;
|
||||
}
|
||||
|
||||
public RegionResponseBean getRegionById(Long id) {
|
||||
log.info("Fetching region with ID: {}", id);
|
||||
RegionEntity regionEntity = regionRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.REGION_NOT_FOUND_MSG)));
|
||||
return convertRegionEntityToRegionResponse(regionEntity);
|
||||
}
|
||||
public void deleteById(Long id) {
|
||||
log.info("Deleting region with ID: {}", id);
|
||||
regionRepository.findById(id)
|
||||
|
||||
@@ -2,12 +2,12 @@ package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.RegionEntity;
|
||||
import net.gepafin.tendermanagement.entities.RoleEntity;
|
||||
import net.gepafin.tendermanagement.model.request.RoleReq;
|
||||
import net.gepafin.tendermanagement.model.response.RegionResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.RoleResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.RoleRepository;
|
||||
import net.gepafin.tendermanagement.service.RegionService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
@@ -28,9 +28,6 @@ public class RoleDao {
|
||||
@Autowired
|
||||
private RoleRepository roleRepository;
|
||||
|
||||
@Autowired
|
||||
private RegionService regionService;
|
||||
|
||||
@Autowired
|
||||
private RegionDao regionDao;
|
||||
|
||||
@@ -48,7 +45,8 @@ public class RoleDao {
|
||||
roleEntity.setRoleType(roleReq.getRoleType());
|
||||
roleEntity.setPermissions(roleReq.getPermissions());
|
||||
roleEntity.setDescription(roleReq.getDescription());
|
||||
roleEntity.setRegion(regionService.getRegionById(roleReq.getRegionId()));
|
||||
RegionEntity regionEntity =regionDao.validateRegion(roleReq.getRegionId());
|
||||
roleEntity.setRegion(regionEntity);
|
||||
return roleEntity;
|
||||
}
|
||||
|
||||
@@ -68,7 +66,7 @@ public class RoleDao {
|
||||
|
||||
public RoleResponseBean updateRole(Long id, RoleReq roleReq) {
|
||||
log.info("Updating role with ID: {}", id);
|
||||
RoleEntity existingRole = getRoleById(id);
|
||||
RoleEntity existingRole = validateRole(id);
|
||||
|
||||
// Log changes before update
|
||||
log.info("Current role details: {}", existingRole);
|
||||
@@ -85,14 +83,20 @@ public class RoleDao {
|
||||
return Utils.convertObject(existingRole, RoleResponseBean.class);
|
||||
}
|
||||
|
||||
public RoleEntity getRoleById(Long id) {
|
||||
public RoleEntity validateRole(Long id) {
|
||||
log.info("Fetching role with ID: {}", id);
|
||||
RoleEntity roleEntity = roleRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.ROLE_NOT_FOUND)));
|
||||
log.info("Role found: {}", roleEntity);
|
||||
return roleEntity;
|
||||
}
|
||||
|
||||
public RoleResponseBean getRoleById(Long id) {
|
||||
log.info("Fetching role with ID: {}", id);
|
||||
RoleEntity roleEntity = roleRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.ROLE_NOT_FOUND)));
|
||||
log.info("Role found: {}", roleEntity);
|
||||
return convertRoleEntityToRoleResponse(roleEntity);
|
||||
}
|
||||
public void deleteById(Long id) {
|
||||
log.info("Deleting role with ID: {}", id);
|
||||
roleRepository.findById(id)
|
||||
|
||||
@@ -12,7 +12,6 @@ import net.gepafin.tendermanagement.model.response.RoleResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||
import net.gepafin.tendermanagement.service.RoleService;
|
||||
import net.gepafin.tendermanagement.service.impl.AuthenticationService;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
@@ -36,9 +35,6 @@ public class UserDao {
|
||||
@Autowired
|
||||
private AuthenticationService authService;
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
@@ -81,7 +77,7 @@ public class UserDao {
|
||||
setIfUpdated(userEntity::getAddress, userEntity::setAddress, userReq.getAddress());
|
||||
setIfUpdated(userEntity::getPhoneNumber, userEntity::setPhoneNumber, userReq.getPhoneNumber());
|
||||
if (userReq.getRoleId() != null) {
|
||||
RoleEntity roleEntity = roleService.getRoleById(userReq.getRoleId());
|
||||
RoleEntity roleEntity = roleDao.validateRole(userReq.getRoleId());
|
||||
setIfUpdated(userEntity::getRoleEntity, userEntity::setRoleEntity, roleEntity);
|
||||
}
|
||||
userEntity = userRepository.save(userEntity);
|
||||
@@ -99,7 +95,7 @@ public class UserDao {
|
||||
userEntity.setOrganization(userReq.getOrganization());
|
||||
userEntity.setAddress(userReq.getAddress());
|
||||
userEntity.setPhoneNumber(userReq.getPhoneNumber());
|
||||
userEntity.setRoleEntity(roleService.getRoleById(userReq.getRoleId()));
|
||||
userEntity.setRoleEntity(roleDao.validateRole(userReq.getRoleId()));
|
||||
return userEntity;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,6 @@ import lombok.Data;
|
||||
@Data
|
||||
public class CreateCallRequestStep2 {
|
||||
|
||||
@NotNull
|
||||
private Long callId;
|
||||
|
||||
private Long threshold;
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.CallTypeEnum;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class CallDetailsResponseBean {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String descriptionShort;
|
||||
|
||||
private String descriptionLong;
|
||||
|
||||
private List<LocalDateTime> dates;
|
||||
|
||||
private CallTypeEnum status;
|
||||
|
||||
private Long regionId;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private BigDecimal amountMax;
|
||||
|
||||
private String contactInfo;
|
||||
|
||||
private String submissionMethod;
|
||||
|
||||
private Long threshold;
|
||||
|
||||
private String priorityArea;
|
||||
|
||||
private String documentationReqested;
|
||||
|
||||
private LocalDateTime createdDate;
|
||||
|
||||
private LocalDateTime updatedDate;
|
||||
|
||||
private List<LookUpDataResponse> aimedTo;
|
||||
|
||||
private List<EvaluationCriteriaResponseBean> criteria;
|
||||
|
||||
private List<DocumentResponseBean> docs;
|
||||
|
||||
private List<FaqResponseBean> faq;
|
||||
|
||||
private List<DocumentResponseBean> images;
|
||||
|
||||
private List<LookUpDataResponse> checkList;
|
||||
|
||||
private String currentStep;
|
||||
}
|
||||
@@ -18,7 +18,9 @@ public class CreateCallResponseBean {
|
||||
|
||||
private String descriptionLong;
|
||||
|
||||
private List<LocalDateTime> dates;
|
||||
private LocalDateTime startDate;
|
||||
|
||||
private LocalDateTime endDate;
|
||||
|
||||
private CallTypeEnum status;
|
||||
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
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.CreateCallResponseBean;
|
||||
|
||||
public interface CallService {
|
||||
|
||||
CreateCallResponseBean createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest);
|
||||
|
||||
CreateCallResponseBean createCallStep2(HttpServletRequest request, CreateCallRequestStep2 createCallRequest);
|
||||
CreateCallResponseBean createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest);
|
||||
|
||||
CreateCallResponseBean updateCallStep1(HttpServletRequest request, Long callId, UpdateCallRequestStep1 updateCallRequest);
|
||||
|
||||
CreateCallResponseBean getCallById (Long callId);
|
||||
|
||||
List<CallDetailsResponseBean> getAllCalls();
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface RegionService {
|
||||
|
||||
RegionResponseBean updateRegion(Long regionId, RegionReq regionReq);
|
||||
|
||||
RegionEntity getRegionById(Long regionId);
|
||||
RegionResponseBean getRegionById(Long regionId);
|
||||
|
||||
void deleteRegion(Long regionId);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public interface RoleService {
|
||||
|
||||
RoleResponseBean updateRole(Long roleId, RoleReq roleReq);
|
||||
|
||||
RoleEntity getRoleById(Long roleId);
|
||||
RoleResponseBean getRoleById(Long roleId);
|
||||
|
||||
void deleteRole(Long roleId);
|
||||
|
||||
|
||||
@@ -6,11 +6,14 @@ import net.gepafin.tendermanagement.dao.CallDao;
|
||||
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.CreateCallResponseBean;
|
||||
import net.gepafin.tendermanagement.service.CallService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -24,21 +27,36 @@ public class CallServiceImpl implements CallService {
|
||||
private TokenProvider tokenProvider;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CreateCallResponseBean createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest) {
|
||||
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
|
||||
return callDao.createCallStep1(createCallRequest, Long.parseLong(userInfo.get("userId").toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateCallResponseBean createCallStep2(HttpServletRequest request, CreateCallRequestStep2 createCallRequest) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CreateCallResponseBean createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest) {
|
||||
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
|
||||
return callDao.createCallStep2(createCallRequest, Long.parseLong(userInfo.get("userId").toString()));
|
||||
return callDao.createCallStep2(callId, createCallRequest, Long.parseLong(userInfo.get("userId").toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CreateCallResponseBean updateCallStep1(HttpServletRequest request, Long callId,
|
||||
UpdateCallRequestStep1 updateCallRequest) {
|
||||
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
|
||||
return callDao.updateCallStep1(callId, updateCallRequest, Long.parseLong(userInfo.get("userId").toString()));
|
||||
}
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public CreateCallResponseBean getCallById(Long callId) {
|
||||
return callDao.getCallById(callId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<CallDetailsResponseBean> getAllCalls() {
|
||||
return callDao.getAllCalls();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,8 @@ package net.gepafin.tendermanagement.service.impl;
|
||||
import java.util.List;
|
||||
|
||||
import net.gepafin.tendermanagement.dao.RegionDao;
|
||||
import net.gepafin.tendermanagement.entities.RegionEntity;
|
||||
import net.gepafin.tendermanagement.model.request.RegionReq;
|
||||
import net.gepafin.tendermanagement.model.response.RegionResponseBean;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateRegionReq;
|
||||
import net.gepafin.tendermanagement.service.RegionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -32,7 +30,7 @@ public class RegionServiceImpl implements RegionService {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public RegionEntity getRegionById(Long regionId) {
|
||||
public RegionResponseBean getRegionById(Long regionId) {
|
||||
return regionDao.getRegionById(regionId);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.gepafin.tendermanagement.service.impl;
|
||||
import java.util.List;
|
||||
|
||||
import net.gepafin.tendermanagement.dao.RoleDao;
|
||||
import net.gepafin.tendermanagement.entities.RoleEntity;
|
||||
import net.gepafin.tendermanagement.model.request.RoleReq;
|
||||
import net.gepafin.tendermanagement.model.response.RoleResponseBean;
|
||||
import net.gepafin.tendermanagement.service.RoleService;
|
||||
@@ -31,7 +30,7 @@ public class RoleServiceImpl implements RoleService {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public RoleEntity getRoleById(Long roleId) {
|
||||
public RoleResponseBean getRoleById(Long roleId) {
|
||||
return roleDao.getRoleById(roleId);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
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.model.response.LoginResponse;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
@@ -13,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
@@ -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;
|
||||
@@ -10,17 +22,10 @@ import jakarta.validation.Valid;
|
||||
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.CreateCallResponseBean;
|
||||
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.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@Validated
|
||||
public interface CallApi {
|
||||
@@ -51,11 +56,11 @@ public interface CallApi {
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@PutMapping(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);
|
||||
@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 = {
|
||||
@@ -72,5 +77,30 @@ public interface CallApi {
|
||||
public ResponseEntity<Response<CreateCallResponseBean>> 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<CreateCallResponseBean>> 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();
|
||||
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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.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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@RestController
|
||||
@@ -37,8 +41,8 @@ public class CallApiController implements CallApi {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep2(HttpServletRequest request, CreateCallRequestStep2 createCallRequest) {
|
||||
CreateCallResponseBean createCallResponseBean = callService.createCallStep2(request, createCallRequest);
|
||||
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest) {
|
||||
CreateCallResponseBean createCallResponseBean = callService.createCallStep2(request, callId, createCallRequest);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(createCallResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_CREATED_SUCCESSFULLY_MSG)));
|
||||
}
|
||||
@@ -50,4 +54,21 @@ public class CallApiController implements CallApi {
|
||||
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<CreateCallResponseBean>> getCallById(Long callId) {
|
||||
CreateCallResponseBean 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)));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -46,6 +46,8 @@ document.id.not.found=Document ID not found.
|
||||
call.created.successfully=Call created successfully.
|
||||
call.invalid.date=Invalid start or end date.
|
||||
call.update.successfully=Call updated successfully.
|
||||
call.fetch.success=Call details fetched successfully.
|
||||
|
||||
call.not.found=Call not found.
|
||||
|
||||
# Login-related messages
|
||||
|
||||
@@ -45,6 +45,7 @@ document.not.found=Documento non trovato.
|
||||
document.id.not.found=ID documento non trovato.
|
||||
call.invalid.date=Data di inizio o fine non valida.
|
||||
call.update.successfully=Chiamata aggiornata con successo.
|
||||
call.fetch.success=Dettagli della chiamata recuperati con successo.
|
||||
call.not.found=Chiamata non trovata.
|
||||
|
||||
# Login-related messages
|
||||
|
||||
Reference in New Issue
Block a user