<?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="org.xyzh.system.mapper.UserInfoMapper">
  <resultMap id="BaseResultMap" type="TbSysUserInfo">
    <id column="id" property="id" />
    <result column="user_id" property="userID" />
    <result column="avatar" property="avatar" />
    <result column="gender" property="gender" />
    <result column="family_name" property="familyName" />
    <result column="given_name" property="givenName" />
    <result column="full_name" property="fullName" />
    <result column="level" property="level" />
    <result column="id_card" property="idCard" />
    <result column="address" property="address" />
    <result column="create_time" property="createTime" />
    <result column="update_time" property="updateTime" />
    <result column="delete_time" property="deleteTime" />
    <result column="deleted" property="deleted" />
  </resultMap>

  <sql id="Base_Column_List">
    id, user_id, avatar, gender, family_name, given_name, full_name, level, id_card, address, create_time, update_time, delete_time, deleted
  </sql>
  <!-- insertUserInfo --> 

  <insert id="insertUserInfo">
    INSERT INTO tb_sys_user_info (id, user_id, avatar, create_time)
    VALUES (#{userInfo.id}, #{userInfo.userID}, #{userInfo.avatar}, #{userInfo.createTime})
  </insert>

  <!-- updateUserInfo --> 

  <update id="updateUserInfo">
    UPDATE tb_sys_user_info
    <set>
      <if test="userInfo.avatar != null">avatar = #{userInfo.avatar},</if>
      <if test="userInfo.gender != null">gender = #{userInfo.gender},</if>
      <if test="userInfo.familyName != null">family_name = #{userInfo.familyName},</if>
      <if test="userInfo.givenName != null">given_name = #{userInfo.givenName},</if>
      <if test="userInfo.fullName != null">full_name = #{userInfo.fullName},</if>
      <if test="userInfo.level != null">level = #{userInfo.level},</if>
      <if test="userInfo.idCard != null">id_card = #{userInfo.idCard},</if>
      <if test="userInfo.address != null">address = #{userInfo.address},</if>
      <if test="userInfo.updater != null">updater = #{userInfo.updater},</if>
      <if test="userInfo.updateTime != null">update_time = #{userInfo.updateTime},</if>
    </set>
    WHERE user_id = #{userInfo.userID}
  </update>

  <delete id="deleteUserInfo">
    DELETE FROM tb_sys_user_info
    WHERE user_id = #{userID}
  </delete>
</mapper>