This commit is contained in:
zyh
2025-08-26 15:18:14 +08:00
parent 599ec0a36b
commit d3fe8fda7d
77 changed files with 1149 additions and 60 deletions

View File

@@ -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 &lt;= NOW()
</when>
<otherwise>
AND expire_at &gt; 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 &lt;= NOW()
</when>
<otherwise>
AND expire_at &gt; NOW()
</otherwise>
</choose>
</if>
</where>
</select>
</mapper>