WhitelistSnMapper.xml 2.48 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="cn.com.glsx.admin.modules.mapper.WhitelistSnMapper">
    <resultMap id="BaseMap" type="cn.com.glsx.admin.modules.entity.WhitelistSn">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="vin" property="vin" jdbcType="VARCHAR"/>
        <result column="sn" property="sn" jdbcType="VARCHAR"/>
        <result column="department_id" property="departmentId" jdbcType="INTEGER"/>
        <result column="del_flag" property="delFlag" jdbcType="TINYINT"/>
        <result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
        <result column="created_by" property="createdBy" jdbcType="INTEGER"/>
        <result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
        <result column="updated_by" property="updatedBy" jdbcType="INTEGER"/>
    </resultMap>
    <sql id="BaseColumns">
	  id, vin, sn, department_id, del_flag, created_date, created_by, updated_date,	updated_by
    </sql>

    <select id="selectAllByDepartmentId" resultMap="BaseMap">
        select
        <include refid="BaseColumns"/>
        from t_whitelist_sn
        where department_id = #{departmentId} and del_flag = 0
    </select>

    <update id="logicDeleteSnByDepartmentId">
        update t_whitelist_sn set del_flag = 1 where department_id = #{departmentId}
    </update>

    <select id="getWriteListVin" resultType="String">
        SELECT DISTINCT vin FROM t_whitelist_sn WHERE del_flag = 0
        <if test="deptIds != null and deptIds.size() > 0">
            and department_id IN
            <foreach collection="deptIds" separator="," open="(" close=")" item="item">
                #{item}
            </foreach>
        </if>
    </select>

    <!-- getWriteListVinListAndDeptIds -->

    <select id="getWriteListVinListAndDeptIds" resultType="String">
        SELECT DISTINCT vin FROM t_whitelist_sn WHERE del_flag = 0
        <if test="deptIds != null and deptIds.size() > 0">
            and department_id IN
            <foreach collection="deptIds" separator="," open="(" close=")" item="item">
                #{item}
            </foreach>
        </if>
        <if test="vinList != null and vinList.size() > 0">
            and vin IN
            <foreach collection="vinList" separator="," open="(" close=")" item="item">
                #{item}
            </foreach>
        </if>
    </select>
</mapper>