<?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="cn.iocoder.yudao.module.knowledge.mapper.TRegulatoryFrameworkMapper">

    <sql id="column">
        id,CODE,NAME,version,file_url,file_size,file_name,filing_time,is_filing,deleted,laws_a,laws_b,creator,creator_id,create_time,update_time,dept_id,identity_id,describe_info,tenant_id,type
    </sql>
    <update id="updateByLawId">
        UPDATE t_regulatory_framework
        SET
            code = #{dto.code},
            version = #{dto.version},
            file_url = #{dto.fileUrl},
            file_size = #{dto.fileSize},
            file_name = #{dto.fileName},
            describe_info = #{dto.describeInfo}
        WHERE
            id = #{dto.id}
    </update>

    <update id="deleteByIds">
        UPDATE t_regulatory_framework
        SET
            deleted = 0
        WHERE id = #{id}
    </update>

    <update id="filling">
        UPDATE t_regulatory_framework
        SET
            is_filing = '1'
        WHERE id = #{id}
    </update>

    <select id="judgeIsFilling" resultType="int">
        SELECT COUNT(1)
                   is_filing
        FROM
            t_regulatory_framework
        WHERE
            is_filing = '1'
          AND
            id = #{id}
          AND
            deleted = 0
    </select>


    <select id="getListPage" resultType="cn.iocoder.yudao.module.knowledge.entity.TRegulatoryFramework">
        SELECT
            <include refid="column"></include>
        FROM
            t_regulatory_framework
        WHERE
            deleted = 0 and is_filing!=1
            <if test="dto.name != '' and dto.name != null">
                AND `name` LIKE CONCAT( '%',#{dto.name}, '%')
            </if>
            <if test=" dto.createTime != null">
                AND DATE(create_time) = #{dto.createTime}
            </if>
        ORDER BY
            create_time DESC
    </select>

    <select id="selectForApp" resultType="cn.iocoder.yudao.module.knowledge.entity.TRegulatoryFramework">
        SELECT
            <include refid="column"></include>
        FROM
        t_regulatory_framework
        WHERE
        deleted = 0 and is_filing!=1
        <if test="dto.name != '' and dto.name != null">
            AND `name` LIKE CONCAT( '%',#{dto.name}, '%')
        </if>
        <if test=" dto.createTime != null">
            AND DATE(create_time) = #{dto.createTime}
        </if>
        ORDER BY
        create_time DESC
    </select>


</mapper>

