zjk
2026-09-29 54dcf0a82e7490fa58b1c056d5c0b9cb739c2931
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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<SysRegion> {
 
    /**
     * 按地区编码查询单条行政区划。
     */
    @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<SysRegion> 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<SysRegion> selectAllOrdered();
}