AdministerStationRoleMapper.xml 3.61 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.AdministerStationRoleMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.laowu.model.AdministerStationRoleDO">
        <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="administer_id" property="administerId" />
    </resultMap>

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

    <select id="workstationRoleAdministers" resultType="com.laowu.vo.admin.WorkstationRolesAdministersVO">
        SELECT DISTINCT
            t2.id,
            t.role_id,
            t.workstation_id,
            t.administer_id,
            t2.user_name,
            t2.account,
            t2.telephone
        FROM
            administer_station_role t
            LEFT JOIN administer t2 ON t.administer_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t.workstation_id = #{workstationId}
            AND t.role_id = #{roleId}
            <if test="province != null and province != ''">
                AND t.province = #{province}
            </if>
            <if test="city != null and city != ''">
                AND t.city = #{city}
            </if>
            <if test="county != null and county != ''">
                AND t.county = #{county}
            </if>
            <if test="town != null and town != ''">
                AND t.town = #{town}
            </if>
            <if test="village!=null and village != ''">
                AND t.village = ##{village}
            </if>
    </select>

    <select id="workstationAdministerGeos" resultType="com.laowu.model.AdministerStationRoleDO">
        SELECT
            t.*
        FROM
            administer_station_role t
        WHERE
            t.delete_date IS NULL
            AND t.administer_id = #{administerId}
            AND t.workstation_id = #{workstationId}
            AND t.role_id = #{roleId}
    </select>

    <select id="geoCount" resultType="integer">
        SELECT
            count(1)
        FROM
            administer_station_role t
        WHERE
            t.delete_date IS NULL
            AND t.administer_id = #{administerId}
            AND t.workstation_id = #{workstationId}
            AND t.role_id = #{roleId}
            AND t.province = #{province}
            AND t.city = #{city}
            AND t.county = #{county}
            AND t.town = #{town}
            AND t.village = #{village}
    </select>

    <select id="administerStations" parameterType="long" resultType="com.laowu.vo.admin.AdministerStationsVO">
        SELECT
            t.id,
            t2.workstation_name,
            t.county,
            t.town,
            t.village
        FROM
            administer_station_role t
            LEFT JOIN workstation_dict t2 ON t.workstation_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.administer_id = #{administerId}
    </select>

    <select id="administerRegionIds" parameterType="long" resultType="long">
        SELECT
            t.id
        FROM
            administer_station_role t
        WHERE
            t.delete_date IS NULL
            AND t.administer_id = #{administerId}
    </select>

</mapper>