<?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.TOperaDocMapper">

    <sql id="column">
        id,cn_name,en_name,version,file_code,file_name,qr_code,tag,create_time,update_time,url,setx,file_size
    </sql>

    <select id="selectPageDoc" parameterType="cn.iocoder.yudao.module.knowledge.controller.requestdto.TOperationDocRequest"
            resultType="cn.iocoder.yudao.module.knowledge.entity.TOperationDocument">
        SELECT
            <include refid="column"></include>
        FROM
            t_operation_document
        WHERE
            deleted = 0
            <if test="docRequest.cnName != '' and docRequest.cnName != null">
                AND `cn_name` LIKE CONCAT( '%',#{docRequest.cnName}, '%')
            </if>
            <if test="docRequest.selTagValue != '' and docRequest.selTagValue != null">
                AND `tag` = #{docRequest.selTagValue}
            </if>
            <if test="docRequest.createTime != null and docRequest.createTime != ''">
                AND (create_time >= date_format(#{docRequest.createTime},'%y-%m-%d 00:00:00') and create_time <![CDATA[<=]]> date_format(#{docRequest.createTime},'%y-%m-%d 23:59:59'))
            </if>
        ORDER BY
            create_time DESC
    </select>

    <update id="updateByCode">
        UPDATE t_product_raw_materials
        SET
        deleted = '1'
        WHERE operation_document_code in
        <foreach collection="codes" item="cod" index="index" open="(" separator="," close=")">
            #{cod}
        </foreach>
    </update>

    <update id="updateGyByCode">
        UPDATE t_technology_equipment
        SET
        deleted = '1'
        WHERE operation_document_code in
        <foreach collection="codes" item="cod" index="index" open="(" separator="," close=")">
            #{cod}
        </foreach>
    </update>

    <select id="selectPRMByCode" resultType="cn.iocoder.yudao.module.knowledge.entity.TProductRawMaterials">
        SELECT
            *
        FROM
            t_product_raw_materials
        WHERE
            deleted = 0
          AND operation_document_code = #{code}
        LIMIT 1
    </select>

    <select id="selectTEByCode" resultType="cn.iocoder.yudao.module.knowledge.entity.TTechnologyEquipment">
        SELECT
            *
        FROM
            t_technology_equipment
        WHERE
            deleted = 0
            AND operation_document_code = #{code}
        LIMIT 1
    </select>


</mapper>

