<?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.yd.dal.mapper.survey.SurveyCustomerAnswersMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.survey.SurveyCustomerAnswers">
    <!--@mbg.generated-->
    <!--@Table ag_survey_customer_answers-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="customer_id" jdbcType="BIGINT" property="customerId" />
    <result column="page_id" jdbcType="BIGINT" property="pageId" />
    <result column="order_id" jdbcType="BIGINT" property="orderId" />
    <result column="question_id" jdbcType="BIGINT" property="questionId" />
    <result column="question_name" jdbcType="VARCHAR" property="questionName" />
    <result column="option_name" jdbcType="VARCHAR" property="optionName" />
    <result column="option_id_selected" jdbcType="BIGINT" property="optionIdSelected" />
    <result column="customer_input" jdbcType="VARCHAR" property="customerInput" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
    <result column="updated_by" jdbcType="BIGINT" property="updatedBy" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, customer_id, page_id, order_id, question_id, question_name, option_name, option_id_selected, 
    customer_input, is_active, created_at, created_by, updated_at, updated_by
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from ag_survey_customer_answers
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from ag_survey_customer_answers
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.survey.SurveyCustomerAnswers" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_survey_customer_answers (customer_id, page_id, order_id, 
      question_id, question_name, option_name, 
      option_id_selected, customer_input, is_active, 
      created_at, created_by, updated_at, 
      updated_by)
    values (#{customerId,jdbcType=BIGINT}, #{pageId,jdbcType=BIGINT}, #{orderId,jdbcType=BIGINT}, 
      #{questionId,jdbcType=BIGINT}, #{questionName,jdbcType=VARCHAR}, #{optionName,jdbcType=VARCHAR}, 
      #{optionIdSelected,jdbcType=BIGINT}, #{customerInput,jdbcType=VARCHAR}, #{isActive,jdbcType=INTEGER}, 
      #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP}, 
      #{updatedBy,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.survey.SurveyCustomerAnswers" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_survey_customer_answers
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="customerId != null">
        customer_id,
      </if>
      <if test="pageId != null">
        page_id,
      </if>
      <if test="orderId != null">
        order_id,
      </if>
      <if test="questionId != null">
        question_id,
      </if>
      <if test="questionName != null">
        question_name,
      </if>
      <if test="optionName != null">
        option_name,
      </if>
      <if test="optionIdSelected != null">
        option_id_selected,
      </if>
      <if test="customerInput != null">
        customer_input,
      </if>
      <if test="isActive != null">
        is_active,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedAt != null">
        updated_at,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="customerId != null">
        #{customerId,jdbcType=BIGINT},
      </if>
      <if test="pageId != null">
        #{pageId,jdbcType=BIGINT},
      </if>
      <if test="orderId != null">
        #{orderId,jdbcType=BIGINT},
      </if>
      <if test="questionId != null">
        #{questionId,jdbcType=BIGINT},
      </if>
      <if test="questionName != null">
        #{questionName,jdbcType=VARCHAR},
      </if>
      <if test="optionName != null">
        #{optionName,jdbcType=VARCHAR},
      </if>
      <if test="optionIdSelected != null">
        #{optionIdSelected,jdbcType=BIGINT},
      </if>
      <if test="customerInput != null">
        #{customerInput,jdbcType=VARCHAR},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.survey.SurveyCustomerAnswers">
    <!--@mbg.generated-->
    update ag_survey_customer_answers
    <set>
      <if test="customerId != null">
        customer_id = #{customerId,jdbcType=BIGINT},
      </if>
      <if test="pageId != null">
        page_id = #{pageId,jdbcType=BIGINT},
      </if>
      <if test="orderId != null">
        order_id = #{orderId,jdbcType=BIGINT},
      </if>
      <if test="questionId != null">
        question_id = #{questionId,jdbcType=BIGINT},
      </if>
      <if test="questionName != null">
        question_name = #{questionName,jdbcType=VARCHAR},
      </if>
      <if test="optionName != null">
        option_name = #{optionName,jdbcType=VARCHAR},
      </if>
      <if test="optionIdSelected != null">
        option_id_selected = #{optionIdSelected,jdbcType=BIGINT},
      </if>
      <if test="customerInput != null">
        customer_input = #{customerInput,jdbcType=VARCHAR},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.survey.SurveyCustomerAnswers">
    <!--@mbg.generated-->
    update ag_survey_customer_answers
    set customer_id = #{customerId,jdbcType=BIGINT},
      page_id = #{pageId,jdbcType=BIGINT},
      order_id = #{orderId,jdbcType=BIGINT},
      question_id = #{questionId,jdbcType=BIGINT},
      question_name = #{questionName,jdbcType=VARCHAR},
      option_name = #{optionName,jdbcType=VARCHAR},
      option_id_selected = #{optionIdSelected,jdbcType=BIGINT},
      customer_input = #{customerInput,jdbcType=VARCHAR},
      is_active = #{isActive,jdbcType=INTEGER},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      updated_by = #{updatedBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
    <select id="findByObjGroupByOrderBy" resultMap="BaseResultMap">
      select
      <include refid="Base_Column_List" />
      from ag_survey_customer_answers
      <where>
        <if test="info.id != null">
          id = #{info.id,jdbcType=BIGINT}
        </if>
        <if test="info.customerId != null">
          and customer_id = #{info.customerId,jdbcType=BIGINT}
        </if>
        <if test="info.pageId != null">
          and page_id = #{info.pageId,jdbcType=BIGINT}
        </if>
        <if test="info.orderId != null">
          and order_id = #{info.orderId,jdbcType=BIGINT}
        </if>
        <if test="info.questionId != null">
          and question_id = #{info.questionId,jdbcType=BIGINT}
        </if>
        <if test="info.questionName != null">
          and question_name = #{info.questionName,jdbcType=VARCHAR}
        </if>
        <if test="info.optionName != null">
          and option_name = #{info.optionName,jdbcType=VARCHAR}
        </if>
        <if test="info.optionIdSelected != null">
          and option_id_selected = #{info.optionIdSelected,jdbcType=BIGINT}
        </if>
        <if test="info.customerInput != null">
          and customer_input = #{info.customerInput,jdbcType=VARCHAR}
        </if>
        <if test="info.isActive != null">
          and is_active = #{info.isActive,jdbcType=INTEGER}
        </if>
        <if test="info.createdAt != null">
          and created_at = #{info.createdAt,jdbcType=TIMESTAMP}
        </if>
        <if test="info.createdBy != null">
          and created_by = #{info.createdBy,jdbcType=BIGINT}
        </if>
        <if test="info.updatedAt != null">
          and updated_at = #{info.updatedAt,jdbcType=TIMESTAMP}
        </if>
        <if test="info.updatedBy != null">
          and updated_by = #{info.updatedBy,jdbcType=BIGINT}
        </if>
      </where>
      <if test="groupBy != null">
        GROUP BY ${groupBy}
      </if>
      <if test="orderBy != null">
        ORDER BY ${orderBy}
      </if>
    </select>
</mapper>