<?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.goafanti.common.dao.OrganizationPropertiesMapper" >
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.OrganizationProperties" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="oid" property="oid" jdbcType="VARCHAR" />
    <result column="qualification" property="qualification" jdbcType="VARCHAR" />
    <result column="turnover" property="turnover" jdbcType="INTEGER" />
    <result column="college_attribute" property="collegeAttribute" jdbcType="VARCHAR" />
    <result column="college_establish_time" property="collegeEstablishTime" jdbcType="VARCHAR" />
    <result column="academician" property="academician" jdbcType="INTEGER" />
    <result column="doctoral_tutor" property="doctoralTutor" jdbcType="INTEGER" />
    <result column="master_tutor" property="masterTutor" jdbcType="INTEGER" />
    <result column="other_expert" property="otherExpert" jdbcType="INTEGER" />
    <result column="national_lab" property="nationalLab" jdbcType="INTEGER" />
    <result column="education_lab" property="educationLab" jdbcType="INTEGER" />
    <result column="enterprise_center" property="enterpriseCenter" jdbcType="INTEGER" />
    <result column="other_center" property="otherCenter" jdbcType="INTEGER" />
    <result column="institution_establish_time" property="institutionEstablishTime" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, oid, qualification, turnover, college_attribute, college_establish_time, academician, 
    doctoral_tutor, master_tutor, other_expert, national_lab, education_lab, enterprise_center, 
    other_center, institution_establish_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from organization_properties
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from organization_properties
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.OrganizationProperties" >
    insert into organization_properties (id, oid, qualification, 
      turnover, college_attribute, college_establish_time, 
      academician, doctoral_tutor, master_tutor, 
      other_expert, national_lab, education_lab, 
      enterprise_center, other_center, institution_establish_time
      )
    values (#{id,jdbcType=VARCHAR}, #{oid,jdbcType=VARCHAR}, #{qualification,jdbcType=VARCHAR}, 
      #{turnover,jdbcType=INTEGER}, #{collegeAttribute,jdbcType=VARCHAR}, #{collegeEstablishTime,jdbcType=VARCHAR}, 
      #{academician,jdbcType=INTEGER}, #{doctoralTutor,jdbcType=INTEGER}, #{masterTutor,jdbcType=INTEGER}, 
      #{otherExpert,jdbcType=INTEGER}, #{nationalLab,jdbcType=INTEGER}, #{educationLab,jdbcType=INTEGER}, 
      #{enterpriseCenter,jdbcType=INTEGER}, #{otherCenter,jdbcType=INTEGER}, #{institutionEstablishTime,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.OrganizationProperties" >
    insert into organization_properties
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="oid != null" >
        oid,
      </if>
      <if test="qualification != null" >
        qualification,
      </if>
      <if test="turnover != null" >
        turnover,
      </if>
      <if test="collegeAttribute != null" >
        college_attribute,
      </if>
      <if test="collegeEstablishTime != null" >
        college_establish_time,
      </if>
      <if test="academician != null" >
        academician,
      </if>
      <if test="doctoralTutor != null" >
        doctoral_tutor,
      </if>
      <if test="masterTutor != null" >
        master_tutor,
      </if>
      <if test="otherExpert != null" >
        other_expert,
      </if>
      <if test="nationalLab != null" >
        national_lab,
      </if>
      <if test="educationLab != null" >
        education_lab,
      </if>
      <if test="enterpriseCenter != null" >
        enterprise_center,
      </if>
      <if test="otherCenter != null" >
        other_center,
      </if>
      <if test="institutionEstablishTime != null" >
        institution_establish_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="oid != null" >
        #{oid,jdbcType=VARCHAR},
      </if>
      <if test="qualification != null" >
        #{qualification,jdbcType=VARCHAR},
      </if>
      <if test="turnover != null" >
        #{turnover,jdbcType=INTEGER},
      </if>
      <if test="collegeAttribute != null" >
        #{collegeAttribute,jdbcType=VARCHAR},
      </if>
      <if test="collegeEstablishTime != null" >
        #{collegeEstablishTime,jdbcType=VARCHAR},
      </if>
      <if test="academician != null" >
        #{academician,jdbcType=INTEGER},
      </if>
      <if test="doctoralTutor != null" >
        #{doctoralTutor,jdbcType=INTEGER},
      </if>
      <if test="masterTutor != null" >
        #{masterTutor,jdbcType=INTEGER},
      </if>
      <if test="otherExpert != null" >
        #{otherExpert,jdbcType=INTEGER},
      </if>
      <if test="nationalLab != null" >
        #{nationalLab,jdbcType=INTEGER},
      </if>
      <if test="educationLab != null" >
        #{educationLab,jdbcType=INTEGER},
      </if>
      <if test="enterpriseCenter != null" >
        #{enterpriseCenter,jdbcType=INTEGER},
      </if>
      <if test="otherCenter != null" >
        #{otherCenter,jdbcType=INTEGER},
      </if>
      <if test="institutionEstablishTime != null" >
        #{institutionEstablishTime,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.OrganizationProperties" >
    update organization_properties
    <set >
      <if test="oid != null" >
        oid = #{oid,jdbcType=VARCHAR},
      </if>
      <if test="qualification != null" >
        qualification = #{qualification,jdbcType=VARCHAR},
      </if>
      <if test="turnover != null" >
        turnover = #{turnover,jdbcType=INTEGER},
      </if>
      <if test="collegeAttribute != null" >
        college_attribute = #{collegeAttribute,jdbcType=VARCHAR},
      </if>
      <if test="collegeEstablishTime != null" >
        college_establish_time = #{collegeEstablishTime,jdbcType=VARCHAR},
      </if>
      <if test="academician != null" >
        academician = #{academician,jdbcType=INTEGER},
      </if>
      <if test="doctoralTutor != null" >
        doctoral_tutor = #{doctoralTutor,jdbcType=INTEGER},
      </if>
      <if test="masterTutor != null" >
        master_tutor = #{masterTutor,jdbcType=INTEGER},
      </if>
      <if test="otherExpert != null" >
        other_expert = #{otherExpert,jdbcType=INTEGER},
      </if>
      <if test="nationalLab != null" >
        national_lab = #{nationalLab,jdbcType=INTEGER},
      </if>
      <if test="educationLab != null" >
        education_lab = #{educationLab,jdbcType=INTEGER},
      </if>
      <if test="enterpriseCenter != null" >
        enterprise_center = #{enterpriseCenter,jdbcType=INTEGER},
      </if>
      <if test="otherCenter != null" >
        other_center = #{otherCenter,jdbcType=INTEGER},
      </if>
      <if test="institutionEstablishTime != null" >
        institution_establish_time = #{institutionEstablishTime,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.OrganizationProperties" >
    update organization_properties
    set oid = #{oid,jdbcType=VARCHAR},
      qualification = #{qualification,jdbcType=VARCHAR},
      turnover = #{turnover,jdbcType=INTEGER},
      college_attribute = #{collegeAttribute,jdbcType=VARCHAR},
      college_establish_time = #{collegeEstablishTime,jdbcType=VARCHAR},
      academician = #{academician,jdbcType=INTEGER},
      doctoral_tutor = #{doctoralTutor,jdbcType=INTEGER},
      master_tutor = #{masterTutor,jdbcType=INTEGER},
      other_expert = #{otherExpert,jdbcType=INTEGER},
      national_lab = #{nationalLab,jdbcType=INTEGER},
      education_lab = #{educationLab,jdbcType=INTEGER},
      enterprise_center = #{enterpriseCenter,jdbcType=INTEGER},
      other_center = #{otherCenter,jdbcType=INTEGER},
      institution_establish_time = #{institutionEstablishTime,jdbcType=VARCHAR}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  
  
  <select id="selectOrgProByUserId" parameterType="java.lang.String" resultMap="BaseResultMap">
    select 
    	op.id, 
    	op.oid, 
    	op.qualification, 
    	op.turnover, 
    	op.college_attribute, 
    	op.college_establish_time, 
    	op.academician, 
        op.doctoral_tutor, 
        op.master_tutor, 
        op.other_expert, 
        op.national_lab, 
        op.education_lab, 
        op.enterprise_center, 
        op.other_center, 
        op.institution_establish_time
	from user u
	LEFT JOIN organization_info oi on oi.uid = u.id
	LEFT JOIN organization_properties op on op.oid = oi.id
	where u.id = #{uid,jdbcType=VARCHAR}
  </select>
  
  <select id="findByOid" parameterType="java.lang.String" resultMap="BaseResultMap">
  	 select 
    <include refid="Base_Column_List" />
    from organization_properties
    where oid = #{oid,jdbcType=VARCHAR}
  </select>
 
</mapper>