CityDictMapper.xml 1.19 KB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.laowu.mapper.CityDictMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.laowu.model.CityDictDO">
        <id column="id" property="id" />
        <result column="create_date" property="createDate" />
        <result column="update_date" property="updateDate" />
        <result column="delete_date" property="deleteDate" />
        <result column="province_id" property="provinceId" />
        <result column="city" property="city" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, province_id, city
    </sql>

    <select id="getCityName" parameterType="long" resultType="string">
        SELECT
            concat( t2.province, t.city ) AS cityName
        FROM
            city_dict t
            LEFT JOIN province_dict t2 ON t.province_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.id = #{id}
    </select>
</mapper>