56 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			XML
		
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			XML
		
	
	
	
<?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.bonus.material.contract.mapper.BmContractMapper">
 | 
						|
    <insert id="add" useGeneratedKeys="true" keyProperty="id">
 | 
						|
        insert into bm_contract(contract_code, contract_name, status, create_time, owner_id, owner_com)
 | 
						|
        values(#{contractCode}, #{contractName}, #{status}, now(), #{ownerId}, #{ownerCom})
 | 
						|
    </insert>
 | 
						|
    <update id="edit">
 | 
						|
        update bm_contract set
 | 
						|
        <if test="contractName != null and contractName != ''">contract_name = #{contractName},</if>
 | 
						|
        <if test="status != null">status = #{status},</if>
 | 
						|
        owner_id = #{ownerId},
 | 
						|
        owner_com = #{ownerCom},
 | 
						|
        update_time = now()
 | 
						|
        where id = #{id}
 | 
						|
    </update>
 | 
						|
    <update id="updateStatus">
 | 
						|
        update bm_contract set status = #{status} where id = #{id}
 | 
						|
    </update>
 | 
						|
    <update id="updateStatusOther">
 | 
						|
        update bm_contract set status = 0 where owner_com = #{ownerCom} and id != #{id}
 | 
						|
    </update>
 | 
						|
    <delete id="del">
 | 
						|
        delete from bm_contract where id = #{id}
 | 
						|
    </delete>
 | 
						|
 | 
						|
    <select id="list" resultType="com.bonus.material.contract.domain.BmContract">
 | 
						|
        select id, contract_code as contractCode, contract_name as contractName, status, create_time as createTime, update_time as updateTime, owner_id as ownerId, owner_com as ownerCom from bm_contract
 | 
						|
        <where>
 | 
						|
            owner_com = #{ownerCom}
 | 
						|
            <if test="contractCode != null and contractCode != ''">
 | 
						|
                and contract_code like concat('%', #{contractCode}, '%')
 | 
						|
            </if>
 | 
						|
            <if test="contractName != null and contractName != ''">
 | 
						|
                and contract_name like concat('%', #{contractName}, '%')
 | 
						|
            </if>
 | 
						|
            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
 | 
						|
                AND update_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
 | 
						|
            </if>
 | 
						|
            <if test="status != null">
 | 
						|
                and status = #{status}
 | 
						|
            </if>
 | 
						|
        </where>
 | 
						|
    </select>
 | 
						|
    <select id="selectTaskNumByMonth" resultType="java.lang.String">
 | 
						|
        SELECT SUBSTRING(contract_code, - 4) as code
 | 
						|
        FROM bm_contract
 | 
						|
        WHERE DATE_FORMAT(create_time, '%y%m') = DATE_FORMAT(#{date}, '%y%m')
 | 
						|
        ORDER BY create_time DESC LIMIT 1
 | 
						|
    </select>
 | 
						|
    <select id="lisTemplate" resultType="com.bonus.material.contract.domain.BmContract">
 | 
						|
        select * from bm_contract_template where type = 0
 | 
						|
    </select>
 | 
						|
</mapper> |