diff --git a/mhd_oms/src/main/java/com/mhd/oms/application/service/erpCountry/ErpCountryApplicationService.java b/mhd_oms/src/main/java/com/mhd/oms/application/service/erpCountry/ErpCountryApplicationService.java index e39317e01..a55282432 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/application/service/erpCountry/ErpCountryApplicationService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/application/service/erpCountry/ErpCountryApplicationService.java @@ -2,19 +2,23 @@ package com.mhd.oms.application.service.erpCountry; import com.mhd.common.core.web.page.TableDataInfo; +import com.mhd.common.security.utils.SecurityUtils; import com.mhd.oms.domain.erpCountry.entity.ErpCountry; import com.mhd.oms.domain.erpCountry.repository.mapper.ErpCountryMapper; import com.mhd.oms.domain.erpCountry.repository.po.ErpCountryPO; import com.mhd.oms.interfaces.dto.erpCountry.ErpCountryDTO; +import com.mhd.system.api.model.LoginUser; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Date; import java.util.List; @Service @Slf4j -public class ErpCountryApplicationService { +public class ErpCountryApplicationService{ @Resource private ErpCountryMapper erpCountryMapper; @@ -30,4 +34,34 @@ public class ErpCountryApplicationService { } + + public int insert(ErpCountryDTO erpCountryDTO) { + ErpCountry erpCountry = new ErpCountry(); + BeanUtils.copyProperties(erpCountryDTO, erpCountry); + erpCountry.setPushStatus(1); + erpCountry.setDelFlag(1); + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (loginUser != null) { + erpCountry.setCreateBy(loginUser.getUserid()); + erpCountry.setOrganizationId(loginUser.getUserPo().getOrganizationId()); + erpCountry.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); + } + erpCountry.setCreateTime(new Date()); + return erpCountryMapper.insert(erpCountry); + } + + public int update(ErpCountryDTO erpCountryDTO) { + ErpCountry erpCountry = new ErpCountry(); + BeanUtils.copyProperties(erpCountryDTO, erpCountry); + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (loginUser != null) { + erpCountry.setUpdateBy(loginUser.getUserid()); + erpCountry.setUpdateTime(new Date()); + } + return erpCountryMapper.updateById(erpCountry); + } + + public int deleteByIds(List idList) { + return erpCountryMapper.deleteByIds(idList); + } } diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/erpCountry/repository/mapper/ErpCountryMapper.java b/mhd_oms/src/main/java/com/mhd/oms/domain/erpCountry/repository/mapper/ErpCountryMapper.java index 434d4a3c4..2d8e6fedf 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/erpCountry/repository/mapper/ErpCountryMapper.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/erpCountry/repository/mapper/ErpCountryMapper.java @@ -1,6 +1,7 @@ package com.mhd.oms.domain.erpCountry.repository.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.mhd.oms.domain.erpCountry.entity.ErpCountry; import com.mhd.oms.domain.erpCountry.repository.po.ErpCountryPO; import com.mhd.oms.interfaces.dto.erpCountry.ErpCountryDTO; @@ -10,7 +11,7 @@ import org.apache.ibatis.annotations.Param; import java.util.List; @Mapper -public interface ErpCountryMapper { +public interface ErpCountryMapper extends BaseMapper { /** * @@ -18,4 +19,6 @@ public interface ErpCountryMapper { * @return */ List queryList(@Param("erpCountryDTO") ErpCountryDTO erpCountryDTO); + + int deleteByIds(@Param("idList") List idList); } diff --git a/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/erpCountry/ErpCountryApi.java b/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/erpCountry/ErpCountryApi.java index b17ea0881..038560e02 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/erpCountry/ErpCountryApi.java +++ b/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/erpCountry/ErpCountryApi.java @@ -2,15 +2,17 @@ package com.mhd.oms.interfaces.facade.erpCountry; import com.mhd.common.core.web.controller.BaseController; +import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.core.web.page.TableDataInfo; import com.mhd.oms.application.service.erpCountry.ErpCountryApplicationService; import com.mhd.oms.interfaces.dto.erpCountry.ErpCountryDTO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; @Api(tags = "企业国别管理") @@ -27,5 +29,29 @@ public class ErpCountryApi extends BaseController{ return erpCountryApplicationService.queryList(erpCountryDTO); } + @ApiOperation("编辑企业国别") + @PostMapping("/edit") + public AjaxResult edit(@RequestBody ErpCountryDTO erpCountryDTO) { + if (erpCountryDTO.getId() != null) { + return toAjax(erpCountryApplicationService.update(erpCountryDTO)); + } else { + return toAjax(erpCountryApplicationService.insert(erpCountryDTO)); + } + } + + + @ApiOperation("删除企业国别") + @DeleteMapping("/deleteBatch") + public AjaxResult deleteBatch(@RequestParam("ids") String ids) { + if (ids == null || ids.isEmpty()) { + return AjaxResult.error("没有选择要删除的数据"); + } + List idList = new ArrayList<>(); + for (String id : ids.split(",")) { + idList.add(Long.parseLong(id)); + } + return toAjax(erpCountryApplicationService.deleteByIds(idList)); + } + } diff --git a/mhd_oms/src/main/resources/mapper/erpCountry/ErpCountryMapper.xml b/mhd_oms/src/main/resources/mapper/erpCountry/ErpCountryMapper.xml index 72ef2edf0..d3ac78fc3 100644 --- a/mhd_oms/src/main/resources/mapper/erpCountry/ErpCountryMapper.xml +++ b/mhd_oms/src/main/resources/mapper/erpCountry/ErpCountryMapper.xml @@ -23,4 +23,11 @@ ORDER BY CREATE_TIME DESC + + UPDATE ERP_COUNTRY SET DEL_FLAG = 0 WHERE ID IN + + #{id} + + + \ No newline at end of file