package com.tcm.training.admin.app.register.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.tcm.training.admin.app.register.entity.SysRegion; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.util.List; /** * APP 注册行政区划查询 Mapper。 */ @Mapper public interface SysRegionMapper extends BaseMapper { /** * 按地区编码查询单条行政区划。 */ @Select("SELECT id, name, code, cityCode, parentId, english FROM sys_region WHERE code = #{code} LIMIT 1") SysRegion selectByCode(@Param("code") String code); /** * 按父级 ID 查询下级行政区划列表。 */ @Select("SELECT id, name, code, cityCode, parentId, english FROM sys_region WHERE parentId = #{parentId} ORDER BY id ASC") List selectByParentId(@Param("parentId") Long parentId); /** * 按父级 ID 和名称查询单条行政区划。 */ @Select("SELECT id, name, code, cityCode, parentId, english FROM sys_region WHERE parentId = #{parentId} AND name = #{name} LIMIT 1") SysRegion selectByParentIdAndName(@Param("parentId") Long parentId, @Param("name") String name); /** * 查询全部行政区划,用于构建地区滚轮选择器的数据集。 */ @Select("SELECT id, name, code, cityCode, parentId, english FROM sys_region ORDER BY code ASC, id ASC") List selectAllOrdered(); }