瀏覽代碼

Merge remote-tracking branch 'origin/master' into master

zhangweixin 4 年之前
父節點
當前提交
fb982e469a
共有 1 個文件被更改,包括 46 次插入19 次删除
  1. 46 19
      docs/.vuepress/components/TableDesig.vue

+ 46 - 19
docs/.vuepress/components/TableDesig.vue

@@ -44,7 +44,7 @@ export default {
   components: {},
   created: function() {
     this.getData();
-    this.getUrlData();
+    // this.getUrlData();
   },
   mounted: function() {
     // alert(this.schema);
@@ -64,8 +64,9 @@ export default {
     },
     //生成实体类
     genEntrty() {
+      this.getUrlData();
       let strBuild = new SStringBuilder();
-      const table = this.toHump(this.table);
+      const table = this.toHump(this.urlObj.urlType);
       strBuild.append(
         `package cn.sagacloud.server.datacenter.models.entities
 
@@ -80,12 +81,12 @@ import javax.persistence.Id
 import javax.persistence.Table
 
 /**
- * 资产信息实体类
+ * ${this.urlObj.urlName}信息实体类
  *
  * @author  自动生成
  */
 @ApiModel(description = "资产信息实体类")
-@Table(name = "${this.schema}.${table}")
+@Table(name = "${this.schema}.${this.urlObj.urlType}")
 open class ${table} : BaseInfo(),Comparator<${table}> {
 `
       );
@@ -102,7 +103,7 @@ open class ${table} : BaseInfo(),Comparator<${table}> {
         }
         strBuild.append(`    @Column(name = "${element.ColumnName}")`);
         strBuild.append(
-          `    var ${this.toHump(element.ColumnName)}: ${this.typeToName(
+          `    var ${this.toSmallHump(element.ColumnName)}: ${this.typeToName(
             element.ColumnType
           )}? = null\n`
         );
@@ -113,6 +114,7 @@ open class ${table} : BaseInfo(),Comparator<${table}> {
     },
     //生成接口类
     genControler() {
+      this.getUrlData();
       let strBuild = new SStringBuilder();
       const className = `${this.toHump(this.urlObj.urlType)}Controller`;
       strBuild.append(`package cn.sagacloud.server.datacenter.controllers
@@ -161,9 +163,9 @@ open class ${className} {
      */
     @ApiOperation(value = "创建${this.urlObj.urlName}信息", notes = "")
     @PostMapping(value = ["/create"])
-    fun create(@RequestBody request: SCreateRequest<${this.typeToName(
-      this.urlObj.urlType
-    )}>): SCreateResponse<${this.typeToName(this.urlObj.urlType)}> {
+    fun create(@RequestBody request: SCreateRequest<${this.toHump(
+      this.table
+    )}>): SCreateResponse<${this.toHump(this.table)}> {
 
         return PropertyService.createList( request)
     } // Function create()
@@ -176,8 +178,8 @@ open class ${className} {
      */
     @ApiOperation(value = "根据id删除${this.urlObj.urlName}信息", notes = "")
     @PostMapping(value = ["/delete"])
-    fun delete(@RequestBody idList: ArrayList<${this.typeToName(
-      this.urlObj.urlType
+    fun delete(@RequestBody idList: ArrayList<${this.toHump(
+      this.table
     )}>): SBaseResponse {
         return PropertyService.deleteByKeysList(idList)
     } // Function delete()
@@ -190,8 +192,8 @@ open class ${className} {
      */
     @ApiOperation(value = "更新${this.urlObj.urlName}信息", notes = "")
     @PostMapping(value = ["/update"])
-    fun update(@RequestBody request: SUpdateRequest<${this.typeToName(
-      this.urlObj.urlType
+    fun update(@RequestBody request: SUpdateRequest<${this.toHump(
+      this.table
     )}>): SBaseResponse {
         return PropertyService.updateList(request)
     } // Function update()
@@ -204,8 +206,8 @@ open class ${className} {
      */
     @ApiOperation(value = "查询${this.urlObj.urlName}信息", notes="")
     @PostMapping(value = ["/query"])
-    fun query(@RequestBody request: SQueryRequest): SQueryResponse<${this.typeToName(
-      this.urlObj.urlType
+    fun query(@RequestBody request: SQueryRequest): SQueryResponse<${this.toHump(
+      this.table
     )}> {
         return PropertyService.pageQuery(request)
     } // Function query()
@@ -220,7 +222,8 @@ open class ${className} {
     } // Function count()
     `);
       strBuild.append(`} // Class ${className}`);
-      this.download(`${className}.kt`, strBuild.toString());
+      console.log("className", className);
+      //   this.download(`${className}.kt`, strBuild.toString());
     },
     // 数据包类型到实体类的转换
     typeToName(name) {
@@ -251,13 +254,37 @@ open class ${className} {
       }
       return arr.join("");
     },
+    //转小驼峰
+    toSmallHump(str) {
+      var arr = str.split("_");
+      for (var i = 1; i < arr.length; i++) {
+        arr[i] = arr[i].charAt(0).toUpperCase() + arr[i].substring(1);
+      }
+      return arr.join("");
+    },
     // 获取路径名称以及路径type
     getUrlData() {
       const dataArr = window.location.href.split("#")[1].split("-");
-      const obj = {
-        urlType: dataArr[1],
-        urlName: decodeURIComponent(dataArr[0])
-      };
+      let obj = {};
+      if (dataArr.length == 2) {
+        obj = {
+          urlType: dataArr[1],
+          urlName: decodeURIComponent(dataArr[0])
+        };
+      } else {
+        let urlName = "";
+        let lengthNum = dataArr.length;
+        dataArr.forEach((item, i) => {
+          if (i + 2 <= lengthNum) {
+            urlName = urlName + "-" + item;
+          }
+        });
+        obj = {
+          urlType: dataArr[lengthNum-1],
+          urlName: decodeURIComponent(urlName)
+        };
+      }
+
       this.urlObj = obj;
     },
     // 下载文件