You've already forked FrameTour-BE
refactor(puzzle): 移除边缘渲染任务数据访问层
- 删除了 PuzzleEdgeRenderTaskMapper 接口文件 - 移除了对应的 MyBatis XML 映射文件 - 清理了数据库操作相关的实体映射配置 - 移除了任务领取、成功标记、失败标记等数据库操作方法 - 删除了查询下一条可领取任务的业务逻辑实现
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
package com.ycwl.basic.puzzle.edge.mapper;
|
||||
|
||||
import com.ycwl.basic.puzzle.edge.entity.PuzzleEdgeRenderTaskEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Mapper
|
||||
public interface PuzzleEdgeRenderTaskMapper {
|
||||
|
||||
PuzzleEdgeRenderTaskEntity getById(@Param("id") Long id);
|
||||
|
||||
int insert(PuzzleEdgeRenderTaskEntity entity);
|
||||
|
||||
/**
|
||||
* 获取下一条可领取任务ID:PENDING 或 RUNNING但租约已过期
|
||||
*/
|
||||
Long findNextClaimableTaskId();
|
||||
|
||||
/**
|
||||
* 领取任务(并写入租约与attempt)
|
||||
*/
|
||||
int claimTask(@Param("taskId") Long taskId,
|
||||
@Param("workerId") Long workerId,
|
||||
@Param("leaseExpireTime") Date leaseExpireTime);
|
||||
|
||||
int markSuccess(@Param("taskId") Long taskId, @Param("workerId") Long workerId);
|
||||
|
||||
int markFail(@Param("taskId") Long taskId,
|
||||
@Param("workerId") Long workerId,
|
||||
@Param("errorMessage") String errorMessage);
|
||||
}
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
<?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.ycwl.basic.puzzle.edge.mapper.PuzzleEdgeRenderTaskMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.ycwl.basic.puzzle.edge.entity.PuzzleEdgeRenderTaskEntity">
|
||||
<id column="id" property="id"/>
|
||||
<result column="record_id" property="recordId"/>
|
||||
<result column="template_id" property="templateId"/>
|
||||
<result column="template_code" property="templateCode"/>
|
||||
<result column="scenic_id" property="scenicId"/>
|
||||
<result column="face_id" property="faceId"/>
|
||||
<result column="content_hash" property="contentHash"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="worker_id" property="workerId"/>
|
||||
<result column="lease_expire_time" property="leaseExpireTime"/>
|
||||
<result column="attempt_count" property="attemptCount"/>
|
||||
<result column="output_format" property="outputFormat"/>
|
||||
<result column="output_quality" property="outputQuality"/>
|
||||
<result column="original_object_key" property="originalObjectKey"/>
|
||||
<result column="cropped_object_key" property="croppedObjectKey"/>
|
||||
<result column="payload_json" property="payloadJson"/>
|
||||
<result column="error_message" property="errorMessage"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, record_id, template_id, template_code, scenic_id, face_id, content_hash,
|
||||
status, worker_id, lease_expire_time, attempt_count,
|
||||
output_format, output_quality,
|
||||
original_object_key, cropped_object_key,
|
||||
payload_json, error_message,
|
||||
create_time, update_time
|
||||
</sql>
|
||||
|
||||
<select id="getById" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM puzzle_edge_render_task
|
||||
WHERE id = #{id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.ycwl.basic.puzzle.edge.entity.PuzzleEdgeRenderTaskEntity"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO puzzle_edge_render_task (
|
||||
record_id, template_id, template_code, scenic_id, face_id, content_hash,
|
||||
status, worker_id, lease_expire_time, attempt_count,
|
||||
output_format, output_quality,
|
||||
original_object_key, cropped_object_key,
|
||||
payload_json, error_message,
|
||||
create_time, update_time
|
||||
) VALUES (
|
||||
#{recordId}, #{templateId}, #{templateCode}, #{scenicId}, #{faceId}, #{contentHash},
|
||||
#{status}, #{workerId}, #{leaseExpireTime}, #{attemptCount},
|
||||
#{outputFormat}, #{outputQuality},
|
||||
#{originalObjectKey}, #{croppedObjectKey},
|
||||
#{payloadJson}, #{errorMessage},
|
||||
NOW(), NOW()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="findNextClaimableTaskId" resultType="java.lang.Long">
|
||||
SELECT id
|
||||
FROM puzzle_edge_render_task
|
||||
WHERE status = 0
|
||||
OR (status = 1 AND lease_expire_time IS NOT NULL AND lease_expire_time < NOW())
|
||||
ORDER BY id ASC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<update id="claimTask">
|
||||
UPDATE puzzle_edge_render_task
|
||||
SET worker_id = #{workerId},
|
||||
status = 1,
|
||||
lease_expire_time = #{leaseExpireTime},
|
||||
attempt_count = attempt_count + 1,
|
||||
update_time = NOW()
|
||||
WHERE id = #{taskId}
|
||||
AND (
|
||||
status = 0
|
||||
OR (status = 1 AND lease_expire_time IS NOT NULL AND lease_expire_time < NOW())
|
||||
)
|
||||
</update>
|
||||
|
||||
<update id="markSuccess">
|
||||
UPDATE puzzle_edge_render_task
|
||||
SET status = 2,
|
||||
lease_expire_time = NULL,
|
||||
error_message = NULL,
|
||||
update_time = NOW()
|
||||
WHERE id = #{taskId}
|
||||
AND worker_id = #{workerId}
|
||||
AND status = 1
|
||||
</update>
|
||||
|
||||
<update id="markFail">
|
||||
UPDATE puzzle_edge_render_task
|
||||
SET status = 3,
|
||||
lease_expire_time = NULL,
|
||||
error_message = #{errorMessage},
|
||||
update_time = NOW()
|
||||
WHERE id = #{taskId}
|
||||
AND worker_id = #{workerId}
|
||||
AND status = 1
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user