-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf($Database): abstract MyBatis Plus configuration; delete Druid co…
…nfiguration
- Loading branch information
1 parent
0a7ca5e
commit e88b4d6
Showing
4 changed files
with
60 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 0 additions & 62 deletions
62
...arter/src/main/java/com/jmsoftware/maf/springbootstarter/database/DruidConfiguration.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...main/java/com/jmsoftware/maf/springbootstarter/database/MyBatisPlusMetaObjectHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.jmsoftware.maf.springbootstarter.database; | ||
|
||
import com.baomidou.mybatisplus.annotation.DbType; | ||
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; | ||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; | ||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; | ||
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; | ||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; | ||
import com.jmsoftware.maf.common.domain.DeleteFlag; | ||
import com.jmsoftware.maf.springbootstarter.configuration.MafConfiguration; | ||
import lombok.extern.slf4j.Slf4j; | ||
import lombok.val; | ||
import org.apache.ibatis.reflection.MetaObject; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* <h1>MyBatisPlusConfiguration</h1> | ||
* <p> | ||
* Change description here. | ||
* <p> | ||
* | ||
* @author Johnny Miller (锺俊), email: johnnysviva@outlook.com | ||
* @date 2019-05-02 11:57 | ||
**/ | ||
@Slf4j | ||
@Component | ||
public class MyBatisPlusMetaObjectHandler implements MetaObjectHandler { | ||
@Override | ||
public void insertFill(MetaObject metaObject) { | ||
log.info("Start to insert fill ...."); | ||
val now = new Date(); | ||
this.strictInsertFill(metaObject, "deleted", Byte.class, DeleteFlag.NOT_DELETED.getValue()); | ||
this.strictInsertFill(metaObject, "createdTime", Date.class, now); | ||
this.strictInsertFill(metaObject, "modifiedTime", Date.class, now); | ||
} | ||
|
||
@Override | ||
public void updateFill(MetaObject metaObject) { | ||
log.info("Start to update fill ...."); | ||
this.strictUpdateFill(metaObject, "modifiedTime", Date.class, new Date()); | ||
} | ||
} |