Helius
2020-11-24 45b922e93d8cf867a46f15d1db30c7e380e965b1
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
<?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.WtTokenDao">
    <!-- 定义WtToken 的复杂关联map -->
 
    <!-- 字段sql -->
    <sql id="columns">
            id,
            symbol,
            price,
            main,
            fee,
            create_time,
            amount,
            contract_address,
            symbol_name
    </sql>
 
    <!-- 属性sql -->
    <sql id="propertys">
            #{item.id},
            #{item.symbol},
            #{item.price},
            #{item.main},
            #{item.fee},
            #{item.createTime},
            #{item.amount},
            #{item.contractAddress},
            #{item.symbolName}
    </sql>
 
    <!--  插入方法   -->
    <insert id="insert" parameterType="com.xcong.excoin.modules.login.entity.WtToken"
            useGeneratedKeys="true" keyProperty="item.id">
        INSERT INTO wt_token (
        <include refid="columns"></include>
        )
        VALUES (
        <include refid="propertys"></include>
        )
    </insert>
 
 
    <!--  批量插入   -->
    <insert id="batchInsert" parameterType="java.util.List">
        INSERT INTO wt_token (
        <include refid="columns"></include>
        )
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">(
            <include refid="propertys"></include>
            )
        </foreach>
    </insert>
 
 
 
    <!--  根据对象更新 部分更新   -->
    <update id="updateByModel" parameterType="Integer">
        UPDATE wt_token
        <set>
            <if test="record.symbol != null and record.symbol != '' ">
                symbol = #{record.symbol},
            </if>
            <if test="record.price != null ">
                price = #{record.price},
            </if>
            <if test="record.main != null ">
                main = #{record.main},
            </if>
        </set>
        WHERE id=#{record.id}
    </update>
 
 
 
    <!-- 根据id删除-->
    <delete id="deleteById" parameterType="Integer">
        DELETE FROM wt_token
        where  id=#{id}
    </delete>
 
 
 
 
 
 
    <!-- 根据id查询-->
    <select id="selectById" resultType="com.xcong.excoin.modules.login.entity.WtToken">
        select
        <include refid="columns"></include>
        from wt_token
        where id=#{id}
    </select>
 
    <select id="selectBySymbol" resultType="com.xcong.excoin.modules.login.entity.WtToken">
        select
        <include refid="columns"></include>
        from wt_token
        where symbol =#{symbol}
    </select>
 
    <select id="selectAllToken" resultType="com.xcong.excoin.modules.login.entity.WtToken">
        select
        <include refid="columns"></include>
        from wt_token
    </select>
 
    <select id="selectMainToken" resultType="com.xcong.excoin.modules.login.entity.WtToken">
        select
        <include refid="columns"></include>
        from wt_token where main = 1
    </select>
 
</mapper>