Commit d9a6d3ac authored by frank.xa.zhang's avatar frank.xa.zhang

add apis for report delete

parent b0315d01
......@@ -8,8 +8,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.common.ApplicationException;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.TemplateDto;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import pwc.taxtech.atms.dto.UpateNameParam;
import pwc.taxtech.atms.service.TemplateService;
import javax.servlet.http.HttpServletResponse;
......@@ -105,4 +107,10 @@ public class TemplateController {
List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs) {
return templateService.getTemplateUniqList(serviceTypeID, payTaxType, reportType, industryIDs);
}
@RequestMapping(value = "updateTemplateName",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto<Object> updateTemplateName(@RequestBody UpateNameParam param){
return templateService.updateTemplateName(param);
}
}
package pwc.taxtech.atms.dto;
public class DeleteTemplateParam {
private String ID;
private boolean isDeletePermanent;
private String path;
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public boolean isDeletePermanent() {
return isDeletePermanent;
}
public void setDeletePermanent(boolean deletePermanent) {
isDeletePermanent = deletePermanent;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.TemplateDto;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import pwc.taxtech.atms.dto.UpateNameParam;
import pwc.taxtech.atms.dto.*;
import java.util.List;
......@@ -20,4 +17,7 @@ public interface TemplateService {
List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs);
OperationResultDto<Object> updateTemplateName(UpateNameParam param);
OperationResultDto<String> deleteTemplate(DeleteTemplateParam param);
}
package pwc.taxtech.atms.service.impl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.constant.enums.TemplateGroupType;
......@@ -69,7 +70,7 @@ public class TemplateGroupServiceImpl extends AbstractService implements Templat
}
@Override
@Transactional
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
public OperationResultDto<Object> deleteTemplateGroup(TemplateGroupDto templateGroupDto) {
OperationResultDto<Object> result = new OperationResultDto<>();
TemplateGroup templateGroupDb = templateGroupMapper.selectByPrimaryKey(templateGroupDto.getID());
......@@ -115,11 +116,9 @@ public class TemplateGroupServiceImpl extends AbstractService implements Templat
}
public class TemplateGroupMessage {
public static final String TEMPLATE_GROUP_NAME_EXIST = "TemplateGroupNameExist";
public static final String SYSTEM_TYPE_CANNOT_DELETE = "SystemTypeCannotDelete";
public static final String ORGANIZATION_USED_TEMPLATE_GROUP = "OrganizationUsedTemplateGroup";
static final String TEMPLATE_GROUP_NAME_EXIST = "TemplateGroupNameExist";
static final String SYSTEM_TYPE_CANNOT_DELETE = "SystemTypeCannotDelete";
static final String ORGANIZATION_USED_TEMPLATE_GROUP = "OrganizationUsedTemplateGroup";
}
}
package pwc.taxtech.atms.service.impl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.entitiy.CellTemplateExample;
import pwc.taxtech.atms.entitiy.Template;
import pwc.taxtech.atms.entitiy.TemplateExample;
import pwc.taxtech.atms.service.TemplateService;
......@@ -15,6 +18,7 @@ import static java.util.stream.Collectors.groupingBy;
@Service
public class TemplateServiceImpl extends AbstractService implements TemplateService {
private final String PREFIX_VALUE = "~";
@Override
public List<TemplateDto> get(String templateGroupID, Integer reportType) {
......@@ -45,7 +49,7 @@ public class TemplateServiceImpl extends AbstractService implements TemplateServ
Template template = templateMapper.selectByPrimaryKey(templateID);
if (template != null) {
if (template.getPath().startsWith("~")) {
if (template.getPath().startsWith(PREFIX_VALUE)) {
result = template.getPath().substring(1, template.getPath().length());
} else {
result = template.getPath();
......@@ -124,7 +128,7 @@ public class TemplateServiceImpl extends AbstractService implements TemplateServ
result.setResultMsg("TemplateNotExist");
return result;
}
Map<String, Object> map = new HashMap<>();
Map<String, Object> map = new HashMap<>(3);
map.put("templateGroupID", templateDb.getTemplateGroupID());
map.put("templateID", param.getID());
map.put("templateName", param.getName());
......@@ -146,4 +150,49 @@ public class TemplateServiceImpl extends AbstractService implements TemplateServ
result.setResult(true);
return result;
}
@Override
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public OperationResultDto<String> deleteTemplate(DeleteTemplateParam param) {
OperationResultDto<String> result = new OperationResultDto<>();
Template templateDb = templateMapper.selectByPrimaryKey(param.getID());
String path = "";
if (templateDb != null) {
TemplateExample example = new TemplateExample();
example.createCriteria().andCodeEqualTo(templateDb.getCode()).andIDEqualTo(templateDb.getID()).andIsActiveAssociationEqualTo(false);
long count = templateMapper.countByExample(example);
if (count > 0) {
path = templateDb.getPath();
//物理删除
deleteIsAtiveAssociation(templateDb);
} else {
if (param.isDeletePermanent() && !templateDb.getIsSystemType()) {
path = templateDb.getPath();
//物理删除
deleteIsAtiveAssociation(templateDb);
} else {
//逻辑删除
logicDeleteIsActiveAssociation(templateDb);
}
}
}
result.setResult(true);
result.setData(path);
return result;
}
private void logicDeleteIsActiveAssociation(Template templateDb) {
templateDb.setIsActiveAssociation(false);
templateMapper.updateByPrimaryKeySelective(templateDb);
}
private void deleteIsAtiveAssociation(Template templateDb) {
cellTemplateConfigMapper.deleteCellTemplateConfigByCellTemplate(templateDb.getID());
keyValueReferenceMapper.deleteKeyValueReferenceByCellTemplate(templateDb.getID());
CellTemplateExample example = new CellTemplateExample();
example.createCriteria().andReportTemplateIDEqualTo(templateDb.getID());
cellTemplateMapper.deleteByExample(example);
}
}
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