<?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.biz.dal.dao.MemberFeeSettingDao">
	
	<resultMap type="com.ym.mec.biz.dal.entity.MemberFeeSetting" id="MemberFeeSetting">
		<result column="id_" property="id" />
		<result column="current_day_fee_" property="currentDayFee" />
		<result column="original_day_fee_" property="originalDayFee" />
		<result column="current_month_fee_" property="currentMonthFee" />
		<result column="original_month_fee_" property="originalMonthFee" />
		<result column="current_half_year_fee_" property="currentHalfYearFee" />
		<result column="original_half_year_fee_" property="originalHalfYearFee" />
		<result column="current_year_fee_" property="currentYearFee" />
		<result column="original_year_fee_" property="originalYearFee" />
	</resultMap>
	
	<!-- 根据主键查询一条记录 -->
	<select id="get" resultMap="MemberFeeSetting" >
		SELECT * FROM member_fee_setting WHERE id_ = #{id} 
	</select>
	
	<!-- 全查询 -->
	<select id="findAll" resultMap="MemberFeeSetting">
		SELECT * FROM member_fee_setting ORDER BY id_
	</select>
	
	<!-- 向数据库增加一条记录 -->
	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MemberFeeSetting" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
		<!--
		<selectKey resultClass="int" keyProperty="id" > 
		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
		</selectKey>
		-->
		INSERT INTO member_fee_setting (id_,current_day_fee_,original_day_fee_,current_month_fee_,original_month_fee_,current_half_year_fee_,original_half_year_fee_,current_year_fee_,original_year_fee_) VALUES(#{id},#{currentDayFee},#{originalDayFee},#{currentMonthFee},#{originalMonthFee},#{currentHalfYearFee},#{originalHalfYearFee},#{currentYearFee},#{originalYearFee})
	</insert>
	
	<!-- 根据主键查询一条记录 -->
	<update id="update" parameterType="com.ym.mec.biz.dal.entity.MemberFeeSetting">
		UPDATE member_fee_setting <set>
		<if test="originalHalfYearFee != null">
		original_half_year_fee_ = #{originalHalfYearFee},
		</if>
		<if test="originalDayFee != null">
		original_day_fee_ = #{originalDayFee},
		</if>
		<if test="currentHalfYearFee != null">
		current_half_year_fee_ = #{currentHalfYearFee},
		</if>
		<if test="currentMonthFee != null">
		current_month_fee_ = #{currentMonthFee},
		</if>
		<if test="currentDayFee != null">
		current_day_fee_ = #{currentDayFee},
		</if>
		<if test="originalMonthFee != null">
		original_month_fee_ = #{originalMonthFee},
		</if>
		<if test="originalYearFee != null">
		original_year_fee_ = #{originalYearFee},
		</if>
		<if test="currentYearFee != null">
		current_year_fee_ = #{currentYearFee},
		</if>
		</set> WHERE id_ = #{id}
	</update>
	
	<!-- 根据主键删除一条记录 -->
	<delete id="delete" >
		DELETE FROM member_fee_setting WHERE id_ = #{id} 
	</delete>
	
	<!-- 分页查询 -->
	<select id="queryPage" resultMap="MemberFeeSetting" parameterType="map">
		SELECT * FROM member_fee_setting ORDER BY id_ <include refid="global.limit"/>
	</select>
	
	<!-- 查询当前表的总记录数 -->
	<select id="queryCount" resultType="int">
		SELECT COUNT(*) FROM member_fee_setting
	</select>
    <select id="findByRankIdAndOrganId" resultMap="MemberFeeSetting">
		SELECT mfs.* FROM member_rank_organization_fee_mapper mro
		LEFT JOIN member_fee_setting mfs ON mfs.id_ = mro.member_fee_setting_id_
		WHERE mro.member_rank_setting_id_ = #{rankId} AND mro.organ_id_ = #{organId}
	</select>
</mapper>
