<?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.ruoyi.materialClass.mapper.MaterialClassSubMapper">

    <resultMap type="MaterialClassSub" id="MaterialClassSubResult">
        <result property="id"    column="id"    />
        <result property="mastId"    column="mast_id"    />
        <result property="classMastType"    column="class_mast_type"    />
        <result property="classMastId"    column="class_mast_id"    />
        <result property="classSubId"    column="class_sub_id"    />
        <result property="classNameSub"    column="class_name_sub"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="deptId"    column="dept_id"    />
        <result property="createUserId"    column="create_user_id"    />
        <result property="updateUserId"    column="update_user_id"    />
    </resultMap>

    <sql id="selectMaterialClassSubVo">
        select class_sub_id, class_mast_id, class_name_sub from material_class_sub
    </sql>

    <select id="selectMaterialClassSubList" parameterType="MaterialClassSub" resultMap="MaterialClassSubResult">
        <include refid="selectMaterialClassSubVo"/>
        <where>
            <if test="mastId != null "> and mast_id = #{mastId}</if>
            <if test="classMastType != null  and classMastType != ''"> and class_mast_type = #{classMastType}</if>
            <if test="classMastId != null  and classMastId != ''"> and class_mast_id = #{classMastId}</if>
            <if test="classSubId != null  and classSubId != ''"> and class_sub_id = #{classSubId}</if>
            <if test="classNameSub != null  and classNameSub != ''"> and class_name_sub like concat('%', #{classNameSub}, '%')</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
            <if test="updateUserId != null "> and update_user_id = #{updateUserId}</if>
        </where>
    </select>

    <select id="selectMaterialClassSubByClassSubId" parameterType="String" resultMap="MaterialClassSubResult">
            <include refid="selectMaterialClassSubVo"/>
            where class_sub_id = #{classSubId}
    </select>

    <delete id="deleteMaterialClassSubByClassMastId" parameterType="String">
        delete
        from material_class_sub
        where mast_id = #{classMastId}
    </delete>


</mapper>