<?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.IndustryCategoryMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.IndustryCategory">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="pid" jdbcType="INTEGER" property="pid" />
    <result column="value" jdbcType="DECIMAL" property="value" />
  </resultMap>
  <sql id="Base_Column_List">
    id, name, pid, value
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from industry_category
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from industry_category
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.IndustryCategory">
    insert into industry_category (id, name, pid, 
      value)
    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{pid,jdbcType=INTEGER}, 
      #{value,jdbcType=DECIMAL})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.IndustryCategory">
    insert into industry_category
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="pid != null">
        pid,
      </if>
      <if test="value != null">
        value,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="pid != null">
        #{pid,jdbcType=INTEGER},
      </if>
      <if test="value != null">
        #{value,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.IndustryCategory">
    update industry_category
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="pid != null">
        pid = #{pid,jdbcType=INTEGER},
      </if>
      <if test="value != null">
        value = #{value,jdbcType=DECIMAL},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.IndustryCategory">
    update industry_category
    set name = #{name,jdbcType=VARCHAR},
      pid = #{pid,jdbcType=INTEGER},
      value = #{value,jdbcType=DECIMAL}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <select id="listByPid" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from industry_category
    where pid = #{pid,jdbcType=INTEGER}
  </select>
  <select id="selectindustryList" resultType="com.goafanti.common.bo.fieldGlossoryBo">
  	SELECT id, name, pid, `level`
	FROM aft.field_glossory
	WHERE level=1
  </select>
  
  <select id="selectDomainList" resultType="com.goafanti.common.bo.fieldGlossoryBo">
  	SELECT id,name,pid
	FROM aft.industry_category
	WHERE pid=0
  </select>
</mapper>