|
@@ -5,10 +5,16 @@ import io.netty.buffer.ByteBuf;
|
|
import io.netty.buffer.Unpooled;
|
|
import io.netty.buffer.Unpooled;
|
|
import org.apache.commons.beanutils.BeanUtilsBean;
|
|
import org.apache.commons.beanutils.BeanUtilsBean;
|
|
import org.apache.commons.beanutils.Converter;
|
|
import org.apache.commons.beanutils.Converter;
|
|
|
|
+import org.jetlinks.community.Interval;
|
|
|
|
+import org.jetlinks.community.utils.TimeUtils;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
|
|
+import org.springframework.util.unit.DataSize;
|
|
|
|
+
|
|
|
|
+import java.time.Duration;
|
|
|
|
|
|
@Configuration
|
|
@Configuration
|
|
|
|
+@SuppressWarnings("all")
|
|
public class CommonConfiguration {
|
|
public class CommonConfiguration {
|
|
|
|
|
|
static {
|
|
static {
|
|
@@ -35,6 +41,27 @@ public class CommonConfiguration {
|
|
}
|
|
}
|
|
}, MediaType.class);
|
|
}, MediaType.class);
|
|
|
|
|
|
|
|
+ BeanUtilsBean.getInstance().getConvertUtils().register(new Converter() {
|
|
|
|
+ @Override
|
|
|
|
+ public <T> T convert(Class<T> type, Object value) {
|
|
|
|
+ return (T) DataSize.parse(String.valueOf(value));
|
|
|
|
+ }
|
|
|
|
+ }, DataSize.class);
|
|
|
|
+
|
|
|
|
+ BeanUtilsBean.getInstance().getConvertUtils().register(new Converter() {
|
|
|
|
+ @Override
|
|
|
|
+ public <T> T convert(Class<T> type, Object value) {
|
|
|
|
+ return (T) TimeUtils.parse(String.valueOf(value));
|
|
|
|
+ }
|
|
|
|
+ }, Duration.class);
|
|
|
|
+
|
|
|
|
+ BeanUtilsBean.getInstance().getConvertUtils().register(new Converter() {
|
|
|
|
+ @Override
|
|
|
|
+ public <T> T convert(Class<T> type, Object value) {
|
|
|
|
+ return (T) Interval.of(String.valueOf(value));
|
|
|
|
+ }
|
|
|
|
+ }, Interval.class);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|