1、如何使用BaseMapper进行数据库的操作。
2、使用BaseMapper进行插入实体时如何让UUID的主键自动生成。
Student实体类,其中id属性主键为UUID
package com.huixiaoer.ant.api.model.bean;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
public class Student {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column student.id
*
* @mbg.generated Thu Oct 31 14:09:39 CST 2019
*/
@TableId(type= IdType.UUID)
private String id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column student.user_name
*
* @mbg.generated Thu Oct 31 14:09:39 CST 2019
*/
private String userName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column student.age
*
* @mbg.generated Thu Oct 31 14:09:39 CST 2019
*/
private Integer age;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column student.phone
*
* @mbg.generated Thu Oct 31 14:09:39 CST 2019
*/
private String phone;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table student
*
* @mbg.generated Thu Oct 31 14:09:39 CST 2019
*/
public Student(String id, String userName, Integer age, String phone) {
this.id = id;
this.userName = userName;
this.age = age;
this.phone = phone;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table student
*
* @mbg.generated Thu Oct 31 14:09:39 CST 2019
*/
public Student() {
super();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column student.id
*
* @return the value of student.id
*
* @mbg.generated Thu Oct 31 14:09:39 CST 2019
*/
public String getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column student.id
*
* @param id the value for student.id
*
* @mbg.generated Thu Oct 31 14:09:39 CST 2019
*/
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column student.user_name
*
* @return the value of student.user_name
*
* @mbg.generated Thu Oct 31 14:09:39 CST 2019
*/
public String getUserName() {