feat: 扩展rest-bean能力,支持提供表格,表格前端支持状态切换
This commit is contained in:
parent
baa458ae2c
commit
60f66900c2
@ -1,5 +1,7 @@
|
|||||||
package com.flyfish.framework.compiler.core;
|
package com.flyfish.framework.compiler.core;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -26,10 +28,33 @@ class MemoryClassLoader extends URLClassLoader {
|
|||||||
return super.findClass(name);
|
return super.findClass(name);
|
||||||
}
|
}
|
||||||
classBytes.remove(name);
|
classBytes.remove(name);
|
||||||
return defineClass(name, buf, 0, buf.length);
|
return defineClass(name, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, byte[]> getClassBytes() {
|
public Map<String, byte[]> getClassBytes() {
|
||||||
return classBytes;
|
return classBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修复获取package为null的问题,定义并验证class
|
||||||
|
*
|
||||||
|
* @param name 名称
|
||||||
|
* @param buf 二进制数据
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
private Class<?> defineClass(String name, byte[] buf) {
|
||||||
|
// 先定义class,然后在上下文基础上判断package有效性
|
||||||
|
Class<?> defined = defineClass(name, buf, 0, buf.length);
|
||||||
|
synchronized (defined) {
|
||||||
|
// 补偿定义包,防止缺失
|
||||||
|
if (null == defined.getPackage()) {
|
||||||
|
// 包名
|
||||||
|
String packageName = StringUtils.substringBeforeLast(name, ".");
|
||||||
|
definePackage(packageName, null, null,
|
||||||
|
null, null, null, null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.flyfish.framework.domain.po;
|
||||||
|
|
||||||
|
import com.flyfish.framework.domain.base.Domain;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在线表单
|
||||||
|
*/
|
||||||
|
@Document("online-forms")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class OnlineForm extends Domain {
|
||||||
|
|
||||||
|
// 配置信息
|
||||||
|
private String form;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,7 @@ package com.flyfish.framework.beans.meta;
|
|||||||
|
|
||||||
import com.flyfish.framework.bean.Result;
|
import com.flyfish.framework.bean.Result;
|
||||||
import com.flyfish.framework.beans.resolver.DynamicRestBeanResolver;
|
import com.flyfish.framework.beans.resolver.DynamicRestBeanResolver;
|
||||||
|
import com.flyfish.framework.domain.base.Vo;
|
||||||
import com.flyfish.framework.utils.StringFormats;
|
import com.flyfish.framework.utils.StringFormats;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ClassUtils;
|
import org.apache.commons.lang3.ClassUtils;
|
||||||
@ -42,7 +43,12 @@ public class BeanController {
|
|||||||
BeanInfo info = new BeanInfo();
|
BeanInfo info = new BeanInfo();
|
||||||
info.setCode(StringFormats.camel2Line(ClassUtils.getShortClassName(clazz)));
|
info.setCode(StringFormats.camel2Line(ClassUtils.getShortClassName(clazz)));
|
||||||
if (clazz.isAnnotationPresent(RestBean.class)) {
|
if (clazz.isAnnotationPresent(RestBean.class)) {
|
||||||
info.setName(clazz.getAnnotation(RestBean.class).name());
|
RestBean annotation = clazz.getAnnotation(RestBean.class);
|
||||||
|
info.setName(annotation.name());
|
||||||
|
info.setSearch(BeanProperty.from(annotation.queryClass()));
|
||||||
|
if (!Vo.class.equals(annotation.listViewClass())) {
|
||||||
|
info.setColumns(BeanProperty.from(annotation.listViewClass()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
info.setProperties(BeanProperty.from(clazz));
|
info.setProperties(BeanProperty.from(clazz));
|
||||||
return Result.ok(info);
|
return Result.ok(info);
|
||||||
|
@ -19,4 +19,10 @@ public class BeanInfo {
|
|||||||
|
|
||||||
// bean的属性们
|
// bean的属性们
|
||||||
private List<BeanProperty> properties;
|
private List<BeanProperty> properties;
|
||||||
|
|
||||||
|
// 表格列属性
|
||||||
|
private List<BeanProperty> columns;
|
||||||
|
|
||||||
|
// 表格查询属性
|
||||||
|
private List<BeanProperty> search;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.flyfish.framework.controller.BaseController;
|
|||||||
import com.flyfish.framework.controller.SafeController;
|
import com.flyfish.framework.controller.SafeController;
|
||||||
import com.flyfish.framework.domain.base.NameLikeQo;
|
import com.flyfish.framework.domain.base.NameLikeQo;
|
||||||
import com.flyfish.framework.domain.base.Qo;
|
import com.flyfish.framework.domain.base.Qo;
|
||||||
|
import com.flyfish.framework.domain.base.Vo;
|
||||||
import com.flyfish.framework.repository.DefaultRepository;
|
import com.flyfish.framework.repository.DefaultRepository;
|
||||||
import com.flyfish.framework.service.BaseService;
|
import com.flyfish.framework.service.BaseService;
|
||||||
import com.flyfish.framework.service.impl.BaseServiceImpl;
|
import com.flyfish.framework.service.impl.BaseServiceImpl;
|
||||||
@ -51,6 +52,20 @@ public @interface RestBean {
|
|||||||
*/
|
*/
|
||||||
Class<? extends Qo> queryClass() default NameLikeQo.class;
|
Class<? extends Qo> queryClass() default NameLikeQo.class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定列表视图
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
Class<? extends Vo> listViewClass() default Vo.class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定详情视图
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
Class<? extends Vo> viewClass() default Vo.class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仓库的超类,默认是default
|
* 仓库的超类,默认是default
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user