<?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.mca.cmmn.mapper.UserCertificationMapper">

  <insert id="insertCertificationNum" parameterType="userCertificationVO">
    insert into user_certification values(
      #{userid}, #{certification_num}, #{expiration_date}, 'ready'
    )ON DUPLICATE KEY UPDATE
      certification_num = #{certification_num},
      expiration_date = #{expiration_date},
      status = 'ready';
  </insert>
  <select id="selectCertificationInfo" parameterType="userCertificationVO" resultType="userCertificationVO">
    select *
    from user_certification
    <where>
      <if test='userid != null and userid != ""'>
        and userid = #{userid}
      </if>
      <if test='certification_num != null and certification_num != ""'>
        and certification_num = #{certification_num}
      </if>
    </where>
  </select>
  <update id="updateCertificationNumStatus" parameterType="userCertificationVO">
    update user_certification
    set status = #{status}
    where userid = #{userid}
  </update>
</mapper>