<?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.pcloud.book.custom.mapper.CustomTimeControlUserMapper" >
  <resultMap id="BaseResultMap" type="com.pcloud.book.custom.entity.CustomTimeControlUser" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="custom_time_control_id" property="customTimeControlId" jdbcType="INTEGER" />
    <result column="robot_id" property="robotId" jdbcType="VARCHAR" />
    <result column="wx_id" property="wxId" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, custom_time_control_id, robot_id, wx_id, create_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    select 
    <include refid="Base_Column_List" />
    from custom_time_control_user
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    delete from custom_time_control_user
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.pcloud.book.custom.entity.CustomTimeControlUser" >
    insert into custom_time_control_user (
        id, custom_time_control_id, robot_id, wx_id, create_time
      )
    values (#{id,jdbcType=BIGINT}, #{customTimeControlId,jdbcType=INTEGER}, #{robotId,jdbcType=VARCHAR},
      #{wxId,jdbcType=VARCHAR}, now()
      )
  </insert>

  <select id="getByWxIdAndControlId" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from custom_time_control_user
    where wx_id = #{wxId}
    and custom_time_control_id = #{customTimeControlId}
    limit 1
  </select>
</mapper>