<?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="cn.com.victorysoft.business.indicator.dao.UnitApproveThresholdDao">
  <resultMap id="BaseResultMap" type="cn.com.victorysoft.business.indicator.entity.UnitApproveThreshold">
    <result column="COMPANY_CODE" jdbcType="VARCHAR" property="companyCode" />
    <result column="COMPANY_NAME" jdbcType="VARCHAR" property="companyName" />
    <result column="THRESHOLD" jdbcType="DECIMAL" property="threshold" />
  </resultMap>

  <select id="selectList" resultMap="BaseResultMap">
    select iuat.COMPANY_CODE, iuat.THRESHOLD, su.unitname COMPANY_NAME
    from INDI_UNIT_APPROVE_THRESHOLD iuat, sys_unitinfo su
    where iuat.company_code = su.unitcode
  </select>

  <select id="selectByCompany" resultMap="BaseResultMap">
    select iuat.COMPANY_CODE, iuat.THRESHOLD, su.unitname COMPANY_NAME
    from INDI_UNIT_APPROVE_THRESHOLD iuat, sys_unitinfo su
    where iuat.company_code = su.unitcode
    and iuat.company_code = #{value}
  </select>

  <insert id="insert" parameterType="cn.com.victorysoft.business.indicator.entity.UnitApproveThreshold">
    insert into INDI_UNIT_APPROVE_THRESHOLD (COMPANY_CODE, THRESHOLD)
    values (#{companyCode,jdbcType=VARCHAR}, #{threshold,jdbcType=DECIMAL})
  </insert>

  <update id="update" parameterType="cn.com.victorysoft.business.indicator.entity.UnitApproveThreshold">
    update INDI_UNIT_APPROVE_THRESHOLD
    set THRESHOLD = #{threshold,jdbcType=DECIMAL}
    where COMPANY_CODE = #{companyCode,jdbcType=VARCHAR}
  </update>

  <insert id="insertSelective" parameterType="cn.com.victorysoft.business.indicator.entity.UnitApproveThreshold">
    insert into INDI_UNIT_APPROVE_THRESHOLD
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="companyCode != null">
        COMPANY_CODE,
      </if>
      <if test="threshold != null">
        THRESHOLD,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="companyCode != null">
        #{companyCode,jdbcType=VARCHAR},
      </if>
      <if test="threshold != null">
        #{threshold,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
</mapper>
