
mybatis.contract.ContractMapper.xml Maven / Gradle / Ivy
<?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.higgschain.trust.slave.dao.mysql.contract.ContractDao"> <!-- Result Map --> <resultMap id="baseResultMap" type="com.higgschain.trust.slave.dao.po.contract.ContractPO"> <result column="id" property="id"/> <result column="block_height" property="blockHeight"/> <result column="tx_id" property="txId"/> <result column="action_index" property="actionIndex"/> <result column="address" property="address"/> <result column="language" property="language"/> <result column="version" property="version"/> <result column="code" property="code" /> <result column="create_time" property="createTime"/> </resultMap> <!-- contract table all fields --> <sql id="baseColumnList"> id, block_height, tx_id, action_index, address, language, version, code, create_time </sql> <!-- add --> <insert id="add" parameterType="com.higgschain.trust.slave.dao.po.contract.ContractPO"> INSERT INTO contract (block_height, tx_id, action_index, address, language, version, code, create_time) VALUES (#{blockHeight}, #{txId}, #{actionIndex}, #{address}, #{language}, #{version}, #{code}, now(3)) </insert> <insert id ="batchInsert" parameterType="java.util.List" > insert into contract (block_height, tx_id, action_index, address, language, version, code, create_time) values <foreach collection ="list" item="item" index= "index" separator =","> (#{item.blockHeight}, #{item.txId}, #{item.actionIndex}, #{item.address}, #{item.language}, #{item.version}, #{item.code}, now(3)) </foreach> </insert> <!-- delete --> <delete id="delete" parameterType="java.lang.String"> DELETE FROM contract WHERE id=#{id} </delete> <!-- query by contract address --> <select id="queryByAddress" resultMap="baseResultMap" parameterType="java.lang.String"> SELECT <include refid="baseColumnList"/> FROM contract WHERE address=#{address} </select> <!-- get query count --> <select id="getQueryCount" resultType="java.lang.Long"> SELECT COUNT(1) FROM contract WHERE 1=1 <if test="height != null"> and block_height = #{height} </if> <if test="txId != null"> and tx_id = #{txId} </if> </select> <!-- query list --> <select id="query" resultMap="baseResultMap"> SELECT <include refid="baseColumnList"/> FROM contract WHERE 1=1 <if test="height != null"> and block_height = #{height} </if> <if test="txId != null and txId !=''"> and tx_id = #{txId} </if> ORDER BY id DESC LIMIT #{startIndex}, #{endIndex} </select> <!-- query by txId --> <select id="queryByTxId" resultMap="baseResultMap"> SELECT <include refid="baseColumnList"/> FROM contract WHERE action_index = #{actionIndex} and tx_id = #{txId} </select> </mapper>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy