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; ...@@ -13,6 +13,9 @@ import java.util.List;
@Repository @Repository
public interface CampaignCfgRepository extends JpaRepository<CampaignCfg, Long> { 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") @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); 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 { ...@@ -20,7 +20,7 @@ public interface CampaignCfgService {
ResultDTO deleteList(CampaignCfgRequestDTO campaignCfgRequestDTO); ResultDTO deleteList(CampaignCfgRequestDTO campaignCfgRequestDTO);
ResultDTO deleteById(Long id); ResultDTO deleteById(CampaignCfgRequestDTO campaignCfgRequestDTO);
ResultDTO findMaxValueCampaignCompleteCode(CampaignCfgDTO completeCodeDTO); ResultDTO findMaxValueCampaignCompleteCode(CampaignCfgDTO completeCodeDTO);
......
...@@ -241,14 +241,23 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -241,14 +241,23 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteCompleteCode(CampaignCfgRequestDTO completeCodeDTO) { public ResultDTO deleteCompleteCode(CampaignCfgRequestDTO completeCodeDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
List<Long> listId = new ArrayList<>();
listId.add(completeCodeDTO.getCampaignCompleteCodeID());
try { try {
// delete // delete
if (completeCodeDTO != null) { if (completeCodeDTO != null) {
completeCodeRepository.deleteCampaignCompleteCodeBy(completeCodeDTO.getCampaignCompleteCodeID(), completeCodeDTO.getCompanySiteId()); // 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);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else { } else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
...@@ -256,6 +265,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -256,6 +265,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
} catch (Exception e) { } catch (Exception e) {
// e.printStackTrace(); // e.printStackTrace();
logger.error(e.getMessage(), e);
} }
return resultDTO; return resultDTO;
...@@ -284,26 +294,36 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -284,26 +294,36 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
} }
} catch (Exception e) { } catch (Exception e) {
// e.printStackTrace(); // e.printStackTrace();
logger.error(e.getMessage(), e);
} }
return resultDTO; return resultDTO;
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteById(Long id) { public ResultDTO deleteById(CampaignCfgRequestDTO completeCodeDTO) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
try { try {
completeCodeRepository.deleteById(id); if (completeCodeDTO != null) {
result.setErrorCode(Constants.Status.ACTIVE_STR); if (completeCodeRepository.findAllCampaignCfg(completeCodeDTO.getListId(), completeCodeDTO.getCompanySiteId()).size() > 0) {
result.setDescription(Constants.Status.ACTIVE_STR); 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) { } catch (Exception e) {
result.setErrorCode("-1"); // e.printStackTrace();
return result; logger.error(e.getMessage(), e);
} }
result.setErrorCode("0"); return result;
return result;
} }
......
...@@ -10,5 +10,5 @@ public class CampaignCfgRequestDTO { ...@@ -10,5 +10,5 @@ public class CampaignCfgRequestDTO {
List<Long> listId; List<Long> listId;
Long companySiteId; Long companySiteId;
Long campaignCompleteCodeID; Long campaignCompleteCodeID;
String completeValue;
} }
...@@ -106,9 +106,9 @@ public class CampaignCfgController { ...@@ -106,9 +106,9 @@ public class CampaignCfgController {
@PostMapping("/deleteById") @PostMapping("/deleteById")
@ResponseBody @ResponseBody
public ResultDTO deleteById(@RequestParam("id") Long id){ public ResultDTO deleteById(@RequestBody @Valid CampaignCfgRequestDTO campaignCfgRequestDTO){
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
resultDTO = completeCodeService.deleteById(id); resultDTO = completeCodeService.deleteById(campaignCfgRequestDTO);
return resultDTO; 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