content: package com.allen.moments.v2.dao;
  
  import com.allen.moments.v2.model.User;
  import org.apache.ibatis.jdbc.SQL;
  
  public class UserSqlProvider {
  
      public String insertSelective(User record) {
          SQL sql = new SQL();
          sql.INSERT_INTO("user");
          
          if (record.getUid() == 0) {
              sql.VALUES("uid", "#{uid,jdbcType=INTEGER}");
          }
          
          if (record.getName() != null) {
              sql.VALUES("name", "#{name,jdbcType=VARCHAR}");
          }
          
          if (record.getAge() != null) {
              sql.VALUES("age", "#{age,jdbcType=INTEGER}");
          }
          
          if (record.getSex() != null) {
              sql.VALUES("sex", "#{sex,jdbcType=INTEGER}");
          }
          
          if (record.getPassword() != null) {
              sql.VALUES("password", "#{password,jdbcType=VARCHAR}");
          }
          
          return sql.toString();
      }
  
      public String updateByPrimaryKeySelective(User record) {
          SQL sql = new SQL();
          sql.UPDATE("user");
          
          if (record.getName() != null) {
              sql.SET("name = #{name,jdbcType=VARCHAR}");
          }
          
          if (record.getAge() != null) {
              sql.SET("age = #{age,jdbcType=INTEGER}");
          }
          
          if (record.getSex() != null) {
              sql.SET("sex = #{sex,jdbcType=INTEGER}");
          }
          
          if (record.getPassword() != null) {
              sql.SET("password = #{password,jdbcType=VARCHAR}");
          }
          
          sql.WHERE("uid = #{uid,jdbcType=INTEGER}");
          
          return sql.toString();
      }
  }