xiangpei
2024-04-07 1d14ba39daf0422199c44b5b2ffc67d2364b2be2
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
<?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.CalculateRecordMapper">
    
    <resultMap type="com.ycl.platform.domain.entity.CalculateRecord" id="CalculateRecordResult">
        <result property="id"    column="id"    />
        <result property="date"    column="date"    />
        <result property="ruleId"    column="rule_id"    />
        <result property="unitId"    column="unit_id"    />
        <result property="totalMount"    column="totalMount"    />
        <result property="deductAmount"    column="deduct_amount"    />
        <result property="score"    column="score"    />
    </resultMap>
 
    <sql id="selectCalculateRecordVo">
        select id, date, rule_id, unit_id, totalMount, deduct_amount, score from t_calculate_record
    </sql>
 
    <select id="selectCalculateRecordList" resultMap="CalculateRecordResult">
        <include refid="selectCalculateRecordVo"/>
        <where>  
            <if test="date != null "> and date = #{date}</if>
            <if test="ruleId != null "> and rule_id = #{ruleId}</if>
            <if test="unitId != null "> and unit_id = #{unitId}</if>
            <if test="totalMount != null "> and totalMount = #{totalMount}</if>
            <if test="deductAmount != null "> and deduct_amount = #{deductAmount}</if>
            <if test="score != null "> and score = #{score}</if>
        </where>
    </select>
    
    <select id="selectCalculateRecordById" resultMap="CalculateRecordResult">
        <include refid="selectCalculateRecordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCalculateRecord" parameterType="CalculateRecord">
        insert into t_calculate_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="date != null">date,</if>
            <if test="ruleId != null">rule_id,</if>
            <if test="unitId != null">unit_id,</if>
            <if test="totalMount != null">totalMount,</if>
            <if test="deductAmount != null">deduct_amount,</if>
            <if test="score != null">score,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="date != null">#{date},</if>
            <if test="ruleId != null">#{ruleId},</if>
            <if test="unitId != null">#{unitId},</if>
            <if test="totalMount != null">#{totalMount},</if>
            <if test="deductAmount != null">#{deductAmount},</if>
            <if test="score != null">#{score},</if>
         </trim>
    </insert>
 
    <update id="updateCalculateRecord">
        update t_calculate_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="date != null">date = #{date},</if>
            <if test="ruleId != null">rule_id = #{ruleId},</if>
            <if test="unitId != null">unit_id = #{unitId},</if>
            <if test="totalMount != null">totalMount = #{totalMount},</if>
            <if test="deductAmount != null">deduct_amount = #{deductAmount},</if>
            <if test="score != null">score = #{score},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteCalculateRecordById" >
        delete from t_calculate_record where id = #{id}
    </delete>
 
    <delete id="deleteCalculateRecordByIds" >
        delete from t_calculate_record where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>