提交 57fd068a 编写于 作者: O o2null

Merge branch 'fix/describejs0706' into 'develop'

Fix/describejs0706

See merge request o2oa/o2oa!1039

(cherry picked from commit 5e722127)

779c8aa4 '增加数据库表结构显示功能'
上级 409e84f0
......@@ -161,5 +161,5 @@ typings/
#pom.xml.versionsBackup
*.versionsBackup
/nbproject/private/
*netbean
**/nbproject/
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -75,7 +75,7 @@ public class ApiBuilder {
builder.scan(dir);
FileUtils.copyDirectory(sourcedir, new File(dir, "sources"));
//FileUtils.copyDirectory(sourcedir, new File(dir, "sources"));
}
......
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.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.OrderColumn;
import org.apache.openjpa.persistence.jdbc.ElementColumn;
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.openjpa.persistence.jdbc.ContainerTable;
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.annotation.DescribeBuilder.JaxrsMethod;
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 TableBuilder {
private static Logger logger = LoggerFactory.getLogger(TableBuilder.class);
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/table");
FileUtils.forceMkdir(dir);
TableBuilder builder = new TableBuilder();
builder.scan(dir,fileName);
}
private void scan(File dir,String fileName) {
try {
List<JaxrsClass> jaxrsClasses = new ArrayList<>();
List<Class<?>> classes = this.scanJaxrsClass();
for (Class<?> clz : classes) {
jaxrsClasses.add(this.jaxrsClass(clz));
}
LinkedHashMap<String, List<?>> map = new LinkedHashMap<>();
map.put("tables", jaxrsClasses);
File file = new File(dir, fileName + ".json");
FileUtils.writeStringToFile(file, XGsonBuilder.toJson(map), DefaultCharset.charset);
if (dir.isDirectory()) {
LinkedHashMap<String,String> mapList = new LinkedHashMap<>();
File[] fs = dir.listFiles();
for(File f:fs){
if(f.isFile()) {
String fileNameJosn = f.getName();
if(!fileNameJosn.equalsIgnoreCase("tableList.json")) {
mapList.put(fileNameJosn.substring(0,fileNameJosn.lastIndexOf(".")), fileNameJosn);
}
}
}
File fileList = new File(dir, "tableList.json");
FileUtils.writeStringToFile(fileList, XGsonBuilder.toJson(mapList), 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(Entity.class.getName())) {
Class<?> o = ClassUtils.getClass(info.getName());
Entity entity = o.getAnnotation(Entity.class);
if (null != entity) {
classes.add(o);
}
}
return classes;
}
}
private JaxrsClass jaxrsClass(Class<?> clz) throws Exception {
logger.print("describe class:{}.", clz.getName());
Table table = clz.getAnnotation(Table.class);
JaxrsClass jaxrsClass = new JaxrsClass();
jaxrsClass.setModuleName(clz.getSimpleName());
jaxrsClass.setTableName(table.name());
for (Field field : clz.getDeclaredFields()) {
Column column = field.getAnnotation(Column.class);
FieldDescribe fieldDescribe = field.getAnnotation(FieldDescribe.class);
Lob lob = field.getAnnotation(Lob.class);
ContainerTable containerTable = field.getAnnotation(ContainerTable.class);
if (null != column) {
ColumnProperty columnElement = new ColumnProperty();
columnElement.setName(column.name());
if(lob != null) {
columnElement.setType("Lob");
}else {
columnElement.setType(javaTypeToSqlType(field.getType().getCanonicalName()));
}
columnElement.setLength(column.length()+"");
columnElement.setRemark(fieldDescribe.value());
jaxrsClass.getColumn().add(columnElement);
}else {
//关联表
if(null != containerTable) {
ColumnProperty columnElement = new ColumnProperty();
columnElement.setName(field.getName());
columnElement.setType("ContainerTable");
columnElement.setLength("");
columnElement.setRemark(fieldDescribe.value());
ContainerTableProperty containerTableProperty = new ContainerTableProperty();
containerTableProperty.setName(containerTable.name());
ContainerTableColumnProperty idColumnProperty= new ContainerTableColumnProperty();
idColumnProperty.setName(clz.getSimpleName() + "_XID");
idColumnProperty.setType("VARCHAR");
idColumnProperty.setRemark("主键");;
containerTableProperty.getContainerTableColumnProperty().add(idColumnProperty);
OrderColumn orderColumn = field.getAnnotation(OrderColumn.class);
if(null != orderColumn) {
ContainerTableColumnProperty orderColumnProperty= new ContainerTableColumnProperty();
orderColumnProperty.setName(orderColumn.name());
orderColumnProperty.setType("INTEGER");
orderColumnProperty.setRemark("排序");;
containerTableProperty.getContainerTableColumnProperty().add(orderColumnProperty);
}
ElementColumn elementColumn = field.getAnnotation(ElementColumn.class);
if(null != elementColumn) {
ContainerTableColumnProperty elementColumnProperty= new ContainerTableColumnProperty();
elementColumnProperty.setName(elementColumn.name());
elementColumnProperty.setType("VARCHAR");
elementColumnProperty.setRemark("值");
elementColumnProperty.setLength(elementColumn.length()+"");
containerTableProperty.getContainerTableColumnProperty().add(elementColumnProperty);
}
columnElement.setContainerTable(containerTableProperty);
jaxrsClass.getColumn().add(columnElement);
}
}
}
return jaxrsClass;
}
private String javaTypeToSqlType(String javaType) {
String sqlTye = javaType;
if(javaType.equalsIgnoreCase("java.lang.String")) {
sqlTye = "VARCHAR";
}else if(javaType.equalsIgnoreCase("java.lang.byte[]")) {
sqlTye = "BLOB";
}else if(javaType.equalsIgnoreCase("java.lang.Long")) {
sqlTye = "INTEGER";
}else if(javaType.equalsIgnoreCase("java.lang.Integer")) {
sqlTye = "INTEGER";
}else if(javaType.equalsIgnoreCase("java.math.BigInteger")) {
sqlTye = "BIGINT";
}else if(javaType.equalsIgnoreCase("java.lang.Float")) {
sqlTye = "FLOAT";
}else if(javaType.equalsIgnoreCase("java.lang.Double")) {
sqlTye = "DOUBLE";
}else if(javaType.equalsIgnoreCase("java.math.BigDecimal")) {
sqlTye = "DECIMAL";
}else if(javaType.equalsIgnoreCase("java.lang.Integer")) {
sqlTye = "DECIMAL";
}else if(javaType.equalsIgnoreCase("java.sql.Date") || javaType.equalsIgnoreCase("java.util.Date")) {
sqlTye = "DATE";
}else if(javaType.equalsIgnoreCase("java.sql.Time")) {
sqlTye = "TIME";
}else if(javaType.equalsIgnoreCase("java.sql.Timestamp")) {
sqlTye = "DATETIME";
}else if(javaType.equalsIgnoreCase("java.lang.Boolean")) {
sqlTye = "BOOLEAN";
}
return sqlTye;
}
public class JaxrsClass {
private String moduleName;
private String tableName;
private List<ColumnProperty> columnProperty = new ArrayList<>();
public String getModuleName() {
return moduleName;
}
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public List<ColumnProperty> getColumn() {
return columnProperty;
}
public void setColumn(List<ColumnProperty> columnProperty) {
this.columnProperty = columnProperty;
}
}
public class ColumnProperty{
private String name;
private String type;
private String length;
private String remark;
private ContainerTableProperty containerTableProperty;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getLength() {
return length;
}
public void setLength(String length) {
this.length = length;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public ContainerTableProperty getContainerTable() {
return containerTableProperty;
}
public void setContainerTable(ContainerTableProperty containerTableProperty) {
this.containerTableProperty = containerTableProperty;
}
}
public class ContainerTableProperty{
private String name;
private String remark;
private List<ContainerTableColumnProperty> containerTableColumnProperty = new ArrayList<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public List<ContainerTableColumnProperty> getContainerTableColumnProperty() {
return containerTableColumnProperty;
}
public void setContainerTableColumnProperty(List<ContainerTableColumnProperty> containerTableColumnProperty) {
this.containerTableColumnProperty = containerTableColumnProperty;
}
}
public class ContainerTableColumnProperty{
private String name;
private String type;
private String length;
private String remark;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getLength() {
return length;
}
public void setLength(String length) {
this.length = length;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
}
\ No newline at end of file
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -23,6 +23,24 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -27,6 +27,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -27,6 +27,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
var Describe = function() {
// 20180730
}
Describe.splitValue = function(str) {
if (str) {
if (str.length > 0) {
return str.split(',');
}
}
return [];
}
Describe.joinValue = function(o, split) {
var s = ',';
if (split) {
s = '' + split;
}
if (o) {
if (toString.apply(o) === '[object Array]') {
return o.join(s);
}
}
return o;
}
Describe.getUrlParam = function(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null; //返回参数值
}
Describe.prototype = {
"load" : function() {
var str = '<ul>';
//var url = '../describe/table/x_calendar_core_entity.json';
var url = '../describe/table/'+ Describe.getUrlParam("param");
$.getJSON(url+'?rd=' + Math.random(), function(json) {
Describe.json = json;
$.each(json.tables, function(ji, j) {
str += '<li xtype="menu" ' + 'style="margin-top: 30px;font-size:14px;font-weight:bold;"title="' +'" ><a id ="' + j.tableName + '_' + j.moduleName + '" href="#">' + "表:" +j.tableName + ' </a><span style="font-style:italic">(类:' + j.moduleName+ ')</span>';
str += '</li>'
});
str += '</ul>';
$("#menu").html(str);
$.each(json.tables, function(mi, m) {
$('#' + m.tableName + '_' + m.moduleName).click(
function() {
$('#result').html('');
var txt = "";
txt += '<table>';
txt += '<tr><td width ="3%"><b>序号</b></td><td width ="10%"><b>列名</b></td><td width ="5%"><b>类型</b></td><td width ="5%"><b>长度</b></td><td width ="*"><b>用途</b></td></tr>';
$.each(m.columnProperty, function(ci, c) {
if(c.type == "ContainerTable"){
txt += '<tr><td>'+(ci+1)+'</td><td>'+c.name+'</td><td>'+c.type+'</td><td>'+c.length+'</td><td>'+c.remark+ "("+ c.containerTableProperty.name+')</td><td>'
txt +='</td></tr>';
txt += '<tr><td></td><td colspan="4"><table><tr><td width ="3%"><b>序号</b></td><td width ="8%"><b>列名</b></td><td width ="5%"><b>类型</b></td><td width ="*"><b>用途</b></td></tr>';
$.each(c.containerTableProperty.containerTableColumnProperty, function(cti, ct) {
txt += '<tr><td>'+(cti+1)+'</td><td>'+ct.name+'</td><td>'+ct.type+'</td><td>'+ct.remark+'</td></tr>';
});
txt +='</table></td></tr>';
}else{
txt += '<tr><td>'+(ci+1)+'</td><td>'+c.name+'</td><td>'+c.type+'</td><td>'+c.length+'</td><td>'+c.remark+'</td><td></td></tr>';
}
});
txt += '</table>';
$('#result').html(txt);
});
});
$("[xtype='menu']").click(
function(event) {
if(event.stopPropagation){
event.stopPropagation();
}else{
event.cancelBubble = true;
}
$(this).children().each(function(i){
debugger;
//if(this.tagName != "SPAN"){
//$(this).toggle();
//}
});
});
$("[xtype='li']").click( function(event) {
if(event.stopPropagation){
event.stopPropagation();
}else{
event.cancelBubble = true;
}
})
$("[xtype='menu']").each(function(i){
if(i!=0){
$(this).children().each(function(i){
//if(this.tagName != "SPAN"){
//$(this).toggle();
//}
});
}
}
);
});
}
}
<!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>
var appMap = new Map();
appMap.set("x_attendance_core_entity", "考勤相关");
appMap.set("x_bbs_core_entity", "论坛相关");
appMap.set("x_calendar_core_entity", "日程管理相关");
appMap.set("x_component_core_entity", "组件管理相关");
appMap.set("x_file_core_entity", "云文件相关");
appMap.set("x_general_core_entity","常用功能相关");
appMap.set("x_hotpic_core_entity", "热点信息相关");
appMap.set("x_jpush_core_entity", "极光推送");
appMap.set("x_meeting_core_entity", "会议管理相关");
appMap.set("x_message_core_entity", "消息通信相关");
appMap.set("x_mind_core_entity", "脑图模块相关");
appMap.set("x_okr_core_entity", "执行力相关");
appMap.set("x_organization_core_entity", "组织管理相关");
appMap.set("x_portal_core_entity", "门户");
appMap.set("x_teamwork_core_entity", "团队");
$(function() {
$.getJSON('../describe/table/tableList.json?rd=' + Math.random(), function(json) {
var str = '<table border="1">';
for(var key in json){
str += '<tr>';
if(typeof(appMap.get(key)) == "undefined"){
str += '<td>' + '</td>';
}else{
str += '<td>' + appMap.get(key) + '</td>';
}
str += '<td>' + key + '</td>';
str += '<td>';
var url = "./listTableDetail.html?param="+ json[key]
str += '<a href="'+url+'" target="_blank">' + json[key] + '</a><br/>'; ;
str += '</td>';
str += '</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>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<script src="./jquery.min.js"></script>
<script src="./clipboard.min.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;
}
input, select,textarea {
padding:1px;
margin:2px;
font-size:11px;
}
fieldset {
padding:10px;
margin-top:10px;
border:1px solid #A4CDF2;
background:#fff;
}
fieldset legend {
color:#1E7ACE;
font-weight:bold;
padding:3px 20px 3px 20px;
border:1px solid #A4CDF2;
background:#fff;
}
input {
border:1px solid #A4CDF2;
}
button {
border:1px solid #A4CDF2;
background-color : #FFFFFF;
height:25px;
margin-top:10px;
font-weight:bold;
color:#1E7ACE;
}
-->
</style>
<script>
var describe;
$.getScript('./describeTable.js?rd=' + Math.random()).then(function() {
describe = new Describe();
describe.load();
}).catch( function() {
alert('get describe error.');
});
$(document).ready(function(){
var clipboard = new Clipboard("#btn_copy");
$('#butSearch').click(function() {
var strKey = $('#inpSearch').val();
if(strKey == ""){
window.location.reload();
}else{
describe.search(strKey);
}
})
$('#inpSearch').bind('keyup', function(event) {
   if (event.keyCode == "13") {
     $('#butSearch').click();
   }
});
});
</script>
</head>
<body style="font-size: 12px; font-family: Microsoft Yahei; margin: 0px;border-image: linear-gradient(#ffffff, #e7e7e7 15%, #e7e7e7 100%, #ffffff);box-shadow: inset 15px 0 5px -16px #e7e7e7;background-image: -webkit-radial-gradient(right, #f2f2f2, #ffffff 100%);">
<table style="width: 1800px; margin: 0 auto">
<tr>
<td style="width: 350px;" valign="top">
<fieldset>
<legend>table List</legend>
<div id="menu" style="height: 850px; overflow: auto;">&nbsp;</div>
</fieldset>
</td>
<td valign="top">
<!--<fieldset>
<legend>Content</legend>
<div id="content"
style="white-space: pre; font-size: 12px; word-break: break-all; word-wrap: break-word">&nbsp;</div>
</fieldset> -->
<div id="content"
style="white-space: pre; font-size: 12px; word-break: break-all; word-wrap: break-word;border-image: linear-gradient(#ffffff, #e7e7e7 15%, #e7e7e7 100%, #ffffff);box-shadow: inset 15px 0 5px -16px #e7e7e7;background-image: -webkit-radial-gradient(right, #f2f2f2, #ffffff 100%);">&nbsp;</div>
<fieldset>
<legend>
字段列表&nbsp;<a id="btn_copy" href="javascript:" data-clipboard-target="#result">copy</a>&nbsp;
</legend>
<div id="result"
style="white-space: pre; font-size: 12px; word-break: break-all; word-wrap: break-word; width: 1400px">&nbsp;</div>
</fieldset>
</td>
</tr>
</table>
</body>
</html>
\ No newline at end of file
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
......@@ -23,6 +23,23 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>TableBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.TableBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>metaModelBuilder</id>
<phase>generate-sources</phase>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册