180 lines
7.6 KiB
XML
180 lines
7.6 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.DatasetMapper">
|
|
|
|
<resultMap id="DatasetResult" type="com.bonus.ai.domain.dataset.DataSetEntity">
|
|
<id property="datasetId" column="dataset_id"/>
|
|
<result property="datasetUuid" column="dataset_uuid"/>
|
|
<result property="datasetName" column="dataset_name"/>
|
|
<result property="datasetDesc" column="description"/>
|
|
<result property="dataType" column="data_type"/>
|
|
<result property="dataSource" column="data_source"/>
|
|
<result property="inputPath" column="input_path"/>
|
|
<result property="outputPath" column="output_path"/>
|
|
<result property="inputId" column="input_id"/>
|
|
<result property="outputId" column="output_id"/>
|
|
<result property="annotationStatus" column="annotation_status"/>
|
|
<result property="isPublic" column="is_public"/>
|
|
<result property="delFlag" column="del_flag"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
<result property="updateTime" column="update_time"/>
|
|
<result property="isAnnotated" column="is_annotated"/>
|
|
<!-- <result property="projectId" column="project_id"/>-->
|
|
</resultMap>
|
|
|
|
<sql id="selectDatasetVo">
|
|
SELECT
|
|
ad.dataset_id,
|
|
ad.dataset_uuid,
|
|
ad.dataset_name,
|
|
ad.description,
|
|
ad.data_type,
|
|
ad.data_source,
|
|
ad.input_path,
|
|
ad.output_path,
|
|
ad.annotation_status,
|
|
ad.is_public,
|
|
ad.del_flag,
|
|
ad.create_by,
|
|
ad.create_time,
|
|
ad.update_by,
|
|
ad.update_time,
|
|
ad.input_id,
|
|
ad.output_id,
|
|
(SELECT COUNT(*)
|
|
FROM ai_dataset_file_map adfm
|
|
WHERE adfm.dataset_id = ad.dataset_id) AS annotatedCount,
|
|
(SELECT COUNT(*)
|
|
FROM ai_dataset_file_map adfm
|
|
WHERE adfm.dataset_id = ad.dataset_id AND adfm.is_annotated = '0') AS notAnnotatedCount
|
|
FROM
|
|
ai_dataset ad
|
|
</sql>
|
|
|
|
<insert id="insert" parameterType="com.bonus.ai.domain.dataset.DataSetEntity" useGeneratedKeys="true" keyProperty="datasetId">
|
|
insert into ai_dataset (
|
|
dataset_uuid, dataset_name, description, data_type, data_source, input_path, input_id, output_path,output_id, create_by, update_by
|
|
) values (
|
|
#{datasetUuid}, #{datasetName}, #{datasetDesc}, #{dataType},#{dataSource}, #{inputPath},#{inputId},
|
|
#{outputPath},#{outputId}, #{createBy}, #{updateBy}
|
|
)
|
|
</insert>
|
|
|
|
<update id="update" parameterType="com.bonus.ai.domain.dataset.DataSetEntity">
|
|
update ai_dataset
|
|
<set>
|
|
<if test="datasetName != null">dataset_name = #{datasetName},</if>
|
|
<if test="datasetDesc != null">description = #{datasetDesc},</if>
|
|
<if test="dataType != null">data_type = #{dataType},</if>
|
|
<if test="dataSource != null">data_source = #{dataSource},</if>
|
|
<if test="inputPath != null">input_path = #{inputPath},</if>
|
|
<if test="outputPath != null">output_path = #{outputPath},</if>
|
|
<if test="annotationStatus != null">annotation_status = #{annotationStatus},</if>
|
|
<if test="isPublic != null">is_public = #{isPublic},</if>
|
|
<if test="isAnnotated != null">is_annotated = #{isAnnotated},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
</set>
|
|
where dataset_id = #{datasetId}
|
|
</update>
|
|
|
|
<delete id="deleteById">
|
|
update ai_dataset set del_flag = '1'
|
|
where dataset_id = #{datasetId}
|
|
</delete>
|
|
|
|
<delete id="deleteByIds" parameterType="String">
|
|
update ai_dataset set del_flag = '1'
|
|
where dataset_id in
|
|
<foreach collection="array" item="datasetId" open="(" separator="," close=")">
|
|
#{datasetId}
|
|
</foreach>
|
|
</delete>
|
|
<delete id="removeDataSetBasicFile">
|
|
delete from ai_dataset_file_map
|
|
where dataset_id = #{datasetId} AND file_id in
|
|
<foreach collection="fileIds" item="fileId" open="(" separator="," close=")">
|
|
#{fileId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="selectById" resultMap="DatasetResult">
|
|
select d.dataset_id, d.dataset_uuid, d.dataset_name, d.description, d.data_type, d.data_source, d.input_path,
|
|
d.output_path, d.annotation_status, d.is_annotated, d.is_public, d.create_by, d.create_time, bf.file_id,
|
|
bf.file_name, bf.file_url, bf.file_size,bf.is_directory, bf.is_public
|
|
from ai_dataset d
|
|
left join ai_dataset_file_map fp on fp.dataset_id = d.dataset_id
|
|
left join ai_basic_file bf on bf.file_id = fp.file_id
|
|
where dataset_id = #{datasetId}
|
|
and del_flag = '0'
|
|
</select>
|
|
|
|
<select id="selectByUuid" resultMap="DatasetResult">
|
|
<include refid="selectDatasetVo"/>
|
|
where dataset_uuid = #{datasetUuid}
|
|
and del_flag = '0'
|
|
</select>
|
|
|
|
<select id="getDatasetList" parameterType="com.bonus.ai.domain.dataset.DataSetEntity" resultMap="DatasetResult">
|
|
<include refid="selectDatasetVo"/>
|
|
<where>
|
|
and ad.del_flag = '0'
|
|
<if test="datasetName != null and datasetName != ''">
|
|
AND ad.dataset_name like concat('%', #{datasetName}, '%')
|
|
</if>
|
|
<if test="dataType != null and dataType != ''">
|
|
AND ad.data_type = #{dataType}
|
|
</if>
|
|
<if test="annotationStatus != null and annotationStatus != ''">
|
|
AND ad.annotation_status = #{annotationStatus}
|
|
</if>
|
|
<if test="isPublic != null and isPublic != ''">
|
|
AND ad.is_public = #{isPublic}
|
|
</if>
|
|
<if test="createBy != null and createBy != ''">
|
|
AND ad.create_by = #{createBy}
|
|
</if>
|
|
</where>
|
|
order by create_time desc
|
|
</select>
|
|
|
|
<update id="updatePublicStatus">
|
|
update ai_dataset
|
|
set is_public = #{isPublic},
|
|
update_time = sysdate()
|
|
where dataset_id = #{datasetId}
|
|
</update>
|
|
|
|
<update id="updateAnnotationStatus">
|
|
update ai_dataset
|
|
set annotation_status = #{annotationStatus},
|
|
update_time = sysdate()
|
|
where dataset_id = #{datasetId}
|
|
</update>
|
|
|
|
<select id="checkDatasetNameUnique" parameterType="String" resultMap="DatasetResult">
|
|
select dataset_id, dataset_name
|
|
from ai_dataset
|
|
where dataset_name = #{datasetName}
|
|
and del_flag = '0' limit 1
|
|
</select>
|
|
<select id="selectAllList" resultMap="DatasetResult">
|
|
|
|
</select>
|
|
<select id="getDataSetBasicFile" parameterType="com.bonus.ai.domain.DataSetBasicFileEntity" resultType="com.bonus.ai.domain.DataSetBasicFileEntity">
|
|
SELECT
|
|
adfm.file_id AS fileId,
|
|
abf.file_name AS fileName,
|
|
abf.file_size AS fileSize,
|
|
adfm.create_time AS createTime
|
|
FROM
|
|
ai_dataset_file_map adfm
|
|
LEFT JOIN ai_basic_file abf ON abf.file_id = adfm.file_id AND abf.del_flag='0'
|
|
where adfm.dataset_id =#{dataSetId}
|
|
<if test="fileName != null and fileName != ''">
|
|
AND abf.file_name like concat('%', #{fileName}, '%')
|
|
</if>
|
|
</select>
|
|
</mapper> |