<?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.WtWalletDao">
|
<!-- 定义WtWallet 的复杂关联map -->
|
<resultMap type="com.xcong.excoin.modules.login.entity.WtWallet" id="WtWalletMap">
|
<result property="privateKey" column="private_key" />
|
<result property="mnemonicWords" column="mnemonic_words" />
|
<result property="password" column="password" />
|
<result property="walletName" column="wallet_name" />
|
<result property="terminalId" column="terminal_Id" />
|
</resultMap>
|
|
|
<!-- 字段sql -->
|
<sql id="columns">
|
address,
|
private_key,
|
mnemonic_words,
|
password,
|
wallet_name,
|
terminal_Id
|
</sql>
|
<sql id="simpleColumns">
|
address,
|
wallet_name
|
</sql>
|
|
<!-- 属性sql -->
|
<sql id="propertys">
|
#{item.address},
|
#{item.privateKey},
|
#{item.mnemonicWords},
|
#{item.password},
|
#{item.walletName},
|
#{item.terminalId}
|
</sql>
|
|
|
|
<!-- 插入方法 -->
|
<insert id="insert" parameterType="com.xcong.excoin.modules.login.entity.WtWallet"
|
useGeneratedKeys="true" keyProperty="item.address">
|
INSERT INTO wt_wallet (
|
<include refid="columns"></include>
|
)
|
VALUES (
|
<include refid="propertys"></include>
|
)
|
</insert>
|
|
|
|
<!-- 批量插入 -->
|
<insert id="batchInsert" parameterType="java.util.List">
|
INSERT INTO wt_wallet (
|
<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
|
<set>
|
<if test="record.password != null and record.password != '' ">
|
password = #{record.password},
|
</if>
|
<if test="record.walletName != null and record.walletName != '' ">
|
wallet_name = #{record.walletName},
|
</if>
|
<if test="record.terminalId != null and record.terminalId != '' ">
|
terminal_Id = #{record.terminalId},
|
</if>
|
</set>
|
WHERE address=#{record.address}
|
</update>
|
|
<!-- 批量删除 -->
|
<delete id="deleteByIds" parameterType="java.util.List">
|
delete from wt_wallet where address in
|
<foreach collection="list" index="index" item="item" open="("
|
separator="," close=")">
|
#{item}
|
</foreach>
|
</delete>
|
|
<!-- 根据id删除-->
|
<delete id="deleteById" parameterType="String">
|
DELETE FROM wt_wallet
|
where address=#{address}
|
</delete>
|
|
|
<!-- 根据id查询-->
|
<select id="selectById" resultMap="WtWalletMap">
|
select
|
<include refid="columns" ></include>
|
from wt_wallet
|
where address=#{address}
|
</select>
|
<select id="selectSimpleById" resultMap="WtWalletMap">
|
select
|
<include refid="simpleColumns" ></include>
|
from wt_wallet
|
where address=#{address}
|
</select>
|
|
<select id="selectSimpleByTerminalId" resultMap="WtWalletMap">
|
select
|
<include refid="simpleColumns" ></include>
|
from wt_wallet
|
where terminal_Id=#{terminalId}
|
limit 1
|
</select>
|
|
<select id="selectByMnemonicWords" resultMap="WtWalletMap">
|
select
|
address,
|
mnemonic_words,
|
wallet_name,
|
password,
|
terminal_Id
|
from wt_wallet
|
where mnemonic_words=#{mnemonic_words}
|
</select>
|
|
<update id="clearTerminalId" parameterType="string">
|
update wt_wallet set terminal_id = null where address = #{address}
|
</update>
|
|
<update id="deleteTerminal" parameterType="string">
|
update wt_wallet set terminal_Id = null where terminal_id = #{terminalId}
|
</update>
|
|
</mapper>
|