| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package com.zxyj.mapper;
- import com.baomidou.mybatisplus.core.mapper.BaseMapper;
- import com.zxyj.entity.Street;
- import org.apache.ibatis.annotations.Mapper;
- import org.apache.ibatis.annotations.Param;
- import org.apache.ibatis.annotations.Select;
- import java.util.List;
- @Mapper
- public interface StreetMapper extends BaseMapper<Street> {
- /**
- * 根据层级查询地址列表
- */
- @Select("SELECT * FROM streets WHERE level = #{level} ORDER BY sort_order, id")
- List<Street> findByLevel(@Param("level") Integer level);
- /**
- * 根据父级ID查询子级地址
- */
- @Select("SELECT * FROM streets WHERE parent_id = #{parentId} ORDER BY sort_order, id")
- List<Street> findByParentId(@Param("parentId") Long parentId);
- /**
- * 根据编码查询
- */
- @Select("SELECT * FROM streets WHERE street_code = #{code}")
- Street findByCode(@Param("code") String code);
- /**
- * 查询所有省份
- */
- @Select("SELECT * FROM streets WHERE level = 1 ORDER BY sort_order, id")
- List<Street> findAllProvinces();
- /**
- * 查询指定省份下的城市
- */
- @Select("SELECT * FROM streets WHERE level = 2 AND parent_id = #{provinceId} ORDER BY sort_order, id")
- List<Street> findCitiesByProvince(@Param("provinceId") Long provinceId);
- /**
- * 查询指定城市下的区县
- */
- @Select("SELECT * FROM streets WHERE level = 3 AND parent_id = #{cityId} ORDER BY sort_order, id")
- List<Street> findDistrictsByCity(@Param("cityId") Long cityId);
- /**
- * 查询指定区县下的街道
- */
- @Select("SELECT * FROM streets WHERE level = 4 AND parent_id = #{districtId} ORDER BY sort_order, id")
- List<Street> findStreetsByDistrict(@Param("districtId") Long districtId);
- /**
- * 搜索地址(模糊匹配)
- */
- @Select("SELECT * FROM streets WHERE full_name LIKE CONCAT('%', #{keyword}, '%') ORDER BY level, sort_order LIMIT 20")
- List<Street> search(@Param("keyword") String keyword);
- }
|