<?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">
<!--mybatis-3-mapper.dtd:约束文件的名称，限制和检查在当前文件中出现的标签和属性符合mybatis的要求-->
<!--namespace：命名空间，要有唯一的值，要求使用dao接口的权限定名称（一个dao接口对应一个mapper，namespace指明对应哪个dao接口）-->
<mapper namespace="com.ruoyi.test.mapper.UserMapper">
    <!-- 所有的数据库操作都要写在mapper标签中，可以使用特定的标签表示数据库中的特定操作 -->

 <insert id="insertUser" parameterType="User">
  insert into user(
--   <if test="userId != null and userId != ''">user_id,</if>
  <if test="name != null and name != ''">name,</if>
  <if test="tname != null and tname != ''">tname,</if>
  <if test="age != null and age != 0">age,</if>
  <if test="sex != null and sex != ''">sex,</if>
  <if test="birthday != null and birthday != ''">birthday,</if>
  <if test="telephone != null and telephone != ''">telephone,</if>
  <if test="grade != null and grade != ''">grade,</if>
  <if test="state != null">state,</if>
  <if test="roleKey != null and roleKey != ''">role_key,</if>
   <if test="zhId != null and zhId != ''">zh_id</if>,
    createtime
  ) values (
--   <if test="userId != null and userId != ''">#{userId},</if>
  <if test="name != null and name != ''">#{name},</if>
  <if test="tname != null and tname != ''">#{tname},</if>
  <if test="age != null and age != 0">#{age},</if>
  <if test="sex != null and sex != ''">#{sex},</if>
  <if test="birthday != null and birthday != ''">#{birthday},</if>
  <if test="telephone != null and telephone != ''">#{telephone},</if>
  <if test="grade != null and grade != ''">#{grade},</if>
  <if test="state != null">#{state},</if>
  <if test="roleKey != null and roleKey != ''">#{roleKey},</if>
   <if test="zhId != null and zhId != ''">#{zhId}</if>,
     NOW() -- 或者使用数据库的当前时间函数
  )
 </insert>
</mapper>
