148 lines
7.0 KiB
XML
148 lines
7.0 KiB
XML
|
|
<?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.ruoyi.office.mapper.TtPublishTaskMapper">
|
||
|
|
|
||
|
|
<resultMap type="TtPublishTask" id="PublishTaskResult">
|
||
|
|
<id property="publishId" column="publish_id" />
|
||
|
|
<result property="taskId" column="task_id" />
|
||
|
|
<result property="codeId" column="code_id" />
|
||
|
|
<result property="codeName" column="code_name" />
|
||
|
|
<result property="platform" column="platform" />
|
||
|
|
<result property="title" column="title" />
|
||
|
|
<result property="content" column="content" />
|
||
|
|
<result property="tags" column="tags" />
|
||
|
|
<result property="videoUrl" column="video_url" />
|
||
|
|
<result property="imageUrls" column="image_urls" />
|
||
|
|
<result property="coverUrl" column="cover_url" />
|
||
|
|
<result property="status" column="status" />
|
||
|
|
<result property="statusMessage" column="status_message" />
|
||
|
|
<result property="lastError" column="last_error" />
|
||
|
|
<result property="bridgeToken" column="bridge_token" />
|
||
|
|
<result property="bridgeExpiresAt" column="bridge_expires_at" />
|
||
|
|
<result property="startedAt" column="started_at" />
|
||
|
|
<result property="readyAt" column="ready_at" />
|
||
|
|
<result property="finishedAt" column="finished_at" />
|
||
|
|
<result property="createBy" column="create_by" />
|
||
|
|
<result property="createTime" column="create_time" />
|
||
|
|
<result property="updateBy" column="update_by" />
|
||
|
|
<result property="updateTime" column="update_time" />
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<resultMap type="PublishProjectRow" id="PublishProjectResult">
|
||
|
|
<id property="codeId" column="code_id" />
|
||
|
|
<result property="codeName" column="code_name" />
|
||
|
|
<result property="xiaohongshuTaskId" column="xiaohongshu_task_id" />
|
||
|
|
<result property="xiaohongshuStatus" column="xiaohongshu_status" />
|
||
|
|
<result property="douyinTaskId" column="douyin_task_id" />
|
||
|
|
<result property="douyinStatus" column="douyin_status" />
|
||
|
|
<result property="wechatChannelsTaskId" column="wechat_channels_task_id" />
|
||
|
|
<result property="wechatChannelsStatus" column="wechat_channels_status" />
|
||
|
|
<result property="bilibiliTaskId" column="bilibili_task_id" />
|
||
|
|
<result property="bilibiliStatus" column="bilibili_status" />
|
||
|
|
<result property="xianyuTaskId" column="xianyu_task_id" />
|
||
|
|
<result property="xianyuStatus" column="xianyu_status" />
|
||
|
|
<result property="lastPublishTime" column="last_publish_time" />
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<sql id="selectPublishTaskVo">
|
||
|
|
select t.publish_id, t.task_id, t.code_id, c.code_name, t.platform,
|
||
|
|
t.title, t.content, t.tags, t.video_url, t.image_urls, t.cover_url,
|
||
|
|
t.status, t.status_message, t.last_error, t.bridge_token,
|
||
|
|
t.bridge_expires_at, t.started_at, t.ready_at, t.finished_at,
|
||
|
|
t.create_by, t.create_time, t.update_by, t.update_time
|
||
|
|
from tt_publish_task t
|
||
|
|
inner join tt_code c on c.code_id = t.code_id
|
||
|
|
</sql>
|
||
|
|
|
||
|
|
<select id="selectPublishProjectList" parameterType="PublishProjectRow" resultMap="PublishProjectResult">
|
||
|
|
select c.code_id,
|
||
|
|
c.code_name,
|
||
|
|
x.task_id as xiaohongshu_task_id,
|
||
|
|
x.status as xiaohongshu_status,
|
||
|
|
d.task_id as douyin_task_id,
|
||
|
|
d.status as douyin_status,
|
||
|
|
w.task_id as wechat_channels_task_id,
|
||
|
|
w.status as wechat_channels_status,
|
||
|
|
b.task_id as bilibili_task_id,
|
||
|
|
b.status as bilibili_status,
|
||
|
|
y.task_id as xianyu_task_id,
|
||
|
|
y.status as xianyu_status,
|
||
|
|
greatest(
|
||
|
|
ifnull(x.update_time, '1970-01-01 00:00:00'),
|
||
|
|
ifnull(d.update_time, '1970-01-01 00:00:00'),
|
||
|
|
ifnull(w.update_time, '1970-01-01 00:00:00'),
|
||
|
|
ifnull(b.update_time, '1970-01-01 00:00:00'),
|
||
|
|
ifnull(y.update_time, '1970-01-01 00:00:00')
|
||
|
|
) as last_publish_time
|
||
|
|
from tt_code c
|
||
|
|
left join tt_publish_task x on x.publish_id = (
|
||
|
|
select max(tx.publish_id) from tt_publish_task tx
|
||
|
|
where tx.code_id = c.code_id and tx.platform = 'xiaohongshu'
|
||
|
|
)
|
||
|
|
left join tt_publish_task d on d.publish_id = (
|
||
|
|
select max(td.publish_id) from tt_publish_task td
|
||
|
|
where td.code_id = c.code_id and td.platform = 'douyin'
|
||
|
|
)
|
||
|
|
left join tt_publish_task w on w.publish_id = (
|
||
|
|
select max(tw.publish_id) from tt_publish_task tw
|
||
|
|
where tw.code_id = c.code_id and tw.platform = 'wechat_channels'
|
||
|
|
)
|
||
|
|
left join tt_publish_task b on b.publish_id = (
|
||
|
|
select max(tb.publish_id) from tt_publish_task tb
|
||
|
|
where tb.code_id = c.code_id and tb.platform = 'bilibili'
|
||
|
|
)
|
||
|
|
left join tt_publish_task y on y.publish_id = (
|
||
|
|
select max(ty.publish_id) from tt_publish_task ty
|
||
|
|
where ty.code_id = c.code_id and ty.platform = 'xianyu'
|
||
|
|
)
|
||
|
|
<where>
|
||
|
|
<if test="codeName != null and codeName != ''">
|
||
|
|
and c.code_name like concat('%', #{codeName}, '%')
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
order by c.code_id desc
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectPublishTaskByTaskId" parameterType="String" resultMap="PublishTaskResult">
|
||
|
|
<include refid="selectPublishTaskVo" />
|
||
|
|
where t.task_id = #{taskId}
|
||
|
|
limit 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectPublishTaskByBridge" resultMap="PublishTaskResult">
|
||
|
|
<include refid="selectPublishTaskVo" />
|
||
|
|
where t.task_id = #{taskId}
|
||
|
|
and t.bridge_token = #{bridgeToken}
|
||
|
|
and t.bridge_expires_at > now()
|
||
|
|
limit 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="insertPublishTask" parameterType="TtPublishTask" useGeneratedKeys="true" keyProperty="publishId">
|
||
|
|
insert into tt_publish_task
|
||
|
|
(task_id, code_id, platform, title, content, tags, video_url,
|
||
|
|
image_urls, cover_url, status, status_message, bridge_token,
|
||
|
|
bridge_expires_at, create_by, create_time, update_by, update_time)
|
||
|
|
values
|
||
|
|
(#{taskId}, #{codeId}, #{platform}, #{title}, #{content}, #{tags},
|
||
|
|
#{videoUrl}, #{imageUrls}, #{coverUrl}, #{status}, #{statusMessage},
|
||
|
|
#{bridgeToken}, #{bridgeExpiresAt}, #{createBy}, now(), #{updateBy}, now())
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="updatePublishTaskStatus" parameterType="TtPublishTask">
|
||
|
|
update tt_publish_task
|
||
|
|
<set>
|
||
|
|
status = #{status},
|
||
|
|
status_message = #{statusMessage},
|
||
|
|
last_error = #{lastError},
|
||
|
|
<if test="startedAt != null">started_at = #{startedAt},</if>
|
||
|
|
<if test="readyAt != null">ready_at = #{readyAt},</if>
|
||
|
|
<if test="finishedAt != null">finished_at = #{finishedAt},</if>
|
||
|
|
update_by = #{updateBy},
|
||
|
|
update_time = now()
|
||
|
|
</set>
|
||
|
|
where task_id = #{taskId}
|
||
|
|
</update>
|
||
|
|
</mapper>
|