init:米东项目初始化
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.saye.hospitalgd.config.dataSourceConfig;
|
||||
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.apache.ibatis.reflection.wrapper.MapWrapper;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author thuang
|
||||
* @version 1.0
|
||||
* @description: 用来将查询结果的key全转为大写
|
||||
* @date 2021/5/8 10:05
|
||||
*/
|
||||
public class MapKeyUpperWrapper extends MapWrapper {
|
||||
|
||||
public MapKeyUpperWrapper(MetaObject metaObject, Map<String, Object> map) {
|
||||
super(metaObject, map);
|
||||
}
|
||||
@Override
|
||||
public String findProperty(String name, boolean useCamelCaseMapping) {
|
||||
return name==null?"":name.toUpperCase() ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.saye.hospitalgd.config.dataSourceConfig;
|
||||
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.apache.ibatis.reflection.wrapper.ObjectWrapper;
|
||||
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author thuang
|
||||
* @version 1.0
|
||||
* @description: 重写工厂类使用自定义的MapKeyUpperWrapper
|
||||
* @date 2021/5/8 10:08
|
||||
*/
|
||||
public class MapWrapperFactory implements ObjectWrapperFactory {
|
||||
|
||||
@Override
|
||||
public boolean hasWrapperFor(Object object) {
|
||||
return object != null && object instanceof Map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
|
||||
return new MapKeyUpperWrapper(metaObject, (Map) object);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.saye.hospitalgd.config.dataSourceConfig;
|
||||
|
||||
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author thuang
|
||||
* @version 1.0
|
||||
* @description: 自定义Convert 转换类 springboot只认ObjectWrapperFactory 自定义的那名字不认
|
||||
* @date 2021/5/8 10:27
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationPropertiesBinding
|
||||
public class ObjectWrapperFactoryConverter implements Converter<String, ObjectWrapperFactory> {
|
||||
@Override
|
||||
public ObjectWrapperFactory convert(String source) {
|
||||
try {
|
||||
return (ObjectWrapperFactory) Class.forName(source).newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user