Commit 4b60bd3e authored by đinh thị đầm's avatar đinh thị đầm

fix bug tester

parent e5740e4c
......@@ -13,6 +13,9 @@ import java.util.List;
@Repository
public interface CampaignCfgRepository extends JpaRepository<CampaignCfg, Long> {
@Query("select c from CampaignCfg c where c.companySiteId=:p_company_site_id and c.status = 1")
List<CampaignCfg> findByCampaignCompleteCodeId( @Param("p_company_site_id") Long p_company_site_id);
@Query("select c from CampaignCfg c where c.campaignCompleteCodeId in (:p_ids) and c.companySiteId=:p_company_site_id and c.status = 1")
List<CampaignCfg> findAllCampaignCfg(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id);
......
......@@ -20,7 +20,7 @@ public interface CampaignCfgService {
ResultDTO deleteList(CampaignCfgRequestDTO campaignCfgRequestDTO);
ResultDTO deleteById(Long id);
ResultDTO deleteById(CampaignCfgRequestDTO campaignCfgRequestDTO);
ResultDTO findMaxValueCampaignCompleteCode(CampaignCfgDTO completeCodeDTO);
......
......@@ -241,10 +241,14 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteCompleteCode(CampaignCfgRequestDTO completeCodeDTO) {
ResultDTO resultDTO = new ResultDTO();
List<Long> listId = new ArrayList<>();
listId.add(completeCodeDTO.getCampaignCompleteCodeID());
try {
// delete
if (completeCodeDTO != null) {
// completeCodeRepository.deleteCampaignCompleteCodeBy(completeCodeDTO.getCampaignCompleteCodeID(), completeCodeDTO.getCompanySiteId());
if (completeCodeRepository.findAllCampaignCfg(listId, completeCodeDTO.getCompanySiteId()).size() > 0) {
completeCodeRepository.deleteCampaignCompleteCodeBy(completeCodeDTO.getCampaignCompleteCodeID(), completeCodeDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
......@@ -254,8 +258,14 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
// e.printStackTrace();
logger.error(e.getMessage(), e);
}
return resultDTO;
......@@ -284,25 +294,35 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
}
} catch (Exception e) {
// e.printStackTrace();
logger.error(e.getMessage(), e);
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteById(Long id) {
public ResultDTO deleteById(CampaignCfgRequestDTO completeCodeDTO) {
ResultDTO result = new ResultDTO();
try {
completeCodeRepository.deleteById(id);
result.setErrorCode(Constants.Status.ACTIVE_STR);
result.setDescription(Constants.Status.ACTIVE_STR);
if (completeCodeDTO != null) {
if (completeCodeRepository.findAllCampaignCfg(completeCodeDTO.getListId(), completeCodeDTO.getCompanySiteId()).size() > 0) {
completeCodeRepository.deletedList(completeCodeDTO.getListId(), completeCodeDTO.getCompanySiteId());
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
}
} else {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
result.setErrorCode("-1");
return result;
// e.printStackTrace();
logger.error(e.getMessage(), e);
}
result.setErrorCode("0");
return result;
}
......
......@@ -10,5 +10,5 @@ public class CampaignCfgRequestDTO {
List<Long> listId;
Long companySiteId;
Long campaignCompleteCodeID;
String completeValue;
}
......@@ -106,9 +106,9 @@ public class CampaignCfgController {
@PostMapping("/deleteById")
@ResponseBody
public ResultDTO deleteById(@RequestParam("id") Long id){
public ResultDTO deleteById(@RequestBody @Valid CampaignCfgRequestDTO campaignCfgRequestDTO){
ResultDTO resultDTO = new ResultDTO();
resultDTO = completeCodeService.deleteById(id);
resultDTO = completeCodeService.deleteById(campaignCfgRequestDTO);
return resultDTO;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment