xiaoyong931011
2020-11-30 a681544d9109ab0f9c7b79803ca66234b47c64c5
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?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.xcong.excoin.modules.login.dao.WalletDetailDao">
    <!-- 定义WtWalletDetail 的复杂关联map -->
    <resultMap type="com.xcong.excoin.modules.login.entity.WtWalletDetail" id="WtWalletDetailMap">
        <id property="id" column="id"/>
        <result property="address" column="address"/>
        <result property="symbol" column="symbol"/>
        <result property="balance" column="balance"/>
        <result property="show" column="show"/>
    </resultMap>
 
 
    <!-- 字段sql -->
    <sql id="columns">
            id,
            address,
            symbol,
            balance,
            main,
            is_show
    </sql>
 
    <!-- 属性sql -->
    <sql id="propertys">
            #{item.id},
            #{item.address},
            #{item.symbol},
            #{item.balance},
            #{item.main},
            #{item.isShow}
    </sql>
 
 
    <!--  插入方法   -->
    <insert id="insert" parameterType="com.xcong.excoin.modules.login.entity.WtWalletDetail"
            useGeneratedKeys="true" keyProperty="item.id">
        INSERT INTO wt_wallet_detail (
        <include refid="columns"></include>
        )
        VALUES (
        <include refid="propertys"></include>
        )
    </insert>
 
 
    <!--  批量插入   -->
    <insert id="batchInsert" parameterType="java.util.List">
        INSERT INTO wt_wallet_detail (
        <include refid="columns"></include>
        )
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">(
            <include refid="propertys"></include>
            )
        </foreach>
    </insert>
 
    <!--  根据对象更新 部分更新   -->
    <update id="updateByModel" parameterType="String">
        UPDATE wt_wallet_detail
        <set>
            <if test="record.address != null and record.address != '' ">
                address = #{record.address},
            </if>
            <if test="record.symbol != null and record.symbol != '' ">
                symbol = #{record.symbol},
            </if>
            <if test="record.balance != null ">
                balance = #{record.balance},
            </if>
            <if test="record.isShow != null ">
                is_show = #{record.isShow},
            </if>
        </set>
        WHERE id=#{record.id}
    </update>
 
    <!-- 批量删除 -->
    <delete id="deleteByIds" parameterType="java.util.List">
        delete from wt_wallet_detail where id in
        <foreach collection="list" index="index" item="item" open="("
                 separator="," close=")">
            #{item}
        </foreach>
    </delete>
 
    <!-- 根据id删除-->
    <delete id="deleteById" parameterType="String">
        DELETE FROM wt_wallet_detail
        where  id=#{id} 
    </delete>
 
 
 
 
 
    <!-- 根据id查询-->
    <select id="selectById" resultMap="WtWalletDetailMap">
        select
        <include refid="columns"></include>
        from wt_wallet_detail
        where id=#{id}
    </select>
 
    <select id="selectByAddressAndSymbol" resultMap="WtWalletDetailMap">
        select
        <include refid="columns"></include>
        from wt_wallet_detail
        where address=#{address} and symbol = #{symbol}
    </select>
 
 
    <!-- 根据对象查询-->
    <select id="selectByModel" resultMap="WtWalletDetailMap">
        select
        <include refid="columns"></include>
        from wt_wallet_detail
        <where>
           <if test="address !=null and address != ''">
               and address = #{address}
           </if>
           <if test="symbol !=null and symbol != ''">
               and symbol = #{symbol}
           </if>
        </where>
        order by main desc
    </select>
 
    <update id="updateWalletBalance" parameterType="map">
        update wt_wallet_detail set balance = balance + #{balance} where id = #{id}
    </update>
</mapper>