ZhimaCertMapper.xml 3.57 KB
<?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.yoho.order.dal.ZhimaCertMapper" >
  <resultMap id="BaseResultMap" type="com.yoho.order.model.ZhimaCert" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="uid" property="uid" jdbcType="INTEGER" />
    <result column="valid_status" property="validStatus" jdbcType="TINYINT" />
    <result column="cert_name" property="certName" jdbcType="VARCHAR" />
    <result column="cert_no" property="certNo" jdbcType="VARCHAR" />
    <result column="biz_no" property="bizNo" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="INTEGER" />
    <result column="update_time" property="updateTime" jdbcType="INTEGER" />
    <result column="valid_photo" property="validPhoto" jdbcType="TINYINT" />
    <result column="image_url" property="imageUrl" jdbcType="VARCHAR" />
    <result column="invest_name" property="investName" jdbcType="VARCHAR" />
    <result column="entry_type" property="entryType" jdbcType="INTEGER" />
    <result column="enter_time" property="enterTime" jdbcType="INTEGER" />
    <result column="quit_time" property="quitTime" jdbcType="INTEGER" />
    <result column="s_create_time" property="sCreateTime" jdbcType="INTEGER" />
    <result column="s_valid_status" property="sValidStatus" jdbcType="TINYINT" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, uid, valid_status, cert_name, cert_no, biz_no, create_time, update_time, valid_photo, 
    image_url, invest_name
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select
    <include refid="Base_Column_List" />
    from zhima_cert
    where id = #{id,jdbcType=INTEGER}
  </select>

  <select id="selectCountByCondition" resultType="java.lang.Integer" >
    select count(1)
    from zhima_cert z left join ufo_order.stored_seller s
    on z.uid = s.uid
    where z.valid_status = 1
    <include refid="Query_Condition_Sql" />
  </select>

  <select id="selectByConditionPage" resultMap="BaseResultMap">
    select z.uid,z.cert_name,s.entry_type,z.cert_no,z.image_url,z.invest_name,s.enter_time,s.quit_time,s.create_time s_create_time,
    s.valid_status s_valid_status
    from zhima_cert z left join ufo_order.stored_seller s
    on z.uid = s.uid
    where z.valid_status = 1
    <include refid="Query_Condition_Sql" />
    order by z.id desc
    limit #{sellerReqBO.start},#{sellerReqBO.size}
  </select>

  <sql id="Query_Condition_Sql" >

    <if test="sellerReqBO.uid != null">
      and z.uid =  #{sellerReqBO.uid}
    </if>

    <if test="sellerReqBO.certName != null">
      and z.cert_name =  #{sellerReqBO.certName}
    </if>

    <if test="sellerReqBO.validStatus != null and sellerReqBO.validStatus != 0">
      and s.valid_status =  #{sellerReqBO.validStatus}
    </if>
    <if test="sellerReqBO.sellerType != null and sellerReqBO.sellerType != 0 and sellerReqBO.sellerType != 4">
      and s.entry_type =  #{sellerReqBO.sellerType} and s.valid_status = 1
    </if>
    <if test="sellerReqBO.sellerType != null  and sellerReqBO.sellerType == 4">
      and (s.entry_type = null or s.entry_type = '' or s.entry_type is null or s.valid_status = 9)
    </if>
    <if test="sellerReqBO.investName != null">
      and z.invest_name LIKE '%${sellerReqBO.investName}%'
    </if>
  </sql>

  <update id="updateInvestNameByUid">
    update zhima_cert
    set invest_name = #{investName,jdbcType=VARCHAR}
    where valid_status = 1 and uid = #{uid,jdbcType=INTEGER}
  </update>


</mapper>