<?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.djhk.uav.warLawLibrary.mapper.WarLawLibraryMapper">

    <resultMap type="com.djhk.uav.warLawLibrary.domain.WarLawLibrary" id="WarLawLibraryResult">
        <result property="id"    column="id"    />
        <result property="warName"    column="war_name"    />
        <result property="warContent"    column="war_content"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="deptId"    column="dept_id"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectWarLawLibraryVo">
        select id, war_name, war_content, create_by, create_time, del_flag, dept_id, update_by, update_time from war_law_library
    </sql>

    <select id="selectWarLawLibraryList" parameterType="com.djhk.uav.warLawLibrary.domain.WarLawLibrary" resultMap="WarLawLibraryResult">
        <include refid="selectWarLawLibraryVo"/>
        <where>
            <if test="warName != null  and warName != ''"> and war_name like concat('%', #{warName}, '%')</if>
            <if test="warContent != null  and warContent != ''"> and war_content = #{warContent}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
        </where>
    </select>

    <select id="selectWarLawLibraryById" parameterType="Long" resultMap="WarLawLibraryResult">
        <include refid="selectWarLawLibraryVo"/>
        where id = #{id}
    </select>

    <insert id="insertWarLawLibrary" parameterType="com.djhk.uav.warLawLibrary.domain.WarLawLibrary" useGeneratedKeys="true" keyProperty="id">
        insert into war_law_library
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="warName != null">war_name,</if>
            <if test="warContent != null">war_content,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="warName != null">#{warName},</if>
            <if test="warContent != null">#{warContent},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateWarLawLibrary" parameterType="com.djhk.uav.warLawLibrary.domain.WarLawLibrary">
        update war_law_library
        <trim prefix="SET" suffixOverrides=",">
            <if test="warName != null">war_name = #{warName},</if>
            <if test="warContent != null">war_content = #{warContent},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWarLawLibraryById" parameterType="Long">
        delete from war_law_library where id = #{id}
    </delete>

    <delete id="deleteWarLawLibraryByIds" parameterType="String">
        delete from war_law_library where id = #{id}

    </delete>
    <delete id="removeByWarName" parameterType="String">
        delete from war_law_library where war_name = #{warName}

    </delete>
</mapper>
