parent
415b87ee77
commit
1be5703c90
@ -0,0 +1,33 @@
|
|||||||
|
package com.example.demo.config.config;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||||
|
import com.example.demo.domain.Task;
|
||||||
|
import org.apache.ibatis.reflection.MetaObject;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class BaseEntityMetaObjectHandler implements MetaObjectHandler {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertFill(MetaObject metaObject) {
|
||||||
|
// 创建时间自动填充
|
||||||
|
if (metaObject.hasSetter(Task.CREATE_TIME) && ObjectUtil.isNull(getFieldValByName(Task.CREATE_TIME, metaObject))) {
|
||||||
|
this.strictInsertFill(metaObject, Task.CREATE_TIME, LocalDateTime.class, LocalDateTime.now());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateFill(MetaObject metaObject) {
|
||||||
|
//修改时间自动填充
|
||||||
|
if (metaObject.hasSetter(Task.MODIFIED_TIME) && ObjectUtil.isNull(getFieldValByName(Task.MODIFIED_TIME, metaObject))) {
|
||||||
|
this.strictUpdateFill(metaObject, Task.MODIFIED_TIME, LocalDateTime.class, LocalDateTime.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.example.demo.config.config;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MybatisPlus 配置类
|
||||||
|
*
|
||||||
|
* @author huang
|
||||||
|
* @since 2022-03-18
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class MybatisPlusConfig {
|
||||||
|
/**
|
||||||
|
* 分页插件
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||||
|
return interceptor;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.example.demo.config.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web 配置类
|
||||||
|
*
|
||||||
|
* @author huang
|
||||||
|
* @since 2022-03-18
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class WebConfig implements WebMvcConfigurer {
|
||||||
|
@Override
|
||||||
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
|
registry.addViewController("/").setViewName("login/login");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue