Commit 0a050f4a authored by neo's avatar neo

[DEL] delete organization structrue service interface

parent 819be5cb
package pwc.taxtech.atms.controller; package pwc.taxtech.atms.controller;
import java.util.List; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -11,51 +10,52 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -11,51 +10,52 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import pwc.taxtech.atms.dto.IdModel; import pwc.taxtech.atms.dto.IdModel;
import pwc.taxtech.atms.dto.OrganizationStructureDto; import pwc.taxtech.atms.dto.OrganizationStructureDto;
import pwc.taxtech.atms.dto.OrganizationStructureInputDto; import pwc.taxtech.atms.dto.OrganizationStructureInputDto;
import pwc.taxtech.atms.service.OrganizationStructureService; import pwc.taxtech.atms.service.impl.OrganizationStructureServiceImpl;
import java.util.List;
/** @see PwC.Tax.Tech.Atms.WebApi.Controllers.OrganizationStructureController.cs */
@RestController @RestController
@RequestMapping("/api/v1/organizationstructure") @RequestMapping("/api/v1/organizationstructure")
public class OrganizationStructureController { public class OrganizationStructureController {
private static Logger logger = LoggerFactory.getLogger(OrganizationStructureController.class); private static Logger logger = LoggerFactory.getLogger(OrganizationStructureController.class);
@Autowired @Autowired
private OrganizationStructureService organizationStructureService; private OrganizationStructureServiceImpl organizationStructureService;
@ApiOperation(value = "主数据机构层级查询") @ApiOperation(value = "主数据机构层级查询")
@RequestMapping(value = "/getlist", method = RequestMethod.GET) @RequestMapping(value = "/getlist", method = RequestMethod.GET)
public @ResponseBody List<OrganizationStructureDto> getOrganizationStructures() { public @ResponseBody
List<OrganizationStructureDto> getOrganizationStructures() {
logger.debug("OrganizationStructureController /getlist"); logger.debug("OrganizationStructureController /getlist");
return organizationStructureService.getOrganizationStructures(); return organizationStructureService.getOrganizationStructures();
} }
@ApiOperation(value = "主数据机构层级增加") @ApiOperation(value = "主数据机构层级增加")
// @ApiImplicitParam(name = "organizationStructureDtoList", value = "organizationStructureDto List", required = true, dataType = "List<OrganizationStructureDto>") // @ApiImplicitParam(name = "organizationStructureDtoList", value = "organizationStructureDto List", required = true, dataType = "List<OrganizationStructureDto>")
@RequestMapping(value= "/add", method = RequestMethod.POST) @RequestMapping(value = "/add", method = RequestMethod.POST)
public void addOrganizationStructures(@RequestBody List<OrganizationStructureInputDto> organizationStructureDtoList) { public void addOrganizationStructures(@RequestBody List<OrganizationStructureInputDto> organizationStructureDtoList) {
logger.debug("OrganizationStructureController /add"); logger.debug("OrganizationStructureController /add");
organizationStructureService.addOrganizationStructures(organizationStructureDtoList); organizationStructureService.addOrganizationStructures(organizationStructureDtoList);
} }
@ApiOperation(value = "主数据机构层级删除") @ApiOperation(value = "主数据机构层级删除")
@ApiImplicitParam(name = "idModel", value = "idModel", required = true, dataType = "IdModel") @ApiImplicitParam(name = "idModel", value = "idModel", required = true, dataType = "IdModel")
@RequestMapping(value= "/delete", method = RequestMethod.POST) @RequestMapping(value = "/delete", method = RequestMethod.POST)
public @ResponseBody Integer deleteOrganizationStructure(@RequestBody IdModel idModel) { public @ResponseBody
Integer deleteOrganizationStructure(@RequestBody IdModel idModel) {
logger.debug("OrganizationStructureController /delete"); logger.debug("OrganizationStructureController /delete");
return organizationStructureService.deleteOrganizationStructure(idModel); return organizationStructureService.deleteOrganizationStructure(idModel);
} }
@ApiOperation(value = "主数据机构层级修改") @ApiOperation(value = "主数据机构层级修改")
// @ApiImplicitParam(name = "organizationStructureDtoList", value = "organizationStructureDto List", required = true, dataType = "List<OrganizationStructureDto>") // @ApiImplicitParam(name = "organizationStructureDtoList", value = "organizationStructureDto List", required = true, dataType = "List<OrganizationStructureDto>")
@RequestMapping(method = RequestMethod.PUT) @RequestMapping(method = RequestMethod.PUT)
public @ResponseBody Boolean updateOrganizationStructure(@RequestBody List<OrganizationStructureInputDto> organizationStructureDtoList) { public @ResponseBody
Boolean updateOrganizationStructure(@RequestBody List<OrganizationStructureInputDto> organizationStructureDtoList) {
logger.debug("OrganizationStructureController update"); logger.debug("OrganizationStructureController update");
return organizationStructureService.updateOrganizationStructures(organizationStructureDtoList); return organizationStructureService.updateOrganizationStructures(organizationStructureDtoList);
} }
......
package pwc.taxtech.atms.service;
import java.util.List;
import pwc.taxtech.atms.dto.IdModel;
import pwc.taxtech.atms.dto.OrganizationStructureDto;
import pwc.taxtech.atms.dto.OrganizationStructureInputDto;
public interface OrganizationStructureService {
List<OrganizationStructureDto> getOrganizationStructures();
void addOrganizationStructures(List<OrganizationStructureInputDto> organizationStructureList);
Integer deleteOrganizationStructure(IdModel idModel);
Boolean updateOrganizationStructures(List<OrganizationStructureInputDto> organizationStructureDtoList);
}
package pwc.taxtech.atms.service.impl; package pwc.taxtech.atms.service.impl;
import java.util.ArrayList; import com.alibaba.fastjson.JSON;
import java.util.Date;
import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSON;
import pwc.taxtech.atms.exception.ApplicationException;
import pwc.taxtech.atms.common.AuthUserHelper; import pwc.taxtech.atms.common.AuthUserHelper;
import pwc.taxtech.atms.common.CommonConstants; import pwc.taxtech.atms.common.CommonConstants;
import pwc.taxtech.atms.common.CommonUtils; import pwc.taxtech.atms.common.CommonUtils;
...@@ -27,13 +20,16 @@ import pwc.taxtech.atms.dto.OrganizationStructureInputDto; ...@@ -27,13 +20,16 @@ import pwc.taxtech.atms.dto.OrganizationStructureInputDto;
import pwc.taxtech.atms.dto.UpdateLogParams; import pwc.taxtech.atms.dto.UpdateLogParams;
import pwc.taxtech.atms.entity.OrganizationStructure; import pwc.taxtech.atms.entity.OrganizationStructure;
import pwc.taxtech.atms.entity.OrganizationStructureExample; import pwc.taxtech.atms.entity.OrganizationStructureExample;
import pwc.taxtech.atms.exception.ApplicationException;
import pwc.taxtech.atms.service.OperationLogService; import pwc.taxtech.atms.service.OperationLogService;
import pwc.taxtech.atms.service.OrganizationService; import pwc.taxtech.atms.service.OrganizationService;
import pwc.taxtech.atms.service.OrganizationStructureService;
/** @see PwC.Tax.Tech.Atms.Admin.Application.Services.Impl.OrganizationStructureService.cs */ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service @Service
public class OrganizationStructureServiceImpl implements OrganizationStructureService { public class OrganizationStructureServiceImpl {
private static final Logger logger = LoggerFactory.getLogger(OrganizationStructureServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(OrganizationStructureServiceImpl.class);
...@@ -49,7 +45,6 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe ...@@ -49,7 +45,6 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe
@Autowired @Autowired
private AuthUserHelper authUserHelper; private AuthUserHelper authUserHelper;
@Override
public List<OrganizationStructureDto> getOrganizationStructures() { public List<OrganizationStructureDto> getOrganizationStructures() {
logger.debug("OrganizationStructureService getOrganizationStructures"); logger.debug("OrganizationStructureService getOrganizationStructures");
OrganizationStructureExample organizationStructureExample = new OrganizationStructureExample(); OrganizationStructureExample organizationStructureExample = new OrganizationStructureExample();
...@@ -59,7 +54,6 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe ...@@ -59,7 +54,6 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe
return rotateOrganizationStructureList(organizationStructureList); return rotateOrganizationStructureList(organizationStructureList);
} }
@Override
public void addOrganizationStructures(List<OrganizationStructureInputDto> organizationStructureDtoList) { public void addOrganizationStructures(List<OrganizationStructureInputDto> organizationStructureDtoList) {
logger.debug("OrganizationStructureService addOrganizationStructure"); logger.debug("OrganizationStructureService addOrganizationStructure");
logger.debug("organization structure to add: {}", JSON.toJSONString(organizationStructureDtoList, true)); logger.debug("organization structure to add: {}", JSON.toJSONString(organizationStructureDtoList, true));
...@@ -72,7 +66,7 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe ...@@ -72,7 +66,7 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe
} }
} }
public void addOrganizationStructure(OrganizationStructureInputDto organizationStructureDto) { public void addOrganizationStructure(OrganizationStructureInputDto organizationStructureDto) {
OrganizationStructure organizationStructure = rotateOrganizationStructureDto(organizationStructureDto); OrganizationStructure organizationStructure = rotateOrganizationStructureDto(organizationStructureDto);
organizationStructure.setId(CommonUtils.getUUID()); organizationStructure.setId(CommonUtils.getUUID());
...@@ -87,17 +81,16 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe ...@@ -87,17 +81,16 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe
operationLogDto.setAction(OperationAction.New.value()); operationLogDto.setAction(OperationAction.New.value());
operationLogService.addOperationLog(operationLogDto); operationLogService.addOperationLog(operationLogDto);
} }
private void makeUpOperationLogDto(OperationLogDto operationLogDto) { private void makeUpOperationLogDto(OperationLogDto operationLogDto) {
operationLogDto.setModule(OperationModule.BasicDataOrganizationStructure.value()); operationLogDto.setModule(OperationModule.BasicDataOrganizationStructure.value());
operationLogDto.setLogType(OperateLogType.OperationLogBasicData.value()); operationLogDto.setLogType(OperateLogType.OperationLogBasicData.value());
} }
@Override
public Integer deleteOrganizationStructure(IdModel idModel) { public Integer deleteOrganizationStructure(IdModel idModel) {
logger.debug("OrganizationStructureService deleteOrganizationStructure"); logger.debug("OrganizationStructureService deleteOrganizationStructure");
logger.debug("organization structure to delete, id: {}", JSON.toJSONString(idModel, true)); logger.debug("organization structure to delete, id: {}", JSON.toJSONString(idModel, true));
if (idModel == null || idModel.getId() == null) { if (idModel == null || idModel.getId() == null) {
throw new ApplicationException(CommonConstants.JSONNULLOBJECT); throw new ApplicationException(CommonConstants.JSONNULLOBJECT);
} }
...@@ -118,11 +111,10 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe ...@@ -118,11 +111,10 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe
return result; return result;
} }
@Override
public Boolean updateOrganizationStructures(List<OrganizationStructureInputDto> organizationStructureDtoList) { public Boolean updateOrganizationStructures(List<OrganizationStructureInputDto> organizationStructureDtoList) {
logger.debug("OrganizationStructureService updateOrganizationStructures"); logger.debug("OrganizationStructureService updateOrganizationStructures");
logger.debug("organization structure to update: {}", JSON.toJSONString(organizationStructureDtoList, true)); logger.debug("organization structure to update: {}", JSON.toJSONString(organizationStructureDtoList, true));
if (organizationStructureDtoList.isEmpty()) { if (organizationStructureDtoList.isEmpty()) {
throw new ApplicationException(CommonConstants.JSONNULLOBJECT); throw new ApplicationException(CommonConstants.JSONNULLOBJECT);
} }
...@@ -130,22 +122,22 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe ...@@ -130,22 +122,22 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe
for (OrganizationStructureInputDto organizationStructureDto : organizationStructureDtoList) { for (OrganizationStructureInputDto organizationStructureDto : organizationStructureDtoList) {
//isActive changed or not //isActive changed or not
boolean isStatusChangeOperation = false; boolean isStatusChangeOperation = false;
if (organizationStructureDto == null || !StringUtils.hasText(organizationStructureDto.getId())) { if (organizationStructureDto == null || !StringUtils.hasText(organizationStructureDto.getId())) {
throw new ApplicationException("primary key can't be null"); throw new ApplicationException("primary key can't be null");
} }
// current OrganizationStructure // current OrganizationStructure
OrganizationStructure organizationStructure = organizationStructureMapper OrganizationStructure organizationStructure = organizationStructureMapper
.selectByPrimaryKey(organizationStructureDto.getId()); .selectByPrimaryKey(organizationStructureDto.getId());
if (organizationStructure == null) { if (organizationStructure == null) {
throw new ApplicationException("can't find organizationStructure, id: " + organizationStructureDto.getId()); throw new ApplicationException("can't find organizationStructure, id: " + organizationStructureDto.getId());
} }
//copy current OrganizationStructure as tmp //copy current OrganizationStructure as tmp
OrganizationStructure originOrganizationStructure = new OrganizationStructure(); OrganizationStructure originOrganizationStructure = new OrganizationStructure();
CommonUtils.copyProperties(organizationStructure, originOrganizationStructure); CommonUtils.copyProperties(organizationStructure, originOrganizationStructure);
if (organizationStructureDto.getIsActive() != organizationStructure.getIsActive() || organizationStructureDto.getName() != organizationStructure.getName()) { if (organizationStructureDto.getIsActive() != organizationStructure.getIsActive() || organizationStructureDto.getName() != organizationStructure.getName()) {
isStatusChangeOperation = true; isStatusChangeOperation = true;
organizationStructure.setIsActive(organizationStructureDto.getIsActive()); organizationStructure.setIsActive(organizationStructureDto.getIsActive());
...@@ -157,9 +149,9 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe ...@@ -157,9 +149,9 @@ public class OrganizationStructureServiceImpl implements OrganizationStructureSe
} }
organizationStructure.setUpdateTime(new Date()); organizationStructure.setUpdateTime(new Date());
organizationStructureMapper.updateByPrimaryKey(organizationStructure); organizationStructureMapper.updateByPrimaryKey(organizationStructure);
//add operation log //add operation log
if(isStatusChangeOperation) { if (isStatusChangeOperation) {
UpdateLogParams updateLogParams = new UpdateLogParams(); UpdateLogParams updateLogParams = new UpdateLogParams();
updateLogParams.setOperationObject(originOrganizationStructure.getName()); updateLogParams.setOperationObject(originOrganizationStructure.getName());
updateLogParams.setOriginalState(originOrganizationStructure); updateLogParams.setOriginalState(originOrganizationStructure);
......
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