<?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.modules.stm.compliane.item.mapper.StComplianeItemMapper">
    <select id="queryStComplianeItems" resultType="org.jeecg.modules.stm.compliane.item.vo.StComplianeItemVo">
        SELECT A.id,A.compliane_no AS complianeNo,A.ca_no AS caNo,
        A.compliane_item AS complianeItem,A.compliane_ask AS complianeAsk,
        A.applicable_code AS applicableCode,A.approve_flag AS approveFlag,
        A.valid,A.created_user,A.created_time AS createdTime,A.updated_user AS updatedUser,
        C.ca_name AS caName FROM st_compliane_item A
        left JOIN st_compliane_item_ca B ON A.id=B.itemid
        left JOIN st_ca_main C ON C.ca_no=B.ca_no
        <where>
            <if test="query.complianeNo!=null">
                A.compliane_no = #{query.complianeNo}
            </if>
        </where>
        order by  A.id
    </select>
    <insert id="insertItemCa"  parameterType="org.jeecg.modules.stm.compliane.item.entity.StComplianeItemCa">
        insert into st_compliane_item_ca(ca_no,itemid) value(#{caNo},#{itemid})
    </insert>

    <delete id="deleteItemCa"  parameterType="org.jeecg.modules.stm.compliane.item.entity.StComplianeItemCa">
        delete from st_compliane_item_ca where itemid = #{itemid};
    </delete>

</mapper>