添加User表的mybatis文件
This commit is contained in:
parent
bcf26cd8a9
commit
3723aa700f
76
src/main/java/generator/domain/User.java
Normal file
76
src/main/java/generator/domain/User.java
Normal file
@ -0,0 +1,76 @@
|
||||
package generator.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName user
|
||||
*/
|
||||
@TableName(value ="user")
|
||||
@Data
|
||||
public class User implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String password;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
User other = (User) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
|
||||
&& (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||
result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", name=").append(name);
|
||||
sb.append(", password=").append(password);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
18
src/main/java/generator/mapper/UserMapper.java
Normal file
18
src/main/java/generator/mapper/UserMapper.java
Normal file
@ -0,0 +1,18 @@
|
||||
package generator.mapper;
|
||||
|
||||
import generator.domain.User;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 2511
|
||||
* @description 针对表【user】的数据库操作Mapper
|
||||
* @createDate 2024-08-22 16:16:55
|
||||
* @Entity generator.domain.User
|
||||
*/
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
13
src/main/java/generator/service/UserService.java
Normal file
13
src/main/java/generator/service/UserService.java
Normal file
@ -0,0 +1,13 @@
|
||||
package generator.service;
|
||||
|
||||
import generator.domain.User;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 2511
|
||||
* @description 针对表【user】的数据库操作Service
|
||||
* @createDate 2024-08-22 16:16:55
|
||||
*/
|
||||
public interface UserService extends IService<User> {
|
||||
|
||||
}
|
22
src/main/java/generator/service/impl/UserServiceImpl.java
Normal file
22
src/main/java/generator/service/impl/UserServiceImpl.java
Normal file
@ -0,0 +1,22 @@
|
||||
package generator.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import generator.domain.User;
|
||||
import generator.service.UserService;
|
||||
import generator.mapper.UserMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 2511
|
||||
* @description 针对表【user】的数据库操作Service实现
|
||||
* @createDate 2024-08-22 16:16:55
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
||||
implements UserService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
16
src/main/resources/mapper/UserMapper.xml
Normal file
16
src/main/resources/mapper/UserMapper.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?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="generator.mapper.UserMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="generator.domain.User">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="password" column="password" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,name,password
|
||||
</sql>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user