根据三方区域类型获取区域列表 0-根 1=大区 2=战区 3=小区(督导区 4=门店

This commit is contained in:
wangxiaopeng
2024-03-29 11:41:02 +08:00
parent 967afb5352
commit b4b5ad4ec4
7 changed files with 80 additions and 4 deletions

View File

@@ -1,6 +1,5 @@
package com.cool.store.dao; package com.cool.store.dao;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.dto.RegionNode; import com.cool.store.dto.RegionNode;
import com.cool.store.entity.RegionDO; import com.cool.store.entity.RegionDO;
import com.cool.store.mapper.RegionMapper; import com.cool.store.mapper.RegionMapper;
@@ -8,11 +7,13 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -172,5 +173,8 @@ public class RegionDao {
return regionMapper.getRegionByParentIds(regionIdList); return regionMapper.getRegionByParentIds(regionIdList);
} }
public List<RegionDO> listByThirdRegionType(Long parentId, String thirdRegionType) {
return regionMapper.listByThirdRegionType(parentId, thirdRegionType);
}
} }

View File

@@ -94,4 +94,7 @@ public interface RegionMapper {
List<RegionDO> getRegionByParentIds(@Param("regionIdList") List<String> regionIdList); List<RegionDO> getRegionByParentIds(@Param("regionIdList") List<String> regionIdList);
List<RegionDO> listByThirdRegionType(@Param("parentId")Long parentId, @Param("thirdRegionType")String thirdRegionType);
} }

View File

@@ -17,7 +17,8 @@
region_type as regionType, region_type as regionType,
region_path as regionPath, region_path as regionPath,
deleted as deleted, deleted as deleted,
third_dept_id as thirdDeptId third_dept_id as thirdDeptId,
third_region_type as thirdRegionType
</sql> </sql>
<select id="getRegionByRegionIdsForMap" resultType="com.cool.store.entity.RegionDO"> <select id="getRegionByRegionIdsForMap" resultType="com.cool.store.entity.RegionDO">
@@ -332,4 +333,17 @@
</select> </select>
<select id="listByThirdRegionType" resultType="com.cool.store.entity.RegionDO">
select <include refid="fields"/>
from region_${enterpriseId}
where deleted = 0
<if test="parentId != null">
and parent_id= #{parentId}
</if>
<if test="thirdRegionType != null and thirdRegionType != ''">
and third_region_type = #{thirdRegionType}
</if>
</select>
</mapper> </mapper>

View File

@@ -150,6 +150,8 @@ public class RegionDO {
*/ */
private Boolean isExternalNode; private Boolean isExternalNode;
private String thirdRegionType;
public RegionDO(Long id, String name, String parentId, String groupId, Long createTime, String createName) { public RegionDO(Long id, String name, String parentId, String groupId, Long createTime, String createName) {
this.id = id; this.id = id;
this.name = name; this.name = name;

View File

@@ -1,7 +1,10 @@
package com.cool.store.service; package com.cool.store.service;
import com.cool.store.entity.RegionDO;
import com.cool.store.vo.RegionPathNameVO; import com.cool.store.vo.RegionPathNameVO;
import java.util.List;
public interface RegionService { public interface RegionService {
RegionPathNameVO getAllRegionName(Long regionId); RegionPathNameVO getAllRegionName(Long regionId);
@@ -13,4 +16,6 @@ public interface RegionService {
*/ */
Long getBigRegionIdByAreaId(Long wantShopAreaId); Long getBigRegionIdByAreaId(Long wantShopAreaId);
List<RegionDO> listByThirdRegionType(Long parentId, String thirdRegionType);
} }

View File

@@ -24,6 +24,8 @@ import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.cool.store.enums.ErrorCodeEnum.PARAMS_VALIDATE_ERROR;
/** /**
* @ClassName RegionServiceImpl * @ClassName RegionServiceImpl
* @Description 区域服务 * @Description 区域服务
@@ -114,4 +116,12 @@ public class RegionServiceImpl implements RegionService {
} }
return 0L; return 0L;
} }
@Override
public List<RegionDO> listByThirdRegionType(Long parentId, String thirdRegionType) {
if(Objects.isNull(parentId) && StringUtils.isBlank(thirdRegionType)){
throw new ServiceException(PARAMS_VALIDATE_ERROR);
}
return regionDao.listByThirdRegionType(parentId, thirdRegionType);
}
} }

View File

@@ -0,0 +1,38 @@
package com.cool.store.controller.webb;
import com.cool.store.entity.RegionDO;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.RegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @ClassName RegionController
* @Description 区域
*/
@RestController
@RequestMapping("/pc/region")
@Api(tags = "区域信息")
@Slf4j
public class RegionController {
@Autowired
private RegionService regionService;
@ApiOperation("根据三方区域类型获取区域列表 0-根 1=大区 2=战区 3=小区(督导区 4=门店")
@GetMapping("/listByThirdRegionType")
public ResponseResult<List<RegionDO>> listByThirdRegionType(@RequestParam(value = "parentId", required = false) Long parentId,
@RequestParam(value = "thirdRegionType", required = false) String thirdRegionType) {
return ResponseResult.success(regionService.listByThirdRegionType(parentId, thirdRegionType));
}
}