Pu Zhibing
2025-02-27 b380c7e0d061b5502114ab1214c2a217f7f6ee92
新增加行政区划查询接口
5个文件已修改
136 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/api/SystemUserController.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/dao/SystemUserMapper.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/ISystemUserService.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/SystemUserServiceImpl.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/resources/mapper/SystemUserMapper.xml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/api/SystemUserController.java
@@ -19,6 +19,8 @@
import com.panzhihua.sangeshenbian.warpper.SystemUserListVo;
import com.panzhihua.sangeshenbian.warpper.TokenVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.RedisTemplate;
@@ -27,9 +29,7 @@
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -243,4 +243,31 @@
        BeanUtils.copyProperties(systemUser, systemUserVo);
        return R.ok(systemUserVo);
    }
    @GetMapping("/getAdministrativeDivision/{id}/{tier}")
    @ApiOperation(value = "获取行政区划层级联动数据", tags = {"三个身边后台-人员管理"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "上级id", required = false, dataType = "string"),
            @ApiImplicitParam(name = "tier", value = "数据层级(2=区县,3=街道,4=社区)", required = true, dataType = "int"),
    })
    @OperLog(operModul = "三个身边后台",operType = 0,businessType = "获取行政区划层级联动数据")
    public R<List<Map<String, Object>>> getAdministrativeDivision(@PathVariable("id") String id, @PathVariable("tier") Integer tier){
        List<Map<String, Object>> list = new ArrayList<>();
        //区县
        if(2 == tier){
            list = systemUserService.getRegion("510400");
        }
        //街道
        if(3 == tier){
            list = systemUserService.getStreet(id);
        }
        //社区
        if(4 == tier){
            list = systemUserService.getCommunity(id);
        }
        return R.ok(list);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/dao/SystemUserMapper.java
@@ -9,6 +9,9 @@
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
 * @author zhibing.pu
 * @Date 2025/2/18 22:29
@@ -22,4 +25,27 @@
     * @return
     */
    IPage<SystemUserListVo> list(Page page, @Param("accountLevel") Integer accountLevel, @Param("query") SystemUserList query);
    /**
     * 获取行政区划数据
     * @param pcode
     * @return
     */
    List<Map<String, Object>> getRegion(@Param("pcode") String pcode);
    /**
     * 获取街道数据
     * @param areaCode
     * @return
     */
    List<Map<String, Object>> getStreet(@Param("areaCode") String areaCode);
    /**
     * 获取社区数据
     * @param streetId
     * @return
     */
    List<Map<String, Object>> getCommunity(@Param("streetId") String streetId);
}
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/ISystemUserService.java
@@ -7,6 +7,8 @@
import com.panzhihua.sangeshenbian.warpper.SystemUserList;
import com.panzhihua.sangeshenbian.warpper.SystemUserListVo;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
@@ -26,4 +28,28 @@
     * 根据手机号码查询小程序用户在三个身边的上级角色用户
     */
    Optional<SystemUser> getSystemUserByPhone(String phone);
    /**
     * 获取行政区划数据
     * @param pcode
     * @return
     */
    List<Map<String, Object>> getRegion(String pcode);
    /**
     * 获取街道数据
     * @param areaCode
     * @return
     */
    List<Map<String, Object>> getStreet(String areaCode);
    /**
     * 获取社区数据
     * @param streetId
     * @return
     */
    List<Map<String, Object>> getCommunity(String streetId);
}
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/SystemUserServiceImpl.java
@@ -11,6 +11,8 @@
import com.panzhihua.sangeshenbian.warpper.SystemUserListVo;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
@@ -48,4 +50,37 @@
                .eq(SystemUser::getPhone, phone).ne(SystemUser::getStatus, 3)
                .eq(SystemUser::getIsAdmin, 1).last("LIMIT 1").oneOpt();
    }
    /**
     * 获取行政区划数据
     * @param pcode
     * @return
     */
    @Override
    public List<Map<String, Object>> getRegion(String pcode) {
        return this.baseMapper.getRegion(pcode);
    }
    /**
     * 获取街道数据
     * @param areaCode
     * @return
     */
    @Override
    public List<Map<String, Object>> getStreet(String areaCode) {
        return this.baseMapper.getStreet(areaCode);
    }
    /**
     * 获取社区数据
     * @param streetId
     * @return
     */
    @Override
    public List<Map<String, Object>> getCommunity(String streetId) {
        return this.baseMapper.getCommunity(streetId);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/resources/mapper/SystemUserMapper.xml
@@ -46,4 +46,20 @@
        </if>
        order by a.create_time desc
    </select>
    <select id="getRegion" resultType="map">
        select region_code as id, region_name as name from bc_region where parent_id = #{pcode}
    </select>
    <select id="getStreet" resultType="map">
        select street_id as id, name as name from com_street where area_code = #{pcode}
    </select>
    <select id="getCommunity" resultType="map">
        select community_id as id, name as name from com_act where street_id = #{streetId}
    </select>
</mapper>