<?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.ym.mec.collectfee.dao.MecUserDao">
	
	<resultMap type="com.ym.mec.collectfee.entity.MecUser" id="MecUser">
		<result column="user_id_" property="userId" />
		<result column="user_name_" property="userName" />
		<result column="mobile_" property="mobile" />
		<result column="branch_id_" property="branchId" />
		<result column="city_" property="city" />
		<result column="real_name_" property="realName" />
		<result column="sex_" property="sex" />
		<result column="ethnic_" property="ethnic" />
		<result column="card_no_" property="cardNo" />
		<result column="birth_day_" property="birthDay" />
		<result column="company_" property="company" />
		<result column="clazz_" property="clazz" />
		<result column="p_name_" property="pName" />
		<result column="p_company_" property="pCompany" />
		<result column="balance_" property="balance" />
		<result column="active_" property="active" />
		<result column="wx_account_" property="wxAccount" />
		<result column="ali_account_" property="aliAccount" />
	</resultMap>
	
	<!-- 根据主键查询一条记录 -->
	<select id="get" resultMap="MecUser" >
		SELECT * FROM mec_user WHERE user_id_ = #{userId} 
	</select>
	
	<!-- 全查询 -->
	<select id="findAll" resultMap="MecUser">
		SELECT * FROM mec_user ORDER BY user_id_
	</select>
	
	<!-- 向数据库增加一条记录 -->
	<insert id="insert" parameterType="com.ym.mec.collectfee.entity.MecUser" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
		INSERT INTO mec_user (user_id_,user_name_,mobile_,branch_id_,city_,real_name_,sex_,ethnic_,card_no_,birth_day_,company_,clazz_,p_name_,p_company_,balance_,active_,wx_account_,ali_account_) VALUES(#{userId},#{userName},#{mobile},#{branchId},#{city},#{realName},#{sex},#{ethnic},#{cardNo},#{birthDay},#{company},#{clazz},#{pName},#{pCompany},#{balance},#{active},#{wxAccount},#{aliAccount})
	</insert>
	
	<!-- 根据主键查询一条记录 -->
	<update id="update" parameterType="com.ym.mec.collectfee.entity.MecUser">
		UPDATE mec_user
		<set>
			<if test="company != null and company != ''">
				company_ = #{company},
			</if>
			<if test="userName != null and userName != ''">
				user_name_ = #{userName},
			</if>
			<if test="ethnic != null">
				ethnic_ = #{ethnic},
			</if>
			<if test="cardNo != null">
				card_no_ = #{cardNo},
			</if>
			<if test="clazz != null">
				clazz_ = #{clazz},
			</if>
			<if test="birthDay != null">
				birth_day_ = #{birthDay},
			</if>
			<if test="branchId != null">
				branch_id_ = #{branchId},
			</if>
			<if test="sex != null">
				sex_ = #{sex},
			</if>
			<if test="realName != null">
				real_name_ = #{realName},
			</if>
			<if test="wxAccount != null">
				wx_account_ = #{wxAccount},
			</if>
			<if test="city != null">
				city_ = #{city},
			</if>
			<if test="pCompany != null">
				p_company_ = #{pCompany},
			</if>
			<if test="pName != null">
				p_name_ = #{pName},
			</if>
			<if test="active != null">
				active_ = #{active},
			</if>
			<if test="mobile != null">
				mobile_ = #{mobile},
			</if>
			<if test="aliAccount != null">
				ali_account_ = #{aliAccount},
			</if>
		</set>
		WHERE user_id_ = #{userId}
	</update>
	
	<!-- 根据主键删除一条记录 -->
	<delete id="delete" >
		DELETE FROM mec_user WHERE user_id_ = #{userId} 
	</delete>
	
	<!-- 分页查询 -->
	<select id="queryPage" resultMap="MecUser" parameterType="map">
		SELECT * FROM mec_user ORDER BY user_id_ <include refid="global.limit"/>
	</select>
	
	<!-- 查询当前表的总记录数 -->
	<select id="findCount" resultType="int">
		SELECT COUNT(*) FROM mec_user
	</select>
</mapper>
