<?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.ActivityPlanDao">
	
	<resultMap type="com.ym.mec.biz.dal.entity.ActivityPlan" id="ActivityPlan">
		<result column="id_" property="id" />
		<result column="organ_id_" property="organId" />
		<result column="name_" property="name" />
		<result column="description_" property="description" />
		<result column="type_" property="type" />
		<result column="start_time_" property="startTime" />
		<result column="end_time_" property="endTime" />
		<result column="courses_start_time_" property="coursesStartTime" />
		<result column="courses_end_time_" property="coursesEndTime" />
		<result column="apply_to_student_type_" property="applyToStudentType" />
		<result column="max_buy_num_" property="maxBuyNum" />
		<result column="course_arranging_type_" property="courseArrangingType" />
		<result column="course_type_" property="courseType" />
		<result column="category_id_" property="categoryId" />
		<result column="single_course_time_" property="singleCourseTime" />
		<result column="min_course_num_" property="minCourseNum" />
		<result column="max_course_num_" property="maxCourseNum" />
		<result column="discount_" property="discount" />
		<result column="full_minus_course_times_" property="fullMinusCourseTimes" />
		<result column="give_course_type_" property="giveCourseType" />
		<result column="give_category_id_" property="giveCategoryId" />
		<result column="give_course_num_" property="giveCourseNum" />
		<result column="member_rank_id_" property="memberRankId" />
		<result column="member_time_" property="memberTime" />
		<result column="salary_settlement_json_" property="salarySettlementJson" />
		<result column="del_flag_" property="delFlag" />
		<result column="enable_" property="enable" />
		<result column="create_time_" property="createTime" />
		<result column="update_time_" property="updateTime" />
		<result column="tenant_id_" property="tenantId" />
	</resultMap>
	
	<!-- 根据主键查询一条记录 -->
	<select id="get" resultMap="ActivityPlan" >
		SELECT * FROM activity_plan WHERE id_ = #{id} 
	</select>
	
	<!-- 全查询 -->
	<select id="findAll" resultMap="ActivityPlan">
		SELECT * FROM activity_plan where tenant_id_ = #{tenantId} ORDER BY id_
	</select>
	
	<!-- 向数据库增加一条记录 -->
	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ActivityPlan" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
		INSERT INTO activity_plan (organ_id_,name_,description_,type_,start_time_,end_time_,courses_start_time_,
					   courses_end_time_,apply_to_student_type_,max_buy_num_,course_arranging_type_,
					   course_type_,category_id_,single_course_time_,min_course_num_,max_course_num_,
					   discount_,full_minus_course_times_,give_course_type_,give_category_id_,give_course_num_,
					   member_rank_id_,member_time_,salary_settlement_json_,del_flag_,enable_,create_time_,update_time_,tenant_id_)
					   VALUES(#{organId},#{name},#{description},#{type},#{startTime},#{endTime},#{coursesStartTime},
							  #{coursesEndTime},#{applyToStudentType},#{maxBuyNum},#{courseArrangingType},#{courseType},
							  #{categoryId},#{singleCourseTime},#{minCourseNum},#{maxCourseNum},#{discount},
							  #{fullMinusCourseTimes},#{giveCourseType},#{giveCategoryId},#{giveCourseNum},
							  #{memberRankId},#{memberTime},#{salarySettlementJson},#{delFlag},#{enable},#{createTime},#{updateTime},#{tenantId})
	</insert>
	
	<!-- 根据主键查询一条记录 -->
	<update id="update" parameterType="com.ym.mec.biz.dal.entity.ActivityPlan">
		UPDATE activity_plan <set>
		<if test="memberRankId != null">
		member_rank_id_ = #{memberRankId},
		</if>
		<if test="coursesEndTime != null">
		courses_end_time_ = #{coursesEndTime},
		</if>
		<if test="giveCategoryId != null">
		give_category_id_ = #{giveCategoryId},
		</if>
		<if test="name != null">
		name_ = #{name},
		</if>
		<if test="categoryId != null">
		category_id_ = #{categoryId},
		</if>
		<if test="updateTime != null">
		update_time_ = #{updateTime},
		</if>
		<if test="description != null">
		description_ = #{description},
		</if>
		<if test="courseType != null">
		course_type_ = #{courseType},
		</if>
		<if test="giveCourseNum != null">
		give_course_num_ = #{giveCourseNum},
		</if>
		<if test="coursesStartTime != null">
		courses_start_time_ = #{coursesStartTime},
		</if>
		<if test="maxBuyNum != null">
		max_buy_num_ = #{maxBuyNum},
		</if>
		<if test="delFlag != null">
		del_flag_ = #{delFlag},
		</if>
		<if test="organId != null">
		organ_id_ = #{organId},
		</if>
		<if test="id != null">
		id_ = #{id},
		</if>
		<if test="giveCourseType != null">
		give_course_type_ = #{giveCourseType},
		</if>
		<if test="applyToStudentType != null">
		apply_to_student_type_ = #{applyToStudentType},
		</if>
		<if test="endTime != null">
		end_time_ = #{endTime},
		</if>
		<if test="fullMinusCourseTimes != null">
		full_minus_course_times_ = #{fullMinusCourseTimes},
		</if>
		<if test="memberTime != null">
		member_time_ = #{memberTime},
		</if>
		<if test="startTime != null">
		start_time_ = #{startTime},
		</if>
		<if test="createTime != null">
		create_time_ = #{createTime},
		</if>
		<if test="courseArrangingType != null">
		course_arranging_type_ = #{courseArrangingType},
		</if>
		<if test="enable != null">
		enable_ = #{enable},
		</if>
		<if test="singleCourseTime != null">
		single_course_time_ = #{singleCourseTime},
		</if>
		<if test="maxCourseNum != null">
		max_course_num_ = #{maxCourseNum},
		</if>
		<if test="minCourseNum != null">
		min_course_num_ = #{minCourseNum},
		</if>
		<if test="discount != null">
		discount_ = #{discount},
		</if>
		<if test="salarySettlementJson != null">
		salary_settlement_json_ = #{salarySettlementJson},
		</if>
		<if test="type != null">
		type_ = #{type},
		</if>
		</set> WHERE id_ = #{id} and tenant_id_ = #{tenantId}
	</update>
	
	<!-- 根据主键删除一条记录 -->
	<delete id="delete" >
		DELETE FROM activity_plan WHERE id_ = #{id} 
	</delete>
	
	<!-- 分页查询 -->
	<select id="queryPage" resultMap="ActivityPlan" parameterType="map">
		SELECT * FROM activity_plan where tenant_id_ = #{tenantId} ORDER BY id_ <include refid="global.limit"/>
	</select>
	
	<!-- 查询当前表的总记录数 -->
	<select id="queryCount" resultType="int">
		SELECT COUNT(*) FROM activity_plan where tenant_id_ = #{tenantId}
	</select>
</mapper>
