<?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.lightinit.hsdataportal.mapper.RequirementApiMapper">
  <resultMap id="BaseResultMap" type="com.lightinit.hsdataportal.entity.RequirementApi">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="system_name" jdbcType="VARCHAR" property="systemName" />
    <result column="system_type" jdbcType="VARCHAR" property="systemType" />
    <result column="belong_to" jdbcType="VARCHAR" property="belongTo" />
    <result column="has_ownership" jdbcType="TINYINT" property="hasOwnership" />
    <result column="network_type" jdbcType="VARCHAR" property="networkType" />
    <result column="dev_language" jdbcType="VARCHAR" property="devLanguage" />
    <result column="interface_count" jdbcType="INTEGER" property="interfaceCount" />
    <result column="deadline" jdbcType="TIMESTAMP" property="deadline" />
    <result column="rqrmnt_user" jdbcType="VARCHAR" property="rqrmntUser" />
    <result column="contact1" jdbcType="VARCHAR" property="contact1" />
    <result column="phone1" jdbcType="VARCHAR" property="phone1" />
    <result column="contact2" jdbcType="VARCHAR" property="contact2" />
    <result column="phone2" jdbcType="VARCHAR" property="phone2" />
    <result column="need_platform_support" jdbcType="VARCHAR" property="needPlatformSupport" />
    <result column="category_id" jdbcType="BIGINT" property="categoryId" />
    <result column="expected_quote" jdbcType="DECIMAL" property="expectedQuote" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="deleted_at" jdbcType="TIMESTAMP" property="deletedAt" />
    <result column="deleted_by" jdbcType="BIGINT" property="deletedBy" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.lightinit.hsdataportal.entity.RequirementApiWithBLOBs">
    <result column="system_desc" jdbcType="LONGVARCHAR" property="systemDesc" />
    <result column="url" jdbcType="LONGVARCHAR" property="url" />
    <result column="attachment" jdbcType="LONGVARCHAR" property="attachment" />
    <result column="description" jdbcType="LONGVARCHAR" property="description" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, system_name, system_type, belong_to, has_ownership, network_type, dev_language, 
    interface_count, deadline, rqrmnt_user, contact1, phone1, contact2, phone2, need_platform_support, 
    category_id, expected_quote, created_at, created_by, deleted_at, deleted_by
  </sql>
  <sql id="Blob_Column_List">
    system_desc, url, attachment, description
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="com.lightinit.hsdataportal.entity.RequirementApiExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from requirement_api
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExample" parameterType="com.lightinit.hsdataportal.entity.RequirementApiExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from requirement_api
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from requirement_api
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from requirement_api
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.lightinit.hsdataportal.entity.RequirementApiExample">
    delete from requirement_api
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.lightinit.hsdataportal.entity.RequirementApiWithBLOBs">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into requirement_api (id,system_name, system_type, belong_to,
      has_ownership, network_type, dev_language, 
      interface_count, deadline, rqrmnt_user, 
      contact1, phone1, contact2, 
      phone2, need_platform_support, category_id, 
      expected_quote, created_at, created_by, 
      deleted_at, deleted_by, system_desc, 
      url, attachment, description
      )
    values (#{id},#{systemName,jdbcType=VARCHAR}, #{systemType,jdbcType=VARCHAR}, #{belongTo,jdbcType=VARCHAR},
      #{hasOwnership,jdbcType=TINYINT}, #{networkType,jdbcType=VARCHAR}, #{devLanguage,jdbcType=VARCHAR}, 
      #{interfaceCount,jdbcType=INTEGER}, #{deadline,jdbcType=TIMESTAMP}, #{rqrmntUser,jdbcType=VARCHAR}, 
      #{contact1,jdbcType=VARCHAR}, #{phone1,jdbcType=VARCHAR}, #{contact2,jdbcType=VARCHAR}, 
      #{phone2,jdbcType=VARCHAR}, #{needPlatformSupport,jdbcType=VARCHAR}, #{categoryId,jdbcType=BIGINT}, 
      #{expectedQuote,jdbcType=DECIMAL}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, 
      #{deletedAt,jdbcType=TIMESTAMP}, #{deletedBy,jdbcType=BIGINT}, #{systemDesc,jdbcType=LONGVARCHAR}, 
      #{url,jdbcType=LONGVARCHAR}, #{attachment,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.lightinit.hsdataportal.entity.RequirementApiWithBLOBs">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into requirement_api
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="systemName != null">
        system_name,
      </if>
      <if test="systemType != null">
        system_type,
      </if>
      <if test="belongTo != null">
        belong_to,
      </if>
      <if test="hasOwnership != null">
        has_ownership,
      </if>
      <if test="networkType != null">
        network_type,
      </if>
      <if test="devLanguage != null">
        dev_language,
      </if>
      <if test="interfaceCount != null">
        interface_count,
      </if>
      <if test="deadline != null">
        deadline,
      </if>
      <if test="rqrmntUser != null">
        rqrmnt_user,
      </if>
      <if test="contact1 != null">
        contact1,
      </if>
      <if test="phone1 != null">
        phone1,
      </if>
      <if test="contact2 != null">
        contact2,
      </if>
      <if test="phone2 != null">
        phone2,
      </if>
      <if test="needPlatformSupport != null">
        need_platform_support,
      </if>
      <if test="categoryId != null">
        category_id,
      </if>
      <if test="expectedQuote != null">
        expected_quote,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="deletedAt != null">
        deleted_at,
      </if>
      <if test="deletedBy != null">
        deleted_by,
      </if>
      <if test="systemDesc != null">
        system_desc,
      </if>
      <if test="url != null">
        url,
      </if>
      <if test="attachment != null">
        attachment,
      </if>
      <if test="description != null">
        description,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="systemName != null">
        #{systemName,jdbcType=VARCHAR},
      </if>
      <if test="systemType != null">
        #{systemType,jdbcType=VARCHAR},
      </if>
      <if test="belongTo != null">
        #{belongTo,jdbcType=VARCHAR},
      </if>
      <if test="hasOwnership != null">
        #{hasOwnership,jdbcType=TINYINT},
      </if>
      <if test="networkType != null">
        #{networkType,jdbcType=VARCHAR},
      </if>
      <if test="devLanguage != null">
        #{devLanguage,jdbcType=VARCHAR},
      </if>
      <if test="interfaceCount != null">
        #{interfaceCount,jdbcType=INTEGER},
      </if>
      <if test="deadline != null">
        #{deadline,jdbcType=TIMESTAMP},
      </if>
      <if test="rqrmntUser != null">
        #{rqrmntUser,jdbcType=VARCHAR},
      </if>
      <if test="contact1 != null">
        #{contact1,jdbcType=VARCHAR},
      </if>
      <if test="phone1 != null">
        #{phone1,jdbcType=VARCHAR},
      </if>
      <if test="contact2 != null">
        #{contact2,jdbcType=VARCHAR},
      </if>
      <if test="phone2 != null">
        #{phone2,jdbcType=VARCHAR},
      </if>
      <if test="needPlatformSupport != null">
        #{needPlatformSupport,jdbcType=VARCHAR},
      </if>
      <if test="categoryId != null">
        #{categoryId,jdbcType=BIGINT},
      </if>
      <if test="expectedQuote != null">
        #{expectedQuote,jdbcType=DECIMAL},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="deletedAt != null">
        #{deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deletedBy != null">
        #{deletedBy,jdbcType=BIGINT},
      </if>
      <if test="systemDesc != null">
        #{systemDesc,jdbcType=LONGVARCHAR},
      </if>
      <if test="url != null">
        #{url,jdbcType=LONGVARCHAR},
      </if>
      <if test="attachment != null">
        #{attachment,jdbcType=LONGVARCHAR},
      </if>
      <if test="description != null">
        #{description,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.lightinit.hsdataportal.entity.RequirementApiExample" resultType="java.lang.Long">
    select count(*) from requirement_api
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update requirement_api
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.systemName != null">
        system_name = #{record.systemName,jdbcType=VARCHAR},
      </if>
      <if test="record.systemType != null">
        system_type = #{record.systemType,jdbcType=VARCHAR},
      </if>
      <if test="record.belongTo != null">
        belong_to = #{record.belongTo,jdbcType=VARCHAR},
      </if>
      <if test="record.hasOwnership != null">
        has_ownership = #{record.hasOwnership,jdbcType=TINYINT},
      </if>
      <if test="record.networkType != null">
        network_type = #{record.networkType,jdbcType=VARCHAR},
      </if>
      <if test="record.devLanguage != null">
        dev_language = #{record.devLanguage,jdbcType=VARCHAR},
      </if>
      <if test="record.interfaceCount != null">
        interface_count = #{record.interfaceCount,jdbcType=INTEGER},
      </if>
      <if test="record.deadline != null">
        deadline = #{record.deadline,jdbcType=TIMESTAMP},
      </if>
      <if test="record.rqrmntUser != null">
        rqrmnt_user = #{record.rqrmntUser,jdbcType=VARCHAR},
      </if>
      <if test="record.contact1 != null">
        contact1 = #{record.contact1,jdbcType=VARCHAR},
      </if>
      <if test="record.phone1 != null">
        phone1 = #{record.phone1,jdbcType=VARCHAR},
      </if>
      <if test="record.contact2 != null">
        contact2 = #{record.contact2,jdbcType=VARCHAR},
      </if>
      <if test="record.phone2 != null">
        phone2 = #{record.phone2,jdbcType=VARCHAR},
      </if>
      <if test="record.needPlatformSupport != null">
        need_platform_support = #{record.needPlatformSupport,jdbcType=VARCHAR},
      </if>
      <if test="record.categoryId != null">
        category_id = #{record.categoryId,jdbcType=BIGINT},
      </if>
      <if test="record.expectedQuote != null">
        expected_quote = #{record.expectedQuote,jdbcType=DECIMAL},
      </if>
      <if test="record.createdAt != null">
        created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=BIGINT},
      </if>
      <if test="record.deletedAt != null">
        deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.deletedBy != null">
        deleted_by = #{record.deletedBy,jdbcType=BIGINT},
      </if>
      <if test="record.systemDesc != null">
        system_desc = #{record.systemDesc,jdbcType=LONGVARCHAR},
      </if>
      <if test="record.url != null">
        url = #{record.url,jdbcType=LONGVARCHAR},
      </if>
      <if test="record.attachment != null">
        attachment = #{record.attachment,jdbcType=LONGVARCHAR},
      </if>
      <if test="record.description != null">
        description = #{record.description,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    update requirement_api
    set id = #{record.id,jdbcType=BIGINT},
      system_name = #{record.systemName,jdbcType=VARCHAR},
      system_type = #{record.systemType,jdbcType=VARCHAR},
      belong_to = #{record.belongTo,jdbcType=VARCHAR},
      has_ownership = #{record.hasOwnership,jdbcType=TINYINT},
      network_type = #{record.networkType,jdbcType=VARCHAR},
      dev_language = #{record.devLanguage,jdbcType=VARCHAR},
      interface_count = #{record.interfaceCount,jdbcType=INTEGER},
      deadline = #{record.deadline,jdbcType=TIMESTAMP},
      rqrmnt_user = #{record.rqrmntUser,jdbcType=VARCHAR},
      contact1 = #{record.contact1,jdbcType=VARCHAR},
      phone1 = #{record.phone1,jdbcType=VARCHAR},
      contact2 = #{record.contact2,jdbcType=VARCHAR},
      phone2 = #{record.phone2,jdbcType=VARCHAR},
      need_platform_support = #{record.needPlatformSupport,jdbcType=VARCHAR},
      category_id = #{record.categoryId,jdbcType=BIGINT},
      expected_quote = #{record.expectedQuote,jdbcType=DECIMAL},
      created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=BIGINT},
      deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{record.deletedBy,jdbcType=BIGINT},
      system_desc = #{record.systemDesc,jdbcType=LONGVARCHAR},
      url = #{record.url,jdbcType=LONGVARCHAR},
      attachment = #{record.attachment,jdbcType=LONGVARCHAR},
      description = #{record.description,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update requirement_api
    set id = #{record.id,jdbcType=BIGINT},
      system_name = #{record.systemName,jdbcType=VARCHAR},
      system_type = #{record.systemType,jdbcType=VARCHAR},
      belong_to = #{record.belongTo,jdbcType=VARCHAR},
      has_ownership = #{record.hasOwnership,jdbcType=TINYINT},
      network_type = #{record.networkType,jdbcType=VARCHAR},
      dev_language = #{record.devLanguage,jdbcType=VARCHAR},
      interface_count = #{record.interfaceCount,jdbcType=INTEGER},
      deadline = #{record.deadline,jdbcType=TIMESTAMP},
      rqrmnt_user = #{record.rqrmntUser,jdbcType=VARCHAR},
      contact1 = #{record.contact1,jdbcType=VARCHAR},
      phone1 = #{record.phone1,jdbcType=VARCHAR},
      contact2 = #{record.contact2,jdbcType=VARCHAR},
      phone2 = #{record.phone2,jdbcType=VARCHAR},
      need_platform_support = #{record.needPlatformSupport,jdbcType=VARCHAR},
      category_id = #{record.categoryId,jdbcType=BIGINT},
      expected_quote = #{record.expectedQuote,jdbcType=DECIMAL},
      created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=BIGINT},
      deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{record.deletedBy,jdbcType=BIGINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.lightinit.hsdataportal.entity.RequirementApiWithBLOBs">
    update requirement_api
    <set>
      <if test="systemName != null">
        system_name = #{systemName,jdbcType=VARCHAR},
      </if>
      <if test="systemType != null">
        system_type = #{systemType,jdbcType=VARCHAR},
      </if>
      <if test="belongTo != null">
        belong_to = #{belongTo,jdbcType=VARCHAR},
      </if>
      <if test="hasOwnership != null">
        has_ownership = #{hasOwnership,jdbcType=TINYINT},
      </if>
      <if test="networkType != null">
        network_type = #{networkType,jdbcType=VARCHAR},
      </if>
      <if test="devLanguage != null">
        dev_language = #{devLanguage,jdbcType=VARCHAR},
      </if>
      <if test="interfaceCount != null">
        interface_count = #{interfaceCount,jdbcType=INTEGER},
      </if>
      <if test="deadline != null">
        deadline = #{deadline,jdbcType=TIMESTAMP},
      </if>
      <if test="rqrmntUser != null">
        rqrmnt_user = #{rqrmntUser,jdbcType=VARCHAR},
      </if>
      <if test="contact1 != null">
        contact1 = #{contact1,jdbcType=VARCHAR},
      </if>
      <if test="phone1 != null">
        phone1 = #{phone1,jdbcType=VARCHAR},
      </if>
      <if test="contact2 != null">
        contact2 = #{contact2,jdbcType=VARCHAR},
      </if>
      <if test="phone2 != null">
        phone2 = #{phone2,jdbcType=VARCHAR},
      </if>
      <if test="needPlatformSupport != null">
        need_platform_support = #{needPlatformSupport,jdbcType=VARCHAR},
      </if>
      <if test="categoryId != null">
        category_id = #{categoryId,jdbcType=BIGINT},
      </if>
      <if test="expectedQuote != null">
        expected_quote = #{expectedQuote,jdbcType=DECIMAL},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="deletedAt != null">
        deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deletedBy != null">
        deleted_by = #{deletedBy,jdbcType=BIGINT},
      </if>
      <if test="systemDesc != null">
        system_desc = #{systemDesc,jdbcType=LONGVARCHAR},
      </if>
      <if test="url != null">
        url = #{url,jdbcType=LONGVARCHAR},
      </if>
      <if test="attachment != null">
        attachment = #{attachment,jdbcType=LONGVARCHAR},
      </if>
      <if test="description != null">
        description = #{description,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.lightinit.hsdataportal.entity.RequirementApiWithBLOBs">
    update requirement_api
    set system_name = #{systemName,jdbcType=VARCHAR},
      system_type = #{systemType,jdbcType=VARCHAR},
      belong_to = #{belongTo,jdbcType=VARCHAR},
      has_ownership = #{hasOwnership,jdbcType=TINYINT},
      network_type = #{networkType,jdbcType=VARCHAR},
      dev_language = #{devLanguage,jdbcType=VARCHAR},
      interface_count = #{interfaceCount,jdbcType=INTEGER},
      deadline = #{deadline,jdbcType=TIMESTAMP},
      rqrmnt_user = #{rqrmntUser,jdbcType=VARCHAR},
      contact1 = #{contact1,jdbcType=VARCHAR},
      phone1 = #{phone1,jdbcType=VARCHAR},
      contact2 = #{contact2,jdbcType=VARCHAR},
      phone2 = #{phone2,jdbcType=VARCHAR},
      need_platform_support = #{needPlatformSupport,jdbcType=VARCHAR},
      category_id = #{categoryId,jdbcType=BIGINT},
      expected_quote = #{expectedQuote,jdbcType=DECIMAL},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{deletedBy,jdbcType=BIGINT},
      system_desc = #{systemDesc,jdbcType=LONGVARCHAR},
      url = #{url,jdbcType=LONGVARCHAR},
      attachment = #{attachment,jdbcType=LONGVARCHAR},
      description = #{description,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.lightinit.hsdataportal.entity.RequirementApi">
    update requirement_api
    set system_name = #{systemName,jdbcType=VARCHAR},
      system_type = #{systemType,jdbcType=VARCHAR},
      belong_to = #{belongTo,jdbcType=VARCHAR},
      has_ownership = #{hasOwnership,jdbcType=TINYINT},
      network_type = #{networkType,jdbcType=VARCHAR},
      dev_language = #{devLanguage,jdbcType=VARCHAR},
      interface_count = #{interfaceCount,jdbcType=INTEGER},
      deadline = #{deadline,jdbcType=TIMESTAMP},
      rqrmnt_user = #{rqrmntUser,jdbcType=VARCHAR},
      contact1 = #{contact1,jdbcType=VARCHAR},
      phone1 = #{phone1,jdbcType=VARCHAR},
      contact2 = #{contact2,jdbcType=VARCHAR},
      phone2 = #{phone2,jdbcType=VARCHAR},
      need_platform_support = #{needPlatformSupport,jdbcType=VARCHAR},
      category_id = #{categoryId,jdbcType=BIGINT},
      expected_quote = #{expectedQuote,jdbcType=DECIMAL},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{deletedBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>

  <select id="queryOpenList" parameterType="com.lightinit.hsdataportal.model.APIDemandOpenSearchModel" resultType="com.lightinit.hsdataportal.model.APIDemandOpenListModel">
    <if test="rqrmntName != null and rqrmntName.length() > 0">
      <bind name="rqrmntName" value="'%' + _parameter.rqrmntName + '%'" />
    </if>
    SELECT r.id,r.rqrmnt_name,r.rqrmnt_summary,r.rqrmnt_state,r.publish_at,ra.deadline,r.view_times,
    (SELECT count(*) FROM requirement_follow rf WHERE rf.rqrmnt_id = r.id AND rf.platform_type=#{platformType}) followCount
    FROM requirement r
    JOIN requirement_api ra
    ON r.id = ra.id
    <where>
      r.platform_type = #{platformType}
      AND r.rqrmnt_state = #{rqrmntState}
      <if test="requirementDateFrom != null">
       AND r.publish_at >= #{requirementDateFrom}
      </if>
      <if test="requirementDateTo != null">
        AND  #{requirementDateTo} >= r.publish_at
      </if>
      <if test="rqrmntName != null and rqrmntName.length() > 0">
        AND r.rqrmnt_name like #{rqrmntName}
      </if>
    </where>
    <if test="flag !=null">
      <choose>
        <when test="flag==0">
          ORDER BY r.publish_at DESC
        </when>
        <when test="flag==1">
          ORDER BY r.view_times DESC
        </when>
        <when test="flag==2">
--           ORDER BY follow_times DESC
            ORDER BY r.publish_at DESC
        </when>
      </choose>
    </if>
    <if test="page != null" >
      LIMIT #{page.beginIndex},#{page.pageSize}
    </if>
  </select>

  <select id="queryOpenCount" parameterType="com.lightinit.hsdataportal.model.APIDemandOpenSearchModel" resultType="java.lang.Long">
    <if test="rqrmntName != null and rqrmntName.length() > 0">
      <bind name="rqrmntName" value="'%' + _parameter.rqrmntName + '%'" />
    </if>
    SELECT count(*)
    FROM requirement r
    JOIN requirement_api ra
    ON r.id = ra.id
    <where>
      r.platform_type = #{platformType}
      AND r.rqrmnt_state = #{rqrmntState}
      <if test="requirementDateFrom != null">
        r.publish_at >= #{requirementDateFrom}
      </if>
      <if test="requirementDateTo != null">
        AND  #{provider} >= #{requirementDateTo}
      </if>
      <if test="rqrmntName != null and rqrmntName.length() > 0">
        AND r.rqrmnt_name like #{rqrmntName}
      </if>
    </where>
  </select>

  <select id="queryView" resultType="com.lightinit.hsdataportal.model.APIDemandOpenViewModel" parameterType="java.lang.Long">
    SELECT ra.contact1,ra.phone1,ra.contact2,ra.phone2,need_platform_support,r.rqrmnt_name,r.id,r.view_times,
    ra.category_id,ra.expected_quote,ra.interface_count,r.rqrmnt_summary,ra.rqrmnt_user,
    ra.attachment,ra.system_desc,ra.system_type,ra.dev_language,ra.belong_to,ra.has_ownership,
    ra.url,ra.network_type,ra.description
    FROM requirement r
    JOIN requirement_api ra
    ON r.id = ra.id
    WHERE r.id = #{id}
  </select>
  <select id="selectReceiveList" parameterType="java.lang.Long"  resultType="com.lightinit.hsdataportal.model.APIReceiveListModel">
      SELECT
       u.`username`,rr.`phone`,rr.`received_at`,rr.solution
       FROM
        `requirement` r
       JOIN `requirement_api` rm ON r.id = rm.`id`
       JOIN `requirement_receive` rr ON r.id = rr.`rqrmnt_id`
       JOIN USER u ON rr.`received_by` = u.id
        <where>
          r.id = #{id}
        </where>
  </select>
</mapper>