<?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">
<!-- namespace必须指向DAO接口 -->
<mapper namespace="com.jpsoft.shinestar.modules.wechat.dao.AccessContorlDAO">
    <resultMap id="AccessControlMap" type="com.jpsoft.shinestar.modules.wechat.entity.AccessControl">
        <id property="id" column="id"/>
        <result property="ownerId" column="owner_id"/>
        <result property="openId" column="open_id"/>
        <result property="bindTime" column="bind_time"/>
        <result property="bindFace" column="bind_face"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateBy" column="update_by"/>
    </resultMap>

    <select id="findByOpenId" parameterType="string" resultMap="AccessControlMap">
        select
        * from access_control where
        open_id=#{0}
    </select>

    <insert id="save" parameterType="com.jpsoft.shinestar.modules.wechat.entity.AccessControl">
        insert into access_control
        (id,owner_id,open_id,bind_time,bind_face,create_time)
        values
        (#{id,jdbcType=VARCHAR}
        ,#{ownerId,jdbcType=VARCHAR}
        ,#{openId,jdbcType=VARCHAR}
        ,#{bindTime,jdbcType= TIMESTAMP}
        ,#{bindFace,jdbcType= NUMERIC }
        ,#{createTime,jdbcType= TIMESTAMP }
        )
    </insert>

    <update id="update" parameterType="com.jpsoft.shinestar.modules.wechat.entity.AccessControl">
        update access_control
        <set>
            <if test="createBy!=null">
                create_by=#{createBy,jdbcType=VARCHAR},
            </if>
            <if test="createTime!=null">
                create_time=#{createTime,jdbcType= TIMESTAMP },
            </if>
            <if test="updateBy!=null">
                update_by=#{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime!=null">
                update_time=#{updateTime,jdbcType= TIMESTAMP },
            </if>
            <if test="ownerId!=null">
                owner_id=#{ownerId,jdbcType=VARCHAR},
            </if>
            <if test="openId!=null">
                open_id=#{openId,jdbcType=VARCHAR},
            </if>
            <if test="bindFace!=null">
                bind_face=#{bindFace,jdbcType=NUMERIC},
            </if>
        </set>
        where id=#{id}
    </update>

    <select id="findByOwner" parameterType="string" resultMap="AccessControlMap">
        select
        * from access_control where
        owner_id=#{0}
    </select>



</mapper>
