6ed23464a102fb659d1be708201bff77a8442708.svn-base 5.54 KB
<?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.phxl.modules.goods.dao.ctdept.HisCtDeptDao">

	<!--BaseResultMap -->
	<resultMap id="BaseResultMap"
		type="com.phxl.modules.goods.entity.ctdept.HisCtDept">
		<id column="id" property="id" jdbcType="BIGINT" />
		<result column="hdept_code" property="hdeptCode" jdbcType="VARCHAR" />
		<result column="hdept_name" property="hdeptName" jdbcType="VARCHAR" />
		<result column="help_code" property="helpCode" jdbcType="VARCHAR" />
		<result column="upper_GUID" property="upperGUID" jdbcType="VARCHAR" />
		<result column="is_order_right" property="isOrderRight" jdbcType="VARCHAR" />
		<result column="category" property="category" jdbcType="VARCHAR" />
		<result column="director" property="director" jdbcType="VARCHAR" />
		<result column="state" property="state" jdbcType="VARCHAR" />
		<result column="is_last_level" property="isLastLevel" jdbcType="VARCHAR" />
		<result column="create_time" property="create_time" jdbcType="TIMESTAMP" />
		<result column="update_time" property="update_time" jdbcType="TIMESTAMP" />
	</resultMap>

	<!--Base_Column_List -->
	<sql id="Base_Column_List">id,hdept_code,hdept_name,help_code,upper_GUID,is_order_right,category,director,state,is_last_level,create_time,update_time</sql>

	<!-- 批量查询 -->
	<select id="batchSelect" resultMap="BaseResultMap" parameterType="java.util.HashMap">
		select
		<include refid="Base_Column_List" />
		from med_hli_dept
		<if test="ctcpCodes != null">
			where hdept_code in
			<foreach item="item" index="index" collection="ctcpCodes" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

	<!--批量插入 -->
	<insert id="batchInsert" parameterType="list">
		insert into med_hli_dept (id,hdept_code,hdept_name,help_code,upper_GUID,is_order_right,category,director,state,is_last_level,create_time,update_time)
		values
		<foreach collection ="list" item="obj" separator =",">
		<trim prefix=" (" suffix=")" suffixOverrides=",">
				#{obj.id},
				#{obj.hdeptCode},
				#{obj.hdeptName},
				#{obj.helpCode},
				#{obj.upperGUID},
				#{obj.isOrderRight},
				#{obj.category},
				#{obj.director},
				#{obj.state},
				#{obj.isLastLevel},
				#{obj.create_time},
				#{obj.update_time}
			</trim>
          </foreach>
	</insert>

	<update id="batchUpdate" parameterType="list">
		update med_hli_dept
		<trim prefix="set" suffixOverrides=",">			
			<trim prefix="hdept_code=case" suffix="end,">
				<foreach collection="list" item="obj" index="index">
					<if test="obj.hdeptCode != null and obj.hdeptCode != ''">
						when id = #{obj.id}
						then #{obj.hdeptCode,jdbcType=VARCHAR}
					</if>
				</foreach>
			</trim>
			<trim prefix="hdept_name=case" suffix="end,">
				<foreach collection="list" item="obj" index="index">
					<if test="obj.hdeptName != null  and obj.hdeptName != ''">
						when id = #{obj.id}
						then
						#{obj.hdeptName,jdbcType=VARCHAR}
					</if>
				</foreach>
			</trim>
			<trim prefix="help_code=case" suffix="end,">
				<foreach collection="list" item="obj" index="index">
					<if test="obj.helpCode != null and obj.helpCode != ''">
						when id = #{obj.id}
						then #{obj.helpCode,jdbcType=VARCHAR}
					</if>
				</foreach>
			</trim>
			<trim prefix="upper_GUID=case" suffix="end,">
				<foreach collection="list" item="obj" index="index">
					<if test="obj.upperGUID != null and obj.upperGUID != ''">
						when id = #{obj.id}
						then #{obj.upperGUID,jdbcType=VARCHAR}
					</if>
				</foreach>
			</trim>
			<trim prefix="is_order_right=case" suffix="end,">
				<foreach collection="list" item="obj" index="index">
					<if test="obj.isOrderRight != null and obj.isOrderRight != ''">
						when id = #{obj.id}
						then #{obj.isOrderRight,jdbcType=VARCHAR}
					</if>
				</foreach>
			</trim>			
			<trim prefix="category=case" suffix="end,">
				<foreach collection="list" item="obj" index="index">
					<if test="obj.category != null and obj.category != ''">
						when id = #{obj.id}
						then #{obj.category,jdbcType=VARCHAR}
					</if>
				</foreach>
			</trim>
			<trim prefix="director=case" suffix="end,">
				<foreach collection="list" item="obj" index="index">
					<if test="obj.director != null and obj.director != ''">
						when id = #{obj.id}
						then #{obj.director,jdbcType=VARCHAR}
					</if>
				</foreach>
			</trim>
			<trim prefix="state=case" suffix="end,">
				<foreach collection="list" item="obj" index="index">
					<if test="obj.state != null and obj.state != ''">
						when id = #{obj.id}
						then #{obj.state,jdbcType=VARCHAR}
					</if>
				</foreach>
			</trim>
			<trim prefix="is_last_level=case" suffix="end,">
				<foreach collection="list" item="obj" index="index">
					<if test="obj.isLastLevel != null and obj.isLastLevel != ''">
						when id = #{obj.id}
						then #{obj.isLastLevel,jdbcType=VARCHAR}
					</if>
				</foreach>
			</trim>
			<trim prefix="create_time=case" suffix="end,">
				<foreach collection="list" item="obj" index="index">
					<if test="obj.create_time != null">
						when id = #{obj.id}
						then #{obj.create_time,jdbcType=DATE}
					</if>
				</foreach>
			</trim>
			<trim prefix="update_time=case" suffix="end,">
				<foreach collection="list" item="obj" index="index">
					<if test="obj.update_time != null">
						when id = #{obj.id}
						then #{obj.update_time,jdbcType=DATE}
					</if>
				</foreach>
			</trim>
		</trim>
		where
		<foreach collection="list" separator="or" item="obj" index="index">
			id
			= #{obj.id}
		</foreach>
	</update>


</mapper>