<?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">
<!-- namespace必须指向DAO接口 -->
<mapper namespace="com.jpsoft.shinestar.modules.base.dao.CompanyPositionDAO">
	<resultMap id="CompanyPositionMap" type="com.jpsoft.shinestar.modules.base.entity.CompanyPosition">
		<id property="id" column="id_" />
			<result property="companyId" column="company_id" />
			<result property="position1Name" column="position1_name" />
			<result property="position2Name" column="position2_name" />
			<result property="position3Name" column="position3_name" />
			<result property="position4Name" column="position4_name" />
			<result property="position5Name" column="position5_name" />
			<result property="createBy" column="create_by" />
			<result property="createTime" column="create_time" />
			<result property="updateBy" column="update_by" />
			<result property="updateTime" column="update_time" />
			<result property="delFlag" column="del_flag" />
			</resultMap>
	<insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.CompanyPosition">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into base_company_position
	    (id_,company_id,position1_name,position2_name,position3_name,position4_name,position5_name,create_by,create_time,update_by,update_time,del_flag)
		values
		(
			#{id,jdbcType=VARCHAR}
			,#{companyId,jdbcType=VARCHAR}
			,#{position1Name,jdbcType=VARCHAR}
			,#{position2Name,jdbcType=VARCHAR}
			,#{position3Name,jdbcType=VARCHAR}
			,#{position4Name,jdbcType=VARCHAR}
			,#{position5Name,jdbcType=VARCHAR}
			,#{createBy,jdbcType=VARCHAR}
			,#{createTime,jdbcType= TIMESTAMP }
			,#{updateBy,jdbcType=VARCHAR}
			,#{updateTime,jdbcType= TIMESTAMP }
			,#{delFlag,jdbcType= NUMERIC }
		)
	]]>
	</insert>
	<delete id="delete" parameterType="string">
		delete from base_company_position where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="com.jpsoft.shinestar.modules.base.entity.CompanyPosition">
		update base_company_position
		<set>
				<if test="companyId!=null">
		company_id=#{companyId,jdbcType=VARCHAR},
		</if>
				<if test="position1Name!=null">
		position1_name=#{position1Name,jdbcType=VARCHAR},
		</if>
				<if test="position2Name!=null">
		position2_name=#{position2Name,jdbcType=VARCHAR},
		</if>
				<if test="position3Name!=null">
		position3_name=#{position3Name,jdbcType=VARCHAR},
		</if>
				<if test="position4Name!=null">
		position4_name=#{position4Name,jdbcType=VARCHAR},
		</if>
				<if test="position5Name!=null">
		position5_name=#{position5Name,jdbcType=VARCHAR},
		</if>
				<if test="createBy!=null">
		create_by=#{createBy,jdbcType=VARCHAR},
		</if>
				<if test="createTime!=null">
		create_time=#{createTime,jdbcType= TIMESTAMP },
		</if>
				<if test="updateBy!=null">
		update_by=#{updateBy,jdbcType=VARCHAR},
		</if>
				<if test="updateTime!=null">
		update_time=#{updateTime,jdbcType= TIMESTAMP },
		</if>
				<if test="delFlag!=null">
		del_flag=#{delFlag,jdbcType= NUMERIC },
		</if>
		</set>
	where id_=#{id}
	</update>
	<select id="get" parameterType="string" resultMap="CompanyPositionMap">
		select * from base_company_position where id_=#{0} and del_flag = 0
	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from base_company_position where id_=#{0} and del_flag = 0
	</select>
	<select id="list" resultMap="CompanyPositionMap">
		select * from base_company_position and del_flag = 0
	</select>
	<select id="search" parameterType="hashmap" resultMap="CompanyPositionMap">
		<![CDATA[
			select * from base_company_position
		]]>
		<where>
			del_flag = 0
			<if test="searchParams.companyId != null">
				and company_id = #{searchParams.companyId}
			</if>
		</where>
		<foreach item="sort" collection="sortList"  open="order by" separator=",">
	        ${sort.name} ${sort.order}
	 	</foreach>
	</select>

	<select id="findByCompanyId" parameterType="string" resultMap="CompanyPositionMap">
		select * from base_company_position where company_id=#{companyId} and del_flag = 0
	</select>
</mapper>