微人事
这仅仅只是微人事的后端,因为我不会做前段,所以只做了后端接口。
我的微人事采用的是Springboot框架+JPA,用postman进行测试。
很多人都是用mybaties,但我更喜欢用JPA。
项目原链接: https://github.com/lenve/VBlog.
基本配置
yml配置
spring:
datasource:
url: jdbc:mysql://localhost:3306/vhr?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
server:
port: 8082
jpa:
hibernate:
ddl-auto: update
show-sql: true
main:
allow-bean-definition-overriding: true
- 我用的是德鲁伊连接池,记得加上时区
信息提醒类
整个后端提示都是调用这个类
public class RespBean {
private Integer status;
private String msg;
private Object obj;
public static RespBean build() {
return new RespBean();
}
public static RespBean ok(String msg) {
return new RespBean(200, msg, null);
}
public static RespBean ok(String msg, Object obj) {
return new RespBean(200, msg, obj);
}
public static RespBean error(String msg) {
return new RespBean(500, msg, null);
}
public static RespBean error(String msg, Object obj) {
return new RespBean(500, msg, obj);
}
private RespBean() {
}
private RespBean(Integer status, String msg, Object obj) {
this.status = status;
this.msg = msg;
this.obj = obj;
}
public Integer getStatus() {
return status;
}
public RespBean setStatus(Integer status) {
this.status = status;
return this;
}
public String getMsg() {
return msg;
}
public RespBean setMsg(String msg) {
this.msg = msg;
return this;
}
public Object getObj() {
return obj;
}
public RespBean setObj(Object obj) {
this.obj = obj;
return this;
}
}