fuliqi
2024-09-11 b14531e3b850fe6d2fa916ba7b88b3e2bd2ff30a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?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.ycl.platform.mapper.ContractRuleRecordMapper">
 
    <resultMap type="com.ycl.platform.domain.entity.ContractRuleRecord" id="ContractRuleRecordResult">
        <result property="id" column="id"/>
        <result property="unitId" column="unit_id"/>
        <result property="siteOnline" column="site_online"/>
        <result property="createTime" column="create_time"/>
        <result property="deleted" column="deleted"/>
    </resultMap>
 
    <sql id="selectContractRuleRecordVo">
        select id, unit_id, site_online, create_time, deleted
        from t_contract_rule_record
    </sql>
 
    <select id="selectMonth" resultMap="ContractRuleRecordResult">
        select id, unit_id, site_online, create_time, deleted
        from t_contract_rule_record
        where DATE(create_time) between #{startTime} and #{endTime}
    </select>
    <select id="selectContractRuleRecordList" resultMap="ContractRuleRecordResult">
        <include refid="selectContractRuleRecordVo"/>
        <where>
            <if test="unitId != null ">and unit_id = #{unitId}</if>
            <if test="siteOnline != null ">and site_online = #{siteOnline}</if>
            <if test="deleted != null ">and deleted = #{deleted}</if>
        </where>
    </select>
 
    <select id="selectContractRuleRecordById" resultMap="ContractRuleRecordResult">
        <include refid="selectContractRuleRecordVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertContractRuleRecord" useGeneratedKeys="true" keyProperty="id">
        insert into t_contract_rule_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="unitId != null">unit_id,</if>
            <if test="siteOnline != null">site_online,</if>
            <if test="createTime != null">create_time,</if>
            <if test="deleted != null">deleted,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="unitId != null">#{unitId},</if>
            <if test="siteOnline != null">#{siteOnline},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="deleted != null">#{deleted},</if>
        </trim>
    </insert>
 
    <insert id="insertBatch">
        insert into t_contract_rule_record (unit_id,site_online,create_time)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.unitId},#{item.siteOnline},#{item.createTime})
        </foreach>
    </insert>
 
    <update id="updateContractRuleRecord">
        update t_contract_rule_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="unitId != null">unit_id = #{unitId},</if>
            <if test="siteOnline != null">site_online = #{siteOnline},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="deleted != null">deleted = #{deleted},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteContractRuleRecordById">
        delete
        from t_contract_rule_record
        where id = #{id}
    </delete>
 
    <delete id="deleteContractRuleRecordByIds">
        delete from t_contract_rule_record where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>