mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-14 10:19:04 +00:00
Merge branch 'main' of https://github.com/qq564139153/zfoo
This commit is contained in:
commit
5267e2681d
7 files changed
+112
-5
No files matched your search
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
@@ -11,15 +10,15 @@
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zfoo.boot;
|
||||
|
||||
import com.zfoo.protocol.util.StringUtils;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author godotg
|
||||
* @version 3.0
|
||||
*/
|
||||
@Ignore
|
||||
public class MainTest {
|
||||
|
||||
@Test
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<configuration scan="false" debug="false">
|
||||
|
||||
<contextName>com.zfoo.boot</contextName>
|
||||
|
||||
<property name="LOG_HOME" value="log/boot"/>
|
||||
<property name="PATTERN_FILE"
|
||||
value="%d{yyyy-MM-dd HH:mm:ss} [%5level] [%thread] %logger.%M\\(%F:%line\\) - %msg%n"/>
|
||||
<property name="PATTERN_CONSOLE"
|
||||
value="%d{yyyy-MM-dd HH:mm:ss} [%highlight(%5level)] [%thread] %logger.%M\\(%F:%line\\) - %msg%n"/>
|
||||
<!-- 负责写日志,控制台日志,会打印所有的包的所有级别日志 -->
|
||||
<appender name="zfoo_console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${PATTERN_CONSOLE}</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 根logger -->
|
||||
<root level="info">
|
||||
<appender-ref ref="zfoo_console"/>
|
||||
</root>
|
||||
|
||||
<!--
|
||||
- 1.name:包名或类名,用来指定受此logger约束的某一个包或者具体的某一个类
|
||||
- 2.未设置打印级别,所以继承他的上级<root>的日志级别“DEBUG”
|
||||
- 3.未设置additivity,默认为true,将此logger的打印信息向上级传递;
|
||||
- 4.未设置appender,此logger本身不打印任何信息,级别为“DEBUG”及大于“DEBUG”的日志信息传递给root,
|
||||
- root接到下级传递的信息,交给已经配置好的名为“STDOUT”的appender处理,“STDOUT”appender将信息打印到控制台;
|
||||
-->
|
||||
<logger name="ch.qos.logback" level="info"/>
|
||||
|
||||
<!--*******************************************Spring********************************************************-->
|
||||
<!--logger中的name是指代码的包名或类名,路径要写全,可以配置不同包中的日志输出到不同的文件中。level是日志输出级别 -->
|
||||
<!--过滤掉spring的一些无用的DEBUG信息-->
|
||||
<logger name="org.springframework" level="info"/>
|
||||
<!-- additivity="false"表示不继承父logger的配置和父类没有关系-->
|
||||
<logger name="org.springframework.core" level="info"/>
|
||||
|
||||
|
||||
<!--*******************************************Netty*********************************************************-->
|
||||
<logger name="io.netty" level="info"/>
|
||||
</configuration>
|
||||
@@ -41,6 +41,7 @@ public class ResourceInterpreter {
|
||||
static {
|
||||
var converters = new HashSet<>();
|
||||
converters.add(new JsonToArrayConverter());
|
||||
converters.add(new JsonToListConverter());
|
||||
converters.add(new JsonToMapConverter());
|
||||
converters.add(new JsonToObjectConverter());
|
||||
converters.add(new StringToClassConverter());
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.zfoo.storage.manager;
|
||||
import com.zfoo.protocol.collection.CollectionUtils;
|
||||
import com.zfoo.protocol.exception.ExceptionUtils;
|
||||
import com.zfoo.protocol.exception.RunException;
|
||||
import com.zfoo.protocol.util.ClassUtils;
|
||||
import com.zfoo.protocol.util.FileUtils;
|
||||
import com.zfoo.protocol.util.ReflectionUtils;
|
||||
import com.zfoo.protocol.util.StringUtils;
|
||||
@@ -95,8 +96,9 @@ public class StorageManager implements IStorageManager {
|
||||
|
||||
// 检查class字段是否合法
|
||||
if (!storageConfig.isWriteable()) {
|
||||
for (var definition : resourceDefinitionMap.values()) {
|
||||
var clazz = definition.getClazz();
|
||||
var allRelevantClass = new HashSet<Class<?>>();
|
||||
resourceDefinitionMap.values().forEach(it -> allRelevantClass.addAll(ClassUtils.relevantClass(it.getClazz())));
|
||||
for (var clazz : allRelevantClass) {
|
||||
var fieldList = ReflectionUtils.notStaticAndTransientFields(clazz);
|
||||
for (var field : fieldList) {
|
||||
if (Modifier.isPublic(field.getModifiers())) {
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
|
||||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zfoo.storage.strategy;
|
||||
|
||||
import com.zfoo.protocol.util.JsonUtils;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.ConditionalGenericConverter;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author liqi
|
||||
* @version 4.0
|
||||
*/
|
||||
public class JsonToListConverter implements ConditionalGenericConverter {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
return sourceType.getType() == String.class && List.class.isAssignableFrom(targetType.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ConvertiblePair> getConvertibleTypes() {
|
||||
return Collections.singleton(new ConvertiblePair(String.class, List.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
// String content = (String) source;
|
||||
// return targetType.isPrimitive() ? JsonUtil.string2Object(content, targetType.getObjectType())
|
||||
// : JsonUtil.string2Array(content, targetType.getType());
|
||||
Class<?> clazz = null;
|
||||
|
||||
String content = (String) source;
|
||||
for (var v : targetType.getResolvableType().getGenerics()){
|
||||
clazz = (Class<?>) v.getType();
|
||||
}
|
||||
return Collections.unmodifiableList(JsonUtils.string2List(content, clazz));
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@ import com.zfoo.storage.model.anno.Id;
|
||||
import com.zfoo.storage.model.anno.Index;
|
||||
import com.zfoo.storage.model.anno.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author godotg
|
||||
* @version 4.0
|
||||
@@ -37,6 +39,7 @@ public class StudentResource {
|
||||
private float score;
|
||||
private String[] courses;
|
||||
private User[] users;
|
||||
private List<User> userList;
|
||||
private User user;
|
||||
|
||||
/**
|
||||
@@ -68,6 +71,10 @@ public class StudentResource {
|
||||
return users;
|
||||
}
|
||||
|
||||
public List<User> getUserList() {
|
||||
return userList;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user