<?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.trade.client.consumer.mapper.CustomerUserMapper">

	<resultMap id="BaseResultMap" type="com.trade.client.consumer.domain.CustomerUser">
		<id column="email" property="email" />
		<id column="gmt_create" property="gmtCreate" />
		<id column="gmt_modified" property="gmtModified" />
		<id column="id" property="id" />
		<id column="identifier_no" property="identifierNo" />
		<id column="nickname" property="nickname" />
		<id column="password" property="password" />
		<id column="phone_number" property="phoneNumber" />
	</resultMap>
	<sql id="Base_Column_List">
		id, identifier_no, nickname, password, phone_number, email, gmt_create, gmt_modified
	</sql>

	<select id="selectByPhoneAndName" resultMap="BaseResultMap">
		SELECT <include refid="Base_Column_List" />
		FROM customer_user
		<where>
			<if test="phoneNumber != null">
				phone_number = #{phoneNumber}
			</if>
			<if test="nickname != null">
		      AND nickname = #{nickname}
		  </if>
		</where>
	</select>

	<select id="selectByPhoneOrName" resultMap="BaseResultMap">
		SELECT <include refid="Base_Column_List" />
		FROM customer_user WHERE
		phone_number = #{userName} OR nickname = #{userName}
	</select>

</mapper>