<?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.cultivate.dao.impl.CultivateRobotClassifyDaoImpl" >
  <resultMap id="BaseResultMap" type="com.pcloud.book.cultivate.entity.CultivateRobotClassify" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="wechat_user_id" property="wechatUserId" jdbcType="BIGINT" />
    <result column="cultivate_id" property="cultivateId" jdbcType="BIGINT" />
    <result column="robot_classify_id" property="robotClassifyId" jdbcType="BIGINT" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  </resultMap>

  <sql id="Base_Column_List" >
    id, wechat_user_id, cultivate_id, robot_classify_id, create_time
  </sql>

  <insert id="insert" parameterType="com.pcloud.book.cultivate.entity.CultivateRobotClassify" useGeneratedKeys="true" keyProperty="id">
    insert into cultivate_robot_classify
    (
       wechat_user_id,
       cultivate_id,
       robot_classify_id,
       create_time
      )
    values (
      #{wechatUserId},
      #{cultivateId},
      #{robotClassifyId},
      NOW()
      )
  </insert>

  <select id="getByCondition" parameterType="map" resultMap="BaseResultMap">
    select <include refid="Base_Column_List"/>
    from cultivate_robot_classify
    where 1=1
    <if test="wechatUserId!=null">
      and wechat_user_id=#{wechatUserId}
    </if>
    <if test="cultivateId!=null">
      and cultivate_id=#{cultivateId}
    </if>
    <if test="robotClassifyId!=null">
      and robot_classify_id=#{robotClassifyId}
    </if>
  </select>

</mapper>