<?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.pjilisense.flxai.dao.FilesDao">

    <resultMap type="com.pjilisense.flxai.entity.FilesEntity" id="filesMap" >
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="fileType" column="file_type"/>
        <result property="name" column="name"/>
        <result property="size" column="size"/>
        <result property="url" column="url"/>
        <result property="metadata" column="metadata" typeHandler="com.pjilisense.flxai.handle.JsonbTypeHandler"/>
        <result property="createdAt" column="created_at" jdbcType="TIMESTAMP_WITH_TIMEZONE" javaType="java.time.OffsetDateTime" />
        <result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP_WITH_TIMEZONE" javaType="java.time.OffsetDateTime" />
        <result property="fileHash" column="file_hash"/>
        <result property="chunkTaskId" column="chunk_task_id" typeHandler="com.pjilisense.flxai.handle.UUIDTypeHandler"/>
        <result property="embeddingTaskId" column="embedding_task_id" typeHandler="com.pjilisense.flxai.handle.UUIDTypeHandler"/>
        <result property="accessedAt" column="accessed_at" jdbcType="TIMESTAMP_WITH_TIMEZONE" javaType="java.time.OffsetDateTime" />
        <result property="fileCategory" column="file_category"/>
        <result property="fileStatus" column="file_status"/>
    </resultMap>

    <update id="modifyFileName" parameterType="java.util.Map">
        UPDATE files SET name = #{name,jdbcType=VARCHAR},updated_at = now() WHERE id = #{id}
    </update>

    <update id="modifyFileStatus" parameterType="java.util.Map">
        UPDATE files SET file_status = #{fileStatus,jdbcType=VARCHAR},updated_at = now() WHERE id = #{id}
    </update>

    <update id="modifyFileCategory" parameterType="java.util.Map">
        UPDATE files SET file_category = #{fileCategory,jdbcType=VARCHAR},updated_at = now() WHERE id = #{id}
    </update>
</mapper>