Bonus-Cloud-AI-V2/bonus-modules/bonus-ai/src/main/resources/mapper/ReleaseVersionMapper.xml

72 lines
3.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.bonus.ai.mapper.ReleaseVersionMapper">
<insert id="release" useGeneratedKeys="true" keyProperty="versionId">
INSERT INTO ai_dataset_version (version_name, version_description, dataset_id, task_id, create_by)
VALUES (#{versionName}, #{versionDesc}, #{datasetId}, #{taskId}, #{createBy});
</insert>
<insert id="releaseMap">
INSERT INTO ai_version_file_map (version_id, file_id, annotation_result)
VALUES
<foreach collection="taskBasicFile" item="item" index="index" separator=",">
(#{versionId}, #{item.fileId}, #{item.annotationResult})
</foreach>
</insert>
<update id="delete">
update ai_dataset_version set del_flag='1' where version_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<delete id="deleteMap">
delete from ai_version_file_map where version_id = #{versionId}
</delete>
<select id="getAllReleaseVersions" resultType="com.bonus.ai.domain.dataset.ReleaseVersionEntity">
SELECT
adv.version_id AS versionId,
ad.dataset_name AS datasetName,
adv.version_name AS versionName,
su.user_name AS releaseUserName,
adv.create_time AS createTime,
aat.task_name AS taskName,
aat.annotation_type AS annotationType,
COUNT(avfm.version_id) AS totalCount
FROM
ai_dataset_version adv
LEFT JOIN ai_dataset ad ON adv.dataset_id = ad.dataset_id
LEFT JOIN sys_user su ON adv.create_by = su.user_id
LEFT JOIN ai_annotation_task aat ON adv.task_id = aat.task_id
LEFT JOIN ai_version_file_map avfm ON adv.version_id = avfm.version_id
WHERE adv.dataset_id =#{datasetId} AND adv.del_flag='0'
<if test="versionName != null and versionName != ''">
AND adv.version_name LIKE CONCAT('%', #{versionName}, '%')
</if>
GROUP BY
adv.version_id,
ad.dataset_name,
adv.version_name,
su.user_name,
adv.create_time,
aat.task_name,
aat.annotation_type
ORDER BY
adv.create_time DESC
</select>
<select id="getReleaseMapList" resultType="com.bonus.ai.domain.DataSetBasicFileEntity">
SELECT
adf.file_name AS fileName,
adf.file_url AS fileUrl,
avfm.annotation_result AS annotationResult
from ai_version_file_map avfm
LEFT JOIN ai_basic_file adf ON avfm.file_id = adf.file_id AND adf.del_flag = '0'
WHERE avfm.version_id =#{versionId}
</select>
<select id="selectVersionName" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM ai_dataset_version
WHERE version_name = #{versionName} and dataset_id = #{datasetId}
</select>
</mapper>