diff --git a/ruoyi-plan/src/main/java/com/ruoyi/dhc/service/impl/DhcAreaServiceImpl.java b/ruoyi-plan/src/main/java/com/ruoyi/dhc/service/impl/DhcAreaServiceImpl.java
index 6fead17..372f493 100644
--- a/ruoyi-plan/src/main/java/com/ruoyi/dhc/service/impl/DhcAreaServiceImpl.java
+++ b/ruoyi-plan/src/main/java/com/ruoyi/dhc/service/impl/DhcAreaServiceImpl.java
@@ -4,7 +4,6 @@ import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.common.core.domain.entity.DhcArea;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.dhc.mapper.DhcAreaMapper;
import com.ruoyi.dhc.service.IDhcAreaService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,7 +35,12 @@ public class DhcAreaServiceImpl implements IDhcAreaService
@Override
public DhcArea selectDhcAreaByAreaId(Long areaId)
{
- return dhcAreaMapper.selectDhcAreaByAreaId(areaId);
+ DhcArea area = dhcAreaMapper.selectDhcAreaByAreaId(areaId);
+ if (area != null && area.getParentId() != null && area.getParentId() != 0L) {
+ DhcArea parentArea = dhcAreaMapper.selectDhcAreaByAreaId(area.getParentId());
+ area.setParentName(parentArea.getAreaName());
+ }
+ return area;
}
/**
@@ -61,9 +65,10 @@ public class DhcAreaServiceImpl implements IDhcAreaService
public int insertDhcArea(DhcArea dhcArea)
{
dhcArea.setCreateTime(DateUtils.getNowDate());
+ dhcArea.setDelFlag("0");
Integer count = dhcAreaMapper.selectCount(dhcArea);
- if (count > 1) {
- return -1;
+ if (count > 0) {
+ return -1;
} else {
return dhcAreaMapper.insertDhcArea(dhcArea);
}
@@ -79,8 +84,9 @@ public class DhcAreaServiceImpl implements IDhcAreaService
public int updateDhcArea(DhcArea dhcArea)
{
dhcArea.setUpdateTime(DateUtils.getNowDate());
+ dhcArea.setDelFlag("0");
Integer count = dhcAreaMapper.selectCount(dhcArea);
- if (count > 1) {
+ if (count > 0) {
return -1;
} else {
return dhcAreaMapper.updateDhcArea(dhcArea);
@@ -108,7 +114,15 @@ public class DhcAreaServiceImpl implements IDhcAreaService
@Override
public int deleteDhcAreaByAreaId(Long areaId)
{
- return dhcAreaMapper.deleteDhcAreaByAreaId(areaId);
+ DhcArea dhcArea = new DhcArea();
+ dhcArea.setParentId(areaId);
+ dhcArea.setDelFlag("0");
+ Integer count = dhcAreaMapper.selectCount(dhcArea);
+ if (count > 0) {
+ return -1;
+ } else {
+ return dhcAreaMapper.deleteDhcAreaByAreaId(areaId);
+ }
}
/**
diff --git a/ruoyi-plan/src/main/resources/mapper/dhc/DhcAreaMapper.xml b/ruoyi-plan/src/main/resources/mapper/dhc/DhcAreaMapper.xml
index 20e9858..beed5ad 100644
--- a/ruoyi-plan/src/main/resources/mapper/dhc/DhcAreaMapper.xml
+++ b/ruoyi-plan/src/main/resources/mapper/dhc/DhcAreaMapper.xml
@@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
@@ -22,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- select area_id, parent_id, area_code, area_name, area_type, area_level, order_num, area_desc, status, del_flag, create_by, create_time, update_by, update_time from dhc_area
+ select area_id, parent_id, area_code, area_name, product_line_code, area_type, area_level, order_num, area_desc, status, del_flag, create_by, create_time, update_by, update_time from dhc_area