<?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.ApplyInfoDao">
	
	<resultMap type="com.ym.mec.collectfee.entity.ApplyInfo" id="ApplyInfo">
		<result column="id_" property="id" />
		<result column="name_" property="name" />
		<result column="sex_" property="sex" />
		<result column="birthday_" property="birthday" />
		<result column="city_" property="city" />
		<result column="school_" property="school" />
		<result column="grade_" property="grade" />
		<result column="g_class_" property="gClass" />
		<result column="sub_id_" property="subId" />
		<result column="is_adjust_" property="isAdjust" />
		<result column="patriarch_phone_" property="patriarchPhone" />
		<result column="patriarch_name_" property="patriarchName" />
		<result column="patriarch_unit_" property="patriarchUnit" />
		<result column="status_" property="status" />
		<result column="update_time_" property="updateTime" />
		<result column="create_time_" property="createTime" />
	</resultMap>
	
	<!-- 根据主键查询一条记录 -->
	<select id="get" resultMap="ApplyInfo" >
		SELECT * FROM apply_info WHERE id_ = #{id} 
	</select>
	
	<!-- 全查询 -->
	<select id="findAll" resultMap="ApplyInfo">
		SELECT * FROM apply_info ORDER BY id_
	</select>
	
	<!-- 向数据库增加一条记录 -->
	<insert id="insert" parameterType="com.ym.mec.collectfee.entity.ApplyInfo" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
		<!--
		<selectKey resultClass="int" keyProperty="id" > 
		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
		</selectKey>
		-->
		INSERT INTO apply_info (id_,name_,sex_,birthday_,city_,school_,grade_,g_class_,sub_id_,is_adjust_,patriarch_phone_,patriarch_name_,patriarch_unit_,status_,update_time_,create_time_) VALUES(#{id},#{name},#{sex},#{birthday},#{city},#{school},#{grade},#{gClass},#{subId},#{isAdjust},#{patriarchPhone},#{patriarchName},#{patriarchUnit},#{status},#{updateTime},#{createTime})
	</insert>
	
	<!-- 根据主键查询一条记录 -->
	<update id="update" parameterType="com.ym.mec.collectfee.entity.ApplyInfo">
		UPDATE apply_info SET sub_id_ = #{subId},school_ = #{school},is_adjust_ = #{isAdjust},status_ = #{status},id_ = #{id},g_class_ = #{gClass},sex_ = #{sex},birthday_ = #{birthday},name_ = #{name},create_time_ = #{createTime},city_ = #{city},patriarch_phone_ = #{patriarchPhone},patriarch_name_ = #{patriarchName},patriarch_unit_ = #{patriarchUnit},update_time_ = #{updateTime},grade_ = #{grade} WHERE id_ = #{id} 
	</update>
	
	<!-- 根据主键删除一条记录 -->
	<delete id="delete" >
		DELETE FROM apply_info WHERE id_ = #{id} 
	</delete>
	
	<!-- 分页查询 -->
	<select id="queryPage" resultMap="ApplyInfo" parameterType="map">
		SELECT * FROM apply_info ORDER BY id_ <include refid="global.limit"/>
	</select>
	
	<!-- 查询当前表的总记录数 -->
	<select id="queryCount" resultType="int">
		SELECT COUNT(*) FROM apply_info
	</select>
    <select id="findUserByPhone" resultMap="ApplyInfo">
		SELECT * FROM apply_info WHERE patriarch_phone_ = #{phone} AND school_ = #{clazzId}
	</select>
</mapper>
