refactor mapper xml
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?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.imyeyu.api.modules.gao.mapper.GaoPointLedgerMapper">
|
||||
<select id="selectByIdempotencyKey" resultType="com.imyeyu.api.modules.gao.entity.GaoPointLedger">
|
||||
SELECT *
|
||||
FROM `gao_point_ledger`
|
||||
WHERE `idempotency_key` = #{idempotencyKey}
|
||||
AND `deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectEarnByEventRecordId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointLedger">
|
||||
SELECT *
|
||||
FROM `gao_point_ledger`
|
||||
WHERE `event_record_id` = #{eventRecordId}
|
||||
AND `change_type` = 'EARN'
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `created_at` ASC, `id` ASC
|
||||
</select>
|
||||
|
||||
<select id="selectByIdempotencyKeyList" resultType="com.imyeyu.api.modules.gao.entity.GaoPointLedger">
|
||||
SELECT *
|
||||
FROM `gao_point_ledger`
|
||||
WHERE `deleted_at` IS NULL
|
||||
AND `idempotency_key` IN
|
||||
<foreach collection="idempotencyKeyList" item="idempotencyKey" open="(" separator="," close=")">
|
||||
#{idempotencyKey}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<sql id="queryWhere">
|
||||
`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">
|
||||
AND `store_id` = #{storeId}
|
||||
</if>
|
||||
<if test="customerId != null and customerId != ''">
|
||||
AND `customer_id` = #{customerId}
|
||||
</if>
|
||||
<if test="accountId != null and accountId != ''">
|
||||
AND `account_id` = #{accountId}
|
||||
</if>
|
||||
<if test="changeType != null">
|
||||
AND `change_type` = #{changeType}
|
||||
</if>
|
||||
<if test="beginAt != null">
|
||||
AND `occurred_at` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null">
|
||||
AND `occurred_at` <= #{endAt}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM `gao_point_ledger`
|
||||
WHERE
|
||||
<include refid="queryWhere"/>
|
||||
</select>
|
||||
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoPointLedger">
|
||||
SELECT *
|
||||
FROM `gao_point_ledger`
|
||||
WHERE
|
||||
<include refid="queryWhere"/>
|
||||
ORDER BY `occurred_at` DESC, `created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user