created validate api for call

This commit is contained in:
rajesh
2024-08-28 12:38:11 +05:30
parent ffa07d779b
commit 630643f156
18 changed files with 214 additions and 61 deletions

View File

@@ -7,7 +7,7 @@ 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.response.CallResponse;
import net.gepafin.tendermanagement.service.CallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -28,28 +28,28 @@ public class CallServiceImpl implements CallService {
@Override
@Transactional(rollbackFor = Exception.class)
public CreateCallResponseBean createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest) {
public CallResponse createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest) {
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
return callDao.createCallStep1(createCallRequest, Long.parseLong(userInfo.get("userId").toString()));
}
@Override
@Transactional(rollbackFor = Exception.class)
public CreateCallResponseBean createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest) {
public CallResponse createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest) {
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
return callDao.createCallStep2(callId, createCallRequest, Long.parseLong(userInfo.get("userId").toString()));
}
@Override
@Transactional(rollbackFor = Exception.class)
public CreateCallResponseBean updateCallStep1(HttpServletRequest request, Long callId,
public CallResponse 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) {
public CallResponse getCallById(Long callId) {
return callDao.getCallById(callId);
}
@@ -59,4 +59,10 @@ public class CallServiceImpl implements CallService {
return callDao.getAllCalls();
}
@Override
@Transactional(rollbackFor = Exception.class)
public CallResponse validateCall(Long callId) {
return callDao.validateCall(callDao.validateCall(callId));
}
}

View File

@@ -0,0 +1,31 @@
package net.gepafin.tendermanagement.service.impl;
import net.gepafin.tendermanagement.model.response.CallResponse;
import net.gepafin.tendermanagement.util.FieldValidator;
public class CallValidatorServiceImpl {
public static void validateResponse(CallResponse response) {
FieldValidator.create()
.notNull(response.getId(), "id")
.notNull(response.getName(), "name")
.notNull(response.getDescriptionShort(), "descriptionShort")
.notNull(response.getDescriptionLong(), "descriptionLong")
.notNull(response.getStartDate(), "startDate")
.notNull(response.getEndDate(), "endDate")
.notNull(response.getStatus(), "status")
.notNull(response.getRegionId(), "regionId")
.notNull(response.getAmount(), "amount")
.notNull(response.getAmountMax(), "amountMax")
.notNull(response.getThreshold(), "threshold")
.notNull(response.getDocumentationReqested(), "documentationReqested")
.notEmpty(response.getAimedTo(), "aimedTo")
.notEmpty(response.getCriteria(), "criteria")
.notEmpty(response.getDocs(), "docs")
.notEmpty(response.getFaq(), "faq")
.notEmpty(response.getImages(), "images")
.notEmpty(response.getCheckList(), "checkList")
.validate();
}
}