<?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:必须与对应的接口全类名一致
 -->
<mapper namespace="com.iamberry.wechat.service.mapper.QuestionnaireAnswerMapper">
	<sql id="questionnaireAnswer">
		Q.ANSWER_ID answerId,
		Q.ANSWER_BABY_NAME answerBabyName,
		Q.ANSWER_BABY_PIC answerBabyPic,
		Q.ANSWER_BABY_SEX answerBabySex,
		Q.ANSWER_BABY_HEIGHT answerBabyHeight,
		Q.ANSWER_BABY_WEIGHT answerBabyWeight,
		Q.ANSWER_HEAD_WITH answerHeadWith,
		Q.ANSWER_BABY_AGE answerBabyAge,
		Q.ANSWER_IS_EUTOCIA answerIsEutocia,
		Q.ANSWER_IS_FULLMOON answerIsFullmoon,
		Q.ANSWER_CREATE_DATE answerCreateDate,
		Q.ANSWER_USER_SCORE answerUserScore,
		Q.ANSWER_SCANNED_NUMBER answerScannedNumber,
		Q.ANSWER_SHARE_NUMBER answerShareNumber,
		Q.ANSWER_REMARK answerRemark
	</sql>
	
	<!-- 分页查询所有用户回答信息 -->
	<select id="getAllAnswer" parameterType="QuestionnaireAnswer" resultType="QuestionnaireAnswer">
		SELECT 
			<include refid="questionnaireAnswer" />
		FROM 
			TB_IAMBERRY_QUESTIONNAIRE_ANSWER Q
		<where>
			
			<if test="answerBabyAge != null and answerBabyAge != ''">
				AND Q.ANSWER_BABY_AGE = #{answerBabyAge}
			</if>
			<if test="answerBabyName != null and answerBabyName != ''">
				AND Q.ANSWER_BABY_NAME = #{answerBabyName}
			</if>
		</where>
		LIMIT ${page.recordBegin},${page.pageSize}
	</select>
	<!-- 查询所有用户回答信息条数 -->
	<select id="getAllAnswerCount" parameterType="QuestionnaireAnswer" resultType="Integer">
		SELECT 
			COUNT(Q.ANSWER_ID) 
		FROM 
			TB_IAMBERRY_QUESTIONNAIRE_ANSWER Q
		<where>
			<if test="answerBabyAge != null and answerBabyAge != ''">
				AND Q.ANSWER_BABY_AGE = #{answerBabyAge}
			</if>
		</where>
	</select>
</mapper>