注意时间信息的显示,似乎不太正确。正常的应该是2021-12-01 09:56:30
的格式。这是因为这个时间是带时区的显示,显示的是格林尼的标准时间。在application.properties中可以配置时区和时间格式。
#配置时间格式及时区
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
重启项目,访问url地址。撒花!
[{"id":"1","name":"wz","intro":"coolBoy","career":"developer","level":100,"avatar":null,"sort":0,"isDeleted":0,"gmtCreate":"2021-12-01 09:56:30","gmtModified":"2021-10-06 09:56:44"},{"id":"2","name":"cc","intro":"beautifulgirl","career":"writter","level":18,"avatar":null,"sort":0,"isDeleted":0,"gmtCreate":"2021-10-06 09:57:49","gmtModified":"2021-10-06 09:58:02"}]
下面我们开始crud的传统艺能,先搞个逻辑删除。
步骤如下:
(1)配置一个逻辑删除插件。
@Bean
public ISqlInjector sqlInjector() {
return new LogicSqlInjector();
}
(2)在实体类中对逻辑删除的标识属性isdeleted
添加注解@TableLogic
。
(3)在controller中编写逻辑删除方法。
@DeleteMapping("{id}")
public boolean removeTeacher(@PathVariable String id) {
eduTeacherService.removeById(id);
return false;
}
对以上代码简要解释如下。
由于使用浏览器只能够测试get类型的提交,我们对于delete方法的提交则需要借助一些工具来测试。如swagger、postman。