<?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="OrgEntity">
	<resultMap id="RM_OrgEntity" type="com.blueland.bpm.identity.model.Org">
        <result column="ORG_ID" jdbcType="VARCHAR" property="orgId" />
	    <result column="ORG_NAME" jdbcType="VARCHAR" property="orgName" />
	    <result column="ORG_FULL_NAME" jdbcType="VARCHAR" property="orgFullName" />
	    <result column="ORG_FULL_PATH_NAME" jdbcType="CHAR" property="orgFullPathName" />
	    <result column="ORG_FULL_PATH_ID" jdbcType="CHAR" property="orgFullPathId" />
	    <result column="ORG_PARENT_ID" jdbcType="VARCHAR" property="orgParentId" />
	    <result column="ORG_TYPE" jdbcType="CHAR" property="orgType" />
	    <result column="ORG_LEVEL" jdbcType="INTEGER" property="orgLevel" />
	    <result column="ORG_AREA_TYPE" jdbcType="VARCHAR" property="orgAreaType" />
	    <result column="ORG_SORT" jdbcType="INTEGER" property="orgSort" />
	    <result column="ORG_WORK_PHONE" jdbcType="CHAR" property="orgWorkPhone" />
	    <result column="ORG_WORK_ADDRESS" jdbcType="CHAR" property="orgWorkAddress" />
	    <result column="ORG_PRINCIPAL" jdbcType="CHAR" property="orgPrincipal" />
	    <result column="ORG_STATUS" jdbcType="VARCHAR" property="orgStatus" />
	    <result column="ORG_CREATE_TIME" jdbcType="VARBINARY" property="orgCreateTime" />
	    <result column="REMARK" jdbcType="CHAR" property="remark" />
	    <result column="COMPANY_ID" jdbcType="VARCHAR" property="companyId" />
	    <result column="DEPT_ID" jdbcType="VARCHAR" property="deptId" />
	    <result column="DEPT_NAME" jdbcType="VARCHAR" property="deptName" />
	    <result column="COMPANY_NAME" jdbcType="VARCHAR" property="companyName" />
	    <result column="ORG_BRANCH_LEADER" jdbcType="CHAR" property="orgBranchLeader" />
	</resultMap>
	<sql id="Base_Column_List">
	   COMPANY_ID,COMPANY_NAME,DEPT_ID,DEPT_NAME,ORG_AREA_TYPE,ORG_BRANCH_LEADER,ORG_CREATE_TIME,ORG_FULL_NAME,ORG_FULL_PATH_ID,ORG_FULL_PATH_NAME,ORG_ID,ORG_LEVEL,ORG_NAME,ORG_PARENT_ID,ORG_PRINCIPAL,ORG_SORT,ORG_STATUS,ORG_TYPE,ORG_WORK_ADDRESS,ORG_WORK_PHONE,REMARK
	</sql>
	<insert id="insert">
		insert into `T_PUB_ORG` (<include refid="Base_Column_List"/>) VALUES (
			#{companyId,jdbcType=VARCHAR},
		#{companyName,jdbcType=VARCHAR},
		#{deptId,jdbcType=VARCHAR},
		#{deptName,jdbcType=VARCHAR},
		#{orgAreaType,jdbcType=VARCHAR},
		#{orgBranchLeader,jdbcType=VARCHAR},
		#{orgCreateTime,jdbcType=TIMESTAMP},
		#{orgFullName,jdbcType=VARCHAR},
		#{orgFullPathId,jdbcType=VARCHAR},
		#{orgFullPathName,jdbcType=VARCHAR},
		#{orgId,jdbcType=VARCHAR},
		#{orgLevel,jdbcType=INTEGER},
		#{orgName,jdbcType=VARCHAR},
		#{orgParentId,jdbcType=VARCHAR},
		#{orgPrincipal,jdbcType=VARCHAR},
		#{orgSort,jdbcType=INTEGER},
		#{orgStatus,jdbcType=VARCHAR},
		#{orgType,jdbcType=VARCHAR},
		#{orgWorkAddress,jdbcType=VARCHAR},
		#{orgWorkPhone,jdbcType=VARCHAR},
		#{remark,jdbcType=VARCHAR}
		)
	</insert>
	<update id="updateById">
        UPDATE T_PUB_ORG
        <set>
		  <if test="companyId!=null">COMPANY_ID=#{companyId,jdbcType=VARCHAR},</if>
		  <if test="companyName!=null">COMPANY_NAME=#{companyName,jdbcType=VARCHAR},</if>
		  <if test="deptId!=null">DEPT_ID=#{deptId,jdbcType=VARCHAR},</if>
		  <if test="deptName!=null">DEPT_NAME=#{deptName,jdbcType=VARCHAR},</if>
		  <if test="orgAreaType!=null">ORG_AREA_TYPE=#{orgAreaType,jdbcType=VARCHAR},</if>
		  <if test="orgBranchLeader!=null">ORG_BRANCH_LEADER=#{orgBranchLeader,jdbcType=VARCHAR},</if>
		  <if test="orgCreateTime!=null">ORG_CREATE_TIME=#{orgCreateTime,jdbcType=TIMESTAMP},</if>
		  <if test="orgFullName!=null">ORG_FULL_NAME=#{orgFullName,jdbcType=VARCHAR},</if>
		  <if test="orgFullPathId!=null">ORG_FULL_PATH_ID=#{orgFullPathId,jdbcType=VARCHAR},</if>
		  <if test="orgFullPathName!=null">ORG_FULL_PATH_NAME=#{orgFullPathName,jdbcType=VARCHAR},</if>
		  <if test="orgLevel!=null">ORG_LEVEL=#{orgLevel,jdbcType=INTEGER},</if>
		  <if test="orgName!=null">ORG_NAME=#{orgName,jdbcType=VARCHAR},</if>
		  <if test="orgParentId!=null">ORG_PARENT_ID=#{orgParentId,jdbcType=VARCHAR},</if>
		  <if test="orgPrincipal!=null">ORG_PRINCIPAL=#{orgPrincipal,jdbcType=VARCHAR},</if>
		  <if test="orgSort!=null">ORG_SORT=#{orgSort,jdbcType=INTEGER},</if>
		  <if test="orgStatus!=null">ORG_STATUS=#{orgStatus,jdbcType=VARCHAR},</if>
		  <if test="orgType!=null">ORG_TYPE=#{orgType,jdbcType=VARCHAR},</if>
		  <if test="orgWorkAddress!=null">ORG_WORK_ADDRESS=#{orgWorkAddress,jdbcType=VARCHAR},</if>
		  <if test="orgWorkPhone!=null">ORG_WORK_PHONE=#{orgWorkPhone,jdbcType=VARCHAR},</if>
		  <if test="remark!=null">REMARK=#{remark,jdbcType=VARCHAR}</if>
		</set>
		where ORG_ID = #{orgId,jdbcType=VARCHAR}
    </update>
    <delete id="deleteByOrgId"  parameterType="java.lang.String">
		DELETE FROM T_PUB_ORG WHERE ORG_ID= #{orgId,jdbcType=VARCHAR}
	</delete>
	<select id="findOrgByDeptId" resultMap="RM_OrgEntity">
     SELECT * FROM T_PUB_ORG WHERE DEPT_ID = #{deptId,jdbcType=VARCHAR}
    </select>
</mapper>

