<?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.izouma.awesomeadmin.dao.HouseKeeperMapper">
    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.HouseKeeper">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
        <result column="keep_name" property="keepName" jdbcType="VARCHAR"/>
        <result column="position" property="position" jdbcType="VARCHAR"/>
        <result column="icon" property="icon" jdbcType="VARCHAR"/>
        <result column="telephone" property="telephone" jdbcType="VARCHAR"/>
        <result column="sex" property="sex" jdbcType="VARCHAR"/>
        <result column="introduce" property="introduce" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">
            id,            del_flag,            keep_name,            position,            icon,            telephone,            sex,            introduce,            create_time,            update_time        </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from house_keeper
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from house_keeper
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.HouseKeeper" useGeneratedKeys="true"
            keyProperty="id">
        insert into house_keeper
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id!= null">
                id,
            </if>
            <if test="delFlag!= null">
                del_flag,
            </if>
            <if test="keepName!= null">
                keep_name,
            </if>
            <if test="position!= null">
                position,
            </if>
            <if test="icon!= null">
                icon,
            </if>
            <if test="telephone!= null">
                telephone,
            </if>
            <if test="sex!= null">
                sex,
            </if>
            <if test="introduce!= null">
                introduce,
            </if>
            <if test="createTime!= null">
                create_time,
            </if>
            <if test="updateTime!= null">
                update_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=CHAR},
            </if>
            <if test="keepName != null">
                #{keepName,jdbcType=VARCHAR},
            </if>
            <if test="position != null">
                #{position,jdbcType=VARCHAR},
            </if>
            <if test="icon != null">
                #{icon,jdbcType=VARCHAR},
            </if>
            <if test="telephone != null">
                #{telephone,jdbcType=VARCHAR},
            </if>
            <if test="sex != null">
                #{sex,jdbcType=VARCHAR},
            </if>
            <if test="introduce != null">
                #{introduce,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.HouseKeeper">
        update house_keeper
        <set>
            <if test="id != null">
                id= #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                del_flag= #{delFlag,jdbcType=CHAR},
            </if>
            <if test="keepName != null">
                keep_name= #{keepName,jdbcType=VARCHAR},
            </if>
            <if test="position != null">
                position= #{position,jdbcType=VARCHAR},
            </if>
            <if test="icon != null">
                icon= #{icon,jdbcType=VARCHAR},
            </if>
            <if test="telephone != null">
                telephone= #{telephone,jdbcType=VARCHAR},
            </if>
            <if test="sex != null">
                sex= #{sex,jdbcType=VARCHAR},
            </if>
            <if test="introduce != null">
                introduce= #{introduce,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time= #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                update_time= #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <select id="queryHouseKeeperByPage" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.HouseKeeper">
        select
        <include refid="Base_Column_List"/>
        from house_keeper
        <where>
            and del_flag = 'N'
            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
                and id = #{record.id}
            </if>
            <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
                and del_flag = #{record.delFlag}
            </if>
            <if test="record.keepName != null and !&quot;&quot;.equals(record.keepName)">
                and keep_name = #{record.keepName}
            </if>
            <if test="record.position != null and !&quot;&quot;.equals(record.position)">
                and position = #{record.position}
            </if>
            <if test="record.icon != null and !&quot;&quot;.equals(record.icon)">
                and icon = #{record.icon}
            </if>
            <if test="record.telephone != null and !&quot;&quot;.equals(record.telephone)">
                and telephone = #{record.telephone}
            </if>
            <if test="record.sex != null and !&quot;&quot;.equals(record.sex)">
                and sex = #{record.sex}
            </if>
            <if test="record.introduce != null and !&quot;&quot;.equals(record.introduce)">
                and introduce = #{record.introduce}
            </if>
            <if test="record.createTime != null and !&quot;&quot;.equals(record.createTime)">
                and create_time = #{record.createTime}
            </if>
            <if test="record.updateTime != null and !&quot;&quot;.equals(record.updateTime)">
                and update_time = #{record.updateTime}
            </if>

            <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR">
                    OR keep_name LIKE concat('%',#{record.searchKey},'%')
                    OR position LIKE concat('%',#{record.searchKey},'%')
                    OR telephone LIKE concat('%',#{record.searchKey},'%')
                    OR introduce LIKE concat('%',#{record.searchKey},'%')
                </trim>
            </if>

        </where>
        order by id desc
    </select>
    <select id="queryAllHouseKeeper" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.HouseKeeper">
        select
        <include refid="Base_Column_List"/>
        from house_keeper
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="keepName != null and !&quot;&quot;.equals(keepName)">
                and keep_name = #{keepName}
            </if>
            <if test="position != null and !&quot;&quot;.equals(position)">
                and position = #{position}
            </if>
            <if test="icon != null and !&quot;&quot;.equals(icon)">
                and icon = #{icon}
            </if>
            <if test="telephone != null and !&quot;&quot;.equals(telephone)">
                and telephone = #{telephone}
            </if>
            <if test="sex != null and !&quot;&quot;.equals(sex)">
                and sex = #{sex}
            </if>
            <if test="introduce != null and !&quot;&quot;.equals(introduce)">
                and introduce = #{introduce}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>
        </where>
        order by id desc
    </select>
    <select id="queryHouseKeeper" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.HouseKeeper">
        select
        <include refid="Base_Column_List"/>
        from house_keeper
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="keepName != null and !&quot;&quot;.equals(keepName)">
                and keep_name = #{keepName}
            </if>
            <if test="position != null and !&quot;&quot;.equals(position)">
                and position = #{position}
            </if>
            <if test="icon != null and !&quot;&quot;.equals(icon)">
                and icon = #{icon}
            </if>
            <if test="telephone != null and !&quot;&quot;.equals(telephone)">
                and telephone = #{telephone}
            </if>
            <if test="sex != null and !&quot;&quot;.equals(sex)">
                and sex = #{sex}
            </if>
            <if test="introduce != null and !&quot;&quot;.equals(introduce)">
                and introduce = #{introduce}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>

        </where>
        LIMIT 1
    </select>
    <update id="delete">
        UPDATE house_keeper SET del_flag = 'Y'
        <where>
            AND id = #{id}
        </where>
    </update>
    <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.HouseKeeper">
        select
        <include refid="Base_Column_List"/>
        from house_keeper
        <where>
            and del_flag = 'N'
        </where>
        order by id desc
    </select>
</mapper>

