WorkstationOutsideGeoMapper.xml 3.1 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.WorkstationOutsideGeoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.laowu.model.WorkstationOutsideGeoDO">
        <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="workstation_id" property="workstationId" />
        <result column="outside_geo_name" property="outsideGeoName" />
        <result column="province" property="province" />
        <result column="city" property="city" />
        <result column="county" property="county" />
        <result column="town" property="town" />
        <result column="village" property="village" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, workstation_id, outside_geo_name, province, city, county, town, village
    </sql>

    <select id="geoCnt"  resultType="integer">
        SELECT
            count( 1 )
        FROM
            workstation_outside_geo t
        WHERE
            t.delete_date IS NULL
            AND t.workstation_id = #{workstationId}
            AND t.province = #{province}
            AND t.city = #{city}
            AND t.town = #{town}
            AND t.village = #{village}
            <if test="id != null and id != null">
                and t.id != #{id}
            </if>
    </select>

    <update id="updateGeo">
        update workstation_outside_geo
        <trim suffixOverrides=",">
            update_date = now(),
            <if test="province !=null and province !=''">
                province = #{province},
            </if>
            <if test="city !=null and city !=''">
                city = #{city},
            </if>
            <if test="county !=null and county !=''">
                county = #{county},
            </if>
            <if test="town !=null and town !=''">
                town = #{town},
            </if>
            <if test="village !=null and village !=''">
                village = #{village},
            </if>
        </trim>
        where id = #{id}
    </update>

    <select id="queryGeos" resultType="com.laowu.model.WorkstationOutsideGeoDO">
        SELECT
            *
        FROM
            workstation_outside_geo t
        WHERE
            t.delete_date IS NULL
            AND t.workstation_id = #{workstationId}
            <if test="province != null and province != ''">
                AND t.province = #{province}
            </if>
            <if test="city != null and city != ''">
                AND t.city = #{city}
            </if>
            <if test="town != null and town != ''">
                AND t.town = #{town}
            </if>
            <if test="village != null and village != ''">
                AND t.village = #{village}
            </if>
    </select>

</mapper>