<?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="org.jeecg.module.custom.ocr.dataDao.DuplicateTaskMapper">
  <resultMap id="BaseResultMap" type="org.jeecg.module.custom.ocr.dataobject.DuplicateTask">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="tenant_code" jdbcType="VARCHAR" property="tenantCode" />
    <result column="access_key" jdbcType="VARCHAR" property="accessKey" />
    <result column="timestamp" jdbcType="BIGINT" property="timestamp" />
    <result column="signature" jdbcType="VARCHAR" property="signature" />
    <result column="account_no" jdbcType="BIGINT" property="accountNo" />
    <result column="tenant_no" jdbcType="BIGINT" property="tenantNo" />
    <result column="request_id" jdbcType="BIGINT" property="requestId" />
    <result column="task_nos" jdbcType="VARCHAR" property="taskNos" />
    <result column="query_config" jdbcType="VARCHAR" property="queryConfig" />
    <result column="max_similarity_score" jdbcType="VARCHAR" property="maxSimilarityScore" />
    <result column="completed" jdbcType="TINYINT" property="completed" />
  </resultMap>

  <sql id="Base_Column_List">
    id, tenant_code, access_key, `timestamp`, signature, account_no, tenant_no,
    request_id, task_nos, query_config, max_similarity_score, completed
  </sql>

  <insert id="save" parameterType="org.jeecg.module.custom.ocr.dataobject.DuplicateTask">
    INSERT INTO duplicate_task (
    <include refid="Base_Column_List" />
    ) VALUES (
    #{id},
    #{tenantCode},
    #{accessKey},
    #{timestamp},
    #{signature},
    #{accountNo},
    #{tenantNo},
    #{requestId},
    #{taskNos},
    #{queryConfig},
    #{maxSimilarityScore},
    #{completed}
    )
  </insert>

  <select id="getAllUnCompletedTask" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List" />
    FROM duplicate_task
    WHERE completed = 0
  </select>

  <update id="updateCompletedById" parameterType="java.lang.Long">
    UPDATE duplicate_task
    SET completed = #{completed,jdbcType=BIGINT}
    WHERE id = #{id,jdbcType=BIGINT}
  </update>

  <update id="updateCompletedAndMaxSimilarity">
    UPDATE duplicate_task
    SET completed = #{completed,jdbcType=TINYINT},
        max_similarity_score = #{maxSimilarityScore}
    WHERE id = #{id,jdbcType=BIGINT}
  </update>
</mapper>
