ArchivesBorrowMapper.xml 6.03 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.ruoyi.mapper.ArchivesBorrowMapper">

    <resultMap type="ArchivesBorrow" id="ArchivesBorrowResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="dept"    column="dept"    />
        <result property="borrowDate"    column="borrow_date"    />
        <result property="phone"    column="phone"    />
        <result property="mode"    column="mode"    />
        <result property="boxType"    column="box_type"    />
        <result property="borrowName"    column="borrow_name"    />
        <result property="borrowType"    column="borrow_type"    />
        <result property="collectBoxId"    column="collect_box_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="returnDate"    column="return_date"    />
        <result property="returnedDate"    column="returned_date"    />
        <result property="borrowMark"    column="borrow_mark"    />
        <result property="status"    column="status"    />
    </resultMap>

    <resultMap type="ArchivesBorrow" id="ArchivesBorrowAndBox">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="dept"    column="dept"    />
        <result property="borrowDate"    column="borrow_date"    />
        <result property="phone"    column="phone"    />
        <result property="mode"    column="mode"    />
        <result property="boxType"    column="box_type"    />
        <result property="borrowName"    column="borrow_name"    />
        <result property="borrowType"    column="borrow_type"    />
        <result property="collectBoxId"    column="collect_box_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="returnDate"    column="return_date"    />
        <result property="returnedDate"    column="returned_date"    />
        <result property="borrowMark"    column="borrow_mark"    />
        <result property="status"    column="status"    />
        <result property="archivalCode"    column="archival_code"    />
        <result property="title"    column="title"    />
        <result property="borrowStatus"    column="borrow_status"    />
    </resultMap>

    <sql id="selectArchivesBorrowVo">
        select * from archives_borrow
    </sql>

    <select id="selectArchivesBorrowList" parameterType="ArchivesBorrow" resultMap="ArchivesBorrowResult">
        <include refid="selectArchivesBorrowVo"/>
        <where>
            <if test="name != null  and name != ''"> and name = #{name}</if>
            <if test="dept != null  and dept != ''"> and dept = #{dept}</if>
            <if test="borrowDate != null  and borrowDate != ''"> and borrow_date = #{borrowDate}</if>
            <if test="borrowDateS != null  and borrowDateS != ''"> and borrow_date >= #{borrowDateS}</if>
            <if test="borrowDateE != null  and borrowDateE != ''"> and borrow_date &lt;= #{borrowDateE}</if>
            <if test="borrowMark != null  and borrowMark != ''"> and borrow_mark = #{borrowMark}</if>
            <if test="status = 'wgh'"> and status !='1'</if>
        </where>
    </select>

    <select id="selectArchivesBorrowListByFilingDept" parameterType="ArchivesBorrow" resultMap="ArchivesBorrowAndBox">
        select a.*,b.* from archives_borrow a,archives_collect_box b,archives_dept c
        where a.collect_box_id=b.id and  b.filing_dept=c.dept_id
        <if test="name != null  and name != ''"> and a.name = #{name}</if>
        <if test="dept != null  and dept != ''"> and a.dept = #{dept}</if>
        <if test="borrowDate != null  and borrowDate != ''"> and a.borrow_date = #{borrowDate}</if>
        <if test="borrowDateS != null  and borrowDateS != ''"> and a.borrow_date >= #{borrowDateS}</if>
        <if test="borrowDateE != null  and borrowDateE != ''"> and a.borrow_date &lt;= #{borrowDateE}</if>
        <if test="borrowMark != null  and borrowMark != ''"> and a.borrow_mark = #{borrowMark}</if>
        <if test="filingDept != null  and filingDept != ''"> AND (b.filing_dept=#{filingDept} or FIND_IN_SET(#{filingDept},c.ancestors))</if>
        <if test="filingDept != null  and filingDept != ''"> AND (b.filing_dept=#{filingDept} or FIND_IN_SET(#{filingDept},c.ancestors))</if>
        <if test="status == 'true'"> and a.status != '1'</if>
    </select>

    <select id="selectCollectBoxIds" parameterType="Long" resultType="Long">
        select collect_box_id from archives_borrow where id in
        <foreach collection="array" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>

    <update id="updateArchivesBorrowByIds" parameterType="ArchivesBorrow">
        update archives_borrow
        <trim prefix="SET" suffixOverrides=",">
            <if test="archivesBorrow.borrowDate != null">borrow_date = #{archivesBorrow.borrowDate},</if>
            <if test="archivesBorrow.returnedDate != null">returned_date = #{archivesBorrow.returnedDate},</if>
            <if test="archivesBorrow.status != null">status = #{archivesBorrow.status},</if>
        </trim>
        where id in
        <foreach collection="ids" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <update id="updateArchivesBorrowById" parameterType="ArchivesBorrow">
        update archives_borrow
        <trim prefix="SET" suffixOverrides=",">
            <if test="status != null">status = #{status},</if>
        </trim>
        where id = #{id}
    </update>

</mapper>