xiangpei
2024-11-22 c8bc73954b11b40cc62945099a4f7ca1a73154a1
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
<?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.mapper.PurchaseMapper">
 
    <resultMap type="Purchase" id="PurchaseResult">
        <result property="id"    column="id"    />
        <result property="itemlist"    column="itemlist"    />
        <result property="total"    column="total"    />
        <result property="applytime"    column="applytime"    />
        <result property="applyer"    column="applyer"    />
    </resultMap>
 
    <sql id="selectPurchaseVo">
        select id, itemlist, total, applytime, applyer from purchase
    </sql>
 
    <select id="selectPurchaseList" parameterType="Purchase" resultMap="PurchaseResult">
        <include refid="selectPurchaseVo"/>
        <where>
            <if test="itemlist != null  and itemlist != ''"> and itemlist = #{itemlist}</if>
            <if test="total != null  and total != ''"> and total = #{total}</if>
            <if test="params.beginApplyTime != null and params.beginApplyTime != '' and params.endApplyTime != null and params.endApplyTime != ''"> and applytime between #{params.beginApplyTime} and #{params.endApplyTime}</if>
            <if test="applyer != null  and applyer != ''"> and applyer = #{applyer}</if>
        </where>
    </select>
 
    <select id="selectPurchaseById" parameterType="Long" resultMap="PurchaseResult">
        <include refid="selectPurchaseVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertPurchase" parameterType="Purchase" useGeneratedKeys="true" keyProperty="id">
        insert into purchase
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="itemlist != null and itemlist != ''">itemlist,</if>
            <if test="total != null and total != ''">total,</if>
            <if test="applytime != null">applytime,</if>
            <if test="applyer != null">applyer,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="itemlist != null and itemlist != ''">#{itemlist},</if>
            <if test="total != null and total != ''">#{total},</if>
            <if test="applytime != null">#{applytime},</if>
            <if test="applyer != null">#{applyer},</if>
         </trim>
    </insert>
 
    <update id="updatePurchase" parameterType="Purchase">
        update purchase
        <trim prefix="SET" suffixOverrides=",">
            <if test="itemlist != null and itemlist != ''">itemlist = #{itemlist},</if>
            <if test="total != null and total != ''">total = #{total},</if>
            <if test="applytime != null">applytime = #{applytime},</if>
            <if test="applyer != null">applyer = #{applyer},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deletePurchaseById" parameterType="Long">
        delete from purchase where id = #{id}
    </delete>
 
    <delete id="deletePurchaseByIds" parameterType="String">
        delete from purchase where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
</mapper>