redis 增加了部分封装类

This commit is contained in:
Administrator
2020-10-27 17:44:20 +08:00
parent 0300e5e0b0
commit ab4215a25b
46 changed files with 12562 additions and 4 deletions

View File

@ -0,0 +1,13 @@
package com.chinaunicom.mall.ebtp.cloud.jpa.starter;
public interface CommonConstants {
/**
* 删除
*/
String STATUS_DEL = "deleted";
/**
* 正常
*/
String STATUS_NORMAL = "normal";
}

View File

@ -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);
}
};
}
}

View File

@ -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