diff --git a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/annotation/DescribeWoBuilder.java b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/annotation/DescribeWoBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..e1143d79d8e4886ee31d5502b4216efd8ccab9bf --- /dev/null +++ b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/annotation/DescribeWoBuilder.java @@ -0,0 +1,1006 @@ +package com.x.base.core.project.annotation; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.OPTIONS; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.apache.commons.collections4.list.SetUniqueList; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.ClassUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.apache.commons.lang3.reflect.MethodUtils; +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import org.glassfish.jersey.media.multipart.FormDataParam; + +import com.google.gson.JsonElement; +import com.x.base.core.project.bean.WrapCopier; +import com.x.base.core.project.gson.XGsonBuilder; +import com.x.base.core.project.jaxrs.StandardJaxrsAction; +import com.x.base.core.project.logger.Logger; +import com.x.base.core.project.logger.LoggerFactory; +import com.x.base.core.project.tools.DefaultCharset; +import com.x.base.core.project.tools.ListTools; + +import io.github.classgraph.ClassGraph; +import io.github.classgraph.ClassInfo; +import io.github.classgraph.ScanResult; + +public class DescribeWoBuilder { + + private static Logger logger = LoggerFactory.getLogger(DescribeWoBuilder.class); + private File fileDir = null; + public static void main(String[] args) throws IOException { + + String filePath = args[0]; + String fileName = filePath.substring(filePath.lastIndexOf(File.separator), filePath.length()); + filePath = filePath.substring(0, filePath.lastIndexOf(File.separator)); + filePath = filePath + File.separator+"x_program_center"; + + File basedir = new File(args[0]); + File sourcedir = new File(args[1]); + File dir = new File(filePath ,"src/main/webapp/describe/jsdoc"); + + FileUtils.forceMkdir(dir); + + DescribeWoBuilder builder = new DescribeWoBuilder(); + + builder.scan(dir,fileName); + } + + private void scan(File dir,String fileName) { + try { + this.fileDir = dir; + ArrayList List = new ArrayList(); + List.add("ApplicationDictAction"); + List.add("AttachmentAction"); + List.add("CacheAction"); + List.add("DataAction"); + List.add("JobAction"); + List.add("ReadAction"); + List.add("RecordAction"); + List.add("ReviewAction"); + List.add("TaskAction"); + List.add("TaskCompletedAction"); + List.add("WorkAction"); + List.add("WorkCompletedAction"); + + List.add("AppInfoAction"); + List.add("CategoryInfoAction"); + List.add("DocumentAction"); + List.add("DocumentCommendAction"); + List.add("DocumentCommentInfoAction"); + List.add("DocumentViewRecordAction"); + List.add("FileInfoAction"); + + List jaxrsClasses = new ArrayList<>(); + List> classes = this.scanJaxrsClass(); + for (Class clz : classes) { + if(List.contains(clz.getSimpleName())){ + if (StandardJaxrsAction.class.isAssignableFrom(clz)) { + JaxrsClass jarsClass = this.jaxrsClass(clz); + List methods = jarsClass.getMethods(); + if( methods.size()> 0) { + jaxrsClasses.add(jarsClass); + } + } + } + } + LinkedHashMap> map = new LinkedHashMap<>(); + + jaxrsClasses = jaxrsClasses.stream().sorted(Comparator.comparing(JaxrsClass::getName)) + .collect(Collectors.toList()); + + for(JaxrsClass jaxr:jaxrsClasses) { + File file = new File(dir, jaxr.getName() + ".json"); + FileUtils.writeStringToFile(file, XGsonBuilder.toJson(jaxr), DefaultCharset.charset); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + private List> scanJaxrsClass() throws Exception { + try (ScanResult scanResult = new ClassGraph().disableJarScanning().enableAnnotationInfo().scan()) { + SetUniqueList> classes = SetUniqueList.setUniqueList(new ArrayList>()); + for (ClassInfo info : scanResult.getClassesWithAnnotation(ApplicationPath.class.getName())) { + Class applicationPathClass = ClassUtils.getClass(info.getName()); + for (Class o : (Set>) MethodUtils.invokeMethod(applicationPathClass.newInstance(), + "getClasses")) { + Path path = o.getAnnotation(Path.class); + JaxrsDescribe jaxrsDescribe = o.getAnnotation(JaxrsDescribe.class); + if (null != path && null != jaxrsDescribe) { + classes.add(o); + } + } + } + return classes; + } + } + + private JaxrsClass jaxrsClass(Class clz) throws Exception { + logger.print("describe class:{}.", clz.getName()); + JaxrsDescribe jaxrsDescribe = clz.getAnnotation(JaxrsDescribe.class); + JaxrsClass jaxrsClass = new JaxrsClass(); + jaxrsClass.setClassName(clz.getName()); + jaxrsClass.setName(clz.getSimpleName()); + jaxrsClass.setDescription(jaxrsDescribe.value()); + + for (Method method : clz.getMethods()) { + JaxrsMethodDescribe jaxrsMethodDescribe = method.getAnnotation(JaxrsMethodDescribe.class); + if (null != jaxrsMethodDescribe) { + if (null != method.getAnnotation(GET.class)) { + jaxrsClass.getMethods().add(this.jaxrsMethod(clz, method)); + } + } + } + jaxrsClass.setMethods(jaxrsClass.getMethods().stream().sorted(Comparator.comparing(JaxrsMethod::getName)) + .collect(Collectors.toList())); + + return jaxrsClass; + } + + private JaxrsMethod jaxrsMethod(Class clz, Method method) throws Exception { + JaxrsMethodDescribe jaxrsMethodDescribe = method.getAnnotation(JaxrsMethodDescribe.class); + JaxrsMethod jaxrsMethod = new JaxrsMethod(); + jaxrsMethod.setName(method.getName()); + jaxrsMethod.setDescription(jaxrsMethodDescribe.value()); + Class actionClass = jaxrsMethodDescribe.action(); + jaxrsMethod.setClassName(actionClass.getName()); + if (null != method.getAnnotation(GET.class)) { + jaxrsMethod.setType("GET"); + } else if (null != method.getAnnotation(POST.class)) { + jaxrsMethod.setType("POST"); + } else if (null != method.getAnnotation(PUT.class)) { + jaxrsMethod.setType("PUT"); + } else if (null != method.getAnnotation(DELETE.class)) { + jaxrsMethod.setType("DELETE"); + } else if (null != method.getAnnotation(OPTIONS.class)) { + jaxrsMethod.setType("OPTIONS"); + } else if (null != method.getAnnotation(HEAD.class)) { + jaxrsMethod.setType("HEAD"); + } + + Class woClass = this.getWoClass(actionClass); + if (null != woClass) { + jaxrsMethod.setOuts(this.jaxrsOutField(woClass)); + } + + + +// Class wiClass = this.getWiClass(actionClass); +// if (null != wiClass) { +// jaxrsMethod.setIns(this.jaxrsInField(wiClass)); +// } else { +// if (StringUtils.equals("POST", jaxrsMethod.getType()) || StringUtils.equals("PUT", jaxrsMethod.getType())) { +// /** 如果没有定义Wi对象,那么有可能使用的是jsonElement对象 */ +// if (ArrayUtils.contains(method.getParameterTypes(), JsonElement.class)) { +// jaxrsMethod.setUseJsonElementParameter(true); +// } else { +// jaxrsMethod.setUseStringParameter(true); +// } +// } +// } +// + +// Consumes consumes = method.getAnnotation(Consumes.class); +// if (null != consumes) { +// jaxrsMethod.setContentType(consumes.value()[0]); +// } else { +// jaxrsMethod.setContentType(MediaType.APPLICATION_JSON); +// } +// Produces produces = method.getAnnotation(Produces.class); +// if (null != produces) { +// jaxrsMethod.setResultContentType(produces.value()[0]); +// jaxrsMethod.setResultContentType(produces.value()[0]); +// } +// Path path = method.getAnnotation(Path.class); +// if (null == path) { +// jaxrsMethod.setPath("jaxrs/" + clz.getAnnotation(Path.class).value()); +// } else { +// jaxrsMethod.setPath("jaxrs/" + clz.getAnnotation(Path.class).value() + "/" + path.value()); +// } +// for (Parameter o : method.getParameters()) { +// FormDataParam formDataParam = o.getAnnotation(FormDataParam.class); +// FormParam formParam = o.getAnnotation(FormParam.class); +// PathParam pathParam = o.getAnnotation(PathParam.class); +// QueryParam queryParam = o.getAnnotation(QueryParam.class); +// if (null != formDataParam) { +// jaxrsMethod.getFormParameters().add(this.jaxrsFormDataParameter(clz, method, o)); +// } else if (null != formParam) { +// jaxrsMethod.getFormParameters().add(this.jaxrsFormParameter(clz, method, o)); +// } else if (null != queryParam) { +// jaxrsMethod.getQueryParameters().add(this.jaxrsQueryParameter(clz, method, o)); +// } else if (null != pathParam) { +// jaxrsMethod.getPathParameters().add(this.jaxrsPathParameter(clz, method, o)); +// } +// } +// jaxrsMethod.setFormParameters(jaxrsMethod.getFormParameters().stream().filter(Objects::nonNull) +// .sorted(Comparator.comparing(JaxrsFormParameter::getName, Comparator.nullsLast(String::compareTo))) +// .collect(Collectors.toList())); + /* + jaxrsMethod.setQueryParameters(jaxrsMethod.getQueryParameters().stream().filter(Objects::nonNull) + .sorted(Comparator.comparing(JaxrsQueryParameter::getName, Comparator.nullsLast(String::compareTo))) + .collect(Collectors.toList())); + */ +// jaxrsMethod.setQueryParameters(jaxrsMethod.getQueryParameters().stream().filter(Objects::nonNull) +// .collect(Collectors.toList())); + /* + jaxrsMethod.setPathParameters(jaxrsMethod.getPathParameters().stream().filter(Objects::nonNull) + .sorted(Comparator.comparing(JaxrsPathParameter::getName, Comparator.nullsLast(String::compareTo))) + .collect(Collectors.toList())); + */ +// jaxrsMethod.setPathParameters(jaxrsMethod.getPathParameters().stream().filter(Objects::nonNull) +// .collect(Collectors.toList())); + return jaxrsMethod; + } + + private JaxrsFormParameter jaxrsFormDataParameter(Class clz, Method method, Parameter parameter) { + JaxrsParameterDescribe jaxrsParameterDescribe = parameter.getAnnotation(JaxrsParameterDescribe.class); + FormDataParam formDataParam = parameter.getAnnotation(FormDataParam.class); + if (StringUtils.equalsIgnoreCase("file", formDataParam.value())) { + if (parameter.getType() == FormDataContentDisposition.class) { + /** 单独处理附件 */ + JaxrsFormParameter o = new JaxrsFormParameter(); + o.setType("File"); + o.setName(formDataParam.value()); + if (null != jaxrsParameterDescribe) { + o.setDescription(jaxrsParameterDescribe.value()); + } else { + logger.print("类: {}, 方法: {} ,未设置参数 {} 的JaxrsParameterDescribe.", clz.getName(), method.getName(), + formDataParam.value()); + o.setDescription(""); + } + return o; + } + } else { + JaxrsFormParameter o = new JaxrsFormParameter(); + o.setType(this.simpleType(parameter.getType().toString())); + o.setName(formDataParam.value()); + if (null != jaxrsParameterDescribe) { + o.setDescription(jaxrsParameterDescribe.value()); + } else { + logger.print("类: {}, 方法: {} ,未设置参数 {} 的JaxrsParameterDescribe.", clz.getName(), method.getName(), + formDataParam.value()); + o.setDescription(""); + } + return o; + } + return null; + } + + private JaxrsFormParameter jaxrsFormParameter(Class clz, Method method, Parameter parameter) { + JaxrsParameterDescribe jaxrsParameterDescribe = parameter.getAnnotation(JaxrsParameterDescribe.class); + FormParam formParam = parameter.getAnnotation(FormParam.class); + JaxrsFormParameter o = new JaxrsFormParameter(); + o.setType(this.simpleType(parameter.getType().toString())); + o.setName(formParam.value()); + if (null != jaxrsParameterDescribe) { + o.setDescription(jaxrsParameterDescribe.value()); + } else { + logger.print("类: {}, 方法: {} ,未设置参数 {} 的JaxrsParameterDescribe.", clz.getName(), method.getName(), + formParam.value()); + o.setDescription(""); + } + return o; + } + + private JaxrsQueryParameter jaxrsQueryParameter(Class clz, Method method, Parameter parameter) { + JaxrsParameterDescribe jaxrsParameterDescribe = parameter.getAnnotation(JaxrsParameterDescribe.class); + QueryParam queryParam = parameter.getAnnotation(QueryParam.class); + JaxrsQueryParameter o = new JaxrsQueryParameter(); + if (null != jaxrsParameterDescribe) { + o.setDescription(jaxrsParameterDescribe.value()); + } else { + logger.print("类: {}, 方法: {} ,未设置参数 {} 的JaxrsParameterDescribe.", clz.getName(), method.getName(), + queryParam.value()); + o.setDescription(""); + } + o.setName(queryParam.value()); + o.setType(this.simpleType(parameter.getType().getName())); + return o; + } + + private JaxrsPathParameter jaxrsPathParameter(Class clz, Method method, Parameter parameter) throws Exception { + JaxrsParameterDescribe jaxrsParameterDescribe = parameter.getAnnotation(JaxrsParameterDescribe.class); + PathParam pathParam = parameter.getAnnotation(PathParam.class); + JaxrsPathParameter o = new JaxrsPathParameter(); + o.setName(pathParam.value()); + if (null != jaxrsParameterDescribe) { + o.setDescription(jaxrsParameterDescribe.value()); + } else { + logger.print("类: {}, 方法: {} ,未设置参数 {} 的JaxrsParameterDescribe.", clz.getName(), method.getName(), + pathParam.value()); + o.setDescription(""); + } + o.setType(this.getJaxrsParameterType(parameter)); + return o; + } + + private Class getWiClass(Class actionClass) { + for (Class c : actionClass.getDeclaredClasses()) { + if (StringUtils.equals(c.getSimpleName(), "Wi")) { + return c; + } + } + return null; + } + + private Class getWoClass(Class actionClass) { + for (Class c : actionClass.getDeclaredClasses()) { + if (StringUtils.equals(c.getSimpleName(), "Wo")) { + return c; + } + } + return null; + } + + private List jaxrsInField(Class clz) throws Exception { + List list = new ArrayList<>(); + List fields = FieldUtils.getAllFieldsList(clz); + List copierCopyFields = this.listCopierCopyFields(clz); + if (ListTools.isNotEmpty(copierCopyFields)) { + List os = new ArrayList<>(); + for (Field o : fields) { + FieldDescribe fieldDescribe = o.getAnnotation(FieldDescribe.class); + if ((null != fieldDescribe) + && (copierCopyFields.contains(o.getName()) || this.inWiNotInEntity(o.getName(), clz))) { + os.add(o); + } + fields = os; + } + } + for (Field o : fields) { + FieldDescribe fieldDescribe = o.getAnnotation(FieldDescribe.class); + if (null != fieldDescribe) { + JaxrsField jaxrsField = new JaxrsField(); + jaxrsField.setName(o.getName()); + jaxrsField.setDescription(fieldDescribe.value()); + jaxrsField.setType(this.getJaxrsFieldType(o)); + jaxrsField.setIsBaseType(false); + if (Collection.class.isAssignableFrom(o.getType())) { + jaxrsField.setIsCollection(true); + if (StringUtils.containsAny(jaxrsField.getType(), "", "", "", "", + "", "", "")) { + jaxrsField.setIsBaseType(true); + }else { + //wwx add 获取类信息 + FieldTypeDescribe fieldTypeDescribe = o.getAnnotation(FieldTypeDescribe.class); + if(null !=fieldTypeDescribe) { + jaxrsField.setFieldType(fieldTypeDescribe.fieldType()); + jaxrsField.setFieldValue(fieldTypeDescribe.fieldValue()); + jaxrsField.setFieldTypeName(fieldTypeDescribe.fieldTypeName()); + jaxrsField.setFieldSample(fieldTypeDescribe.fieldSample()); + } + + } + } else { + // O2LEE,String[]未被判断为collection导致组织的JSON格式不符合wrapIn要求 + if (StringUtils.equalsAnyIgnoreCase("String[]", jaxrsField.getType())) { + jaxrsField.setIsCollection(true); + } else { + jaxrsField.setIsCollection(false); + } + if (StringUtils.startsWithAny(jaxrsField.getType(), "String", "Boolean", "Date", "Integer", + "Double", "Long", "Float")) { + jaxrsField.setIsBaseType(true); + }else { + FieldTypeDescribe fieldTypeDescribe = o.getAnnotation(FieldTypeDescribe.class); + if(null !=fieldTypeDescribe) { + jaxrsField.setFieldType(fieldTypeDescribe.fieldType()); + jaxrsField.setFieldValue(fieldTypeDescribe.fieldValue()); + jaxrsField.setFieldTypeName(fieldTypeDescribe.fieldTypeName()); + } + + } + } + list.add(jaxrsField); + } + } + return list; + } + + private List jaxrsOutField(Class clz) throws Exception { + List list = new ArrayList<>(); + List fields = FieldUtils.getAllFieldsList(clz); + List copierEraseFields = this.listCopierEraseFields(clz); + if (ListTools.isNotEmpty(copierEraseFields)) { + List os = new ArrayList<>(); + for (Field o : fields) { + FieldDescribe fieldDescribe = o.getAnnotation(FieldDescribe.class); + if ((null != fieldDescribe) && (!copierEraseFields.contains(o.getName()))) { + os.add(o); + } + } + fields = os; + } + for (Field o : fields) { + FieldDescribe fieldDescribe = o.getAnnotation(FieldDescribe.class); + if (null != fieldDescribe) { + JaxrsField jaxrsField = new JaxrsField(); + jaxrsField.setName(o.getName()); + jaxrsField.setDescription(fieldDescribe.value()); + jaxrsField.setType(this.getJaxrsFieldType(o)); + if (Collection.class.isAssignableFrom(o.getType())) { + jaxrsField.setIsCollection(true); + } else { + jaxrsField.setIsCollection(false); + } + list.add(jaxrsField); + } + } + return list; + } + + + private String getJaxrsFieldType(Field o) { + String typeName = o.getGenericType().getTypeName(); + String value = this.simpleType(typeName); + ArrayList List = new ArrayList(); + List.add("Date"); + List.add("String"); + List.add("Boolean"); + List.add("Long"); + List.add("long"); + List.add("int"); + List.add("Integer"); + List.add("Double"); + List.add("List"); + List.add("List"); + List.add("Map"); + List.add("Map"); + List.add("Map"); + List.add("Map"); + List.add("byte[]"); + List.add("Class"); + List.add("Class[]"); + List.add("Object"); + List.add("String[]"); + List.add("List"); + List.add("List"); + List.add("List"); + List.add("List"); + List.add("List"); + List.add("List"); + List.add("List"); + + boolean listParam = false; + if(!List.contains(value)) { + try { + if(typeName.indexOf("java.util.List<")>-1) { + String[] ss = typeName.split("[,|<|>]"); + typeName = ss[ss.length-1]; + listParam = true; + } + Class clz = Class.forName(typeName); + if(!clz.isEnum()){ + //不是枚举类型 + List fields = FieldUtils.getAllFieldsList(clz); + List list = new ArrayList<>(); + for(Field field : fields ) { + if(!listParam) { + FieldDescribe fieldDescribe = field.getAnnotation(FieldDescribe.class); + if (null != fieldDescribe) { + JaxrsField jaxrsField = new JaxrsField(); + jaxrsField.setName(field.getName()); + jaxrsField.setDescription(fieldDescribe.value()); + jaxrsField.setType(this.getJaxrsFieldType(field)); + if (Collection.class.isAssignableFrom(field.getType())) { + jaxrsField.setIsCollection(true); + } else { + jaxrsField.setIsCollection(false); + } + list.add(jaxrsField); + }else { + JaxrsField jaxrsField = new JaxrsField(); + jaxrsField.setName(field.getName()); + jaxrsField.setDescription(""); + jaxrsField.setType(this.getJaxrsFieldType(field)); + if (Collection.class.isAssignableFrom(field.getType())) { + jaxrsField.setIsCollection(true); + } else { + jaxrsField.setIsCollection(false); + } + list.add(jaxrsField); + } + }else { + //创建List参数中的类型 + FieldDescribe fieldDescribe = field.getAnnotation(FieldDescribe.class); + JaxrsField jaxrsField = new JaxrsField(); + jaxrsField.setName(field.getName()); + if (null != fieldDescribe) { + jaxrsField.setDescription(fieldDescribe.value()); + }else { + jaxrsField.setDescription(""); + } + jaxrsField.setType(this.getJaxrsFieldType(field)); + if (Collection.class.isAssignableFrom(field.getType())) { + jaxrsField.setIsCollection(true); + } else { + jaxrsField.setIsCollection(false); + } + list.add(jaxrsField); + } + } + + try { + File file = new File(this.fileDir, this.simpleType(typeName) + ".json"); + FileUtils.writeStringToFile(file, XGsonBuilder.toJson(list), DefaultCharset.charset); + } catch (IOException e) { + System.out.println("getJaxrsFieldType error............"); + e.printStackTrace(); + } + + }else { + List list = new ArrayList<>(); + Enum[] enumConstants = (Enum[]) clz.getEnumConstants(); + String enumName = ""; + if(enumConstants != null) { + for (Enum enumConstant : enumConstants) { + if(enumName.equalsIgnoreCase("")) { + enumName = enumConstant.name(); + }else { + enumName = enumName + "," + enumConstant.name(); + } + } + + JaxrsField jaxrsField = new JaxrsField(); + jaxrsField.setName(clz.getSimpleName()); + jaxrsField.setDescription(enumName); + jaxrsField.setType("Enum"); + jaxrsField.setIsCollection(false); + list.add(jaxrsField); + + try { + File file = new File(this.fileDir, value + ".json"); + FileUtils.writeStringToFile(file, XGsonBuilder.toJson(list), DefaultCharset.charset); + } catch (IOException e) { + System.out.println("getJaxrsFieldType enum........."+ e.getMessage()); + } + } + } + + } catch (ClassNotFoundException e) { + System.out.println("getJaxrsFieldType error...="+ e.getMessage()); + } + } + //return this.simpleType(value); + return value; + } + + private String getJaxrsParameterType(Parameter o) { + String value = o.getType().getTypeName(); + return this.simpleType(value); + //return value; + } + + private String simpleType(String value) { + value = value.replaceAll(" ", ""); + String[] ss = value.split("[,|<|>]"); + for (String s : ss) { + String[] ns = s.split("[.|\\$]"); + value = value.replace(s, ns[ns.length - 1]); + } + return value; + } + + private List listCopierEraseFields(Class clz) { + try { + Object o = FieldUtils.readStaticField(clz, "copier", true); + WrapCopier copier = (WrapCopier) o; + return copier.getEraseFields(); + } catch (Exception e) { + return null; + } + } + + private List listCopierCopyFields(Class clz) { + try { + Object o = FieldUtils.readStaticField(clz, "copier", true); + WrapCopier copier = (WrapCopier) o; + return copier.getCopyFields(); + } catch (Exception e) { + return null; + } + } + + /** 判断字段是否在Wi中但是没有在Entity类中说明是Wi新增字段,需要进行描述 */ + private Boolean inWiNotInEntity(String field, Class clz) { + try { + Object o = FieldUtils.readStaticField(clz, "copier", true); + WrapCopier copier = (WrapCopier) o; + if ((null != FieldUtils.getField(copier.getOrigClass(), field, true)) + && (null == FieldUtils.getField(copier.getDestClass(), field, true))) { + return true; + } + return false; + } catch (Exception e) { + return null; + } + } + + public class JaxrsClass { + + private String name; + private String className; + private String description; + private List methods = new ArrayList<>(); + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public List getMethods() { + return methods; + } + + public void setMethods(List methods) { + this.methods = methods; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } + + public class JaxrsMethod { + private String name; + private String className; + private String description; + private String type; + private String path; +// private String contentType; +// private String resultContentType; +// private Boolean useJsonElementParameter = false; +// private Boolean useStringParameter = false; +// private List pathParameters = new ArrayList<>(); +// private List formParameters = new ArrayList<>(); +// private List queryParameters = new ArrayList<>(); +// private List ins = new ArrayList<>(); + private List outs = new ArrayList<>(); + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +// public List getIns() { +// return ins; +// } +// +// public void setIns(List ins) { +// this.ins = ins; +// } + + public List getOuts() { + return outs; + } + + public void setOuts(List outs) { + this.outs = outs; + } + +// public String getContentType() { +// return contentType; +// } +// +// public void setContentType(String contentType) { +// this.contentType = contentType; +// } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + +// public List getPathParameters() { +// return pathParameters; +// } +// +// public void setPathParameters(List pathParameters) { +// this.pathParameters = pathParameters; +// } +// +// public List getFormParameters() { +// return formParameters; +// } +// +// public void setFormParameters(List formParameters) { +// this.formParameters = formParameters; +// } +// +// public List getQueryParameters() { +// return queryParameters; +// } +// +// public void setQueryParameters(List queryParameters) { +// this.queryParameters = queryParameters; +// } +// +// public Boolean getUseJsonElementParameter() { +// return useJsonElementParameter; +// } +// +// public void setUseJsonElementParameter(Boolean useJsonElementParameter) { +// this.useJsonElementParameter = useJsonElementParameter; +// } +// +// public String getResultContentType() { +// return resultContentType; +// } +// +// public void setResultContentType(String resultContentType) { +// this.resultContentType = resultContentType; +// } +// +// public Boolean getUseStringParameter() { +// return useStringParameter; +// } +// +// public void setUseStringParameter(Boolean useStringParameter) { +// this.useStringParameter = useStringParameter; +// } + + } + + public class JaxrsField { + + private String name; + private String type; + private Boolean isCollection; + private String description; + private Boolean isBaseType; + + //当参数不是基础类型时,记录类型信息 + private String fieldType; + private String fieldValue; + private String fieldTypeName; + private String fieldSample; + + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Boolean getIsCollection() { + return isCollection; + } + + public void setIsCollection(Boolean isCollection) { + this.isCollection = isCollection; + } + + public Boolean getIsBaseType() { + return isBaseType; + } + + public void setIsBaseType(Boolean isBaseType) { + this.isBaseType = isBaseType; + } + + public String getFieldType() { + return fieldType; + } + + public void setFieldType(String fieldTyp) { + this.fieldType = fieldTyp; + } + + public String getFieldValue() { + return fieldValue; + } + + public void setFieldValue(String fieldValue) { + this.fieldValue = fieldValue; + } + + public String getFieldTypeName() { + return fieldTypeName; + } + + public void setFieldTypeName(String fieldTypeName) { + this.fieldTypeName = fieldTypeName; + } + + public String getFieldSample() { + return fieldSample; + } + + public void setFieldSample(String fieldSample) { + this.fieldSample = fieldSample; + } + } + + public class JaxrsPathParameter { + + private String name; + private String type; + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + } + + public class JaxrsFormParameter { + + private String name; + private String type; + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + } + + public class JaxrsQueryParameter { + + private String name; + private String type; + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + } + +} \ No newline at end of file diff --git a/o2server/x_program_center/src/main/webapp/jest/listJsdoc.html b/o2server/x_program_center/src/main/webapp/jest/listJsdoc.html new file mode 100644 index 0000000000000000000000000000000000000000..0bafef95db87185eaaac664f64a79c19062eca8e --- /dev/null +++ b/o2server/x_program_center/src/main/webapp/jest/listJsdoc.html @@ -0,0 +1,92 @@ + + + + + + + + + + + + +
O2OA Table structure URL
+
 
+ + \ No newline at end of file