MyBatis Plus
参考官网:https://mp.baomidou.com/
quickly start:
Entity:
@TableName("user") public class User implements Serializable { /** 用户ID */ private Long id; /** 用户名 */ private String name; /** 用户年龄 */ private Integer age; @TableField(exist = false) private String state; }
Dao层:
/** * User 表数据库控制层接口 */ public interface UserMapper extends BaseMapper<User> { @Select("selectUserList") List<User> selectUserList(Pagination page,String state); }
配备的XML:
<?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="com.baomidou.springmvc.mapper.system.UserMapper"> <!-- 通用查询结果列--> <sql id="Base_Column_List"> id, name, age </sql> <select id="selectUserList" resultType="User"> SELECT * FROM sys_user WHERE state=#{state} </select> </mapper>
Service层:
/** * * User 表数据服务层接口实现类 * */ @Service public class UserService extends ServiceImpl<UserMapper, User>{ public Page<User> selectUserPage(Page<User> page, String state) { page.setRecords(baseMapper.selectUserList(page,state)); return page; } }
参考:https://www.cnblogs.com/fingerboy/p/6657118.html