ソースを参照

'增加wo参数生成json'

wangwenxiong 5 年 前
コミット
243bb5dcbf

+ 1006 - 0
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<JaxrsClass> jaxrsClasses = new ArrayList<>();
+			List<Class<?>> classes = this.scanJaxrsClass();
+			for (Class<?> clz : classes) {
+				if(List.contains(clz.getSimpleName())){
+					if (StandardJaxrsAction.class.isAssignableFrom(clz)) {
+						  JaxrsClass jarsClass = this.jaxrsClass(clz);
+						  List<JaxrsMethod> methods = jarsClass.getMethods();
+						  if( methods.size()> 0) {
+						    jaxrsClasses.add(jarsClass);
+						  }
+					}
+				}
+			}
+			LinkedHashMap<String, List<?>> 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<Class<?>> scanJaxrsClass() throws Exception {
+		try (ScanResult scanResult = new ClassGraph().disableJarScanning().enableAnnotationInfo().scan()) {
+			SetUniqueList<Class<?>> classes = SetUniqueList.setUniqueList(new ArrayList<Class<?>>());
+			for (ClassInfo info : scanResult.getClassesWithAnnotation(ApplicationPath.class.getName())) {
+				Class<?> applicationPathClass = ClassUtils.getClass(info.getName());
+				for (Class<?> o : (Set<Class<?>>) 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<JaxrsField> jaxrsInField(Class<?> clz) throws Exception {
+		List<JaxrsField> list = new ArrayList<>();
+		List<Field> fields = FieldUtils.getAllFieldsList(clz);
+		List<String> copierCopyFields = this.listCopierCopyFields(clz);
+		if (ListTools.isNotEmpty(copierCopyFields)) {
+			List<Field> 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(), "<String>", "<Boolean>", "<Date>", "<Integer>",
+							"<Double>", "<Long>", "<Float>")) {
+						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<JaxrsField> jaxrsOutField(Class<?> clz) throws Exception {
+		List<JaxrsField> list = new ArrayList<>();
+		List<Field> fields = FieldUtils.getAllFieldsList(clz);
+		List<String> copierEraseFields = this.listCopierEraseFields(clz);
+		if (ListTools.isNotEmpty(copierEraseFields)) {
+			List<Field> 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<K>");
+		List.add("Map");
+		List.add("Map<String,String>");
+		List.add("Map<String,Object>");
+		List.add("Map<K,V>");
+		List.add("byte[]");
+		List.add("Class");
+		List.add("Class[]");
+		List.add("Object");
+		List.add("String[]");
+		List.add("List<String>");
+		List.add("List<Date>");
+		List.add("List<Boolean>");
+		List.add("List<Long>");
+		List.add("List<Integer>");
+		List.add("List<Double>");
+		List.add("List<byte[]>");
+
+		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<Field> fields = FieldUtils.getAllFieldsList(clz);
+			    	List<JaxrsField> 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<JaxrsField> 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<String> 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<String> 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<JaxrsMethod> methods = new ArrayList<>();
+
+		public String getClassName() {
+			return className;
+		}
+
+		public void setClassName(String className) {
+			this.className = className;
+		}
+
+		public List<JaxrsMethod> getMethods() {
+			return methods;
+		}
+
+		public void setMethods(List<JaxrsMethod> 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<JaxrsPathParameter> pathParameters = new ArrayList<>();
+//		private List<JaxrsFormParameter> formParameters = new ArrayList<>();
+//		private List<JaxrsQueryParameter> queryParameters = new ArrayList<>();
+//		private List<JaxrsField> ins = new ArrayList<>();
+		private List<JaxrsField> 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<JaxrsField> getIns() {
+//			return ins;
+//		}
+//
+//		public void setIns(List<JaxrsField> ins) {
+//			this.ins = ins;
+//		}
+
+		public List<JaxrsField> getOuts() {
+			return outs;
+		}
+
+		public void setOuts(List<JaxrsField> 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<JaxrsPathParameter> getPathParameters() {
+//			return pathParameters;
+//		}
+//
+//		public void setPathParameters(List<JaxrsPathParameter> pathParameters) {
+//			this.pathParameters = pathParameters;
+//		}
+//
+//		public List<JaxrsFormParameter> getFormParameters() {
+//			return formParameters;
+//		}
+//
+//		public void setFormParameters(List<JaxrsFormParameter> formParameters) {
+//			this.formParameters = formParameters;
+//		}
+//
+//		public List<JaxrsQueryParameter> getQueryParameters() {
+//			return queryParameters;
+//		}
+//
+//		public void setQueryParameters(List<JaxrsQueryParameter> 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;
+		}
+
+	}
+
+}

+ 92 - 0
o2server/x_program_center/src/main/webapp/jest/listJsdoc.html

@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8" />
+<meta http-equiv="pragma" content="no-cache" />
+<script src="./jquery.min.js"></script>
+<script src="./common.js"></script>
+<style type="text/css">
+	<!--
+	body {
+		font-family: Arial, Helvetica, sans-serif;
+		font-size:12px;
+		color:#666666;
+		background:#fff;
+		text-align:left;
+	}
+	a {
+		color:#1E7ACE;
+		text-decoration:none; 
+	}
+	a:hover {
+		color:#000;
+		text-decoration:underline;
+	}
+	h3 {
+		font-size:14px;
+		font-weight:bold;
+	}
+	
+	pre,p {
+		color:#1E7ACE;
+		margin:4px;
+	}
+	
+	table { 
+		border-collapse: collapse;
+		margin: 0 auto;
+		text-align: left;
+	}
+	 
+	table td, table th {
+		border: 1px solid #cad9ea;
+		color: #666;
+		height: 30px;
+		padding-left:20px;
+		padding-right:60px;
+	}
+	 
+	table thead th {
+		background-color: #CCE8EB;
+		width: 100px;
+	}
+	 
+	table tr:nth-child(odd) {
+		background: #fff;
+	}
+	 
+	table tr:nth-child(even) {
+		background: #F5FAFA;
+	}
+	
+	-->
+</style>
+<script>
+
+function getUrlParam(name) {
+    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
+    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
+    if (r != null) return unescape(r[2]); return null; //返回参数值
+}
+var action = getUrlParam("action");
+$(function() {
+	   $.getJSON('../describe/jsdoc/"+action+".json?rd=' + Math.random(), function(json) {
+				var str = '<table border="1">';
+				str = str + "<tr><td>"
+				for(var key in json){
+					alert(key);
+					str = str + key;
+                }
+				str = str + "</td></tr>"
+				str += '</table>';
+				$('#content').html(str);
+			});
+  });
+</script>
+</head>
+
+<body style="font-size: 12px; font-family: Microsoft Yahei; margin: 0px">
+	<center id="title" style="font-size:32px; font-weight:bold">O2OA Table structure URL</center>	
+	<div id="content" style="margin-top:10px">&nbsp;</div>
+</body>
+</html>