<?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.baseinfo.mapper.BasePosttypeInfoMapper">

    <resultMap type="BasePosttypeInfo" id="BasePosttypeInfoResult">
        <result property="objid"    column="objid"    />
        <result property="postTypeId"    column="post_type_id"    />
        <result property="postTypeName"    column="post_type_name"    />
        <result property="status"    column="status"    />
        <result property="remark"    column="remark"    />
        <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="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectBasePosttypeInfoVo">
        select objid, post_type_id, post_type_name, status, remark, create_by, create_time, update_by, update_time, del_flag from base_posttype_info
    </sql>

    <select id="selectBasePosttypeInfoList" parameterType="BasePosttypeInfo" resultMap="BasePosttypeInfoResult">
        <include refid="selectBasePosttypeInfoVo"/>
        <where>
            <if test="postTypeId != null  and postTypeId != ''"> and post_type_id = #{postTypeId}</if>
            <if test="postTypeName != null  and postTypeName != ''"> and post_type_name like ('%' + #{postTypeName} + '%')</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>

    <select id="selectBasePosttypeInfoById" parameterType="Long" resultMap="BasePosttypeInfoResult">
        <include refid="selectBasePosttypeInfoVo"/>
        where objid = #{objid}
    </select>

    <insert id="insertBasePosttypeInfo" parameterType="BasePosttypeInfo">
        insert into base_posttype_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="objid != null">objid,</if>
            <if test="postTypeId != null">post_type_id,</if>
            <if test="postTypeName != null">post_type_name,</if>
            <if test="status != null">status,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="delFlag != null">del_flag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="objid != null">#{objid},</if>
            <if test="postTypeId != null">#{postTypeId},</if>
            <if test="postTypeName != null">#{postTypeName},</if>
            <if test="status != null">#{status},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
        </trim>
    </insert>

    <update id="updateBasePosttypeInfo" parameterType="BasePosttypeInfo">
        update base_posttype_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="postTypeId != null">post_type_id = #{postTypeId},</if>
            <if test="postTypeName != null">post_type_name = #{postTypeName},</if>
            <if test="status != null">status = #{status},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where objid = #{objid}
    </update>

    <delete id="deleteBasePosttypeInfoById" parameterType="Long">
        delete from base_posttype_info where objid = #{objid}
    </delete>

    <delete id="deleteBasePosttypeInfoByIds" parameterType="String">
        delete from base_posttype_info where objid in
        <foreach item="objid" collection="array" open="(" separator="," close=")">
            #{objid}
        </foreach>
    </delete>


    <select id="selectAddBasePosttypeInfoList" parameterType="BasePosttypeInfo" resultMap="BasePosttypeInfoResult">
        <include refid="selectBasePosttypeInfoVo"/>
    </select>

    <select id="selectEditBasePosttypeInfoList" parameterType="BasePosttypeInfo" resultMap="BasePosttypeInfoResult">
        <include refid="selectBasePosttypeInfoVo"/>
        where post_type_id = #{postTypeID}
    </select>
</mapper>
