IM 即时通讯系统 SSO 系列-03-基于 mybatis 实现 CRUD
2024年11月2日小于 1 分钟
实现基本的 crud
pom.xml
org.mybatis.spring.boot
mybatis-spring-boot-starter
2.2.2
mysql
mysql-connector-java
8.0.33
com.github.pagehelper
pagehelper-spring-boot-starter
1.4.6
实体
- 公司
public class Company {
private Long id;
private String name;
private Date createTime;
private Date updateTime;
//...
}
- 部门
public class Department {
private Long id;
private Long companyId;
private String name;
private Date createTime;
private Date updateTime;
}
- 小组
public class Team {
private Long id;
private Long departmentId;
private String name;
private Date createTime;
private Date updateTime;
- 用户
public class User {
private Long id;
private Long teamId;
private String username;
private String password;
private Integer userType;
private Date createTime;
private Date updateTime;
mapper
实现 mapper 对应的 crud
service
实现 service 对应的 crud
controller
实现 controller 对应的 crud
配置文件
- application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/sso?useSSL=false&serverTimezone=UTC&characterEncoding=utf8
spring.datasource.username=admin
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
mybatis.mapper-locations=classpath:mapper/*.xml
mybatis.type-aliases-package=com.example.ssobackend.entity
参考资料
贡献者
binbin.hou