1
This commit is contained in:
@@ -110,4 +110,64 @@
|
||||
ORDER BY expire_at ASC
|
||||
LIMIT #{size}
|
||||
</select>
|
||||
|
||||
<select id="findLinkTasksWithConditions" resultMap="LinkTaskMap">
|
||||
SELECT id, batch_id, agent_id, code_no, token_hash, expire_at, status, region, machine_id, login_at, refund_at, revoked_at, created_at, updated_at
|
||||
FROM link_task
|
||||
<where>
|
||||
agent_id = #{agentId}
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="batchId != null">
|
||||
AND batch_id = #{batchId}
|
||||
</if>
|
||||
<if test="isExpired != null">
|
||||
<choose>
|
||||
<when test="isExpired == true">
|
||||
AND expire_at <= NOW()
|
||||
</when>
|
||||
<otherwise>
|
||||
AND expire_at > NOW()
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
</where>
|
||||
<choose>
|
||||
<when test="sortBy == 'expireAt'">
|
||||
ORDER BY expire_at ${sortDir}
|
||||
</when>
|
||||
<when test="sortBy == 'updatedAt'">
|
||||
ORDER BY updated_at ${sortDir}
|
||||
</when>
|
||||
<otherwise>
|
||||
ORDER BY created_at ${sortDir}
|
||||
</otherwise>
|
||||
</choose>
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countLinkTasksWithConditions" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM link_task
|
||||
<where>
|
||||
agent_id = #{agentId}
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="batchId != null">
|
||||
AND batch_id = #{batchId}
|
||||
</if>
|
||||
<if test="isExpired != null">
|
||||
<choose>
|
||||
<when test="isExpired == true">
|
||||
AND expire_at <= NOW()
|
||||
</when>
|
||||
<otherwise>
|
||||
AND expire_at > NOW()
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user