<?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>
|