redis 增加了部分封装类
This commit is contained in:
@ -20,10 +20,6 @@
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.chinaunicom.mall.ebtp.cloud.jpa.starter;
|
||||
|
||||
public interface CommonConstants {
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
String STATUS_DEL = "deleted";
|
||||
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
String STATUS_NORMAL = "normal";
|
||||
}
|
@ -1,10 +1,68 @@
|
||||
package com.chinaunicom.mall.ebtp.cloud.jpa.starter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
|
||||
import cn.chinaunicom.sdsi.framework.config.mybatis.MyMetaObjectHandler;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(value = "cn.chinaunicom.sdsi.framework.config.mybatis", excludeFilters = {
|
||||
@Filter(type = FilterType.ASSIGNABLE_TYPE, classes = { MyMetaObjectHandler.class }) })
|
||||
@PropertySource("classpath:jpa-configuration.properties")
|
||||
public class JpaStarterConfiguration {
|
||||
|
||||
@Bean
|
||||
MetaObjectHandler metaObjectHandler() {
|
||||
return new MetaObjectHandler() {
|
||||
/**
|
||||
* 更新元对象字段填充(用于更新时对公共字段的填充)
|
||||
*
|
||||
* @param metaObject 元对象
|
||||
*/
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
final LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
setFieldValByName("updateDate", now, metaObject);
|
||||
setFieldValByName("lastUpdateTime", now, metaObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入元对象字段填充(用于插入时对公共字段的填充)
|
||||
*
|
||||
* @param metaObject 元对象
|
||||
*/
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
Object obj = getFieldValByName("createBy", metaObject);
|
||||
obj = getFieldValByName("createDate", metaObject);
|
||||
if (obj == null) {
|
||||
setFieldValByName("createDate", LocalDateTime.now(), metaObject);
|
||||
}
|
||||
obj = getFieldValByName("updateDate", metaObject);
|
||||
if (obj == null) {
|
||||
setFieldValByName("updateDate", LocalDateTime.now(), metaObject);
|
||||
}
|
||||
obj = getFieldValByName("tenantId", metaObject);
|
||||
if (obj == null) {
|
||||
setFieldValByName("tenantId", "ebtp_mall", metaObject);
|
||||
}
|
||||
obj = getFieldValByName("tenantName", metaObject);
|
||||
if (obj == null) {
|
||||
setFieldValByName("tenantName", "ebtp_mall", metaObject);
|
||||
}
|
||||
setFieldValByName("deleteFlag", CommonConstants.STATUS_NORMAL, metaObject);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
# 默认开启驼峰映射
|
||||
mybatis-plus.configuration.map-undersore-to-camel-case=true
|
||||
# 对所有的 resultMap 都进行自动映射
|
||||
mybatis-plus.configuration.auto-mapping-behavior=full
|
||||
# 项目统一mapper存放位置
|
||||
mybatis-plus.mapper-locations=classpath*:com/chinaunicom/mall/ebtp/**/mapper/*Mapper.xml
|
||||
# 逻辑已删除值
|
||||
mybatis-plus.global-config.db-config.logic-delete-value=0
|
||||
# 逻辑未删除值
|
||||
mybatis-plus.global-config.db-config.logic-not-delete-value=1
|
Reference in New Issue
Block a user