<?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.keao.edu.cms.dal.dao.HelpCenterCatalogDao">
	<resultMap id="HelpCenterCatalog" type="com.keao.edu.cms.dal.entity.HelpCenterCatalog">
		<id column="id_" property="id" jdbcType="INTEGER" />
		<result column="parent_id_" property="parentId" jdbcType="INTEGER" />
		<result column="name_" property="text" jdbcType="VARCHAR" />
		<result column="description_" property="description" jdbcType="VARCHAR" />
		<result column="create_on_" property="createOn" jdbcType="TIMESTAMP" />
		<result column="modify_on_" property="modifyOn" jdbcType="TIMESTAMP" />
		<result column="order_" property="order" jdbcType="INTEGER" />
		<result column="status_" property="status" jdbcType="INTEGER" />
	</resultMap>

	<sql id="Base_Column_List">
		id_, parent_id_, name_, description_, create_on_, modify_on_, order_,status_
	</sql>

	<select id="get" resultMap="HelpCenterCatalog" parameterType="java.lang.Integer">
		select
		<include refid="Base_Column_List" />
		from help_center_catalog
		where id_ = #{id,jdbcType=INTEGER}
	</select>

	<select id="queryPage" parameterType="map" resultMap="HelpCenterCatalog">
		select
		<include refid="Base_Column_List" />
		from
		help_center_catalog
		order by order_ asc
	</select>

	<select id="queryByParentId" parameterType="map" resultMap="HelpCenterCatalog">
		select
		<include refid="Base_Column_List" />
		from
		help_center_catalog
		where 1 = 1
		<if test="parentId != null">
			and parent_id_= #{parentId,jdbcType=INTEGER}
		</if>
		<if test="status != null">
			and status_ = #{status,jdbcType=INTEGER}
		</if>
		order by order_ desc
	</select>

	<delete id="delete" parameterType="java.lang.Integer">
		delete from help_center_catalog
		where id_ = #{id,jdbcType=INTEGER}
	</delete>
	
	<delete id="batchDelete" parameterType="String">
		delete from help_center_catalog
		where id_ in #{ids}
	</delete>
	
	<insert id="insert" parameterType="com.keao.edu.cms.dal.entity.HelpCenterCatalog">
		insert into help_center_catalog (id_, parent_id_, name_,
		description_, create_on_, modify_on_,
		order_,status_)
		values (#{id,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER},
		#{text,jdbcType=VARCHAR},
		#{description,jdbcType=VARCHAR}, #{createOn,jdbcType=TIMESTAMP}, #{modifyOn,jdbcType=TIMESTAMP},
		#{order,jdbcType=INTEGER},#{status,jdbcType=INTEGER})
	</insert>
	
	<update id="update" parameterType="com.keao.edu.cms.dal.entity.HelpCenterCatalog">
		update help_center_catalog
		<set>
			<if test="parentId != null">
				parent_id_ = #{parentId,jdbcType=INTEGER},
			</if>
			<if test="text != null">
				name_ = #{text,jdbcType=VARCHAR},
			</if>
			<if test="description != null">
				description_ = #{description,jdbcType=VARCHAR},
			</if>
			<if test="createOn != null">
				create_on_ = #{createOn,jdbcType=TIMESTAMP},
			</if>
			<if test="modifyOn != null">
				modify_on_ = #{modifyOn,jdbcType=TIMESTAMP},
			</if>
			<if test="order != null">
				order_ = #{order,jdbcType=INTEGER},
			</if>
			<if test="status != null">
				status_ = #{status,jdbcType=INTEGER},
			</if>
		</set>
		where id_ = #{id,jdbcType=INTEGER}
	</update>
</mapper>