VehiclePermitMapper.xml 3.73 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.VehiclePermitMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.VehiclePermit">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="content_id" jdbcType="INTEGER" property="contentId"/>
        <result column="accorder_id" jdbcType="INTEGER" property="accorderId"/>
        <result column="receiver_id" jdbcType="INTEGER" property="receiverId"/>
        <result column="content_type" jdbcType="TINYINT" property="contentType"/>
        <result column="permit_type" jdbcType="VARCHAR" property="permitType"/>
        <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
        <result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
        <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, content_id, accorder_id, receiver_id, content_type, permit_type, del_flag, created_date,
        created_by, updated_date, updated_by
    </sql>

    <select id="selectByContentIdAndReceiverId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_vehicle_permit
        where del_flag = 0
        and content_id = #{contentId}
        and receiver_id = #{receiverId}
    </select>

    <select id="selectByReceiverId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_vehicle_permit
        where del_flag = 0
        and receiver_id = #{receiverId}
    </select>

    <select id="selectPermitVehicleByReceiverId" resultType="cn.com.glsx.admin.modules.model.view.VehiclePermitDTO">
        select concat('v', tvp.content_id) as id,
               tvp.accorder_id                accorderId,
               tv.id                          vehicleId,
               tv.vin,
               tv.owner_name                  ownerName,
               concat('u', tv.created_by)  as pid
        from t_vehicle_permit tvp
                 left join t_vehicle tv on tvp.content_id = tv.id
        where tvp.del_flag = 0
          and tv.del_flag = 0
          and tv.created_by is not null
          and tvp.receiver_id = #{receiverId}
    </select>

    <insert id="insertIgnoreExistedPermit">
        INSERT IGNORE INTO t_vehicle_permit (content_id, accorder_id, receiver_id, content_type, permit_type, del_flag, created_date, created_by)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.contentId},
            #{item.accorderId},
            #{item.receiverId},
            #{item.contentType},
            #{item.permitType},
            0,
            sysdate(),
            #{item.createdBy}
            )
        </foreach>
    </insert>

    <delete id="deleteExistedPermit">
        delete from t_vehicle_permit
        where del_flag = 0
        and content_type = #{contentType}
        and receiver_id = #{receiverId}
        and content_id in
        <foreach collection="contentIds" separator="," open="(" close=")" item="item">
            #{item}
        </foreach>
    </delete>

    <delete id="deletePermitByReceiverId">
        delete from t_vehicle_permit
        where del_flag = 0
          and content_type = #{contentType}
          and receiver_id = #{receiverId}
    </delete>
</mapper>