|
@@ -37,12 +37,14 @@ export default {
|
|
|
backgroundColor: "#e1e4e5",
|
|
|
color: "#2b2b2b",
|
|
|
lineHeight: "30px"
|
|
|
- } // 列表样式
|
|
|
+ }, // 列表样式
|
|
|
+ urlObj: {} // 路径参数
|
|
|
};
|
|
|
},
|
|
|
components: {},
|
|
|
created: function() {
|
|
|
this.getData();
|
|
|
+ this.getUrlData();
|
|
|
},
|
|
|
mounted: function() {
|
|
|
// alert(this.schema);
|
|
@@ -63,6 +65,7 @@ export default {
|
|
|
//生成实体类
|
|
|
genEntrty() {
|
|
|
let strBuild = new SStringBuilder();
|
|
|
+ const table = this.toHump(this.table);
|
|
|
strBuild.append(
|
|
|
`package cn.sagacloud.server.datacenter.models.entities
|
|
|
|
|
@@ -82,8 +85,8 @@ import javax.persistence.Table
|
|
|
* @author 自动生成
|
|
|
*/
|
|
|
@ApiModel(description = "资产信息实体类")
|
|
|
-@Table(name = "${this.schema}.${this.table}")
|
|
|
-open class ${this.toHump(this.table)} : BaseInfo(),Comparator<${this.toHump(this.table)}> {
|
|
|
+@Table(name = "${this.schema}.${table}")
|
|
|
+open class ${table} : BaseInfo(),Comparator<${table}> {
|
|
|
`
|
|
|
);
|
|
|
this.tableData.forEach(element => {
|
|
@@ -98,19 +101,130 @@ open class ${this.toHump(this.table)} : BaseInfo(),Comparator<${this.toHump(this
|
|
|
);
|
|
|
}
|
|
|
strBuild.append(` @Column(name = "${element.ColumnName}")`);
|
|
|
- strBuild.append(` var ${this.toHump(element.ColumnName)}: ${this.typeToName(element.ColumnType)}? = null\n`);
|
|
|
+ strBuild.append(
|
|
|
+ ` var ${this.toHump(element.ColumnName)}: ${this.typeToName(
|
|
|
+ element.ColumnType
|
|
|
+ )}? = null\n`
|
|
|
+ );
|
|
|
});
|
|
|
|
|
|
- strBuild.append(`} // Class ${this.toHump(this.table)}`);
|
|
|
- this.download(`${this.toHump(this.table)}.kt`,strBuild.toString())
|
|
|
+ strBuild.append(`} // Class ${table}`);
|
|
|
+ this.download(`${table}.kt`, strBuild.toString());
|
|
|
},
|
|
|
//生成接口类
|
|
|
genControler() {
|
|
|
- this.tableData;
|
|
|
+ let strBuild = new SStringBuilder();
|
|
|
+ const className = `${this.toHump(this.urlObj.urlType)}Controller`;
|
|
|
+ strBuild.append(`package cn.sagacloud.server.datacenter.controllers
|
|
|
+
|
|
|
+import cn.sagacloud.server.datacenter.models.entities.Property
|
|
|
+import cn.sagacloud.server.datacenter.services.PropertyService
|
|
|
+import com.sybotan.base.extensions.toJson
|
|
|
+import com.sybotan.database.SFilter
|
|
|
+import com.sybotan.service.SPageContext
|
|
|
+import com.sybotan.service.models.requests.SCountRequest
|
|
|
+import com.sybotan.service.models.requests.SCreateRequest
|
|
|
+import com.sybotan.service.models.requests.SQueryRequest
|
|
|
+import com.sybotan.service.models.requests.SUpdateRequest
|
|
|
+import com.sybotan.service.models.responses.SBaseResponse
|
|
|
+import com.sybotan.service.models.responses.SCountResponse
|
|
|
+import com.sybotan.service.models.responses.SCreateResponse
|
|
|
+import com.sybotan.service.models.responses.SQueryResponse
|
|
|
+import io.swagger.annotations.Api
|
|
|
+import io.swagger.annotations.ApiOperation
|
|
|
+import org.slf4j.LoggerFactory
|
|
|
+import org.springframework.web.bind.annotation.PostMapping
|
|
|
+import org.springframework.web.bind.annotation.RequestBody
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping
|
|
|
+import org.springframework.web.bind.annotation.RestController
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * ${this.urlObj.urlName}接口
|
|
|
+ *
|
|
|
+ * @author 自动生成
|
|
|
+ */
|
|
|
+@Api(tags = ["${this.urlObj.urlName}"])
|
|
|
+@RestController
|
|
|
+@RequestMapping("/object/${this.urlObj.urlType}")
|
|
|
+open class ${className} {
|
|
|
+ companion object {
|
|
|
+ /** 日志 */
|
|
|
+ private val logger = LoggerFactory.getLogger(${className}::class.java)
|
|
|
+ } // Companion object
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建${this.urlObj.urlName}
|
|
|
+ *
|
|
|
+ * @param request ${this.urlObj.urlName}对象列表
|
|
|
+ * @return 创建结果信息
|
|
|
+ */
|
|
|
+ @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)}> {
|
|
|
+
|
|
|
+ return PropertyService.createList( request)
|
|
|
+ } // Function create()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id删除${this.urlObj.urlName}
|
|
|
+ *
|
|
|
+ * @param idList id数组
|
|
|
+ * @return 删除的结果信息
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "根据id删除${this.urlObj.urlName}信息", notes = "")
|
|
|
+ @PostMapping(value = ["/delete"])
|
|
|
+ fun delete(@RequestBody idList: ArrayList<${this.typeToName(
|
|
|
+ this.urlObj.urlType
|
|
|
+ )}>): SBaseResponse {
|
|
|
+ return PropertyService.deleteByKeysList(idList)
|
|
|
+ } // Function delete()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新${this.urlObj.urlName}信息
|
|
|
+ *
|
|
|
+ * @param request 更新的内容对象
|
|
|
+ * @return 更新的结果
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "更新${this.urlObj.urlName}信息", notes = "")
|
|
|
+ @PostMapping(value = ["/update"])
|
|
|
+ fun update(@RequestBody request: SUpdateRequest<${this.typeToName(
|
|
|
+ this.urlObj.urlType
|
|
|
+ )}>): SBaseResponse {
|
|
|
+ return PropertyService.updateList(request)
|
|
|
+ } // Function update()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询${this.urlObj.urlName}信息
|
|
|
+ *
|
|
|
+ * @param request 查询信息条件
|
|
|
+ * @return 查询结果
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "查询${this.urlObj.urlName}信息", notes="")
|
|
|
+ @PostMapping(value = ["/query"])
|
|
|
+ fun query(@RequestBody request: SQueryRequest): SQueryResponse<${this.typeToName(
|
|
|
+ this.urlObj.urlType
|
|
|
+ )}> {
|
|
|
+ return PropertyService.pageQuery(request)
|
|
|
+ } // Function query()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据条件查询统计数量
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "根据条件查询统计数量", notes = "")
|
|
|
+ @PostMapping(value = ["/count"])
|
|
|
+ fun count(@RequestBody request: SCountRequest): SCountResponse {
|
|
|
+ return PropertyService.count(request)
|
|
|
+ } // Function count()
|
|
|
+ `);
|
|
|
+ strBuild.append(`} // Class ${className}`);
|
|
|
+ this.download(`${className}.kt`, strBuild.toString());
|
|
|
},
|
|
|
// 数据包类型到实体类的转换
|
|
|
typeToName(name) {
|
|
|
- const obj = {
|
|
|
+ const obj = {
|
|
|
varchar: "String",
|
|
|
char: "String",
|
|
|
timestamptz: "Date",
|
|
@@ -121,7 +235,7 @@ open class ${this.toHump(this.table)} : BaseInfo(),Comparator<${this.toHump(this
|
|
|
date: "Date",
|
|
|
int2: "Int",
|
|
|
json: "HashMap<String, Any?>",
|
|
|
- jsonb:"HashMap<String, Any?>"
|
|
|
+ jsonb: "HashMap<String, Any?>"
|
|
|
};
|
|
|
if (name) {
|
|
|
return obj[name] ? obj[name] : "String";
|
|
@@ -130,22 +244,34 @@ open class ${this.toHump(this.table)} : BaseInfo(),Comparator<${this.toHump(this
|
|
|
}
|
|
|
},
|
|
|
//转驼峰
|
|
|
- toHump(name){
|
|
|
- return name
|
|
|
+ toHump(name) {
|
|
|
+ return name;
|
|
|
+ },
|
|
|
+ // 获取路径名称以及路径type
|
|
|
+ getUrlData() {
|
|
|
+ const dataArr = window.location.href.split("#")[1].split("-");
|
|
|
+ const obj = {
|
|
|
+ urlType: dataArr[1],
|
|
|
+ urlName: decodeURIComponent(dataArr[0])
|
|
|
+ };
|
|
|
+ this.urlObj = obj;
|
|
|
},
|
|
|
// 下载文件
|
|
|
- download(filename, text) {
|
|
|
- var element = document.createElement('a');
|
|
|
- element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
|
|
|
- element.setAttribute('download', filename);
|
|
|
+ download(filename, text) {
|
|
|
+ var element = document.createElement("a");
|
|
|
+ element.setAttribute(
|
|
|
+ "href",
|
|
|
+ "data:text/plain;charset=utf-8," + encodeURIComponent(text)
|
|
|
+ );
|
|
|
+ element.setAttribute("download", filename);
|
|
|
|
|
|
- element.style.display = 'none';
|
|
|
- document.body.appendChild(element);
|
|
|
+ element.style.display = "none";
|
|
|
+ document.body.appendChild(element);
|
|
|
|
|
|
- element.click();
|
|
|
+ element.click();
|
|
|
|
|
|
- document.body.removeChild(element);
|
|
|
-}
|
|
|
+ document.body.removeChild(element);
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|