From 3eafab829244f648c62bcdfdfd558d0baccc3282 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Sun, 10 Apr 2022 12:38:26 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E6=96=B0?=
=?UTF-8?q?=E5=A2=9E=E6=9D=83=E9=99=90=E5=8F=AF=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ZR.CodeGenerator/CodeGeneratorTool.cs | 2 +-
ZR.Model/System/Dto/GenTableDto.cs | 2 +
ZR.Model/System/Generate/GenTable.cs | 2 +
ZR.Service/System/GenTableService.cs | 18 ++-
ZR.Vue/src/views/tool/gen/editTable.vue | 134 +++++++++--------
ZR.Vue/src/views/tool/gen/genInfoForm.vue | 115 +++++++-------
ZR.Vue/src/views/tool/gen/index.vue | 174 +++++++++++-----------
7 files changed, 237 insertions(+), 210 deletions(-)
diff --git a/ZR.CodeGenerator/CodeGeneratorTool.cs b/ZR.CodeGenerator/CodeGeneratorTool.cs
index 8b09e05..915aac3 100644
--- a/ZR.CodeGenerator/CodeGeneratorTool.cs
+++ b/ZR.CodeGenerator/CodeGeneratorTool.cs
@@ -44,7 +44,7 @@ namespace ZR.CodeGenerator
string PKType = "int";
ReplaceDto replaceDto = new();
replaceDto.ModelTypeName = dto.GenTable.ClassName;//表名对应C# 实体类名
- replaceDto.PermissionPrefix = $"{dto.GenTable.ModuleName.ToLower()}:{dto.GenTable.ClassName.ToLower()}";//权限
+ replaceDto.PermissionPrefix = dto.GenTable.PermissionPrefix;
replaceDto.Author = dto.GenTable.FunctionAuthor;
replaceDto.ShowBtnAdd = dto.GenTable.CheckedBtn.Any(f => f == 1);
replaceDto.ShowBtnEdit = dto.GenTable.CheckedBtn.Any(f => f == 2);
diff --git a/ZR.Model/System/Dto/GenTableDto.cs b/ZR.Model/System/Dto/GenTableDto.cs
index a0fc883..c4137ae 100644
--- a/ZR.Model/System/Dto/GenTableDto.cs
+++ b/ZR.Model/System/Dto/GenTableDto.cs
@@ -21,6 +21,7 @@ namespace ZR.Model.System.Dto
public string FunctionAuthor { get; set; }
public string GenType { get; set; }
public string GenPath { get; set; }
+ public string PermissionPrefix { get; set; }
///
/// 额外参数
///
@@ -44,6 +45,7 @@ namespace ZR.Model.System.Dto
/// 额外参数字符串
///
public string checkedBtn { get; set; }
+ public string permissionPrefix { get; set; }
}
public class GenTableColumnDto
{
diff --git a/ZR.Model/System/Generate/GenTable.cs b/ZR.Model/System/Generate/GenTable.cs
index 1dfea22..a50f585 100644
--- a/ZR.Model/System/Generate/GenTable.cs
+++ b/ZR.Model/System/Generate/GenTable.cs
@@ -96,6 +96,8 @@ namespace ZR.Model.System.Generate
[SqlSugar.SugarColumn(IsIgnore = true)]
public object TreeParentCode { get; set; }
+ [SqlSugar.SugarColumn(IsIgnore = true)]
+ public string PermissionPrefix { get; set; }
///
/// 生成的按钮功能
///
diff --git a/ZR.Service/System/GenTableService.cs b/ZR.Service/System/GenTableService.cs
index 40b3657..3a5afa0 100644
--- a/ZR.Service/System/GenTableService.cs
+++ b/ZR.Service/System/GenTableService.cs
@@ -45,7 +45,7 @@ namespace ZR.Service.System
///
public int DeleteGenTableByTbName(string tableName)
{
- return GenTableRepository.Delete(f => f.TableName == tableName) ? 1: 0;
+ return GenTableRepository.Delete(f => f.TableName == tableName) ? 1 : 0;
}
///
@@ -83,16 +83,24 @@ namespace ZR.Service.System
if (options == null) return;
genTable.ParentMenuId = options.GetValueOrDefault("parentMenuId") ?? null;
-
+
genTable.SortType = options.GetValueOrDefault("sortType") ?? "asc";
genTable.SortField = options.GetValueOrDefault("sortField") ?? "";
genTable.TreeParentCode = options.GetValueOrDefault("treeParentCode") ?? "";
genTable.TreeName = options.GetValueOrDefault("treeName") ?? "";
genTable.TreeCode = options.GetValueOrDefault("treeCode") ?? "";
-
+
var checkdBtn = options.GetValueOrDefault("checkedBtn") ?? "";
genTable.CheckedBtn = Tools.SpitIntArrary(checkdBtn.ToString());
+
+ var permPrefix = options.GetValueOrDefault("permissionPrefix", "");
+
+ genTable.PermissionPrefix = permPrefix?.ToString();
+ }
+ if (genTable.PermissionPrefix.IsEmpty())
+ {
+ genTable.PermissionPrefix = $"{genTable.ModuleName.ToLower()}:{genTable.ClassName.ToLower()}";//权限
}
}
@@ -102,7 +110,7 @@ namespace ZR.Service.System
///
///
///
- public PagedInfo GetGenTables(GenTable genTable, Model.PagerInfo pagerInfo)
+ public PagedInfo GetGenTables(GenTable genTable, PagerInfo pagerInfo)
{
var predicate = Expressionable.Create();
predicate = predicate.AndIF(genTable.TableName.IfNotEmpty(), it => it.TableName.Contains(genTable.TableName));
@@ -165,7 +173,7 @@ namespace ZR.Service.System
GenTableColumnService.Insert(insertColumns);
List delColumns = tableColumns.FindAll(column => !dbTableColumneNames.Contains(column.ColumnName));
- if (delColumns!= null && delColumns.Count > 0)
+ if (delColumns != null && delColumns.Count > 0)
{
GenTableColumnService.Delete(delColumns.Select(f => f.ColumnId).ToList());
}
diff --git a/ZR.Vue/src/views/tool/gen/editTable.vue b/ZR.Vue/src/views/tool/gen/editTable.vue
index 0ddc246..d4d4a89 100644
--- a/ZR.Vue/src/views/tool/gen/editTable.vue
+++ b/ZR.Vue/src/views/tool/gen/editTable.vue
@@ -27,7 +27,7 @@
-
+
@@ -117,25 +117,25 @@
diff --git a/ZR.Vue/src/views/tool/gen/genInfoForm.vue b/ZR.Vue/src/views/tool/gen/genInfoForm.vue
index e95184a..cee1e85 100644
--- a/ZR.Vue/src/views/tool/gen/genInfoForm.vue
+++ b/ZR.Vue/src/views/tool/gen/genInfoForm.vue
@@ -75,11 +75,7 @@
-
-
- 查询排序字段
-
-
+
@@ -89,7 +85,17 @@
倒序
-
+
+
+
+ 权限前缀
+
+
+
+
+
+
+
@@ -224,32 +230,32 @@
diff --git a/ZR.Vue/src/views/tool/gen/index.vue b/ZR.Vue/src/views/tool/gen/index.vue
index 7cd9614..db22125 100644
--- a/ZR.Vue/src/views/tool/gen/index.vue
+++ b/ZR.Vue/src/views/tool/gen/index.vue
@@ -68,29 +68,29 @@ import {
listTable,
delTable,
previewTable,
- synchDb,
-} from "@/api/tool/gen";
-import importTable from "./importTable";
-import { Loading } from "element-ui";
-import hljs from "highlight.js";
-import "highlight.js/styles/idea.css"; //这里有多个样式,自己可以根据需要切换
+ synchDb
+} from '@/api/tool/gen'
+import importTable from './importTable'
+import { Loading } from 'element-ui'
+import hljs from 'highlight.js'
+import 'highlight.js/styles/idea.css' // 这里有多个样式,自己可以根据需要切换
export default {
- name: "gen",
+ name: 'gen',
components: { importTable, hljs },
data() {
return {
queryParams: {
pageNum: 1,
pageSize: 20,
- tableName: "",
+ tableName: ''
},
// 预览参数
preview: {
open: false,
- title: "代码预览",
+ title: '代码预览',
data: {},
- activeName: "0",
+ activeName: '0'
},
showGenerate: false,
rules: {},
@@ -103,169 +103,169 @@ export default {
currentSelected: {},
// 选中的列
checkedQueryColumn: [],
- //是否覆盖原先代码
+ // 是否覆盖原先代码
coverd: true,
- // 生成SQL脚本的数据库类型
- dbType: 1,
// 选中的表
tableIds: [],
// 非多个禁用
- multiple: true,
- };
+ multiple: true
+ }
},
created() {
- this.handleSearch();
+ this.handleSearch()
},
methods: {
/**
* 点击查询
*/
handleSearch() {
- this.tableloading = true;
+ this.tableloading = true
listTable(this.queryParams).then((res) => {
- this.tableData = res.data.result;
- this.total = res.data.totalNum;
- this.tableloading = false;
- });
+ this.tableData = res.data.result
+ this.total = res.data.totalNum
+ this.tableloading = false
+ })
},
/**
* 编辑表格
*/
handleEditTable(row) {
- this.queryParams.tableName = row.tableName;
- this.handleSearch();
+ this.queryParams.tableName = row.tableName
+ this.handleSearch()
this.$router.push({
- path: "/gen/editTable",
- query: { tableId: row.tableId },
- });
+ path: '/gen/editTable',
+ query: { tableId: row.tableId }
+ })
},
// 代码预览
handlePreview(row) {
- this.$refs["codeform"].validate((valid) => {
+ this.$refs['codeform'].validate((valid) => {
if (!valid) {
- this.msgError("请先完成表格");
- return;
+ this.msgError('请先完成表格')
+ return
}
+ this.$modal.loading('请稍后...')
previewTable(row.tableId).then((res) => {
if (res.code === 200) {
- this.showGenerate = false;
- this.preview.open = true;
- this.preview.data = res.data;
+ this.showGenerate = false
+ this.preview.open = true
+ this.preview.data = res.data
+ this.$modal.closeLoading()
}
- });
- });
+ })
+ })
},
/**
* 点击生成服务端代码
*/
handleGenTable(row) {
- this.currentSelected = row;
+ this.currentSelected = row
if (!this.currentSelected) {
- this.msgError("请先选择要生成代码的数据表");
- return false;
+ this.msgError('请先选择要生成代码的数据表')
+ return false
}
- this.$refs["codeform"].validate((valid) => {
+ this.$refs['codeform'].validate((valid) => {
if (valid) {
var loadop = {
lock: true,
- text: "正在生成代码...",
- spinner: "el-icon-loading",
- background: "rgba(0, 0, 0, 0.7)",
- };
- const pageLoading = Loading.service(loadop);
+ text: '正在生成代码...',
+ spinner: 'el-icon-loading',
+ background: 'rgba(0, 0, 0, 0.7)'
+ }
+ const pageLoading = Loading.service(loadop)
var seachdata = {
tableId: this.currentSelected.tableId,
- tableName: this.currentSelected.name,
+ tableName: this.currentSelected.name
// queryColumn: this.checkedQueryColumn,
- };
+ }
codeGenerator(seachdata)
.then((res) => {
- const { data } = res;
- this.showGenerate = false;
- if (row.genType === "1") {
- this.msgSuccess("成功生成到自定义路径:" + row.genPath);
+ const { data } = res
+ this.showGenerate = false
+ if (row.genType === '1') {
+ this.msgSuccess('成功生成到自定义路径')
} else {
- this.msgSuccess("恭喜你,代码生成完成!");
- this.download(data.path);
+ this.msgSuccess('恭喜你,代码生成完成!')
+ this.download(data.path)
}
- pageLoading.close();
+ pageLoading.close()
})
.catch((erre) => {
- pageLoading.close();
- });
+ pageLoading.close()
+ })
} else {
- return false;
+ return false
}
- });
+ })
},
cancel() {
- this.showGenerate = false;
- this.currentSelected = {};
+ this.showGenerate = false
+ this.currentSelected = {}
},
/** 重置按钮操作 */
resetQuery() {
- this.resetForm("queryParams");
- this.handleSearch();
+ this.resetForm('queryParams')
+ this.handleSearch()
},
/** 打开导入表弹窗 */
openImportTable() {
- this.$refs.import.show();
+ this.$refs.import.show()
},
handleDelete(row) {
- const tableIds = row.tableId || this.tableIds;
- this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
+ const tableIds = row.tableId || this.tableIds
+ this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
})
.then(() => {
delTable(tableIds.toString()).then((res) => {
if (res.code == 200) {
- this.msgSuccess("删除成功");
+ this.msgSuccess('删除成功')
- this.handleSearch();
+ this.handleSearch()
}
- });
+ })
})
.catch(() => {
this.$message({
- type: "info",
- message: "已取消删除",
- });
- });
+ type: 'info',
+ message: '已取消删除'
+ })
+ })
},
/** 复制代码成功 */
clipboardSuccess() {
- this.msgSuccess("复制成功");
+ this.msgSuccess('复制成功')
},
// 多选框选中数据
handleSelectionChange(section) {
- this.tableIds = section.map((item) => item.tableId);
- this.multiple = !section.length;
- console.log(this.tableIds);
+ this.tableIds = section.map((item) => item.tableId)
+ this.multiple = !section.length
+ console.log(this.tableIds)
},
/** 高亮显示 */
highlightedCode(code, key) {
// var language = key.substring(key.lastIndexOf(".") , key.length)
- const result = hljs.highlightAuto(code || "");
- return result.value || " ";
+ const result = hljs.highlightAuto(code || '')
+ return result.value || ' '
},
// 同步代码
handleSynchDb(row) {
- const tableName = row.tableName;
+ const tableName = row.tableName
this.$confirm('确认要强制同步"' + tableName + '"表结构吗?')
- .then(function () {
- return synchDb(row.tableId, { tableName, dbName: row.dbName });
+ .then(function() {
+ return synchDb(row.tableId, { tableName, dbName: row.dbName })
})
.then(() => {
- this.msgSuccess("同步成功");
+ this.msgSuccess('同步成功')
})
- .catch(() => {});
- },
- },
-};
+ .catch(() => {})
+ }
+ }
+}