diff --git a/Infrastructure/Extensions/AppServiceExtensions.cs b/Infrastructure/Extensions/AppServiceExtensions.cs
index 98545c7..4f3f5e5 100644
--- a/Infrastructure/Extensions/AppServiceExtensions.cs
+++ b/Infrastructure/Extensions/AppServiceExtensions.cs
@@ -59,7 +59,7 @@ namespace Infrastructure.Extensions
services.AddTransient(serviceType, type);
break;
}
- Console.WriteLine($"注册:{serviceType}");
+ //Console.WriteLine($"注册:{serviceType}");
}
else
{
diff --git a/Infrastructure/OptionsSetting.cs b/Infrastructure/OptionsSetting.cs
index fb677bb..6a876d1 100644
--- a/Infrastructure/OptionsSetting.cs
+++ b/Infrastructure/OptionsSetting.cs
@@ -6,22 +6,11 @@ namespace Infrastructure
///
public class OptionsSetting
{
- public static string ConnAdmin = "Conn_admin";
- public static string Conn = "ConnDynamic";
- public static string DbType = "DbType";
- public static string CodeGenDbType = "CodeGenDbType";
+ public static string ConnAdmin = "conn_zrAdmin";
+ public static string ConnDbType = "conn_zrAdmin_Type";
public static string DbKey = "DbKey";
- public string Conn_Admin { get; set; }
-
- public string AppName { get; set; }
- ///
- /// 主库
- ///
- public string Master { get; set; }
-
public string Redis { get; set; }
-
public string Database { get; set; }
///
/// 是否演示模式
diff --git a/README.md b/README.md
index 9962992..431f829 100644
--- a/README.md
+++ b/README.md
@@ -3,15 +3,13 @@
## 🍟概述
* 本项目适合有一定NetCore和 vue基础的开发人员
* 基于.NET 5实现的通用权限管理平台(RBAC模式)。整合最新技术高效快速开发,前后端分离模式,开箱即用。
-* 模块化架构设计,层次清晰,业务层推荐写到单独模块,框架升级不影响业务!
-* 代码量少、通俗易懂、功能强大、易扩展,轻松开发从现在开始!
+* 代码量少、学习简单、通俗易懂、功能强大、易扩展、轻量级,让web开发更快速、简单高效,解决70%的重复工作,专注您的业务,轻松开发从现在开始!
* 前端采用Vue2.0、Element UI。
* 后端采用Net5、Sqlsugar、MySQL。
* 权限认证使用Jwt,支持多终端认证系统。
* 支持加载动态权限菜单,多方式轻松权限控制
-* 基于若依vue分离版本(java版本)修改
-> 如果对您有帮助,点击右上角⭐Star⭐关注 ,感谢支持开源!
+> 如果对您有帮助,您可以点右上角 “Star” 收藏一下 ,这样作者才有继续免费下去的动力,谢谢!~
## 🍿在线体验
体验地址:http://www.izhaorui.cn:8080/
@@ -36,7 +34,7 @@ Vue版前端技术栈 :基于vue、vuex、vue-router 、vue-cli 、axios 和 e
## 🍄快速启动
需要安装:VS2019(最新版)、npm或yarn(最新版)
-准备工作:将document文件夹下面的admin.sql脚本导入到数据库中,修改ZRAdmin项目里面的Conn_Admin数据库连接字符串以及DbType选择对应的数据库类型,目前仅MySQL验证了
+准备工作:将document文件夹下面的admin.sql脚本导入到数据库中,修改ZR.Admin.WebApi项目里面配置文件中的conn_zrAdmin数据库连接字符串以及DbType选择对应的数据库类型,目前仅支持MySQL、SQL server
启动后台:打开项目根目录的startup.bat即可启动(数据库默认MySQL)
启动前端:打开ZR.Vue文件夹,运行npm install命令,再运行npm run serve启动
浏览器访问:http://localhost:8887 (默认前端端口为:8887,后台端口为:8888)
@@ -59,7 +57,30 @@ Vue版前端技术栈 :基于vue、vuex、vue-router 、vue-cli 、axios 和 e
13. [X] 在线构建器:拖动表单元素生成相应的VUE代码。
14. [X] 任务系统:基于Quartz.NET定时任务执行。
15. [X] 文章管理:可以写文章记录。
-16. [X] 代码生成:可以一键生成前后端代码。
+16. [X] 代码生成:可以一键生成前后端代码(.cs、.vue、.js),自定义配置前端展示控件、让开发更快捷高效。
+
+## 项目结构
+
+ZRAdmin解决方案包含:
+
+Infrastructure[基础类库]:包框架的核心组件,包含一系列快速开发中经常用到的Utility辅助工具功能,部分核心功能的实现;
+
+ZR.Service[服务层类库]:提供WebApi接口调用;
+
+ZR.Tasks[定时任务类库]:提供项目定时任务实现功能;
+
+ZR.Repository[仓库层类库]:方便提供有执行存储过程的操作;
+
+ZR.Model[实体层类库],提供项目中的数据库表、数据传输对象;
+
+ZR.CodeGenerator[代码生成功能],包含代码生成的模板、方法、代码生成的下载。
+
+ZR.Admin.WebApi[webapi接口]:为Vue版或其他三方系统提供接口服务。
+
+ZR.Vue[前端UI]:vue版本UI层。
+
+DataBase是最新数据库备份文件,目前支持MS SQL Server和MySql。
+
## 🍎演示图
@@ -92,6 +113,10 @@ Vue版前端技术栈 :基于vue、vuex、vue-router 、vue-cli 、axios 和 e
 |
 |
+
+  |
+  |
+
## 🎉优势
@@ -100,6 +125,7 @@ Vue版前端技术栈 :基于vue、vuex、vue-router 、vue-cli 、axios 和 e
2. 后台系统无需任何二次开发,直接发布即可使用
3. 前台与后台系统分离,分别为不同的系统(域名可独立)
4. 全局异常统一处理
+5. 自定义的代码生成功能
## 💐 特别鸣谢
- 👉Ruoyi.vue:[Ruoyi](http://www.ruoyi.vip/)
diff --git a/ZR.Admin.WebApi/Controllers/CodeGeneratorController.cs b/ZR.Admin.WebApi/Controllers/CodeGeneratorController.cs
index 7cffe87..c504bf6 100644
--- a/ZR.Admin.WebApi/Controllers/CodeGeneratorController.cs
+++ b/ZR.Admin.WebApi/Controllers/CodeGeneratorController.cs
@@ -1,15 +1,25 @@
using Infrastructure;
using Infrastructure.Attribute;
using Infrastructure.Enums;
+using Mapster;
+using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Hosting;
using SqlSugar;
+using System;
using System.Collections.Generic;
+using System.IO;
+using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.CodeGenerator;
using ZR.CodeGenerator.Model;
using ZR.CodeGenerator.Service;
+using ZR.Common;
using ZR.Model;
+using ZR.Model.System.Dto;
+using ZR.Model.System.Generate;
using ZR.Model.Vo;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers
{
@@ -20,6 +30,15 @@ namespace ZR.Admin.WebApi.Controllers
public class CodeGeneratorController : BaseController
{
private CodeGeneraterService _CodeGeneraterService = new CodeGeneraterService();
+ private IGenTableService GenTableService;
+ private IGenTableColumnService GenTableColumnService;
+ private IWebHostEnvironment WebHostEnvironment;
+ public CodeGeneratorController(IGenTableService genTableService, IGenTableColumnService genTableColumnService, IWebHostEnvironment webHostEnvironment)
+ {
+ GenTableService = genTableService;
+ GenTableColumnService = genTableColumnService;
+ WebHostEnvironment = webHostEnvironment;
+ }
///
/// 获取所有数据库的信息
@@ -51,22 +70,6 @@ namespace ZR.Admin.WebApi.Controllers
return SUCCESS(vm);
}
- ///
- /// 获取表格列
- ///
- ///
- ///
- ///
- [HttpGet("getColumnInfo")]
- [ActionPermissionFilter(Permission = "tool:gen:list")]
- public IActionResult QueryColumnInfo(string dbName, string tableName)
- {
- if (string.IsNullOrEmpty(dbName) || string.IsNullOrEmpty(tableName))
- return ToRespose(ResultCode.PARAM_ERROR);
-
- return SUCCESS(_CodeGeneraterService.GetColumnInfo(dbName, tableName));
- }
-
///
/// 代码生成器
///
@@ -77,14 +80,143 @@ namespace ZR.Admin.WebApi.Controllers
[ActionPermissionFilter(Permission = "tool:gen:code")]
public IActionResult Generate([FromBody] GenerateDto dto)
{
- if (string.IsNullOrEmpty(dto.tableName))
+ if (dto.TableId <= 0)
{
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
}
- DbTableInfo dbTableInfo = new() { Name = dto.tableName };
- CodeGeneratorTool.Generate(dbTableInfo, dto);
+ dto.ZipPath = Path.Combine(WebHostEnvironment.WebRootPath, "Generatecode");
+ dto.GenCodePath = Path.Combine(dto.ZipPath, DateTime.Now.ToString("yyyyMMdd"));
- return SUCCESS(dbTableInfo);
+ var genTableInfo = GenTableService.GetGenTableInfo(dto.TableId);
+ genTableInfo.Columns = GenTableColumnService.GenTableColumns(dto.TableId);
+
+ dto.GenTable = genTableInfo;
+ //生成代码
+ CodeGeneratorTool.Generate(genTableInfo, dto);
+ //下载文件
+ CodeGeneratorTool.ZipGenCode(dto);
+
+ //HttpContext.Response.Headers.Add("Content-disposition", $"attachment; filename={zipFileName}");
+ return SUCCESS(new { zipPath = "/Generatecode/" + dto.ZipFileName, fileName = dto.ZipFileName });
+ }
+
+ ///
+ /// 获取代码生成表列表
+ ///
+ /// 表名
+ /// 分页信息
+ ///
+ [HttpGet("listGenTable")]
+ public IActionResult GetGenTable(string tableName, PagerInfo pagerInfo)
+ {
+ //查询原表数据,部分字段映射到代码生成表字段
+ var rows = GenTableService.GetGenTables(new GenTable() { TableName = tableName }, pagerInfo);
+
+ return SUCCESS(rows);
+ }
+
+ ///
+ /// 查询表字段列表
+ ///
+ /// genTable表id
+ ///
+ [HttpGet("column/{tableId}")]
+ public IActionResult GetColumnList(long tableId)
+ {
+ var tableColumns = GenTableColumnService.GenTableColumns(tableId);
+ var tableInfo = GenTableService.GetGenTableInfo(tableId);
+ return SUCCESS(new { result = tableColumns, info = tableInfo });
+ }
+
+ ///
+ /// 删除代码生成
+ ///
+ ///
+ ///
+ [Log(Title = "代码生成", BusinessType = BusinessType.DELETE)]
+ [HttpDelete("{tableIds}")]
+ [ActionPermissionFilter(Permission = "tool:gen:remove")]
+ public IActionResult Remove(string tableIds)
+ {
+ long[] tableId = Tools.SpitLongArrary(tableIds);
+
+ int result = GenTableService.DeleteGenTableByIds(tableId);
+ return SUCCESS(result);
+ }
+
+ ///
+ /// 导入表
+ ///
+ ///
+ ///
+ ///
+ [HttpPost("importTable")]
+ [Log(Title = "代码生成", BusinessType = BusinessType.IMPORT)]
+ [ActionPermissionFilter(Permission = "tool:gen:import")]
+ public IActionResult ImportTableSave(string tables, string dbName)
+ {
+ if (string.IsNullOrEmpty(tables))
+ {
+ throw new CustomException("表不能为空");
+ }
+ string[] tableNames = tables.Split(',', StringSplitOptions.RemoveEmptyEntries);
+ string userName = User.Identity.Name;
+
+ foreach (var tableName in tableNames)
+ {
+ var tabInfo = _CodeGeneraterService.GetTableInfo(dbName, tableName);
+ if (tabInfo != null)
+ {
+ GenTable genTable = new()
+ {
+ BaseNameSpace = "ZR.",//导入默认命名空间前缀
+ ModuleName = "business",//导入默认模块名
+ ClassName = CodeGeneratorTool.GetClassName(tableName),
+ BusinessName = CodeGeneratorTool.GetClassName(tableName),
+ FunctionAuthor = ConfigUtils.Instance.GetConfig(GenConstants.Gen_author),
+ FunctionName = tabInfo.Description,
+ TableName = tableName,
+ TableComment = tabInfo.Description,
+ Create_by = userName,
+ };
+ genTable.TableId = GenTableService.ImportGenTable(genTable);
+
+ if (genTable.TableId > 0)
+ {
+ //保存列信息
+ List dbColumnInfos = _CodeGeneraterService.GetColumnInfo(dbName, tableName);
+ List genTableColumns = CodeGeneratorTool.InitGenTableColumn(genTable, dbColumnInfos);
+
+ GenTableColumnService.DeleteGenTableColumnByTableName(tableName);
+ GenTableColumnService.InsertGenTableColumn(genTableColumns);
+ genTable.Columns = genTableColumns;
+
+ return SUCCESS(genTable);
+ }
+ }
+ }
+
+ return ToRespose(ResultCode.FAIL);
+ }
+
+ ///
+ /// 修改保存代码生成业务
+ ///
+ ///
+ [HttpPut]
+ //[Log(Title = "代码生成", BusinessType = BusinessType.UPDATE)]
+ [ActionPermissionFilter(Permission = "tool:gen:edit")]
+ public IActionResult EditSave([FromBody] GenTableDto genTableDto)
+ {
+ if (genTableDto == null) throw new CustomException("请求参数错误");
+ var genTable = genTableDto.Adapt().ToUpdate(HttpContext);
+
+ int rows = GenTableService.UpdateGenTable(genTable);
+ if (rows > 0)
+ {
+ GenTableColumnService.UpdateGenTableColumn(genTable.Columns);
+ }
+ return SUCCESS(rows);
}
}
}
diff --git a/ZR.Admin.WebApi/Controllers/System/ArticleController.cs b/ZR.Admin.WebApi/Controllers/System/ArticleController.cs
index 6f73f98..e175c26 100644
--- a/ZR.Admin.WebApi/Controllers/System/ArticleController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/ArticleController.cs
@@ -1,22 +1,12 @@
-
-//------------------------------------------------------------------------------
-//
-// 此代码已从模板生成。
-//
-// 手动更改此文件可能导致应用程序出现意外的行为。
-// 如果重新生成代码,将覆盖对此文件的手动更改。
-//
-//------------------------------------------------------------------------------
-
-using Infrastructure.Attribute;
+using Infrastructure.Attribute;
using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
using Infrastructure.Model;
using SqlSugar;
using Mapster;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using Infrastructure.Enums;
using Infrastructure;
using ZR.Admin.WebApi.Extensions;
diff --git a/ZR.Admin.WebApi/Controllers/System/SysDeptController.cs b/ZR.Admin.WebApi/Controllers/System/SysDeptController.cs
index 8dec679..dc99ec2 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysDeptController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysDeptController.cs
@@ -7,7 +7,7 @@ using ZR.Admin.WebApi.Filters;
using ZR.Common;
using ZR.Model.System;
using ZR.Service;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.System
{
diff --git a/ZR.Admin.WebApi/Controllers/System/SysDictDataController.cs b/ZR.Admin.WebApi/Controllers/System/SysDictDataController.cs
index d0968af..c5fe262 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysDictDataController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysDictDataController.cs
@@ -7,7 +7,7 @@ using ZR.Admin.WebApi.Filters;
using ZR.Model;
using ZR.Model.System;
using ZR.Model.Vo;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.System
{
diff --git a/ZR.Admin.WebApi/Controllers/System/SysDictTypeController.cs b/ZR.Admin.WebApi/Controllers/System/SysDictTypeController.cs
index 177430a..d61222c 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysDictTypeController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysDictTypeController.cs
@@ -8,7 +8,7 @@ using ZR.Common;
using ZR.Model;
using ZR.Model.System;
using ZR.Model.Vo;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.System
{
diff --git a/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs b/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs
index b363ab8..08afac8 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs
@@ -11,8 +11,8 @@ using Infrastructure.Model;
using Infrastructure;
using Infrastructure.Attribute;
using ZR.Model.System;
-using ZR.Model.Dto.System;
-using ZR.Service.IService;
+using ZR.Model.System.Dto;
+using ZR.Service.System.IService;
using Hei.Captcha;
using ZR.Common;
diff --git a/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs b/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs
index 27dd846..aa05eaf 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs
@@ -5,10 +5,10 @@ using Infrastructure.Model;
using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
using ZR.Service;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.System
{
diff --git a/ZR.Admin.WebApi/Controllers/System/SysPostController.cs b/ZR.Admin.WebApi/Controllers/System/SysPostController.cs
index 477ee60..ef3da92 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysPostController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysPostController.cs
@@ -8,7 +8,7 @@ using Infrastructure.Extensions;
using Infrastructure.Attribute;
using Infrastructure.Enums;
using Infrastructure;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.System
{
diff --git a/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs b/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs
index d1e2172..29890f1 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs
@@ -12,9 +12,9 @@ using System.IO;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Common;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.System
{
diff --git a/ZR.Admin.WebApi/Controllers/System/SysRoleController.cs b/ZR.Admin.WebApi/Controllers/System/SysRoleController.cs
index 1b92d24..7fa72fc 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysRoleController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysRoleController.cs
@@ -8,7 +8,7 @@ using ZR.Admin.WebApi.Filters;
using ZR.Model;
using ZR.Model.System;
using ZR.Model.Vo;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
using ZR.Admin.WebApi.Extensions;
namespace ZR.Admin.WebApi.Controllers.System
diff --git a/ZR.Admin.WebApi/Controllers/System/SysUserController.cs b/ZR.Admin.WebApi/Controllers/System/SysUserController.cs
index 649738f..e309a41 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysUserController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysUserController.cs
@@ -10,7 +10,7 @@ using ZR.Admin.WebApi.Filters;
using ZR.Model;
using ZR.Model.System;
using ZR.Model.Vo;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.System
{
diff --git a/ZR.Admin.WebApi/Controllers/System/SysUserRoleController.cs b/ZR.Admin.WebApi/Controllers/System/SysUserRoleController.cs
index a801832..b355f44 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysUserRoleController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysUserRoleController.cs
@@ -5,9 +5,9 @@ using System;
using System.Linq;
using ZR.Admin.WebApi.Filters;
using ZR.Model;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.System
{
diff --git a/ZR.Admin.WebApi/Controllers/System/TasksController.cs b/ZR.Admin.WebApi/Controllers/System/TasksController.cs
index ad60385..541ad29 100644
--- a/ZR.Admin.WebApi/Controllers/System/TasksController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/TasksController.cs
@@ -10,9 +10,9 @@ using System.Threading.Tasks;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Model;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
using ZR.Tasks;
namespace ZR.Admin.WebApi.Controllers
diff --git a/ZR.Admin.WebApi/Controllers/System/TasksLogController.cs b/ZR.Admin.WebApi/Controllers/System/TasksLogController.cs
index ca842ca..1a045ec 100644
--- a/ZR.Admin.WebApi/Controllers/System/TasksLogController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/TasksLogController.cs
@@ -1,14 +1,14 @@
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using ZR.Model;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
using Infrastructure.Extensions;
using Infrastructure.Attribute;
using ZR.Admin.WebApi.Filters;
using ZR.Common;
using Infrastructure.Enums;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.System
{
diff --git a/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs b/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs
index 74a4139..686be34 100644
--- a/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs
@@ -5,7 +5,7 @@ using ZR.Common;
using ZR.Model;
using ZR.Model.System;
using ZR.Model.Vo;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.monitor
{
diff --git a/ZR.Admin.WebApi/Controllers/System/monitor/SysOperlogController.cs b/ZR.Admin.WebApi/Controllers/System/monitor/SysOperlogController.cs
index fd76f8f..e2774b2 100644
--- a/ZR.Admin.WebApi/Controllers/System/monitor/SysOperlogController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/monitor/SysOperlogController.cs
@@ -5,10 +5,10 @@ using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Common;
using ZR.Model;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
using ZR.Model.Vo;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.monitor
{
diff --git a/ZR.Admin.WebApi/Extensions/EntityExtension.cs b/ZR.Admin.WebApi/Extensions/EntityExtension.cs
index c472ed5..879a258 100644
--- a/ZR.Admin.WebApi/Extensions/EntityExtension.cs
+++ b/ZR.Admin.WebApi/Extensions/EntityExtension.cs
@@ -49,27 +49,34 @@ namespace ZR.Admin.WebApi.Extensions
return source;
}
- //public static TSource ToUpdate(this TSource source, UserSessionVM userSession)
- //{
- // var types = source.GetType();
+ public static TSource ToUpdate(this TSource source, HttpContext context = null)
+ {
+ var types = source.GetType();
- // if (types.GetProperty("UpdateTime") != null)
- // {
- // types.GetProperty("UpdateTime").SetValue(source, DateTime.Now, null);
- // }
+ if (types.GetProperty("UpdateTime") != null)
+ {
+ types.GetProperty("UpdateTime").SetValue(source, DateTime.Now, null);
+ }
+ if (types.GetProperty("Update_Time") != null)
+ {
+ types.GetProperty("Update_Time").SetValue(source, DateTime.Now, null);
+ }
+ //if (types.GetProperty("UpdateID") != null)
+ //{
+ // types.GetProperty("UpdateID").SetValue(source, userSession.UserID, null);
+ //}
- // if (types.GetProperty("UpdateID") != null)
- // {
- // types.GetProperty("UpdateID").SetValue(source, userSession.UserID, null);
- // }
+ if (types.GetProperty("UpdateBy") != null)
+ {
+ types.GetProperty("UpdateBy").SetValue(source,context.GetName(), null);
+ }
+ if (types.GetProperty("Update_by") != null)
+ {
+ types.GetProperty("Update_by").SetValue(source, context.GetName(), null);
+ }
- // if (types.GetProperty("UpdateName") != null)
- // {
- // types.GetProperty("UpdateName").SetValue(source, userSession.UserName, null);
- // }
-
- // return source;
- //}
+ return source;
+ }
}
}
diff --git a/ZR.Admin.WebApi/Extensions/HttpContextExtension.cs b/ZR.Admin.WebApi/Extensions/HttpContextExtension.cs
index 0720d47..d2cb61f 100644
--- a/ZR.Admin.WebApi/Extensions/HttpContextExtension.cs
+++ b/ZR.Admin.WebApi/Extensions/HttpContextExtension.cs
@@ -71,7 +71,7 @@ namespace ZR.Admin.WebApi.Extensions
}
public static string GetName(this HttpContext context)
{
- var uid = context.User.Identity.Name;
+ var uid = context.User?.Identity?.Name;
return uid;
}
diff --git a/ZR.Admin.WebApi/Extensions/TasksExtension.cs b/ZR.Admin.WebApi/Extensions/TasksExtension.cs
index dda6ba7..d125afa 100644
--- a/ZR.Admin.WebApi/Extensions/TasksExtension.cs
+++ b/ZR.Admin.WebApi/Extensions/TasksExtension.cs
@@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Quartz.Spi;
using System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
using ZR.Tasks;
namespace ZR.Admin.WebApi.Extensions
diff --git a/ZR.Admin.WebApi/Filters/ActionPermissionFilter.cs b/ZR.Admin.WebApi/Filters/ActionPermissionFilter.cs
index 1f87286..88258d7 100644
--- a/ZR.Admin.WebApi/Filters/ActionPermissionFilter.cs
+++ b/ZR.Admin.WebApi/Filters/ActionPermissionFilter.cs
@@ -54,7 +54,7 @@ namespace ZR.Admin.WebApi.Filters
bool isDemoMode = ConfigUtils.Instance.GetAppConfig("DemoMode", false);
//演示公开环境屏蔽权限
- string[] denyPerms = new string[] { "update", "add", "remove", "add", "edit", "delete", "import", "run", "start", "stop", "clear", "code" };
+ string[] denyPerms = new string[] { "update", "add", "remove", "add", "edit", "delete", "import", "run", "start", "stop", "clear" };
if (isDemoMode && (denyPerms.Any(f => Permission.ToLower().Contains(f.ToLower())) || Permission.Equals("system")))
{
context.Result = new JsonResult(new { code = ResultCode.FORBIDDEN, msg = "演示模式 , 不允许操作" });
diff --git a/ZR.Admin.WebApi/Filters/LogActionFilter.cs b/ZR.Admin.WebApi/Filters/LogActionFilter.cs
index 0d9df95..b116d74 100644
--- a/ZR.Admin.WebApi/Filters/LogActionFilter.cs
+++ b/ZR.Admin.WebApi/Filters/LogActionFilter.cs
@@ -12,7 +12,7 @@ using System.Linq;
using System.Text;
using ZR.Admin.WebApi.Extensions;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Filters
{
diff --git a/ZR.Admin.WebApi/Framework/JwtUtil.cs b/ZR.Admin.WebApi/Framework/JwtUtil.cs
index e75abff..1f7f073 100644
--- a/ZR.Admin.WebApi/Framework/JwtUtil.cs
+++ b/ZR.Admin.WebApi/Framework/JwtUtil.cs
@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Http;
+using Infrastructure;
+using Microsoft.AspNetCore.Http;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using System;
@@ -43,12 +44,13 @@ namespace ZR.Admin.WebApi.Framework
{
var tokenHandler = new JwtSecurityTokenHandler();
var key = Encoding.ASCII.GetBytes(KEY);
+ var expires = ConfigUtils.Instance.GetAppConfig("sysConfig:tokenExpire", 10);
var tokenDescriptor = new SecurityTokenDescriptor
{
Subject = new ClaimsIdentity(claims),
//Issuer = "",
//Audience = "",
- Expires = DateTime.Now.AddDays(7),
+ Expires = DateTime.Now.AddMinutes(expires),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
};
var token = tokenHandler.CreateToken(tokenDescriptor);
diff --git a/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs b/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs
index 4bbe298..cca6d89 100644
--- a/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs
+++ b/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Middleware
{
diff --git a/ZR.Admin.WebApi/NLog.config b/ZR.Admin.WebApi/NLog.config
index a9d6783..a6d075c 100644
--- a/ZR.Admin.WebApi/NLog.config
+++ b/ZR.Admin.WebApi/NLog.config
@@ -23,7 +23,8 @@
-// 此代码已从模板生成。
-//
-// 手动更改此文件可能导致应用程序出现意外的行为。
-// 如果重新生成代码,将覆盖对此文件的手动更改。
-//
-//------------------------------------------------------------------------------
-using Infrastructure.Attribute;
-using Microsoft.AspNetCore.Mvc;
-using ZR.Admin.WebApi.Filters;
-using ZR.Model.System;
-using ZR.Service.IService;
-using Infrastructure.Model;
-using SqlSugar;
-using Mapster;
-using ZR.Model.Dto.System;
-using Infrastructure.Enums;
-using Infrastructure;
-using ZR.Admin.WebApi.Extensions;
-
-namespace ZR.Admin.WebApi.Controllers
-{
- ///
- /// T4代码自动生成
- ///
-
- [Verify]
- [Route("system/SysFile")]
- public class SysFile1Controller: BaseController
- {
- ///
- /// 文件管理接口
- ///
- private readonly ISysFileService _SysFileService;
-
- public SysFile1Controller(ISysFileService SysFileService)
- {
- _SysFileService = SysFileService;
- }
-
- ///
- /// 查询文件管理列表
- ///
- ///
- [HttpGet("list")]
- //[ActionPermissionFilter(Permission = "system:SysFile:list")]
- public IActionResult Query([FromQuery] SysFileQueryDto parm)
- {
- //开始拼装查询条件
- var predicate = Expressionable.Create();
-
- //TODO 搜索条件
- //predicate = predicate.And(m => m.Name.Contains(parm.Name));
-
- var response = _SysFileService.GetPages(predicate.ToExpression(), parm);
-
- return SUCCESS(response);
- }
-
- ///
- /// 查询文件管理详情
- ///
- ///
- ///
- [HttpGet("{id}")]
- public IActionResult Get(string id)
- {
- var response = _SysFileService.GetId(id);
-
- return SUCCESS(response);
- }
-
- ///
- /// 添加文件管理
- ///
- ///
- [HttpPost]
- //[ActionPermissionFilter(Permission = "system:SysFile:add")]
- [Log(Title = "文件管理添加", BusinessType = BusinessType.INSERT)]
- public IActionResult Create([FromBody] SysFile parm)
- {
- if (parm == null)
- {
- throw new CustomException("请求参数错误");
- }
- //从 Dto 映射到 实体
- var addModel = parm.Adapt().ToCreate();
- //addModel.CreateID = User.Identity.Name;
-
- return SUCCESS(_SysFileService.Add(addModel));
- }
-
- ///
- /// 更新文件管理
- ///
- ///
- [HttpPut("edit")]
- //[ActionPermissionFilter(Permission = "system:SysFile:update")]
- [Log(Title = "文件管理修改", BusinessType = BusinessType.UPDATE)]
- public IActionResult Update([FromBody] SysFile parm)
- {
- //从 Dto 映射到 实体
- var addModel = parm.Adapt().ToCreate();
- //addModel.CreateID = User.Identity.Name;
- //TODO 字段映射
- var response = _SysFileService.Update(addModel);
-
- return SUCCESS(response);
- }
-
- ///
- /// 删除文件管理
- ///
- ///
- [HttpDelete("{id}")]
- //[ActionPermissionFilter(Permission = "system:SysFile:delete")]
- [Log(Title = "文件管理删除", BusinessType = BusinessType.DELETE)]
- public IActionResult Delete(int id = 0)
- {
- if (id <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
-
- // 删除文件管理
- var response = _SysFileService.Delete(id);
-
- return SUCCESS(response);
- }
- }
-}
\ No newline at end of file
diff --git a/ZR.Admin.WebApi/Template/Controller.tt b/ZR.Admin.WebApi/Template/Controller.tt
deleted file mode 100644
index 3646cc6..0000000
--- a/ZR.Admin.WebApi/Template/Controller.tt
+++ /dev/null
@@ -1,145 +0,0 @@
-<#@ template debug="false" hostspecific="false" language="C#" #>
-<#@ assembly name="System.Core" #>
-<#@ import namespace="System.Linq" #>
-<#@ import namespace="System.Text" #>
-<#@ import namespace="System.Collections.Generic" #>
-<#@ output extension=".cs" #>
-
-<#
-string ModelName="SysFile";
-string ControllerName="SysFile";
-string ServiceName="SysFileService";
-string FileName="文件管理";
-string ModelNameSpace="ZRAdmin.Controllers";
-#>
-//------------------------------------------------------------------------------
-//
-// 此代码已从模板生成。
-//
-// 手动更改此文件可能导致应用程序出现意外的行为。
-// 如果重新生成代码,将覆盖对此文件的手动更改。
-//
-//------------------------------------------------------------------------------
-using Infrastructure.Attribute;
-using Microsoft.AspNetCore.Mvc;
-using ZRAdmin.Filters;
-using ZR.Model;
-using ZR.Model.System;
-using ZR.Model.Vo;
-using ZR.Service.IService;
-using Infrastructure.Model;
-using SqlSugar;
-using Mapster;
-using ZR.Model.Dto.System;
-using Infrastructure.Enums;
-using Infrastructure;
-using ZRAdmin.Extensions;
-
-namespace <#=ModelNameSpace#>
-{
- ///
- /// T4代码自动生成
- ///
-
- [Verify]
- [Route("system/<#=ModelName#>")]
- public class <#=ControllerName#>1Controller: BaseController
- {
- ///
- /// <#=FileName#>接口
- ///
- private readonly I<#=ServiceName#> _<#=ServiceName#>;
-
- public <#=ControllerName#>1Controller(I<#=ServiceName#> <#=ServiceName#>)
- {
- _<#=ServiceName#> = <#=ServiceName#>;
- }
-
- ///
- /// 查询<#=FileName#>列表
- ///
- ///
- [HttpGet("list")]
- //[ActionPermissionFilter(Permission = "system:<#=ModelName#>:list")]
- public IActionResult Query([FromQuery] <#=ModelName#>QueryDto parm)
- {
- //开始拼装查询条件
- var predicate = Expressionable.Create<<#=ModelName#>>();
-
- //TODO 搜索条件
- //predicate = predicate.And(m => m.Name.Contains(parm.Name));
-
- var response = _<#=ServiceName#>.GetPages(predicate.ToExpression(), parm);
-
- return SUCCESS(response);
- }
-
- ///
- /// 查询<#=FileName#>详情
- ///
- ///
- ///
- [HttpGet("{id}")]
- public IActionResult Get(string id)
- {
- var response = _<#=ServiceName#>.GetId(id);
-
- return SUCCESS(response);
- }
-
- ///
- /// 添加<#=FileName#>
- ///
- ///
- [HttpPost]
- //[ActionPermissionFilter(Permission = "system:<#=ModelName#>:add")]
- [Log(Title = "<#=FileName#>添加", BusinessType = BusinessType.INSERT)]
- public IActionResult Create([FromBody] <#=ModelName#> parm)
- {
- if (parm == null)
- {
- throw new CustomException("请求参数错误");
- }
- //从 Dto 映射到 实体
- var addModel = parm.Adapt<<#=ModelName#>>().ToCreate();
- //addModel.CreateID = User.Identity.Name;
-
- return SUCCESS(_<#=ServiceName#>.Add(addModel));
- }
-
- ///
- /// 更新<#=FileName#>
- ///
- ///
- [HttpPut("edit")]
- //[ActionPermissionFilter(Permission = "system:<#=ModelName#>:update")]
- [Log(Title = "<#=FileName#>修改", BusinessType = BusinessType.UPDATE)]
- public IActionResult Update([FromBody] <#=ModelName#> parm)
- {
- //从 Dto 映射到 实体
- var addModel = parm.Adapt<<#=ModelName#>>().ToCreate();
- //addModel.CreateID = User.Identity.Name;
- //TODO 字段映射
- var response = _<#=ServiceName#>.Update(addModel);
-
- return SUCCESS(response);
- }
-
- ///
- /// 删除<#=FileName#>
- ///
- ///
- [HttpDelete("{id}")]
- //[ActionPermissionFilter(Permission = "system:<#=ModelName#>:delete")]
- [Log(Title = "<#=FileName#>删除", BusinessType = BusinessType.DELETE)]
- public IActionResult Delete(int id = 0)
- {
- if (id <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
-
- // 删除<#=FileName#>
- var response = _<#=ServiceName#>.Delete(id);
-
- return SUCCESS(response);
- }
- }
-}
\ No newline at end of file
diff --git a/ZR.Admin.WebApi/Template/ControllersTemplate.txt b/ZR.Admin.WebApi/Template/ControllersTemplate.txt
deleted file mode 100644
index 6d8d8b2..0000000
--- a/ZR.Admin.WebApi/Template/ControllersTemplate.txt
+++ /dev/null
@@ -1,134 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using ZR.Admin.WebApi.Filters;
-using ZR.Admin.WebApi.Controllers;
-using ZR.Service.Business;
-using SqlSugar;
-using Infrastructure;
-using Infrastructure.Attribute;
-using Infrastructure.Enums;
-using Infrastructure.Model;
-using Mapster;
-using ZR.Admin.WebApi.Extensions;
-using {ModelsNamespace}.Dto;
-using {ModelsNamespace}.Models;
-
-namespace ZRAdmin.Controllers
-{
- ///
- /// 代码自动生成
- ///
-
- [Verify]
- [Route("bus/{ModelName}")]
- public class {ControllerName}Controller: BaseController
- {
- ///
- /// {FileName}接口
- ///
- private readonly I{ServiceName} _{ServiceName};
-
- public {ControllerName}Controller(I{ServiceName} {ServiceName})
- {
- _{ServiceName} = {ServiceName};
- }
-
- ///
- /// 查询{FileName}列表
- ///
- ///
- [HttpGet("list")]
- [ActionPermissionFilter(Permission = "{Permission}:list")]
- public IActionResult Query([FromQuery] {ModelName}QueryDto parm)
- {
- //开始拼装查询条件
- var predicate = Expressionable.Create<{ModelName}>();
-
- //TODO 搜索条件
- //predicate = predicate.And(m => m.Name.Contains(parm.Name));
-
- var response = _{ServiceName}.GetPages(predicate.ToExpression(), parm);
-
- return SUCCESS(response);
- }
-
- ///
- /// 查询{FileName}详情
- ///
- ///
- ///
- [HttpGet("{{primaryKey}}")]
- [ActionPermissionFilter(Permission = "{Permission}:query")]
- public IActionResult Get({KeyTypeName} {primaryKey})
- {
- var response = _{ServiceName}.GetId({primaryKey});
-
- return SUCCESS(response);
- }
-
- ///
- /// 添加{FileName}
- ///
- ///
- [HttpPost]
- [ActionPermissionFilter(Permission = "{Permission}:add")]
- [Log(Title = "{FileName}添加", BusinessType = BusinessType.INSERT)]
- public IActionResult Create([FromBody] {ModelName}Dto parm)
- {
- if (parm == null)
- {
- throw new CustomException("请求参数错误");
- }
- //从 Dto 映射到 实体
- var addModel = parm.Adapt<{ModelName}>().ToCreate();
- //addModel.CreateID = User.Identity.Name;
-
- return SUCCESS(_{ServiceName}.Add(addModel));
- }
-
- ///
- /// 更新{FileName}
- ///
- ///
- [HttpPut]
- [ActionPermissionFilter(Permission = "{Permission}:update")]
- [Log(Title = "{FileName}修改", BusinessType = BusinessType.UPDATE)]
- public IActionResult Update([FromBody] {ModelName}Dto parm)
- {
- if (parm == null)
- {
- throw new CustomException("请求实体不能为空");
- }
- //从 Dto 映射到 实体
- var updateModel = parm.Adapt<{ModelName}>().ToCreate();
- //updateModel.CreateID = User.Identity.Name;
-
- var response = _{ServiceName}.Update(w => w.{primaryKey} == updateModel.{primaryKey}, it => new {ModelName}()
- {
- //TODO 字段映射
- {updateColumn}
- });
-
- return SUCCESS(response);
- }
-
- ///
- /// 删除{FileName}
- ///
- ///
- [HttpDelete("{{primaryKey}}")]
- [ActionPermissionFilter(Permission = "{Permission}:delete")]
- [Log(Title = "{FileName}删除", BusinessType = BusinessType.DELETE)]
- public IActionResult Delete({KeyTypeName} {primaryKey} = 0)
- {
- if ({primaryKey} <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
-
- // 删除{FileName}
- var response = _{ServiceName}.Delete({primaryKey});
-
- return SUCCESS(response);
- }
- }
-}
\ No newline at end of file
diff --git a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj
index cbbf3ed..7b52794 100644
--- a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj
+++ b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj
@@ -15,6 +15,11 @@
+
+
+
+
+
@@ -53,10 +58,6 @@
Always
-
- TextTemplatingFileGenerator
- Controller.cs
-
Always
@@ -85,7 +86,7 @@
-
+
@@ -102,12 +103,4 @@
-
-
- True
- True
- Controller.tt
-
-
-
diff --git a/ZR.Admin.WebApi/appsettings.Development.json b/ZR.Admin.WebApi/appsettings.Development.json
deleted file mode 100644
index 61f44c9..0000000
--- a/ZR.Admin.WebApi/appsettings.Development.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information"
- }
- },
- "ConnectionStrings": {
- "Conn_Admin": "server=127.0.0.1;user=zr;pwd=abc;database=admin",
- "ConnDynamic": "server=127.0.0.1;user=zr;pwd=abc;database={database}"//ʹ
- },
- "urls": "http://localhost:8888", //url
- "sysConfig": {
- "DBCommandTimeout": 10,
- "cors": "http://localhost:8887" //ÿַ
- },
- "DemoMode": false, //Ƿʾģʽ
- "DbKey": "",
- "DbType": 0, //MySql = 0, SqlServer = 1, Sqlite = 2, Oracle = 3, PostgreSQL = 4,
- "CodeGenDbType": 0,//ݿ
- "Upload": {
- "UploadDirectory": "/",
- "UploadUrl": "http://localhost:8888"
- },
- "ALYUN_OCS": {
- "REGIONID": "cn-hangzhou",
- "KEY": "XX",
- "SECRET": "XX"
- }
-}
diff --git a/ZR.Admin.WebApi/appsettings.Production.json b/ZR.Admin.WebApi/appsettings.Production.json
deleted file mode 100644
index 8983e0f..0000000
--- a/ZR.Admin.WebApi/appsettings.Production.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information"
- }
- }
-}
diff --git a/ZR.Admin.WebApi/appsettings.json b/ZR.Admin.WebApi/appsettings.json
index 8983e0f..4416867 100644
--- a/ZR.Admin.WebApi/appsettings.json
+++ b/ZR.Admin.WebApi/appsettings.json
@@ -5,5 +5,33 @@
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
+ },
+ "ConnectionStrings": {
+ "conn_zrAdmin": "server=127.0.0.1;user=zr;pwd=abc;database=admin"
+ },
+ "conn_zrAdmin_Type": 0, //MySql = 0, SqlServer = 1
+ "urls": "http://localhost:8888", //Ŀurl
+ "sysConfig": {
+ "DBCommandTimeout": 10,
+ "tokenExpire": 1440,//Jwt tokenʱʱ䣨֣
+ "cors": "http://localhost:8887" //ַ","
+ },
+ "DemoMode": false, //Ƿʾģʽ
+ "DbKey": "", //ݿkey
+ "Upload": {
+ "UploadDirectory": "/",
+ "UploadUrl": "http://localhost:8888"
+ },
+ "ALYUN_OCS": {
+ "REGIONID": "cn-hangzhou",
+ "KEY": "XX",
+ "SECRET": "XX"
+ },
+ "gen": {
+ "conn": "server=127.0.0.1;user=zr;pwd=abc;database={database}",
+ "dbType": 0, //MySql = 0, SqlServer = 1
+ "autoPre": true, //Զȥǰ
+ "author": "zr",
+ "tablePrefix": "live_,sys_" //"ǰǰöŷָ",
}
}
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ControllersTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ControllersTemplate.txt
new file mode 100644
index 0000000..af2cc5c
--- /dev/null
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ControllersTemplate.txt
@@ -0,0 +1,134 @@
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using SqlSugar;
+using Infrastructure;
+using Infrastructure.Attribute;
+using Infrastructure.Enums;
+using Infrastructure.Model;
+using Mapster;
+using {ModelsNamespace}.Dto;
+using {ModelsNamespace}.Models;
+using {ServicesNamespace}.Business;
+using {ApiControllerNamespace}.Extensions;
+using {ApiControllerNamespace}.Filters;
+using ZR.Common;
+
+namespace {ApiControllerNamespace}.Controllers
+{
+ ///
+ /// 代码自动生成
+ ///
+ [Verify]
+ [Route("{ModuleName}/{ModelName}")]
+ public class {ModelName}Controller: BaseController
+ {
+ ///
+ /// {TableDesc}接口
+ ///
+ private readonly I{ModelName}Service _{ModelName}Service;
+
+ public {ModelName}Controller(I{ModelName}Service {ModelName}Service)
+ {
+ _{ModelName}Service = {ModelName}Service;
+ }
+
+ ///
+ /// 查询{TableDesc}列表
+ ///
+ ///
+ [HttpGet("list")]
+ [ActionPermissionFilter(Permission = "{Permission}:list")]
+ public IActionResult Query{ModelName}([FromQuery] {ModelName}QueryDto parm)
+ {
+ //开始拼装查询条件
+ var predicate = Expressionable.Create<{ModelName}>();
+
+ //TODO 搜索条件
+ //predicate = predicate.And(m => m.Name.Contains(parm.Name));
+
+ var response = _{ModelName}Service.GetPages(predicate.ToExpression(), parm);
+
+ return SUCCESS(response);
+ }
+
+ ///
+ /// 查询{TableDesc}详情
+ ///
+ ///
+ ///
+ [HttpGet("{{PrimaryKey}}")]
+ [ActionPermissionFilter(Permission = "{Permission}:query")]
+ public IActionResult Get{ModelName}({PKCsharpType} {PrimaryKey})
+ {
+ var response = _{ModelName}Service.GetId({PrimaryKey});
+
+ return SUCCESS(response);
+ }
+
+ ///
+ /// 添加{TableDesc}
+ ///
+ ///
+ [HttpPost]
+ [ActionPermissionFilter(Permission = "{Permission}:add")]
+ [Log(Title = "{TableDesc}添加", BusinessType = BusinessType.INSERT)]
+ public IActionResult Add{ModelName}([FromBody] {ModelName}Dto parm)
+ {
+ if (parm == null)
+ {
+ throw new CustomException("请求参数错误");
+ }
+ //从 Dto 映射到 实体
+ var model = parm.Adapt<{ModelName}>().ToCreate();
+
+ return SUCCESS(_{ModelName}Service.Add(model, it => new
+ {
+ {InsertColumn}
+ }));
+ }
+
+ ///
+ /// 更新{TableDesc}
+ ///
+ ///
+ [HttpPut]
+ [ActionPermissionFilter(Permission = "{Permission}:update")]
+ [Log(Title = "{TableDesc}修改", BusinessType = BusinessType.UPDATE)]
+ public IActionResult Update{ModelName}([FromBody] {ModelName}Dto parm)
+ {
+ if (parm == null)
+ {
+ throw new CustomException("请求实体不能为空");
+ }
+ //从 Dto 映射到 实体
+ var model = parm.Adapt<{ModelName}>().ToUpdate();
+
+ var response = _{ModelName}Service.Update(w => w.{PrimaryKey} == model.{PrimaryKey}, it => new {ModelName}()
+ {
+ //Update 字段映射
+ {UpdateColumn}
+ });
+
+ return SUCCESS(response);
+ }
+
+ ///
+ /// 删除{TableDesc}
+ ///
+ ///
+ [HttpDelete("{ids}")]
+ [ActionPermissionFilter(Permission = "{Permission}:delete")]
+ [Log(Title = "{TableDesc}删除", BusinessType = BusinessType.DELETE)]
+ public IActionResult Delete{ModelName}(string ids)
+ {
+ int[] idsArr = Tools.SpitIntArrary(ids);
+ if (idsArr.Length <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
+
+ var response = _{ModelName}Service.Delete(idsArr);
+
+ return SUCCESS(response);
+ }
+ }
+}
\ No newline at end of file
diff --git a/ZR.Admin.WebApi/Template/IServiceTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/IServiceTemplate.txt
similarity index 100%
rename from ZR.Admin.WebApi/Template/IServiceTemplate.txt
rename to ZR.Admin.WebApi/wwwroot/CodeGenTemplate/IServiceTemplate.txt
diff --git a/ZR.Admin.WebApi/Template/InputDtoTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/InputDtoTemplate.txt
similarity index 82%
rename from ZR.Admin.WebApi/Template/InputDtoTemplate.txt
rename to ZR.Admin.WebApi/wwwroot/CodeGenTemplate/InputDtoTemplate.txt
index 656cdad..0398c07 100644
--- a/ZR.Admin.WebApi/Template/InputDtoTemplate.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/InputDtoTemplate.txt
@@ -13,8 +13,12 @@ namespace {DtosNamespace}.Dto
{PropertyName}
}
+ ///
+ /// {TableNameDesc}查询对象模型
+ ///
public class {ModelTypeName}QueryDto: PagerInfo
{
+{QueryProperty}
public DateTime? BeginTime { get; set; }
public DateTime? EndTime { get; set; }
}
diff --git a/ZR.Admin.WebApi/Template/ModelTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ModelTemplate.txt
similarity index 100%
rename from ZR.Admin.WebApi/Template/ModelTemplate.txt
rename to ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ModelTemplate.txt
diff --git a/ZR.Admin.WebApi/Template/RepositoryTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/RepositoryTemplate.txt
similarity index 100%
rename from ZR.Admin.WebApi/Template/RepositoryTemplate.txt
rename to ZR.Admin.WebApi/wwwroot/CodeGenTemplate/RepositoryTemplate.txt
diff --git a/ZR.Admin.WebApi/Template/ServiceTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ServiceTemplate.txt
similarity index 95%
rename from ZR.Admin.WebApi/Template/ServiceTemplate.txt
rename to ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ServiceTemplate.txt
index 1c88cf6..340390a 100644
--- a/ZR.Admin.WebApi/Template/ServiceTemplate.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ServiceTemplate.txt
@@ -9,7 +9,6 @@ using System.Text;
using ZR.Common;
using {ModelsNamespace}.Models;
using {IRepositoriesNamespace};
-using {ServicesNamespace}.IService;
namespace {ServicesNamespace}.Business
{
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/SqlTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/SqlTemplate.txt
new file mode 100644
index 0000000..f6e1aff
--- /dev/null
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/SqlTemplate.txt
@@ -0,0 +1,19 @@
+-- 菜单
+INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time, update_by, update_time, remark)
+VALUES ('{FunctionName}', 0, 1, '/{ModuleName}/{ModelTypeName}', '{ModuleName}/{ViewsFileName}/index', 0, 0, 'C', '0', '0', '', '{Permission}:list', '', GETDATE(), '', NULL, '{ModelTypeDesc}');
+
+-- 按钮父菜单id
+declare @menuId int = @@identity
+
+
+INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time, update_by, update_time, remark)
+VALUES ('查询', @menuId, 1, '#', NULL, 0, 0, 'F', '0', '0', '{Permission}:query', '', '', GETDATE(), '', NULL, '');
+
+INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time, update_by, update_time, remark)
+VALUES ('新增', @menuId, 1, '#', NULL, 0, 0, 'F', '0', '0', '{Permission}:add', '', '', GETDATE(), '', NULL, NULL);
+
+INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time, update_by, update_time, remark)
+VALUES ('删除', @menuId, 2, '#', NULL, 0, 0, 'F', '0', '0', '{Permission}:delete', '', '', GETDATE(), '', NULL, NULL);
+
+INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time, update_by, update_time, remark)
+VALUES ('修改', @menuId, 3, '#', NULL, 0, 0, 'F', '0', '0', '{Permission}:update', '', '', GETDATE(), '', NULL, NULL);
diff --git a/ZR.Admin.WebApi/Template/VueJsTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueJsTemplate.txt
similarity index 73%
rename from ZR.Admin.WebApi/Template/VueJsTemplate.txt
rename to ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueJsTemplate.txt
index 719dfc7..d4efae3 100644
--- a/ZR.Admin.WebApi/Template/VueJsTemplate.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueJsTemplate.txt
@@ -4,11 +4,11 @@
* {ModelTypeDesc}分页查询
* @param {查询条件} data
*/
-export function list{ModelTypeName}(data) {
+export function list{ModelTypeName}(query) {
return request({
- url: 'bus/{ModelTypeName}/list',
+ url: '{ModuleName}/{ModelTypeName}/list',
method: 'get',
- params: data,
+ params: query,
})
}
@@ -18,7 +18,7 @@ export function list{ModelTypeName}(data) {
*/
export function add{ModelTypeName}(data) {
return request({
- url: '/bus/{ModelTypeName}',
+ url: '{ModuleName}/{ModelTypeName}',
method: 'post',
data: data,
})
@@ -30,7 +30,7 @@ export function add{ModelTypeName}(data) {
*/
export function update{ModelTypeName}(data) {
return request({
- url: '/bus/{ModelTypeName}',
+ url: '{ModuleName}/{ModelTypeName}',
method: 'PUT',
data: data,
})
@@ -42,7 +42,7 @@ export function update{ModelTypeName}(data) {
*/
export function get{ModelTypeName}(id) {
return request({
- url: '/bus/{ModelTypeName}/' + id,
+ url: '{ModuleName}/{ModelTypeName}/' + id,
method: 'get'
})
}
@@ -53,7 +53,7 @@ export function get{ModelTypeName}(id) {
*/
export function del{ModelTypeName}(pid) {
return request({
- url: '/bus/{ModelTypeName}/' + pid,
+ url: '{ModuleName}/{ModelTypeName}/' + pid,
method: 'delete'
})
}
diff --git a/ZR.Admin.WebApi/Template/VueTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueTemplate.txt
similarity index 73%
rename from ZR.Admin.WebApi/Template/VueTemplate.txt
rename to ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueTemplate.txt
index ac347d3..bca90fa 100644
--- a/ZR.Admin.WebApi/Template/VueTemplate.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueTemplate.txt
@@ -1,24 +1,8 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ {vueQueryFormHtml}
搜索
@@ -35,25 +19,25 @@
修改
- 删除
+ 删除
-
+
{VueViewListContent}
- 编辑
-
- 删除
+ 编辑
+
+ 删除
-
+
@@ -83,7 +67,7 @@ export default {
return {
labelWidth: "100px",
formLabelWidth:"100px",
- // 选中数组
+ // 选中{primaryKey}数组
ids: [],
// 非单个禁用
single: true,
@@ -103,8 +87,7 @@ export default {
form: {},
// 时间范围数组
timeRange: [],
- // xxx下拉框
- statusOptions: [],
+ {VueDataContent}
// 数据列表
dataList: [],
// 总记录数
@@ -124,6 +107,7 @@ export default {
// this.getDicts("sys_normal_disable").then((response) => {
// this.statusOptions = response.data;
// });
+ {MountedMethod}
},
methods: {
// 查询数据
@@ -144,8 +128,8 @@ export default {
// 重置数据表单
reset() {
this.form = {
- {VueViewEditFormContent}
- //需个性化处理内容
+ {VueViewFormResetHtml}
+ //TODO 根据实际内容调整
};
this.resetForm("form");
},
@@ -158,8 +142,9 @@ export default {
pageSize: 20,
//TODO 重置字段
};
+ this.handleQuery();
},
- // 多选框选中数据
+ // 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.{primaryKey});
this.single = selection.length!=1
@@ -183,10 +168,11 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
- del{ModelTypeName}(row.{primaryKey}).then((res) => {
- this.msgSuccess("删除成功");
- this.handleQuery();
- });
+ const {primaryKey}s = row.{primaryKey} || this.ids;
+ del{ModelTypeName}({primaryKey}s.toString()).then((res) => {
+ this.msgSuccess("删除成功");
+ this.handleQuery();
+ });
},
/** 修改按钮操作 */
handleUpdate(row) {
@@ -201,7 +187,6 @@ export default {
});
},
beforeFileUpload(file) { },
- //文件上传成功方法
{vueJsMethod}
/** 提交按钮 */
submitForm: function () {
diff --git a/ZR.CodeGenerator/CodeGenerateOption.cs b/ZR.CodeGenerator/CodeGenerateOption.cs
index abb237f..a3bad7f 100644
--- a/ZR.CodeGenerator/CodeGenerateOption.cs
+++ b/ZR.CodeGenerator/CodeGenerateOption.cs
@@ -49,6 +49,6 @@ namespace ZR.CodeGenerator
///
/// 要生数据的表,用“,”分割
///
- public string TableList { get; set; }
+ //public string TableList { get; set; }
}
}
diff --git a/ZR.CodeGenerator/CodeGenerateTemplate.cs b/ZR.CodeGenerator/CodeGenerateTemplate.cs
index e8c1796..4bca234 100644
--- a/ZR.CodeGenerator/CodeGenerateTemplate.cs
+++ b/ZR.CodeGenerator/CodeGenerateTemplate.cs
@@ -1,152 +1,250 @@
-using SqlSugar;
-using System;
-using System.Collections.Generic;
+using System;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using ZR.CodeGenerator.CodeGenerator;
+using ZR.Model.System.Generate;
namespace ZR.CodeGenerator
{
+ ///
+ /// 代码生成模板
+ ///
public class CodeGenerateTemplate
{
- #region Template
-
- public static string GetVueJsMethod(DbColumnInfo dbColumnInfo)
+ ///
+ /// 生成vuejs模板,目前只有上传文件方法
+ ///
+ ///
+ ///
+ public static string GetVueJsMethod(GenTableColumn dbFieldInfo)
{
- string columnName = CodeGeneratorTool.FirstLowerCase(dbColumnInfo.DbColumnName);
+ string columnName = dbFieldInfo.ColumnName;
string js = "";
- if (CodeGeneratorTool.imageFiled.Any(f => columnName.Contains(f)))
+ if (dbFieldInfo.HtmlType.Equals(GenConstants.HTML_IMAGE_UPLOAD))
{
- js += $"handleUpload{columnName}Success(res, file) {{\n";
- js += $" this.form.{columnName} = URL.createObjectURL(file.raw);\n";
- js += " // this.$refs.upload.clearFiles();\n";
- js += "},\n";
+ js += " //文件上传成功方法\r\n";
+ js += $" handleUpload{dbFieldInfo.CsharpField}Success(res, file) {{\r\n";
+ js += $" this.form.{columnName} = URL.createObjectURL(file.raw);\r\n";
+ js += " // this.$refs.upload.clearFiles();\r\n";
+ js += " },\r";
+ }
+ //有下拉框选项初列表查询数据
+ if (dbFieldInfo.HtmlType == GenConstants.HTML_SELECT && !string.IsNullOrEmpty(dbFieldInfo.DictType))
+ {
+ var sb = new System.Text.StringBuilder(500);
+ sb.AppendLine(@$" // {dbFieldInfo.ColumnComment}字典翻译");
+ sb.AppendLine($" {columnName}Format(row, column) {{");
+ sb.AppendLine(@$" return this.selectDictLabel(this.{columnName}Options, row.{columnName});");
+ sb.AppendLine(@" },");
+ js += sb.ToString();
}
return js;
}
//rules
- public static string GetFormRules(DbColumnInfo dbFieldInfo)
+ public static string GetFormRules(GenTableColumn dbFieldInfo)
{
string vueViewEditFromRuleContent = "";
//Rule 规则验证
- if (!dbFieldInfo.IsNullable && !dbFieldInfo.IsIdentity)
+ if ((!dbFieldInfo.IsPk && !dbFieldInfo.IsIncrement) && dbFieldInfo.IsRequired)
{
- vueViewEditFromRuleContent += $" {dbFieldInfo.DbColumnName}: [\n";
- vueViewEditFromRuleContent += $" {{ required: true, message:\"请输入{dbFieldInfo.ColumnDescription}\", trigger: \"blur\"}},\n";
- //vueViewEditFromRuleContent += " { min: 2, max: 50, message: \"长度在 2 到 50 个字符\", trigger:\"blur\" }\n";
- vueViewEditFromRuleContent += " ],\n";
+ vueViewEditFromRuleContent += $" {dbFieldInfo.ColumnName}: [\r\n";
+ vueViewEditFromRuleContent += $" {{ required: true, message: '请输入{dbFieldInfo.ColumnComment}', trigger: \"blur\"}},\r\n";
+ vueViewEditFromRuleContent += " ],\r\n";
+ }
+ else if (TableMappingHelper.IsNumber(dbFieldInfo.ColumnType) && dbFieldInfo.IsRequired)
+ {
+ vueViewEditFromRuleContent += $" {dbFieldInfo.ColumnName}: [\r\n";
+ vueViewEditFromRuleContent += $" {{ type: 'number', message: '{dbFieldInfo.ColumnName}必须为数字值', trigger: \"blur\"}},\r\n";
+ vueViewEditFromRuleContent += " ],\r\n";
}
return vueViewEditFromRuleContent;
}
//model 属性
- public static string GetModelTemplate(DbColumnInfo dbFieldInfo)
+ public static string GetModelTemplate(GenTableColumn dbFieldInfo)
{
- string columnName = dbFieldInfo.DbColumnName.Substring(0, 1).ToUpper() + dbFieldInfo.DbColumnName[1..];
var modelcontent = "";
- modelcontent += " /// \n";
- modelcontent += $" /// 描述 :{dbFieldInfo.ColumnDescription}\n";
- modelcontent += $" /// 空值 :{dbFieldInfo.IsNullable}\n";
- modelcontent += $" /// 默认 :{dbFieldInfo.DefaultValue}\n";
- modelcontent += " /// \n";
- if (dbFieldInfo.IsIdentity || dbFieldInfo.IsPrimarykey)
+ modelcontent += " /// \r\n";
+ modelcontent += $" /// 描述 :{dbFieldInfo.ColumnComment}\r\n";
+ modelcontent += $" /// 空值 :{!dbFieldInfo.IsRequired}\r\n";
+ modelcontent += " /// \r\n";
+ if (dbFieldInfo.IsPk || dbFieldInfo.IsIncrement)
{
- modelcontent += $" [SqlSugar.SugarColumn(IsPrimaryKey = {dbFieldInfo.IsPrimarykey.ToString().ToLower()}, IsIdentity = {dbFieldInfo.IsIdentity.ToString().ToLower()})]\n";
+ modelcontent += $" [SqlSugar.SugarColumn(IsPrimaryKey = {dbFieldInfo.IsPk.ToString().ToLower()}, IsIdentity = {dbFieldInfo.IsIncrement.ToString().ToLower()})]\r\n";
}
- modelcontent += $" public {TableMappingHelper.GetPropertyDatatype(dbFieldInfo.DataType)} {columnName} {{ get; set; }}\n\r";
+ modelcontent += $" public {dbFieldInfo.CsharpType}{(GetModelRequired(dbFieldInfo))} {dbFieldInfo.CsharpField} {{ get; set; }}\r\n";
return modelcontent;
}
- //DTO model
- public static string GetDtoContent(DbColumnInfo dbFieldInfo)
+ public static string GetModelRequired(GenTableColumn dbFieldInfo)
+ {
+ string str = "";
+ if (!dbFieldInfo.IsRequired && (dbFieldInfo.CsharpType == "int" || dbFieldInfo.CsharpType == "long" || dbFieldInfo.CsharpType == "DateTime"))
+ {
+ str = "?";
+ }
+
+ return str;
+ }
+ //DTO model
+ public static string GetDtoProperty(GenTableColumn dbFieldInfo)
{
- string columnName = dbFieldInfo.DbColumnName.Substring(0, 1).ToUpper() + dbFieldInfo.DbColumnName[1..];
string InputDtoContent = "";
- InputDtoContent += $" public {TableMappingHelper.GetPropertyDatatype(dbFieldInfo.DataType)} {columnName} {{ get; set; }}\n\r";
+ if (GenConstants.inputDtoNoField.Any(f => f.Replace("_", "").ToLower().Contains(dbFieldInfo.CsharpField.ToLower().Replace("_", ""))))
+ {
+ return InputDtoContent;
+ }
+ else if (dbFieldInfo.IsInsert || dbFieldInfo.IsEdit || dbFieldInfo.IsPk || dbFieldInfo.IsIncrement)
+ {
+ InputDtoContent += $" public {dbFieldInfo.CsharpType}{GetModelRequired(dbFieldInfo)} {dbFieldInfo.CsharpField} {{ get; set; }}\r\n";
+ }
return InputDtoContent;
}
+ ///
+ /// 查询Dto属性
+ ///
+ ///
+ ///
+ public static string GetQueryDtoProperty(GenTableColumn dbFieldInfo)
+ {
+ string QueryDtoContent = "";
+ if (dbFieldInfo.IsQuery && !GenConstants.inputDtoNoField.Any(f => f.Replace("_", "").ToLower().Contains(dbFieldInfo.CsharpField.ToLower().Replace("_", ""))))
+ {
+ QueryDtoContent += $" public {dbFieldInfo.CsharpType} {dbFieldInfo.CsharpField} {{ get; set; }}\r\n";
+ }
+
+ return QueryDtoContent;
+ }
//form-item
- public static string GetVueViewFormContent(DbColumnInfo dbFieldInfo)
+ public static string GetVueViewFormContent(GenTableColumn dbFieldInfo)
{
- string columnName = CodeGeneratorTool.FirstLowerCase(dbFieldInfo.DbColumnName);
- string labelName = CodeGeneratorTool.GetLabelName(dbFieldInfo.ColumnDescription, columnName);
+ string columnName = dbFieldInfo.ColumnName;
+ string labelName = CodeGeneratorTool.GetLabelName(dbFieldInfo.ColumnComment, columnName);
string vueViewFromContent = "";
- string labelDisabled = dbFieldInfo.IsIdentity ? ":disabled=\"true\"" : "";
- string placeHolder = dbFieldInfo.IsIdentity ? "" : $"请输入{CodeGeneratorTool.GetLabelName(dbFieldInfo.ColumnDescription, columnName)}";
-
- if (dbFieldInfo.DataType == "datetime")
+ string labelDisabled = dbFieldInfo.IsPk ? ":disabled=\"true\"" : "";
+ string placeHolder = dbFieldInfo.IsIncrement ? "" : $"请输入{labelName}";
+ if (GenConstants.inputDtoNoField.Any(f => f.Replace("_", "").ToLower().Contains(dbFieldInfo.CsharpField.ToLower().Replace("_", ""))))
+ {
+ return vueViewFromContent;
+ }
+ if (!dbFieldInfo.IsInsert || !dbFieldInfo.IsEdit)
+ {
+ return vueViewFromContent;
+ }
+ if (dbFieldInfo.HtmlType == GenConstants.HTML_DATETIME)
{
//时间
- vueViewFromContent += $" \n";
- vueViewFromContent += $" \n";
- vueViewFromContent += " \n";
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += " \r\n";
}
- else if (CodeGeneratorTool.imageFiled.Any(f => columnName.Contains(f)))
+ else if (dbFieldInfo.HtmlType == GenConstants.HTML_IMAGE_UPLOAD)
{
//图片
- vueViewFromContent += $" \n";
- vueViewFromContent += $" \n";
- vueViewFromContent += $"
\n";
- vueViewFromContent += " \n";
- vueViewFromContent += " \n";
- vueViewFromContent += $" \n";
- vueViewFromContent += " \n";
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += $"
\r\n";
+ vueViewFromContent += " \r\n";
+ vueViewFromContent += " \r\n";
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += " \r\n";
}
- else if (CodeGeneratorTool.radioFiled.Any(f => columnName.Contains(f)) && (dbFieldInfo.DataType == "bool" || dbFieldInfo.DataType == "tinyint" || dbFieldInfo.DataType == "int"))
+ else if (dbFieldInfo.HtmlType == GenConstants.HTML_RADIO)
{
- vueViewFromContent += $" ";
- vueViewFromContent += $" \n";
- vueViewFromContent += " {{dict.dictLabel}}\n";
- vueViewFromContent += " \n";
- vueViewFromContent += " \n";
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += " 是\r\n";
+ vueViewFromContent += " 否\r\n";
+ vueViewFromContent += " \r\n";
+ vueViewFromContent += " \r\n";
+ }
+ else if (dbFieldInfo.HtmlType == GenConstants.HTML_TEXTAREA)
+ {
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += " \r\n";
+ }
+ else if (dbFieldInfo.HtmlType == GenConstants.HTML_SELECT && !string.IsNullOrEmpty(dbFieldInfo.DictType))
+ {
+ string value = TableMappingHelper.IsNumber(dbFieldInfo.CsharpType) ? "parseInt(item.dictValue)" : "item.dictValue";
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += " \r\n";
+ vueViewFromContent += " \r\n";
}
else
{
- vueViewFromContent += $" \n";
- vueViewFromContent += $" \n";
- vueViewFromContent += " \n";
+ string inputNumTxt = TableMappingHelper.IsNumber(dbFieldInfo.CsharpType) ? ".number" : "";
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += $" \r\n";
+ vueViewFromContent += " \r\n";
}
return vueViewFromContent;
}
- //table-column
- public static string GetTableColumn(DbColumnInfo dbFieldInfo)
+ ///
+ /// 查询表单
+ ///
+ ///
+ ///
+ public static string GetQueryFormHtml(GenTableColumn dbFieldInfo)
{
- string columnName = CodeGeneratorTool.FirstLowerCase(dbFieldInfo.DbColumnName);
- string label = CodeGeneratorTool.GetLabelName(dbFieldInfo.ColumnDescription, columnName);
- string vueViewListContent = "";
- string showToolTip = dbFieldInfo.DataType.Contains("varchar") ? ":show-overflow-tooltip=\"true\"" : "";
+ string queryFormHtml = "";
+ string labelName = CodeGeneratorTool.GetLabelName(dbFieldInfo.ColumnComment, dbFieldInfo.ColumnName);
+ if (!dbFieldInfo.IsQuery || dbFieldInfo.HtmlType == GenConstants.HTML_FILE_UPLOAD) return queryFormHtml;
- if (CodeGeneratorTool.imageFiled.Any(f => columnName.ToLower().Contains(f)))
+ if (dbFieldInfo.HtmlType == GenConstants.HTML_DATETIME)
{
- vueViewListContent += $" \n";
- vueViewListContent += " \n";
- vueViewListContent += $" \n";
- vueViewListContent += " \n";
- vueViewListContent += " \n";
- }
- else if (dbFieldInfo.DataType == "bool" || dbFieldInfo.DataType == "tinyint")
- {
- vueViewListContent += $" \n";
- vueViewListContent += " \n";
- vueViewListContent += $" ";
- vueViewListContent += $" {{scope.row.{columnName}===true?'启用':'禁用'}} \n";
- vueViewListContent += " \n";
- vueViewListContent += " \n";
+ queryFormHtml += "\r\n";
+ queryFormHtml += " \r\n";
+ queryFormHtml += "\r\n";
}
else
{
- //table-column
- vueViewListContent += $" \n";
+ string inputNumTxt = TableMappingHelper.IsNumber(dbFieldInfo.CsharpType) ? ".number" : "";
+ queryFormHtml += $" \r\n";
+ queryFormHtml += $" \r\n";
+ queryFormHtml += " \r\n";
+ }
+
+ return queryFormHtml;
+ }
+
+ //table-column
+ public static string GetTableColumn(GenTableColumn dbFieldInfo)
+ {
+ string columnName = dbFieldInfo.ColumnName;
+ string label = CodeGeneratorTool.GetLabelName(dbFieldInfo.ColumnComment, columnName);
+ string vueViewListContent = "";
+ string showToolTip = dbFieldInfo.CsharpType == "string" ? ":show-overflow-tooltip=\"true\"" : "";
+ string formatter = !string.IsNullOrEmpty(dbFieldInfo.DictType) ? $" :formatter=\"{columnName}Format\"" : "";
+
+ if (dbFieldInfo.IsList && dbFieldInfo.HtmlType.Equals(GenConstants.HTML_IMAGE_UPLOAD))
+ {
+ vueViewListContent += $" \r\n";
+ vueViewListContent += " \r\n";
+ vueViewListContent += $" \r\n";
+ vueViewListContent += " \r\n";
+ vueViewListContent += " \r\n";
+ }
+ //else if (dbFieldInfo.HtmlType.Equals(GenConstants.HTML_RADIO))
+ //{
+ // vueViewListContent += $" \r\n";
+ // vueViewListContent += " \r\n";
+ // vueViewListContent += $" ";
+ // vueViewListContent += $" {{scope.row.{columnName}===true?'启用':'禁用'}} \r\n";
+ // vueViewListContent += " \r\n";
+ // vueViewListContent += " \r\n";
+ //}
+ else if(dbFieldInfo.IsList)
+ {
+ vueViewListContent += $" \r\n";
}
return vueViewListContent;
}
- #endregion
-
}
}
diff --git a/ZR.CodeGenerator/CodeGeneratorTool.cs b/ZR.CodeGenerator/CodeGeneratorTool.cs
index 8667eab..d2c6d99 100644
--- a/ZR.CodeGenerator/CodeGeneratorTool.cs
+++ b/ZR.CodeGenerator/CodeGeneratorTool.cs
@@ -1,10 +1,15 @@
-using SqlSugar;
+using Infrastructure;
+using SqlSugar;
using System;
using System.Collections.Generic;
using System.IO;
+using System.IO.Compression;
using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using ZR.CodeGenerator.CodeGenerator;
using ZR.CodeGenerator.Model;
-using ZR.CodeGenerator.Service;
+using ZR.Model.System.Generate;
namespace ZR.CodeGenerator
{
@@ -20,38 +25,26 @@ namespace ZR.CodeGenerator
/// 代码生成器配置
///
private static CodeGenerateOption _option = new CodeGenerateOption();
- ///
- /// InputDto输入实体是不包含字段
- ///
- public static readonly string[] inputDtoNoField = new string[] { "DeleteMark", "CreateTime", "updateTime", "addtime" };
- public static readonly string[] imageFiled = new string[] { "icon", "img", "image", "url", "pic", "photo" };
- public static readonly string[] selectFiled = new string[] { "status", "type", "state", "sex", "gender" };
- public static readonly string[] radioFiled = new string[] { "status", "state", "isShow", "isHidden", "ishide" };
///
/// 代码生成器入口方法
///
///
///
- public static void Generate(DbTableInfo dbTableInfo, GenerateDto dto)
+ public static List Generate(GenTable dbTableInfo, GenerateDto dto)
{
- //_option.BaseNamespace = baseNamespace;
- //_option.TableList = listTable;
- _option.ReplaceTableNameStr = dto.replaceTableNameStr;
- _option.DtosNamespace = "ZR.Model";
- _option.ModelsNamespace = "ZR.Model";
- _option.RepositoriesNamespace = "ZR.Repository";
- _option.IRepositoriesNamespace = "ZR.Repository";
- _option.IServicsNamespace = "ZR.Service";
- _option.ServicesNamespace = "ZR.Service";
- _option.ApiControllerNamespace = "ZR.Admin.WebApi";
+ _option.BaseNamespace = dbTableInfo.BaseNameSpace;
+ _option.DtosNamespace = _option.BaseNamespace + "Model";
+ _option.ModelsNamespace = _option.BaseNamespace + "Model";
+ _option.RepositoriesNamespace = _option.BaseNamespace + "Repository";
+ _option.IRepositoriesNamespace = _option.BaseNamespace + "Repository";
+ _option.IServicsNamespace = _option.BaseNamespace + "Service";
+ _option.ServicesNamespace = _option.BaseNamespace + "Service";
+ _option.ApiControllerNamespace = _option.BaseNamespace + "Admin.WebApi";
- CodeGeneraterService codeGeneraterService = new CodeGeneraterService();
+ List list = GenerateSingle(dbTableInfo?.Columns, dbTableInfo, dto);
- List listField = codeGeneraterService.GetColumnInfo(dto.dbName, dbTableInfo.Name);
- GenerateSingle(listField, dbTableInfo, dto);
-
- //GenerateDtoProfile(_option.ModelsNamespace, profileContent, ifExsitedCovered);
+ return list;
}
///
@@ -59,162 +52,172 @@ namespace ZR.CodeGenerator
///
/// 表字段集合
/// 表信息
- /// 如果目标文件存在,是否覆盖。默认为false
- public static void GenerateSingle(List listField, DbTableInfo tableInfo, GenerateDto dto)
+ ///
+ public static List GenerateSingle(List listField, GenTable tableInfo, GenerateDto dto)
{
- bool ifExsitedCovered = dto.coverd;
- var modelTypeName = GetModelClassName(tableInfo.Name);//表名对应C# 实体类名
- var modelTypeDesc = tableInfo.Description;//表描述
- var primaryKey = "id";//主键
-
- string keyTypeName = "int";//主键数据类型
- string modelContent = "";//数据库模型字段
- string InputDtoContent = "";//输入模型
- //string outputDtoContent = "";//输出模型
- string updateColumn = "";//修改数据映射字段
- string vueViewListContent = string.Empty;//Vue列表输出内容
- string vueViewFormContent = string.Empty;//Vue表单输出内容
- string vueViewEditFromContent = string.Empty;//Vue变量输出内容
- string vueViewEditFromBindContent = string.Empty;//Vue显示初始化输出内容
- string vueViewSaveBindContent = string.Empty;//Vue保存时输出内容
- string vueViewEditFromRuleContent = string.Empty;//Vue数据校验
- string vueJsMethod = string.Empty;//Vue js自定义方法
-
- foreach (DbColumnInfo dbFieldInfo in listField)
+ string PKName = "id";
+ string PKType = "int";
+ List genPathList = new();
+ ReplaceDto replaceDto = new();
+ replaceDto.ModelTypeName = tableInfo.ClassName;//表名对应C# 实体类名
+ replaceDto.TableName = tableInfo.TableName;//表名
+ replaceDto.TableDesc = tableInfo.TableComment;//表说明描述
+ replaceDto.Permission = tableInfo.ClassName.ToLower();//权限
+ replaceDto.ViewsFileName = FirstLowerCase(replaceDto.ModelTypeName);
+ //循环表字段信息
+ foreach (GenTableColumn dbFieldInfo in listField)
{
- string columnName = FirstLowerCase(dbFieldInfo.DbColumnName);
+ string columnName = dbFieldInfo.ColumnName;
- if (dbFieldInfo.DataType == "bool" || dbFieldInfo.DataType == "tinyint")
+ if (dbFieldInfo.IsInsert || dbFieldInfo.IsEdit)
{
- vueViewEditFromContent += $" {columnName}: 'true',\n";
- //vueViewEditFromBindContent += $" this.form.{columnName} = res.data.{0}+''\n";
+ replaceDto.VueViewFormResetHtml += $" {columnName}: undefined,\r\n";
}
- else
+ if (dbFieldInfo.IsPk || dbFieldInfo.IsIncrement)
{
- vueViewEditFromContent += $" {columnName}: undefined,\n";
- //vueViewEditFromBindContent += $" {columnName}: row.{columnName},\n";
+ PKName = dbFieldInfo.CsharpField;
+ PKType = dbFieldInfo.CsharpType;
}
- //vueViewSaveBindContent += string.Format(" '{0}':this.editFrom.{0},\n", columnName);
- //主键
- if (dbFieldInfo.IsIdentity || dbFieldInfo.IsPrimarykey)
+ //编辑字段
+ if (dbFieldInfo.IsEdit)
{
- primaryKey = columnName.Substring(0, 1).ToUpper() + columnName[1..];
- keyTypeName = dbFieldInfo.DataType;
+ replaceDto.UpdateColumn += $"{dbFieldInfo.CsharpField} = model.{dbFieldInfo.CsharpField}, ";
}
- else
+ //新增字段
+ if (dbFieldInfo.IsInsert)
{
- var tempColumnName = columnName.Substring(0, 1).ToUpper() + columnName[1..];
- updateColumn += $" {tempColumnName} = parm.{tempColumnName},\n";
+ replaceDto.InsertColumn += $"it.{dbFieldInfo.CsharpField}, ";
+ }
+ //TODO 查询
+ //if (dbFieldInfo.IsQuery)
+ //{
+ // replaceDto.Querycondition += $"predicate = predicate.And(m => m.{dbFieldInfo.CsharpField}.Contains(parm.Name));";
+ //}
+ if ((dbFieldInfo.HtmlType == GenConstants.HTML_SELECT || dbFieldInfo.HtmlType == GenConstants.HTML_RADIO) && !string.IsNullOrEmpty(dbFieldInfo.DictType))
+ {
+ replaceDto.VueDataContent += $" // {dbFieldInfo.ColumnComment}选项列表\n";
+ replaceDto.VueDataContent += $" {FirstLowerCase(dbFieldInfo.CsharpField)}Options: [],";
+
+ replaceDto.MountedMethod += $" this.getDicts(\"{dbFieldInfo.DictType}\").then((response) => {{\n";
+ replaceDto.MountedMethod += $" this.{FirstLowerCase(dbFieldInfo.CsharpField)}Options = response.data;\n";
+ replaceDto.MountedMethod += " })\n";
}
- dbFieldInfo.DbColumnName = columnName;
- modelContent += CodeGenerateTemplate.GetModelTemplate(dbFieldInfo);
- vueViewFormContent += CodeGenerateTemplate.GetVueViewFormContent(dbFieldInfo);
- vueJsMethod += CodeGenerateTemplate.GetVueJsMethod(dbFieldInfo);
- vueViewListContent += CodeGenerateTemplate.GetTableColumn(dbFieldInfo);
- vueViewEditFromRuleContent += CodeGenerateTemplate.GetFormRules(dbFieldInfo);
- InputDtoContent += CodeGenerateTemplate.GetDtoContent(dbFieldInfo);
+ replaceDto.QueryProperty += CodeGenerateTemplate.GetQueryDtoProperty(dbFieldInfo);
+ replaceDto.ModelProperty += CodeGenerateTemplate.GetModelTemplate(dbFieldInfo);
+ replaceDto.VueViewFormHtml += CodeGenerateTemplate.GetVueViewFormContent(dbFieldInfo);
+ replaceDto.VueJsMethod += CodeGenerateTemplate.GetVueJsMethod(dbFieldInfo);
+ replaceDto.VueViewListHtml += CodeGenerateTemplate.GetTableColumn(dbFieldInfo);
+ replaceDto.VueViewEditFormRuleContent += CodeGenerateTemplate.GetFormRules(dbFieldInfo);
+ replaceDto.InputDtoProperty += CodeGenerateTemplate.GetDtoProperty(dbFieldInfo);
+ replaceDto.VueQueryFormHtml += CodeGenerateTemplate.GetQueryFormHtml(dbFieldInfo);
}
+ replaceDto.PKName = PKName;
+ replaceDto.PKType = PKType;
+
if (dto.genFiles.Contains(1))
{
- GenerateModels(_option.ModelsNamespace, modelTypeName, tableInfo.Name, modelContent, modelTypeDesc, keyTypeName, ifExsitedCovered);
+ Tuple tuple = GenerateModels(replaceDto, dto);
+ genPathList.Add(tuple.Item1);
+ WriteAndSave(tuple.Item1, tuple.Item2);
}
if (dto.genFiles.Contains(2))
{
- GenerateInputDto(_option.ModelsNamespace, modelTypeName, modelTypeDesc, InputDtoContent, keyTypeName, ifExsitedCovered);
+ Tuple tuple = GenerateInputDto(replaceDto, dto);
+ genPathList.Add(tuple.Item1);
+ WriteAndSave(tuple.Item1, tuple.Item2);
}
if (dto.genFiles.Contains(3))
{
- GenerateRepository(modelTypeName, modelTypeDesc, tableInfo.Name, keyTypeName, ifExsitedCovered);
+ Tuple tuple = GenerateRepository(replaceDto, dto);
+ genPathList.Add(tuple.Item1);
+ WriteAndSave(tuple.Item1, tuple.Item2);
}
if (dto.genFiles.Contains(4))
{
- GenerateIService(_option.ModelsNamespace, modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
- GenerateService(_option.ModelsNamespace, modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
+ Tuple tuple = GenerateIService(replaceDto, dto);
+ Tuple tuple_1 = GenerateService(replaceDto, dto);
+ genPathList.Add(tuple.Item1);
+ genPathList.Add(tuple_1.Item1);
+ WriteAndSave(tuple.Item1, tuple.Item2);
+ WriteAndSave(tuple_1.Item1, tuple_1.Item2);
}
if (dto.genFiles.Contains(5))
{
- GenerateControllers(modelTypeName, primaryKey, modelTypeDesc, keyTypeName, updateColumn, ifExsitedCovered);
+ Tuple tuple = GenerateControllers(replaceDto, dto);
+ genPathList.Add(tuple.Item1);
+ WriteAndSave(tuple.Item1, tuple.Item2);
}
if (dto.genFiles.Contains(6))
{
- GenerateVueViews(modelTypeName, primaryKey, modelTypeDesc, vueViewListContent, vueViewFormContent, vueViewEditFromContent, vueViewEditFromBindContent, vueViewSaveBindContent, vueViewEditFromRuleContent, vueJsMethod, ifExsitedCovered);
+ Tuple tuple = GenerateVueViews(replaceDto, dto);
+ Tuple tuple_1 = GenerateVueJs(replaceDto, dto);
+ genPathList.Add(tuple.Item1);
+ genPathList.Add(tuple_1.Item1);
+ WriteAndSave(tuple.Item1, tuple.Item2);
+ WriteAndSave(tuple_1.Item1, tuple_1.Item2);
}
- //GenerateIRepository(modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
- //GenerateOutputDto(modelTypeName, modelTypeDesc, outputDtocontent, ifExsitedCovered);
+ if (dto.genFiles.Contains(7))
+ {
+ Tuple tuple = GenerateSql(replaceDto, dto);
+ WriteAndSave(tuple.Item1, tuple.Item2);
+ }
+ return genPathList;
}
-
#region 生成Model
///
/// 生成Models文件
///
- /// 命名空间
- /// 类名
- /// 表名称
- /// 表描述
- /// 数据库表实体内容
- /// 主键数据类型
- /// 如果目标文件存在,是否覆盖。默认为false
- private static Tuple GenerateModels(string modelsNamespace, string modelTypeName, string tableName, string modelContent, string modelTypeDesc, string keyTypeName, bool ifExsitedCovered = false)
+ ///
+ /// 替换实体
+ private static Tuple GenerateModels(ReplaceDto replaceDto, GenerateDto generateDto)
{
- var parentPath = "..";
//../ZR.Model
- var servicesPath = parentPath + "\\" + modelsNamespace + "\\Models\\";
- if (!Directory.Exists(servicesPath))
- {
- Directory.CreateDirectory(servicesPath);
- }
+ var servicesPath = Path.Combine(generateDto.GenCodePath, _option.ModelsNamespace, "Models");
+ Console.WriteLine("创建文件夹" + servicesPath);
+ CreateDirectory(servicesPath);
// ../ZR.Model/Models/User.cs
- var fullPath = servicesPath + modelTypeName + ".cs";
- Console.WriteLine(fullPath);
- if (File.Exists(fullPath) && !ifExsitedCovered)
+ var fullPath = Path.Combine(servicesPath, replaceDto.ModelTypeName + ".cs");
+
+ if (File.Exists(fullPath) && !generateDto.coverd)
return Tuple.Create(fullPath, "");
- var content = ReadTemplate("ModelTemplate.txt");
- content = content
- .Replace("{ModelsNamespace}", modelsNamespace)
- .Replace("{ModelTypeName}", modelTypeName)
- .Replace("{TableNameDesc}", modelTypeDesc)
- .Replace("{KeyTypeName}", keyTypeName)
- .Replace("{PropertyName}", modelContent)
- .Replace("{TableName}", tableName);
- WriteAndSave(fullPath, content);
+
+ var content = ReadTemplate("ModelTemplate.txt")
+ .Replace("{ModelsNamespace}", _option.ModelsNamespace)
+ .Replace("{ModelTypeName}", replaceDto.ModelTypeName)
+ .Replace("{TableNameDesc}", replaceDto.TableDesc)
+ .Replace("{KeyTypeName}", replaceDto.PKName)
+ .Replace("{PropertyName}", replaceDto.ModelProperty)
+ .Replace("{TableName}", replaceDto.TableName);
+
return Tuple.Create(fullPath, content);
}
-
///
/// 生成InputDto文件
///
- ///
- ///
- ///
- ///
- ///
- /// 如果目标文件存在,是否覆盖。默认为false
- private static Tuple GenerateInputDto(string modelsNamespace, string modelTypeName, string modelTypeDesc, string modelContent, string keyTypeName, bool ifExsitedCovered = false)
+ ///
+ /// 替换实体
+ private static Tuple GenerateInputDto(ReplaceDto replaceDto, GenerateDto generateDto)
{
- var parentPath = "..";
- var servicesPath = parentPath + "\\" + modelsNamespace + "\\Dto\\";
- if (!Directory.Exists(servicesPath))
- {
- Directory.CreateDirectory(servicesPath);
- }
+ var servicesPath = Path.Combine(generateDto.GenCodePath, _option.ModelsNamespace, "Dto");
+ CreateDirectory(servicesPath);
// ../ZR.Model/Dto/User.cs
- var fullPath = servicesPath + modelTypeName + "Dto.cs";
- Console.WriteLine(fullPath);
- if (File.Exists(fullPath) && !ifExsitedCovered)
- return Tuple.Create(fullPath, ""); ;
- var content = ReadTemplate("InputDtoTemplate.txt");
- content = content
+ var fullPath = Path.Combine(servicesPath, $"{replaceDto.ModelTypeName}Dto.cs");
+
+ if (File.Exists(fullPath) && !generateDto.coverd)
+ return Tuple.Create(fullPath, "");
+
+ var content = ReadTemplate("InputDtoTemplate.txt")
.Replace("{DtosNamespace}", _option.DtosNamespace)
- .Replace("{ModelsNamespace}", modelsNamespace)
- .Replace("{TableNameDesc}", modelTypeDesc)
- .Replace("{KeyTypeName}", keyTypeName)
- .Replace("{PropertyName}", modelContent)
- .Replace("{ModelTypeName}", modelTypeName);
- WriteAndSave(fullPath, content);
+ .Replace("{ModelsNamespace}", _option.ModelsNamespace)
+ .Replace("{TableNameDesc}", replaceDto.TableDesc)
+ .Replace("{PropertyName}", replaceDto.InputDtoProperty)
+ .Replace("{QueryProperty}", replaceDto.QueryProperty)
+ .Replace("{ModelTypeName}", replaceDto.ModelTypeName);
+
return Tuple.Create(fullPath, content);
}
#endregion
@@ -224,32 +227,25 @@ namespace ZR.CodeGenerator
///
/// 生成Repository层代码文件
///
- ///
- ///
- /// 表名
- ///
- /// 如果目标文件存在,是否覆盖。默认为false
- private static Tuple GenerateRepository(string modelTypeName, string modelTypeDesc, string tableName, string keyTypeName, bool ifExsitedCovered = false)
+ ///
+ /// 替换实体
+ private static Tuple GenerateRepository(ReplaceDto replaceDto, GenerateDto generateDto)
{
- var parentPath = "..";
- var repositoryPath = parentPath + "\\" + _option.RepositoriesNamespace + "\\Repositories\\";
- if (!Directory.Exists(repositoryPath))
- {
- Directory.CreateDirectory(repositoryPath);
- }
- var fullPath = repositoryPath + "\\" + modelTypeName + "Repository.cs";
- Console.WriteLine(fullPath);
- if (File.Exists(fullPath) && !ifExsitedCovered)
+ var repositoryPath = Path.Combine(generateDto.GenCodePath, _option.RepositoriesNamespace, "Repositories");
+ CreateDirectory(repositoryPath);
+
+ var fullPath = Path.Combine(repositoryPath, $"{replaceDto.ModelTypeName}Repository.cs");
+
+ if (File.Exists(fullPath) && !generateDto.coverd)
return Tuple.Create(fullPath, "");
- var content = ReadTemplate("RepositoryTemplate.txt");
- content = content.Replace("{ModelsNamespace}", _option.ModelsNamespace)
- //.Replace("{IRepositoriesNamespace}", _option.IRepositoriesNamespace)
+
+ var content = ReadTemplate("RepositoryTemplate.txt")
+ .Replace("{ModelsNamespace}", _option.ModelsNamespace)
.Replace("{RepositoriesNamespace}", _option.RepositoriesNamespace)
- .Replace("{ModelTypeName}", modelTypeName)
- .Replace("{TableNameDesc}", modelTypeDesc)
- .Replace("{TableName}", tableName)
- .Replace("{KeyTypeName}", keyTypeName);
- WriteAndSave(fullPath, content);
+ .Replace("{ModelTypeName}", replaceDto.ModelTypeName)
+ .Replace("{TableNameDesc}", replaceDto.TableDesc)
+ .Replace("{TableName}", replaceDto.TableName);
+
return Tuple.Create(fullPath, content);
}
@@ -259,66 +255,49 @@ namespace ZR.CodeGenerator
///
/// 生成IService文件
///
- ///
- ///
- ///
- ///
- /// 如果目标文件存在,是否覆盖。默认为false
- private static Tuple GenerateIService(string modelsNamespace, string modelTypeName, string modelTypeDesc, string keyTypeName, bool ifExsitedCovered = false)
+ ///
+ /// 替换实体
+ private static Tuple GenerateIService(ReplaceDto replaceDto, GenerateDto generateDto)
{
- var parentPath = "..";
- var iServicesPath = parentPath + "\\" + _option.IServicsNamespace + "\\Business\\IBusService\\";
- if (!Directory.Exists(iServicesPath))
- {
- Directory.CreateDirectory(iServicesPath);
- }
- var fullPath = $"{iServicesPath}\\I{modelTypeName}Service.cs";
+ var iServicesPath = Path.Combine(generateDto.GenCodePath, _option.IServicsNamespace, "Business", "IBusService");
+ CreateDirectory(iServicesPath);
+
+ var fullPath = Path.Combine(iServicesPath, $"I{replaceDto.ModelTypeName}Service.cs");
Console.WriteLine(fullPath);
- if (File.Exists(fullPath) && !ifExsitedCovered)
+ if (File.Exists(fullPath) && !generateDto.coverd)
return Tuple.Create(fullPath, "");
- var content = ReadTemplate("IServiceTemplate.txt");
- content = content.Replace("{ModelsNamespace}", modelsNamespace)
- .Replace("{TableNameDesc}", modelTypeDesc)
+ var content = ReadTemplate("IServiceTemplate.txt")
+ .Replace("{ModelsNamespace}", _option.ModelsNamespace)
+ .Replace("{TableNameDesc}", replaceDto.TableDesc)
.Replace("{DtosNamespace}", _option.DtosNamespace)
.Replace("{IServicsNamespace}", _option.IServicsNamespace)
.Replace("{RepositoriesNamespace}", _option.RepositoriesNamespace)
- .Replace("{ModelTypeName}", modelTypeName)
- .Replace("{KeyTypeName}", keyTypeName);
- WriteAndSave(fullPath, content);
+ .Replace("{ModelTypeName}", replaceDto.ModelTypeName);
+
return Tuple.Create(fullPath, content);
}
///
/// 生成Service文件
///
- ///
- ///
- ///
- ///
- /// 如果目标文件存在,是否覆盖。默认为false
- private static Tuple GenerateService(string modelsNamespace, string modelTypeName, string modelTypeDesc, string keyTypeName, bool ifExsitedCovered = false)
+ private static Tuple GenerateService(ReplaceDto replaceDto, GenerateDto generateDto)
{
- var parentPath = "..";
- var servicesPath = parentPath + "\\" + _option.ServicesNamespace + "\\Business\\";
- if (!Directory.Exists(servicesPath))
- {
- Directory.CreateDirectory(servicesPath);
- }
- var fullPath = servicesPath + modelTypeName + "Service.cs";
+ var servicesPath = Path.Combine(generateDto.GenCodePath, _option.ServicesNamespace, "Business");
+ CreateDirectory(servicesPath);
+ var fullPath = Path.Combine(servicesPath, $"{replaceDto.ModelTypeName}Service.cs");
Console.WriteLine(fullPath);
- if (File.Exists(fullPath) && !ifExsitedCovered)
+ if (File.Exists(fullPath) && !generateDto.coverd)
return Tuple.Create(fullPath, "");
- var content = ReadTemplate("ServiceTemplate.txt");
- content = content
+
+ var content = ReadTemplate("ServiceTemplate.txt")
.Replace("{IRepositoriesNamespace}", _option.IRepositoriesNamespace)
.Replace("{DtosNamespace}", _option.DtosNamespace)
.Replace("{IServicsNamespace}", _option.IServicsNamespace)
- .Replace("{TableNameDesc}", modelTypeDesc)
- .Replace("{ModelsNamespace}", modelsNamespace)
+ .Replace("{TableNameDesc}", replaceDto.TableDesc)
+ .Replace("{ModelsNamespace}", _option.ModelsNamespace)
.Replace("{ServicesNamespace}", _option.ServicesNamespace)
- .Replace("{ModelTypeName}", modelTypeName)
- .Replace("{KeyTypeName}", keyTypeName);
- WriteAndSave(fullPath, content);
+ .Replace("{ModelTypeName}", replaceDto.ModelTypeName);
+
return Tuple.Create(fullPath, content);
}
@@ -328,36 +307,28 @@ namespace ZR.CodeGenerator
///
/// 生成控制器ApiControllers文件
///
- /// 实体类型名称
- /// 主键
- /// 实体描述
- ///
- /// 如果目标文件存在,是否覆盖。默认为false
- private static Tuple GenerateControllers(string modelTypeName, string primaryKey, string modelTypeDesc, string keyTypeName, string updateColumn, bool ifExsitedCovered = false)
+ private static Tuple GenerateControllers(ReplaceDto replaceDto, GenerateDto generateDto)
{
- var parentPath = "..";
- var servicesPath = parentPath + "\\" + _option.ApiControllerNamespace + "\\Controllers\\business\\";
- if (!Directory.Exists(servicesPath))
- {
- Directory.CreateDirectory(servicesPath);
- }
- var fullPath = servicesPath + modelTypeName + "Controller.cs";
- Console.WriteLine(fullPath);
- if (File.Exists(fullPath) && !ifExsitedCovered)
+ var servicesPath = Path.Combine(generateDto.GenCodePath, _option.ApiControllerNamespace, "Controllers", generateDto.GenTable.ModuleName);
+ CreateDirectory(servicesPath);
+
+ var fullPath = Path.Combine(servicesPath, $"{replaceDto.ModelTypeName}Controller.cs");
+ if (File.Exists(fullPath) && !generateDto.coverd)
return Tuple.Create(fullPath, "");
- var content = ReadTemplate("ControllersTemplate.txt");
- content = content
- //.Replace("{DtosNamespace}", _option.DtosNamespace)
- .Replace("{ControllerName}", modelTypeName)
+
+ var content = ReadTemplate("ControllersTemplate.txt")
+ .Replace("{ApiControllerNamespace}", _option.ApiControllerNamespace)
+ .Replace("{ServicesNamespace}", _option.ServicesNamespace)
.Replace("{ModelsNamespace}", _option.ModelsNamespace)
- .Replace("{FileName}", modelTypeDesc)
- .Replace("{ServiceName}", modelTypeName + "Service")
- .Replace("{ModelName}", modelTypeName)
- .Replace("{Permission}", modelTypeName.ToLower())
- .Replace("{primaryKey}", primaryKey)
- .Replace("{updateColumn}", updateColumn)
- .Replace("{KeyTypeName}", keyTypeName);
- WriteAndSave(fullPath, content);
+ .Replace("{TableDesc}", replaceDto.TableDesc)
+ .Replace("{ModelName}", replaceDto.ModelTypeName)
+ .Replace("{Permission}", replaceDto.Permission)
+ .Replace("{PrimaryKey}", replaceDto.PKName)
+ .Replace("{UpdateColumn}", replaceDto.UpdateColumn)
+ .Replace("{InsertColumn}", replaceDto.InsertColumn)
+ .Replace("{ModuleName}", generateDto.GenTable.ModuleName)
+ .Replace("{PKCsharpType}", replaceDto.PKType);
+
return Tuple.Create(fullPath, content);
}
#endregion
@@ -365,57 +336,71 @@ namespace ZR.CodeGenerator
#region 生成Vue页面
///
/// 生成Vue页面
- ///
- /// 类名
- /// 表/类描述
- ///
- ///
- ///
- ///
- ///
- ///
- /// 如果目标文件存在,是否覆盖。默认为false
- private static Tuple GenerateVueViews(string modelTypeName, string primaryKey, string modelTypeDesc, string vueViewListContent, string vueViewFromContent, string vueViewEditFromContent, string vueViewEditFromBindContent, string vueViewSaveBindContent, string vueViewEditFromRuleContent, string vueJsMethod, bool ifExsitedCovered = false)
+ private static Tuple GenerateVueViews(ReplaceDto replaceDto, GenerateDto generateDto)
{
- //var parentPath = "..\\CodeGenerate";//若要生成到项目中将路径改成 “..\\ZR.Vue\\src”
- var parentPath = "..\\ZR.Vue\\src";
- var servicesPath = parentPath + "\\views\\" + FirstLowerCase(modelTypeName);
- if (!Directory.Exists(servicesPath))
- {
- Directory.CreateDirectory(servicesPath);
- }
- var fullPath = servicesPath + "\\" + "index.vue";
- Console.WriteLine(fullPath);
- if (File.Exists(fullPath) && !ifExsitedCovered)
- return Tuple.Create(fullPath, ""); ;
- var content = ReadTemplate("VueTemplate.txt");
- content = content
- .Replace("{fileClassName}", FirstLowerCase(modelTypeName))
- .Replace("{VueViewListContent}", vueViewListContent)//查询 table列
- .Replace("{VueViewFormContent}", vueViewFromContent)//添加、修改表单
- .Replace("{ModelTypeName}", modelTypeName)
- .Replace("{Permission}", modelTypeName.ToLower())
- .Replace("{VueViewEditFormContent}", vueViewEditFromContent)
- .Replace("{vueJsMethod}", vueJsMethod)
- //.Replace("{VueViewEditFromBindContent}", vueViewEditFromBindContent)
- //.Replace("{VueViewSaveBindContent}", vueViewSaveBindContent)
- .Replace("{primaryKey}", FirstLowerCase(primaryKey))
- .Replace("{VueViewEditFormRuleContent}", vueViewEditFromRuleContent);//添加、修改表单验证规则
- WriteAndSave(fullPath, content);
+ var parentPath = Path.Combine(generateDto.GenCodePath, "ZR.Vue", "src");
+ var servicesPath = Path.Combine(parentPath, "views", generateDto.GenTable.ModuleName, replaceDto.ViewsFileName);
+ CreateDirectory(servicesPath);
- //api js
- servicesPath = parentPath + "\\api\\";
- Directory.CreateDirectory(servicesPath);
- fullPath = servicesPath + "\\" + FirstLowerCase(modelTypeName) + ".js";
- Console.WriteLine(fullPath);
- if (File.Exists(fullPath) && !ifExsitedCovered)
+ var fullPath = Path.Combine(servicesPath, "index.vue");
+
+ if (File.Exists(fullPath) && !generateDto.coverd)
return Tuple.Create(fullPath, "");
- content = ReadTemplate("VueJsTemplate.txt");
- content = content
- .Replace("{ModelTypeName}", modelTypeName)
- .Replace("{ModelTypeDesc}", modelTypeDesc);
- //.Replace("{fileClassName}", fileClassName)
- WriteAndSave(fullPath, content);
+
+ var content = ReadTemplate("VueTemplate.txt")
+ .Replace("{fileClassName}", replaceDto.ViewsFileName)
+ .Replace("{VueViewListContent}", replaceDto.VueViewListHtml)//查询 table列
+ .Replace("{VueViewFormContent}", replaceDto.VueViewFormHtml)//添加、修改表单
+ .Replace("{ModelTypeName}", replaceDto.ModelTypeName)
+ .Replace("{Permission}", replaceDto.Permission)
+ .Replace("{VueViewFormResetHtml}", replaceDto.VueViewFormResetHtml)
+ .Replace("{vueJsMethod}", replaceDto.VueJsMethod)
+ .Replace("{vueQueryFormHtml}", replaceDto.VueQueryFormHtml)
+ .Replace("{VueDataContent}", replaceDto.VueDataContent)
+ .Replace("{primaryKey}", FirstLowerCase(replaceDto.PKName))
+ .Replace("{MountedMethod}", replaceDto.MountedMethod)
+ .Replace("{VueViewEditFormRuleContent}", replaceDto.VueViewEditFormRuleContent);//添加、修改表单验证规则
+
+ return Tuple.Create(fullPath, content);
+ }
+ public static Tuple GenerateVueJs(ReplaceDto replaceDto, GenerateDto generateDto)
+ {
+ //api js
+ var parentPath = Path.Combine(generateDto.GenCodePath, "ZR.Vue", "src");
+ string servicesPath = Path.Combine(parentPath, "api");
+ CreateDirectory(servicesPath);
+
+ string fullPath = Path.Combine(servicesPath, replaceDto.ViewsFileName + ".js");
+
+ if (File.Exists(fullPath) && !generateDto.coverd)
+ return Tuple.Create(fullPath, "");
+
+ var content = ReadTemplate("VueJsTemplate.txt")
+ .Replace("{ModelTypeName}", replaceDto.ModelTypeName)
+ .Replace("{ModelTypeDesc}", replaceDto.TableDesc)
+ .Replace("{ModuleName}", generateDto.GenTable.ModuleName);
+
+ return Tuple.Create(fullPath, content);
+ }
+
+ #endregion
+
+ #region 生成SQL
+
+ public static Tuple GenerateSql(ReplaceDto replaceDto, GenerateDto generateDto)
+ {
+ string fullPath = Path.Combine(generateDto.GenCodePath, replaceDto.ViewsFileName + ".sql");
+
+ if (File.Exists(fullPath) && !generateDto.coverd)
+ return Tuple.Create(fullPath, "");
+ var content = ReadTemplate("SqlTemplate.txt")
+ .Replace("{ModelTypeName}", replaceDto.ModelTypeName)
+ .Replace("{Permission}", replaceDto.Permission)
+ .Replace("{ModelTypeDesc}", replaceDto.TableDesc)
+ .Replace("{ModuleName}", generateDto.GenTable.ModuleName)
+ .Replace("{ViewsFileName}", replaceDto.ViewsFileName)
+ .Replace("{FunctionName}", generateDto.GenTable.FunctionName);
+
return Tuple.Create(fullPath, content);
}
@@ -425,19 +410,29 @@ namespace ZR.CodeGenerator
///
/// 如果有前缀替换将前缀替换成空,替换下划线"_"为空再将首字母大写
+ /// 表名转换成C#类名
///
- ///
+ ///
///
- public static string GetModelClassName(string modelTypeName)
+ public static string GetClassName(string tableName)
{
- if (!string.IsNullOrEmpty(_option.ReplaceTableNameStr))
+ bool autoRemovePre = ConfigUtils.Instance.GetAppConfig(GenConstants.Gen_autoPre, false);
+ string tablePrefix = ConfigUtils.Instance.GetAppConfig(GenConstants.Gen_tablePrefix);
+
+ if (!string.IsNullOrEmpty(tablePrefix) && autoRemovePre)
{
- modelTypeName = modelTypeName.Replace(_option.ReplaceTableNameStr.ToString(), "");
+ string[] searcList = tablePrefix.Split(",", StringSplitOptions.RemoveEmptyEntries);
+ for (int i = 0; i < searcList.Length; i++)
+ {
+ if (!string.IsNullOrEmpty(searcList[i].ToString()))
+ {
+ tableName = tableName.Replace(searcList[i], "");
+ }
+ }
}
- modelTypeName = modelTypeName.Replace("_", "");
- modelTypeName = modelTypeName.Substring(0, 1).ToUpper() + modelTypeName[1..];
- return modelTypeName;
+ return tableName.Substring(0, 1).ToUpper() + tableName[1..].Replace("_", "");
}
+
///
/// 首字母转小写,输出前端
///
@@ -465,8 +460,10 @@ namespace ZR.CodeGenerator
///
private static string ReadTemplate(string templateName)
{
- var path = AppDomain.CurrentDomain.BaseDirectory;
- string fullName = $"{path}\\Template\\{templateName}";
+ string path = Environment.CurrentDirectory;
+ string fullName = $"{path}/wwwroot/CodeGenTemplate/{templateName}";
+
+ Console.WriteLine("开始读取模板=" + fullName);
string temp = fullName;
string str = "";
if (!File.Exists(temp))
@@ -479,11 +476,13 @@ namespace ZR.CodeGenerator
sr = new StreamReader(temp);
str = sr.ReadToEnd(); // 读取文件
}
- catch { }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"读取模板出错了{ex.Message}");
+ }
sr?.Close();
sr?.Dispose();
return str;
-
}
///
@@ -493,6 +492,8 @@ namespace ZR.CodeGenerator
///
private static void WriteAndSave(string fileName, string content)
{
+ fileName = fileName.Replace("\\", "/").Replace("//", "/");
+ Console.WriteLine("写入文件:" + fileName);
try
{
//实例化一个文件流--->与写入文件相关联
@@ -513,6 +514,132 @@ namespace ZR.CodeGenerator
}
}
+ ///
+ /// 创建文件夹
+ ///
+ ///
+ ///
+ public static bool CreateDirectory(string path)
+ {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ {
+ path = path.Replace("\\", "/").Replace("//", "/");
+ }
+ try
+ {
+ if (!Directory.Exists(path))
+ {
+ DirectoryInfo info = Directory.CreateDirectory(path);
+ Console.WriteLine("不存在创建文件夹" + info);
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"创建文件夹出错了,{ex.Message}");
+ return false;
+ }
+ return true;
+ }
+
#endregion
+
+ ///
+ /// 初始化列属性字段数据
+ ///
+ ///
+ ///
+ public static List InitGenTableColumn(GenTable genTable, List dbColumnInfos)
+ {
+ List genTableColumns = new();
+ foreach (var column in dbColumnInfos)
+ {
+ GenTableColumn genTableColumn = new()
+ {
+ ColumnName = FirstLowerCase(column.DbColumnName),
+ ColumnComment = column.ColumnDescription,
+ IsPk = column.IsPrimarykey,
+ ColumnType = column.DataType,
+ TableId = genTable.TableId,
+ TableName = genTable.TableName,
+ CsharpType = TableMappingHelper.GetCSharpDatatype(column.DataType),
+ CsharpField = column.DbColumnName.Substring(0, 1).ToUpper() + column.DbColumnName[1..],
+ IsRequired = !column.IsNullable,
+ IsIncrement = column.IsIdentity,
+ Create_by = genTable.Create_by,
+ Create_time = DateTime.Now,
+ IsInsert = !column.IsIdentity,//非自增字段都需要插入
+ IsQuery = false,
+ HtmlType = GenConstants.HTML_INPUT
+ };
+
+ if (GenConstants.imageFiled.Any(f => column.DbColumnName.ToLower().Contains(f.ToLower())))
+ {
+ genTableColumn.HtmlType = GenConstants.HTML_IMAGE_UPLOAD;
+ }
+ else if (GenConstants.COLUMNTYPE_TIME.Any(f => genTableColumn.CsharpType.ToLower().Contains(f.ToLower())))
+ {
+ genTableColumn.HtmlType = GenConstants.HTML_DATETIME;
+ }
+ else if (GenConstants.radioFiled.Any(f => column.DbColumnName.EndsWith(f, StringComparison.OrdinalIgnoreCase)) ||
+ GenConstants.radioFiled.Any(f => column.DbColumnName.StartsWith(f, StringComparison.OrdinalIgnoreCase)))
+ {
+ genTableColumn.HtmlType = GenConstants.HTML_RADIO;
+ }
+ else if (GenConstants.selectFiled.Any(f => column.DbColumnName == f) ||
+ GenConstants.selectFiled.Any(f => column.DbColumnName.EndsWith(f, StringComparison.OrdinalIgnoreCase)))
+ {
+ genTableColumn.HtmlType = GenConstants.HTML_SELECT;
+ }
+ else if (column.Length > 500)
+ {
+ genTableColumn.HtmlType = GenConstants.HTML_TEXTAREA;
+ }
+ //编辑字段
+ if (GenConstants.COLUMNNAME_NOT_EDIT.Any(f => column.DbColumnName.Contains(f)) && !column.IsIdentity && !column.IsPrimarykey)
+ {
+ genTableColumn.IsEdit = true;
+ }
+ //列表字段
+ if (!GenConstants.COLUMNNAME_NOT_LIST.Any(f => column.DbColumnName.Contains(f) && !column.IsPrimarykey))
+ {
+ genTableColumn.IsList = true;
+ }
+
+ genTableColumns.Add(genTableColumn);
+ }
+ return genTableColumns;
+ }
+
+ ///
+ /// 压缩代码
+ ///
+ ///
+ ///
+ public static string ZipGenCode(GenerateDto dto)
+ {
+ try
+ {
+ //生成压缩包
+ string zipReturnFileName = dto.GenTable.BaseNameSpace + DateTime.Now.ToString("yyyyMMddHHmmss") + ".zip";
+
+ CreateDirectory(dto.GenCodePath);
+ string zipFileName = Path.Combine(dto.ZipPath, zipReturnFileName);
+ if (File.Exists(zipFileName))
+ {
+ File.Delete(zipFileName);
+ }
+
+ ZipFile.CreateFromDirectory(dto.GenCodePath, zipFileName);
+ FileHelper.DeleteDirectory(dto.GenCodePath);
+ dto.ZipFileName = zipReturnFileName;
+ return zipReturnFileName;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("压缩文件出错。" + ex.Message);
+ return "";
+ }
+ }
+
}
}
diff --git a/ZR.CodeGenerator/DbProvider.cs b/ZR.CodeGenerator/DbProvider.cs
index 56525f3..71982e1 100644
--- a/ZR.CodeGenerator/DbProvider.cs
+++ b/ZR.CodeGenerator/DbProvider.cs
@@ -8,6 +8,9 @@ using System.Threading.Tasks;
namespace ZR.CodeGenerator
{
+ ///
+ /// 代码生成数据库连接
+ ///
public class DbProvider
{
protected static SqlSugarScope CodeDb;
@@ -19,12 +22,13 @@ namespace ZR.CodeGenerator
///
public SqlSugarScope GetSugarDbContext(string dbName = "")
{
- string connStr = ConfigUtils.Instance.GetConnectionStrings(OptionsSetting.Conn).Replace("{database}", dbName);
- int dbType = ConfigUtils.Instance.GetAppConfig(OptionsSetting.CodeGenDbType, 0);
+ string connStr = ConfigUtils.Instance.GetConfig(GenConstants.Gen_conn);
+ int dbType = ConfigUtils.Instance.GetAppConfig(GenConstants.Gen_conn_dbType, 0);
+ connStr = connStr.Replace("{database}", dbName);
if (string.IsNullOrEmpty(dbName))
{
connStr = ConfigUtils.Instance.GetConnectionStrings(OptionsSetting.ConnAdmin);
- dbType = ConfigUtils.Instance.GetAppConfig(OptionsSetting.DbType, 0);
+ dbType = ConfigUtils.Instance.GetAppConfig(OptionsSetting.ConnDbType);
}
var db = new SqlSugarScope(new List()
{
diff --git a/ZR.CodeGenerator/FileHelper.cs b/ZR.CodeGenerator/FileHelper.cs
new file mode 100644
index 0000000..66c08e7
--- /dev/null
+++ b/ZR.CodeGenerator/FileHelper.cs
@@ -0,0 +1,183 @@
+using ICSharpCode.SharpZipLib.Checksum;
+using ICSharpCode.SharpZipLib.Zip;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZR.CodeGenerator
+{
+ public class FileHelper
+ {
+ ///
+ /// 制作压缩包(多个文件压缩到一个压缩包,支持加密、注释)
+ ///
+ /// 要压缩的文件
+ /// 压缩文件目录
+ /// 压缩包文件名
+ /// 压缩级别 1-9
+ /// 密码
+ /// 注释
+ public static void ZipFiles(string[] fileNames, string topDirectoryName, string zipedFileName, int? compresssionLevel, string password = "", string comment = "")
+ {
+ using (ZipOutputStream zos = new ZipOutputStream(File.Open(zipedFileName, FileMode.OpenOrCreate)))
+ {
+ if (compresssionLevel.HasValue)
+ {
+ zos.SetLevel(compresssionLevel.Value);//设置压缩级别
+ }
+
+ if (!string.IsNullOrEmpty(password))
+ {
+ zos.Password = password;//设置zip包加密密码
+ }
+
+ if (!string.IsNullOrEmpty(comment))
+ {
+ zos.SetComment(comment);//设置zip包的注释
+ }
+
+ foreach (string file in fileNames)
+ {
+ //string fileName = string.Format("{0}/{1}", topDirectoryName, file);
+ string fileName = file;
+
+ if (File.Exists(fileName))
+ {
+ FileInfo item = new FileInfo(fileName);
+ FileStream fs = File.OpenRead(item.FullName);
+ byte[] buffer = new byte[fs.Length];
+ fs.Read(buffer, 0, buffer.Length);
+
+ ZipEntry entry = new ZipEntry(item.Name);
+ zos.PutNextEntry(entry);
+ zos.Write(buffer, 0, buffer.Length);
+ }
+ }
+ }
+ }
+
+ ///
+ /// 压缩多层目录
+ ///
+ /// 压缩文件目录
+ /// 压缩包文件名
+ /// 压缩级别 1-9
+ /// 密码
+ /// 注释
+ /// 文件类型
+ public static void ZipFileDirectory(string topDirectoryName, string zipedFileName, int compresssionLevel, string password, string comment, string filetype)
+ {
+ using (System.IO.FileStream ZipFile = File.Open(zipedFileName, FileMode.OpenOrCreate))
+ {
+ using (ZipOutputStream zos = new ZipOutputStream(ZipFile))
+ {
+ if (compresssionLevel != 0)
+ {
+ zos.SetLevel(compresssionLevel);//设置压缩级别
+ }
+ if (!string.IsNullOrEmpty(password))
+ {
+ zos.Password = password;//设置zip包加密密码
+ }
+ if (!string.IsNullOrEmpty(comment))
+ {
+ zos.SetComment(comment);//设置zip包的注释
+ }
+ ZipSetp(topDirectoryName, zos, "", filetype);
+ }
+ }
+ }
+
+ ///
+ /// 递归遍历目录
+ ///
+ /// The directory.
+ /// The ZipOutputStream Object.
+ /// The parent path.
+ private static void ZipSetp(string strDirectory, ZipOutputStream s, string parentPath, string filetype)
+ {
+ if (strDirectory[^1] != Path.DirectorySeparatorChar)
+ {
+ strDirectory += Path.DirectorySeparatorChar;
+ }
+ Console.WriteLine("strDirectory=" + strDirectory);
+ Crc32 crc = new Crc32();
+
+ string[] filenames = Directory.GetFileSystemEntries(strDirectory, filetype);
+ foreach (string file in filenames)// 遍历所有的文件和目录
+ {
+ if (Directory.Exists(file))// 先当作目录处理如果存在这个目录就递归Copy该目录下面的文件
+ {
+ string pPath = parentPath;
+ pPath += file[(file.LastIndexOf("/") + 1)..];
+ pPath += "/";
+ Console.WriteLine("递归路径" + pPath);
+ ZipSetp(file, s, pPath, filetype);
+ }
+ else // 否则直接压缩文件
+ {
+ //打开压缩文件
+ using (FileStream fs = File.OpenRead(file))
+ {
+ byte[] buffer = new byte[fs.Length];
+ fs.Read(buffer, 0, buffer.Length);
+ string fileName = parentPath + file[(file.LastIndexOf("/") + 1)..];
+ ZipEntry entry = new ZipEntry(fileName);
+ entry.DateTime = DateTime.Now;
+ entry.Size = fs.Length;
+ fs.Close();
+ crc.Reset();
+ crc.Update(buffer);
+ entry.Crc = crc.Value;
+ s.PutNextEntry(entry);
+ s.Write(buffer, 0, buffer.Length);
+ }
+ }
+ }
+ }
+
+ ///
+ /// 删除指定目录下的所有文件及文件夹(保留目录)
+ ///
+ /// 文件目录
+ public static void DeleteDirectory(string file)
+ {
+ try
+ {
+ //判断文件夹是否还存在
+ if (Directory.Exists(file))
+ {
+ DirectoryInfo fileInfo = new DirectoryInfo(file);
+ //去除文件夹的只读属性
+ fileInfo.Attributes = FileAttributes.Normal & FileAttributes.Directory;
+ foreach (string f in Directory.GetFileSystemEntries(file))
+ {
+ if (File.Exists(f))
+ {
+ //去除文件的只读属性
+ File.SetAttributes(file, FileAttributes.Normal);
+ //如果有子文件删除文件
+ File.Delete(f);
+ }
+ else
+ {
+ //循环递归删除子文件夹
+ DeleteDirectory(f);
+ }
+ }
+ //删除空文件夹
+ Directory.Delete(file);
+ }
+
+ }
+ catch (Exception ex) // 异常处理
+ {
+ //Log4NetHelper.Error("代码生成异常", ex);
+ }
+ }
+
+ }
+}
diff --git a/ZR.CodeGenerator/GenConstants.cs b/ZR.CodeGenerator/GenConstants.cs
new file mode 100644
index 0000000..5b62292
--- /dev/null
+++ b/ZR.CodeGenerator/GenConstants.cs
@@ -0,0 +1,136 @@
+
+
+namespace ZR.CodeGenerator
+{
+ ///
+ /// 代码生成常量
+ ///
+ public class GenConstants
+ {
+ public static string Gen_conn = "gen:conn";
+ public static string Gen_conn_dbType = "gen:dbType";
+ public static string Gen_author = "gen:author";
+ public static string Gen_autoPre = "gen:autoPre";
+ public static string Gen_tablePrefix = "gen:tablePrefix";
+
+ ///
+ /// InputDto输入实体是不包含字段
+ ///
+ public static readonly string[] inputDtoNoField = new string[] { "createTime", "updateTime", "addtime" };
+ ///
+ /// 图片字段
+ ///
+ public static readonly string[] imageFiled = new string[] { "icon", "img", "image", "url", "pic", "photo", "avatar" };
+ ///
+ /// 下拉框字段
+ ///
+ public static readonly string[] selectFiled = new string[] { "status", "type", "state", "sex", "gender" };
+ ///
+ /// 单选按钮字段
+ ///
+ public static readonly string[] radioFiled = new string[] { "status", "state", "is"};
+
+
+ /** 单表(增删改查) */
+ public static string TPL_CRUD = "crud";
+
+ /** 树表(增删改查) */
+ public static string TPL_TREE = "tree";
+
+ /** 主子表(增删改查) */
+ public static string TPL_SUB = "sub";
+
+ /** 树编码字段 */
+ public static string TREE_CODE = "treeCode";
+
+ /** 树父编码字段 */
+ public static string TREE_PARENT_CODE = "treeParentCode";
+
+ /** 树名称字段 */
+ public static string TREE_NAME = "treeName";
+
+ /** 上级菜单ID字段 */
+ public static string PARENT_MENU_ID = "parentMenuId";
+
+ /** 上级菜单名称字段 */
+ public static string PARENT_MENU_NAME = "parentMenuName";
+
+ /** 数据库字符串类型 */
+ public static string[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" };
+
+ /** 数据库文本类型 */
+ public static string[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
+
+ /** 数据库时间类型 */
+ public static string[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
+
+ /** 数据库数字类型 */
+ public static string[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
+ "bit", "bigint", "float", "double", "decimal" };
+
+ /** 页面不需要编辑字段 */
+ public static string[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "delFlag" };
+
+ /** 页面不需要显示的列表字段 */
+ public static string[] COLUMNNAME_NOT_LIST = { "create_by", "create_time", "delFlag", "update_by",
+ "update_time" , "password"};
+
+ /** 页面不需要查询字段 */
+ public static string[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "delFlag", "update_by",
+ "update_time", "remark" };
+
+ /** Entity基类字段 */
+ public static string[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" };
+
+ /** Tree基类字段 */
+ public static string[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" };
+
+ /** 文本框 */
+ public static string HTML_INPUT = "input";
+
+ /** 文本域 */
+ public static string HTML_TEXTAREA = "textarea";
+
+ /** 下拉框 */
+ public static string HTML_SELECT = "select";
+
+ /** 单选框 */
+ public static string HTML_RADIO = "radio";
+
+ /** 复选框 */
+ public static string HTML_CHECKBOX = "checkbox";
+
+ /** 日期控件 */
+ public static string HTML_DATETIME = "datetime";
+
+ /** 图片上传控件 */
+ public static string HTML_IMAGE_UPLOAD = "imageUpload";
+
+ /** 文件上传控件 */
+ public static string HTML_FILE_UPLOAD = "fileUpload";
+
+ /** 富文本控件 */
+ public static string HTML_EDITOR = "editor";
+
+ /** 字符串类型 */
+ public static string TYPE_STRING = "string";
+
+ /** 整型 */
+ public static string TYPE_INT = "int";
+
+ /** 长整型 */
+ public static string TYPE_LONG = "long";
+
+ /** 浮点型 */
+ public static string TYPE_DOUBLE = "Double";
+
+ /** 时间类型 */
+ public static string TYPE_DATE = "Date";
+
+ /** 模糊查询 */
+ public static string QUERY_LIKE = "LIKE";
+
+ /** 需要 */
+ public static string REQUIRE = "1";
+ }
+}
\ No newline at end of file
diff --git a/ZR.CodeGenerator/Model/GenerateDto.cs b/ZR.CodeGenerator/Model/GenerateDto.cs
index 60399fc..4bfe0b0 100644
--- a/ZR.CodeGenerator/Model/GenerateDto.cs
+++ b/ZR.CodeGenerator/Model/GenerateDto.cs
@@ -3,32 +3,45 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using ZR.Model.System.Generate;
namespace ZR.CodeGenerator.Model
{
public class GenerateDto
{
- public string[] queryColumn { get; set; }
- ///
- ///
- ///
- public string dbName { get; set; }
- ///
- /// 项目命名空间
- ///
- public string baseSpace { get; set; }
- ///
- /// 要生成代码的表
- ///
- public string tableName { get; set; }
- ///
- /// 要删除表名的字符串用
- ///
- public string replaceTableNameStr { get; set; }
+ public long TableId { get; set; }
+ public string[] QueryColumn { get; set; }
+
///
/// 要生成的文件
///
public int[] genFiles { get; set; }
+ ///
+ /// 如果目标文件存在,是否覆盖。默认为false
+ ///
public bool coverd { get; set; } = true;
+ public GenTable GenTable { get; set; }
+ #region 存储路径
+ //public string ModelPath { get; set; }
+ //public string ServicePath { get; set; }
+ //public string RepositoryPath { get; set; }
+ //public string ApiPath { get; set; }
+ //public string VuePath { get; set; }
+ //public string VueApiPath { get; set; }
+
+ //public string ParentPath { get; set; } = "..";
+ ///
+ /// 代码生成路径
+ ///
+ public string GenCodePath { get; set; }
+ ///
+ /// 代码生成压缩包路径
+ ///
+ public string ZipPath { get; set; }
+ ///
+ /// 代码生成压缩包名称
+ ///
+ public string ZipFileName { get; set; }
+ #endregion
}
}
diff --git a/ZR.CodeGenerator/Model/ReplaceDto.cs b/ZR.CodeGenerator/Model/ReplaceDto.cs
new file mode 100644
index 0000000..35effe0
--- /dev/null
+++ b/ZR.CodeGenerator/Model/ReplaceDto.cs
@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZR.CodeGenerator.Model
+{
+ public class ReplaceDto
+ {
+ //public string ModelsNamespace { get; set; }
+ //public string DtosNamespace { get; set; }
+ //public string RepositoriesNamespace { get; set; }
+ //public string IRepositoriesNamespace { get; set; }
+ //public string IServicsNamespace { get; set; }
+ //public string ServicesNamespace { get; set; }
+
+ ///
+ /// 主键字段
+ ///
+ public string PKName { get; set; }
+ ///
+ /// 主键类型
+ ///
+ public string PKType { get; set; }
+ ///
+ /// 控制器权限
+ ///
+ public string Permission { get; set; }
+ ///
+ /// C#类名
+ ///
+ public string ModelTypeName { get; set; }
+ ///
+ /// 数据库表名
+ ///
+ public string TableName { get; set; }
+ ///
+ /// 表描述、说明
+ ///
+ public string TableDesc { get; set; }
+ ///
+ /// 修改列
+ ///
+ public string UpdateColumn { get; set; }
+ ///
+ /// 插入列
+ ///
+ public string InsertColumn { get; set; }
+
+
+ ///
+ /// 实体属性模板
+ ///
+ public string ModelProperty { get; set; }
+ ///
+ /// 输入Dto模板
+ ///
+ public string InputDtoProperty { get; set; }
+
+ //vue、api
+ public string VueViewFormResetHtml { get; set; }
+ ///
+ /// 前端列表查询html
+ ///
+ public string VueViewListHtml { get; set; }
+ ///
+ /// 前端添加、编辑表格html
+ ///
+ public string VueViewFormHtml { get; set; }
+ ///
+ /// 前端搜索表单html
+ ///
+ public string VueQueryFormHtml { get; set; }
+ ///
+ /// vue js方法
+ ///
+ public string VueJsMethod { get; set; }
+ ///
+ /// vue 添加、编辑表单规则
+ ///
+ public string VueViewEditFormRuleContent { get; set; }
+ ///
+ /// 查询条件
+ ///
+ public string QueryCondition { get; set; }
+ ///
+ /// 查询属性
+ ///
+ public string QueryProperty { get; set; }
+ ///
+ /// vue data内容
+ ///
+ public string VueDataContent { get; set; }
+ ///
+ /// vue mounted 方法
+ ///
+ public string MountedMethod { get; set; }
+ ///
+ /// views、js文件名
+ ///
+ public string ViewsFileName { get; set; }
+ }
+}
diff --git a/ZR.CodeGenerator/Service/CodeGeneraterService.cs b/ZR.CodeGenerator/Service/CodeGeneraterService.cs
index f22a3bf..1e5612d 100644
--- a/ZR.CodeGenerator/Service/CodeGeneraterService.cs
+++ b/ZR.CodeGenerator/Service/CodeGeneraterService.cs
@@ -33,10 +33,27 @@ namespace ZR.CodeGenerator.Service
{
tableList = tableList.Where(f => f.Name.ToLower().Contains(tableName.ToLower())).ToList();
}
+ tableList = tableList.Where(f => !new string[] { "gen", "sys_" }.Contains(f.Name)).ToList();
pager.TotalNum = tableList.Count;
return tableList.Skip(pager.PageSize * (pager.PageNum - 1)).Take(pager.PageSize).OrderBy(f => f.Name).ToList();
}
+ ///
+ /// 获取单表数据
+ ///
+ ///
+ ///
+ ///
+ public DbTableInfo GetTableInfo(string dbName, string tableName)
+ {
+ var tableList = GetSugarDbContext(dbName).DbMaintenance.GetTableInfoList(true);
+ if (!string.IsNullOrEmpty(tableName))
+ {
+ return tableList.Where(f => f.Name.ToLower() == (tableName.ToLower())).FirstOrDefault();
+ }
+
+ return null;
+ }
///
/// 获取列信息
///
diff --git a/ZR.CodeGenerator/TableMappingHelper.cs b/ZR.CodeGenerator/TableMappingHelper.cs
index 44f8e38..7a0a938 100644
--- a/ZR.CodeGenerator/TableMappingHelper.cs
+++ b/ZR.CodeGenerator/TableMappingHelper.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Text;
using Infrastructure.Extensions;
using ZR.Common.Extension;
@@ -44,69 +45,33 @@ namespace ZR.CodeGenerator.CodeGenerator
return sb.ToString();
}
- public static string GetPropertyDatatype(string sDatatype)
+ ///
+ /// 获取C# 类型
+ ///
+ ///
+ ///
+ public static string GetCSharpDatatype(string sDatatype)
{
- string sTempDatatype = string.Empty;
sDatatype = sDatatype.ToLower();
- switch (sDatatype)
+ string sTempDatatype = sDatatype switch
{
- case "int":
- case "number":
- case "integer":
- case "smallint":
- sTempDatatype = "int?";
- break;
-
- case "bigint":
- sTempDatatype = "long?";
- break;
-
- case "tinyint":
- sTempDatatype = "byte?";
- break;
-
- case "numeric":
- case "real":
- sTempDatatype = "Single?";
- break;
-
- case "float":
- sTempDatatype = "float?";
- break;
-
- case "decimal":
- case "numer(8,2)":
- sTempDatatype = "decimal?";
- break;
-
- case "bit":
- sTempDatatype = "bool?";
- break;
-
- case "date":
- case "datetime":
- case "datetime2":
- case "smalldatetime":
- sTempDatatype = "DateTime?";
- break;
-
- case "money":
- case "smallmoney":
- sTempDatatype = "double?";
- break;
-
- case "char":
- case "varchar":
- case "nvarchar2":
- case "text":
- case "nchar":
- case "nvarchar":
- case "ntext":
- default:
- sTempDatatype = "string";
- break;
- }
+ "int" or "number" or "integer" or "smallint" => "int",
+ "bigint" => "long",
+ "tinyint" => "byte",
+ "numeric" or "real" or "float" => "float",
+ "decimal" or "numer(8,2)" => "decimal",
+ "bit" => "bool",
+ "date" or "datetime" or "datetime2" or "smalldatetime" => "DateTime",
+ "money" or "smallmoney" => "double",
+ _ => "string",
+ };
return sTempDatatype;
}
+
+ public static bool IsNumber(string tableDataType)
+ {
+ string[] arr = new string[] { "int", "long" };
+ return arr.Any(f => f.Contains(GetCSharpDatatype(tableDataType)));
+ }
}
}
diff --git a/ZR.Model/Dto/System/ArticleDto.cs b/ZR.Model/System/Dto/ArticleDto.cs
similarity index 91%
rename from ZR.Model/Dto/System/ArticleDto.cs
rename to ZR.Model/System/Dto/ArticleDto.cs
index ff5a3c0..368b1ea 100644
--- a/ZR.Model/Dto/System/ArticleDto.cs
+++ b/ZR.Model/System/Dto/ArticleDto.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
-namespace ZR.Model.Dto.System
+namespace ZR.Model.System.Dto
{
public class ArticleQueryDto: PagerInfo
{
diff --git a/ZR.Model/System/Dto/GenTableDto.cs b/ZR.Model/System/Dto/GenTableDto.cs
new file mode 100644
index 0000000..7820d7b
--- /dev/null
+++ b/ZR.Model/System/Dto/GenTableDto.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using ZR.Model.System.Generate;
+
+namespace ZR.Model.System.Dto
+{
+ public class GenTableDto
+ {
+ public int TableId { get; set; }
+ public string TableName { get; set; }
+ public string TableComment { get; set; }
+ public string SubTableName { get; set; }
+ public string SubTableFkName { get; set; }
+ public string ClassName { get; set; }
+ public string TplCategory { get; set; }
+ public string BaseNameSpace { get; set; }
+ public string ModuleName { get; set; }
+ public string BusinessName { get; set; }
+ public string FunctionName { get; set; }
+ public string FunctionAuthor { get; set; }
+ public string GenType { get; set; }
+ public string Options { get; set; }
+ public List Columns { get; set; }
+ }
+
+ public class GenTableColumnDto
+ {
+ public int ColumnId { get; set; }
+ public int TableId { get; set; }
+ public string ColumnComment { get; set; }
+ public string CsharpType { get; set; }
+ public string CsharpField { get; set; }
+ public bool IsInsert { get; set; }
+ public bool IsEdit { get; set; }
+ public bool IsList { get; set; }
+ public bool IsQuery { get; set; }
+ public bool IsRequired { get; set; }
+ ///
+ /// 显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)
+ ///
+ public string HtmlType { get; set; }
+ ///
+ /// 查询类型(等于、不等于、大于、小于、范围)
+ ///
+ public string QueryType { get; set; } = "EQ";
+ public int Sort { get; set; }
+ ///
+ /// 字典类型
+ ///
+ public string DictType { get; set; }
+ }
+}
diff --git a/ZR.Model/Dto/System/LoginBodyDto.cs b/ZR.Model/System/Dto/LoginBodyDto.cs
similarity index 95%
rename from ZR.Model/Dto/System/LoginBodyDto.cs
rename to ZR.Model/System/Dto/LoginBodyDto.cs
index cf0fa0b..6bb2246 100644
--- a/ZR.Model/Dto/System/LoginBodyDto.cs
+++ b/ZR.Model/System/Dto/LoginBodyDto.cs
@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
-namespace ZR.Model.Dto.System
+namespace ZR.Model.System.Dto
{
public class LoginBodyDto
{
diff --git a/ZR.Model/Dto/System/MenuDto.cs b/ZR.Model/System/Dto/MenuDto.cs
similarity index 96%
rename from ZR.Model/Dto/System/MenuDto.cs
rename to ZR.Model/System/Dto/MenuDto.cs
index ac241f7..0fa5671 100644
--- a/ZR.Model/Dto/System/MenuDto.cs
+++ b/ZR.Model/System/Dto/MenuDto.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
-namespace ZR.Model.Dto.System
+namespace ZR.Model.System.Dto
{
public class MenuDto
{
diff --git a/ZR.Model/Dto/System/RoleUsersCreateDto.cs b/ZR.Model/System/Dto/RoleUsersCreateDto.cs
similarity index 95%
rename from ZR.Model/Dto/System/RoleUsersCreateDto.cs
rename to ZR.Model/System/Dto/RoleUsersCreateDto.cs
index 2ba0cfb..456621a 100644
--- a/ZR.Model/Dto/System/RoleUsersCreateDto.cs
+++ b/ZR.Model/System/Dto/RoleUsersCreateDto.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
-namespace ZR.Model.Dto.System
+namespace ZR.Model.System.Dto
{
public class RoleUsersCreateDto
{
diff --git a/ZR.Model/Dto/System/SysFileQueryDto.cs b/ZR.Model/System/Dto/SysFileQueryDto.cs
similarity index 81%
rename from ZR.Model/Dto/System/SysFileQueryDto.cs
rename to ZR.Model/System/Dto/SysFileQueryDto.cs
index 5c3d018..868534d 100644
--- a/ZR.Model/Dto/System/SysFileQueryDto.cs
+++ b/ZR.Model/System/Dto/SysFileQueryDto.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
-namespace ZR.Model.Dto.System
+namespace ZR.Model.System.Dto
{
public class SysFileQueryDto : PagerInfo
{
diff --git a/ZR.Model/Dto/System/SysLogininfoDto.cs b/ZR.Model/System/Dto/SysLogininfoDto.cs
similarity index 94%
rename from ZR.Model/Dto/System/SysLogininfoDto.cs
rename to ZR.Model/System/Dto/SysLogininfoDto.cs
index 7d5bc43..a125b9a 100644
--- a/ZR.Model/Dto/System/SysLogininfoDto.cs
+++ b/ZR.Model/System/Dto/SysLogininfoDto.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using ZR.Model.System;
-namespace ZR.Model.Dto.System
+namespace ZR.Model.System.Dto
{
public class SysLogininfoDto : SysBase
{
diff --git a/ZR.Model/Dto/System/SysOperLogDto.cs b/ZR.Model/System/Dto/SysOperLogDto.cs
similarity index 96%
rename from ZR.Model/Dto/System/SysOperLogDto.cs
rename to ZR.Model/System/Dto/SysOperLogDto.cs
index e686da1..23bd3cb 100644
--- a/ZR.Model/Dto/System/SysOperLogDto.cs
+++ b/ZR.Model/System/Dto/SysOperLogDto.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using ZR.Model.System;
-namespace ZR.Model.Dto.System
+namespace ZR.Model.System.Dto
{
public class SysOperLogDto : SysBase
{
diff --git a/ZR.Model/Dto/System/SysRoleDto.cs b/ZR.Model/System/Dto/SysRoleDto.cs
similarity index 94%
rename from ZR.Model/Dto/System/SysRoleDto.cs
rename to ZR.Model/System/Dto/SysRoleDto.cs
index 7ba3d47..5a29195 100644
--- a/ZR.Model/Dto/System/SysRoleDto.cs
+++ b/ZR.Model/System/Dto/SysRoleDto.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using ZR.Model.System;
-namespace ZR.Model.Dto.System
+namespace ZR.Model.System.Dto
{
public class SysRoleDto: SysBase
{
diff --git a/ZR.Model/Dto/System/SysUserDto.cs b/ZR.Model/System/Dto/SysUserDto.cs
similarity index 94%
rename from ZR.Model/Dto/System/SysUserDto.cs
rename to ZR.Model/System/Dto/SysUserDto.cs
index ef7df57..6841ef6 100644
--- a/ZR.Model/Dto/System/SysUserDto.cs
+++ b/ZR.Model/System/Dto/SysUserDto.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using ZR.Model.System;
-namespace ZR.Model.Dto.System
+namespace ZR.Model.System.Dto
{
public class SysUserDto
{
diff --git a/ZR.Model/Dto/System/TasksDto.cs b/ZR.Model/System/Dto/TasksDto.cs
similarity index 99%
rename from ZR.Model/Dto/System/TasksDto.cs
rename to ZR.Model/System/Dto/TasksDto.cs
index bc190bc..f41827f 100644
--- a/ZR.Model/Dto/System/TasksDto.cs
+++ b/ZR.Model/System/Dto/TasksDto.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
-namespace ZR.Model.Dto.System
+namespace ZR.Model.System.Dto
{
public class TasksQueryDto
{
diff --git a/ZR.Model/Dto/System/TasksLogDto.cs b/ZR.Model/System/Dto/TasksLogDto.cs
similarity index 95%
rename from ZR.Model/Dto/System/TasksLogDto.cs
rename to ZR.Model/System/Dto/TasksLogDto.cs
index 7c573e4..0284234 100644
--- a/ZR.Model/Dto/System/TasksLogDto.cs
+++ b/ZR.Model/System/Dto/TasksLogDto.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
-namespace ZR.Model.Dto.System
+namespace ZR.Model.System.Dto
{
public class TasksLogQueryDto
{
diff --git a/ZR.Model/System/Generate/GenTable.cs b/ZR.Model/System/Generate/GenTable.cs
new file mode 100644
index 0000000..0737c33
--- /dev/null
+++ b/ZR.Model/System/Generate/GenTable.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace ZR.Model.System.Generate
+{
+ ///
+ /// 代码生成表
+ ///
+ [SqlSugar.SugarTable("gen_table")]
+ public class GenTable: SysBase
+ {
+ [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+ public int TableId { get; set; }
+ public string TableName { get; set; }
+ public string TableComment { get; set; }
+ public string SubTableName { get; set; }
+ public string SubTableFkName { get; set; }
+ public string ClassName { get; set; }
+ public string TplCategory { get; set; }
+ public string BaseNameSpace { get; set; }
+ public string ModuleName { get; set; }
+ public string BusinessName { get; set; }
+ public string FunctionName { get; set; }
+ public string FunctionAuthor { get; set; }
+ public string GenType { get; set; }
+ public string Options { get; set; }
+
+
+ /** 表列信息 */
+ [SqlSugar.SugarColumn(IsIgnore = true)]
+ public List Columns { get; set; }
+ }
+}
diff --git a/ZR.Model/System/Generate/GenTableColumn.cs b/ZR.Model/System/Generate/GenTableColumn.cs
new file mode 100644
index 0000000..e517540
--- /dev/null
+++ b/ZR.Model/System/Generate/GenTableColumn.cs
@@ -0,0 +1,66 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace ZR.Model.System.Generate
+{
+ ///
+ /// 代码生成表字段
+ ///
+ [SqlSugar.SugarTable("gen_table_column")]
+ public class GenTableColumn: SysBase
+ {
+ [SqlSugar.SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
+ public int ColumnId { get; set; }
+ public string ColumnName { get; set; }
+ [SqlSugar.SugarColumn(IsOnlyIgnoreUpdate = true)]
+ public int TableId { get; set; }
+
+ [SqlSugar.SugarColumn(IsOnlyIgnoreUpdate = true)]
+ public string TableName { get; set; }
+ public string ColumnComment { get; set; }
+
+ [SqlSugar.SugarColumn(IsOnlyIgnoreUpdate = true)]
+ public string ColumnType { get; set; }
+ public string CsharpType { get; set; }
+ public string CsharpField { get; set; }
+ ///
+ /// 是否主键(1是)
+ ///
+ [SqlSugar.SugarColumn(IsOnlyIgnoreUpdate = true)]
+ public bool IsPk { get; set; }
+ ///
+ /// 是否必填(1是)
+ ///
+ public bool IsRequired { get; set; }
+ [SqlSugar.SugarColumn(IsOnlyIgnoreUpdate = true)]
+ public bool IsIncrement { get; set; }
+ ///
+ /// 是否插入
+ ///
+ public bool IsInsert { get; set; }
+ ///
+ /// 是否需要编辑
+ ///
+ public bool IsEdit { get; set; }
+ ///
+ /// isList
+ ///
+ public bool IsList { get; set; }
+ public bool IsQuery { get; set; }
+ ///
+ /// 显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)
+ ///
+ public string HtmlType { get; set; }
+ ///
+ /// 查询类型(等于、不等于、大于、小于、范围)
+ ///
+ public string QueryType { get; set; } = "EQ";
+ public int Sort { get; set; }
+ ///
+ /// 字典类型
+ ///
+ public string DictType { get; set; }
+ }
+}
diff --git a/ZR.Model/System/SysBase.cs b/ZR.Model/System/SysBase.cs
index 07d07f7..22faa64 100644
--- a/ZR.Model/System/SysBase.cs
+++ b/ZR.Model/System/SysBase.cs
@@ -22,10 +22,10 @@ namespace ZR.Model.System
[SugarColumn(IsOnlyIgnoreInsert = true)]
public string Update_by { get; set; }
+ //[JsonIgnore]
[SugarColumn(IsOnlyIgnoreInsert = true)]//设置后插入数据不会有此字段
- [JsonIgnore]
[JsonProperty(propertyName: "UpdateTime")]
- public DateTime Update_time { get; set; } = DateTime.Now;
+ public DateTime? Update_time { get; set; }
public string Remark { get; set; }
@@ -39,7 +39,6 @@ namespace ZR.Model.System
/// [Computed]计算属性,打上此标签,对象地insert,update等操作会忽略此列
///
[SugarColumn(IsIgnore = true)]
- //[Computed]
[JsonIgnore]
public DateTime? BeginTime { get; set; }
@@ -47,7 +46,6 @@ namespace ZR.Model.System
/// 用于搜索使用
///
[SugarColumn(IsIgnore = true)]
- //[Computed]
[JsonIgnore]
public DateTime? EndTime { get; set; }
}
diff --git a/ZR.Model/Vo/System/RouterVo.cs b/ZR.Model/System/Vo/RouterVo.cs
similarity index 100%
rename from ZR.Model/Vo/System/RouterVo.cs
rename to ZR.Model/System/Vo/RouterVo.cs
diff --git a/ZR.Model/Vo/System/TreeSelectVo.cs b/ZR.Model/System/Vo/TreeSelectVo.cs
similarity index 100%
rename from ZR.Model/Vo/System/TreeSelectVo.cs
rename to ZR.Model/System/Vo/TreeSelectVo.cs
diff --git a/ZR.Model/ZR.Model.csproj b/ZR.Model/ZR.Model.csproj
index 975d730..d519378 100644
--- a/ZR.Model/ZR.Model.csproj
+++ b/ZR.Model/ZR.Model.csproj
@@ -17,6 +17,7 @@
+
diff --git a/ZR.Repository/DbProvider/SugarDbContext.cs b/ZR.Repository/DbProvider/SugarDbContext.cs
index 68f7afe..69fee4e 100644
--- a/ZR.Repository/DbProvider/SugarDbContext.cs
+++ b/ZR.Repository/DbProvider/SugarDbContext.cs
@@ -22,7 +22,7 @@ namespace ZR.Repository.DbProvider
{
string connStr = ConfigUtils.Instance.GetConnectionStrings(OptionsSetting.ConnAdmin);
string dbKey = ConfigUtils.Instance.GetAppConfig(OptionsSetting.DbKey);
- int dbType = ConfigUtils.Instance.GetAppConfig(OptionsSetting.DbType, 0);
+ int dbType = ConfigUtils.Instance.GetAppConfig(OptionsSetting.ConnDbType);
if (!string.IsNullOrEmpty(dbKey))
{
connStr = NETCore.Encrypt.EncryptProvider.DESDecrypt(connStr, dbKey);
@@ -52,21 +52,5 @@ namespace ZR.Repository.DbProvider
Console.WriteLine();
};
}
-
- public SqlSugarClient GetSugarDbContext(string dbName)
- {
- string connStr = ConfigUtils.Instance.GetConnectionStrings(OptionsSetting.Conn).Replace("{DbName}", dbName);
- int dbType = ConfigUtils.Instance.GetAppConfig(OptionsSetting.DbType, 0);
-
- return new SqlSugarClient(new List()
- {
- new ConnectionConfig(){
- ConnectionString = connStr,
- DbType = (DbType)dbType,
- IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样
- InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息
- },
- });
- }
}
}
diff --git a/ZR.Repository/System/ArticleRepository.cs b/ZR.Repository/System/ArticleRepository.cs
index 5b0cd75..57001a7 100644
--- a/ZR.Repository/System/ArticleRepository.cs
+++ b/ZR.Repository/System/ArticleRepository.cs
@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
namespace ZR.Repository.System
diff --git a/ZR.Repository/System/SysLogininfoRepository.cs b/ZR.Repository/System/SysLogininfoRepository.cs
index 1bdb962..f91a88d 100644
--- a/ZR.Repository/System/SysLogininfoRepository.cs
+++ b/ZR.Repository/System/SysLogininfoRepository.cs
@@ -2,7 +2,7 @@
using Infrastructure.Extensions;
using System.Collections.Generic;
using ZR.Model;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
namespace ZR.Repository.System
diff --git a/ZR.Repository/System/SysMenuRepository.cs b/ZR.Repository/System/SysMenuRepository.cs
index 0332b87..3fafa0b 100644
--- a/ZR.Repository/System/SysMenuRepository.cs
+++ b/ZR.Repository/System/SysMenuRepository.cs
@@ -3,7 +3,7 @@ using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
namespace ZR.Repository.System
diff --git a/ZR.Repository/System/SysOperLogRepository.cs b/ZR.Repository/System/SysOperLogRepository.cs
index 840de43..9c47b11 100644
--- a/ZR.Repository/System/SysOperLogRepository.cs
+++ b/ZR.Repository/System/SysOperLogRepository.cs
@@ -2,7 +2,7 @@
using Infrastructure.Extensions;
using System.Collections.Generic;
using ZR.Model;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
namespace ZR.Repository.System
diff --git a/ZR.Service/BaseService.cs b/ZR.Service/BaseService.cs
index f2d3830..8eb83d0 100644
--- a/ZR.Service/BaseService.cs
+++ b/ZR.Service/BaseService.cs
@@ -54,6 +54,18 @@ namespace ZR.Service
return Db.Insertable(parm).RemoveDataCache().ExecuteCommand();
}
+ ///
+ /// 添加
+ ///
+ ///
+ /// 插入列
+ /// 忽略null列
+ ///
+ public int Add(T parm, Expression> iClumns = null, bool ignoreNull = true)
+ {
+ return Db.Insertable(parm).InsertColumns(iClumns).IgnoreColumns(ignoreNullColumn: ignoreNull).ExecuteCommand();
+ }
+
///
/// 批量添加数据
///
@@ -65,7 +77,7 @@ namespace ZR.Service
}
///
- /// 添加或更新数据
+ /// 添加或更新数据,不推荐使用了
///
/// List
///
@@ -166,7 +178,7 @@ namespace ZR.Service
/// 查询所有数据(无分页,请慎用)
///
///
- public List GetAll(bool useCache = false, int cacheSecond = 3600)
+ public List GetAll(bool useCache = false, int cacheSecond = 3600)
{
return Db.Queryable().WithCacheIF(useCache, cacheSecond).ToList();
}
diff --git a/ZR.Service/IBaseService.cs b/ZR.Service/IBaseService.cs
index e77d47b..38d2065 100644
--- a/ZR.Service/IBaseService.cs
+++ b/ZR.Service/IBaseService.cs
@@ -42,6 +42,8 @@ namespace ZR.Service
///
int Add(T parm);
+ int Add(T parm, Expression> iClumns = null, bool ignoreNull = false);
+
///
/// 批量添加数据
///
diff --git a/ZR.Service/System/ArticleCategoryService.cs b/ZR.Service/System/ArticleCategoryService.cs
index 9dd5a0a..7ef4573 100644
--- a/ZR.Service/System/ArticleCategoryService.cs
+++ b/ZR.Service/System/ArticleCategoryService.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/ArticleService.cs b/ZR.Service/System/ArticleService.cs
index fd7c06d..863efa9 100644
--- a/ZR.Service/System/ArticleService.cs
+++ b/ZR.Service/System/ArticleService.cs
@@ -1,6 +1,6 @@
using Infrastructure.Attribute;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/GenTableService.cs b/ZR.Service/System/GenTableService.cs
new file mode 100644
index 0000000..782324e
--- /dev/null
+++ b/ZR.Service/System/GenTableService.cs
@@ -0,0 +1,193 @@
+using Infrastructure.Attribute;
+using Infrastructure.Extensions;
+using Infrastructure.Model;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using ZR.Model.System.Generate;
+using ZR.Service.System.IService;
+
+namespace ZR.Service.System
+{
+ ///
+ /// 代码生成表
+ ///
+ [AppService(ServiceType = typeof(IGenTableService), ServiceLifetime = LifeTime.Transient)]
+ public class GenTableService : BaseService, IGenTableService
+ {
+ public IGenTableColumnService GenTableColumnService;
+ public GenTableService(IGenTableColumnService genTableColumnService)
+ {
+ GenTableColumnService = genTableColumnService;
+ }
+
+ ///
+ /// 删除表
+ ///
+ /// 需要删除的表id
+ ///
+ public int DeleteGenTableByIds(long[] tableIds)
+ {
+ Db.Deleteable().Where(f => tableIds.Contains(f.TableId)).ExecuteCommand();
+ return GenTableColumnService.DeleteGenTableColumn(tableIds);
+ }
+
+ ///
+ /// 删除表根据表名
+ ///
+ ///
+ ///
+ public int DeleteGenTableByTbName(string tableName)
+ {
+ return Db.Deleteable().Where(f => f.TableName == tableName).ExecuteCommand();
+ }
+
+ ///
+ /// 获取表信息
+ ///
+ ///
+ ///
+ public GenTable GetGenTableInfo(long tableId)
+ {
+ return GetId(tableId);
+ }
+
+ ///
+ /// 查询代码生成表信息
+ ///
+ ///
+ ///
+ ///
+ public PagedInfo GetGenTables(GenTable genTable, Model.PagerInfo pagerInfo)
+ {
+ var predicate = Expressionable.Create();
+ predicate = predicate.AndIF(genTable.TableName.IfNotEmpty(), it => it.TableName.Contains(genTable.TableName));
+
+ return GetPages(predicate.ToExpression(), pagerInfo);
+ }
+
+ ///
+ /// 插入代码生成表
+ ///
+ ///
+ ///
+ public int ImportGenTable(GenTable table)
+ {
+ var db = Db;
+ table.Create_time = db.GetDate();
+ //导入前删除现有表
+ //DeleteGenTableByIds(new long[] { table.TableId });
+ DeleteGenTableByTbName(table.TableName);
+
+ return db.Insertable(table).IgnoreColumns(ignoreNullColumn: true).ExecuteReturnIdentity();
+ }
+
+ ///
+ /// 获取表数据
+ ///
+ ///
+ ///
+ public List SelectDbTableListByNamess(string[] tableNames)
+ {
+ throw new NotImplementedException();
+ }
+
+ public int UpdateGenTable(GenTable genTable)
+ {
+ var db = Db;
+ genTable.Update_time = db.GetDate();
+ return db.Updateable(genTable).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
+ }
+ }
+
+ ///
+ /// 代码生成表列
+ ///
+ [AppService(ServiceType = typeof(IGenTableColumnService), ServiceLifetime = LifeTime.Transient)]
+ public class GenTableColumnService : BaseService, IGenTableColumnService
+ {
+ ///
+ /// 删除表字段
+ ///
+ ///
+ ///
+ public int DeleteGenTableColumn(long tableId)
+ {
+ return DeleteGenTableColumn(new long[] { tableId });
+ }
+ ///
+ /// 根据表id批量删除表字段
+ ///
+ ///
+ ///
+ public int DeleteGenTableColumn(long[] tableId)
+ {
+ return Db.Deleteable().Where(f => tableId.Contains(f.TableId)).ExecuteCommand();
+ }
+
+ ///
+ /// 根据表名删除字段
+ ///
+ ///
+ ///
+ public int DeleteGenTableColumnByTableName(string tableName)
+ {
+ return Db.Deleteable().Where(f => f.TableName == tableName).ExecuteCommand();
+ }
+
+ ///
+ /// 获取表所有字段
+ ///
+ ///
+ ///
+ public List GenTableColumns(long tableId)
+ {
+ return Db.Queryable().Where(f => f.TableId == tableId).OrderBy(x => x.Sort).ToList();
+ }
+
+ ///
+ /// 插入表字段
+ ///
+ ///
+ ///
+ public int InsertGenTableColumn(List tableColumn)
+ {
+ return Db.Insertable(tableColumn).IgnoreColumns(x => new { x.Remark }).ExecuteCommand();
+ }
+
+ ///
+ /// 批量更新表字段
+ ///
+ ///
+ ///
+ public int UpdateGenTableColumn(List tableColumn)
+ {
+ foreach (var item in tableColumn)
+ {
+ Db.Updateable()
+ .Where(f => f.TableId == item.TableId)
+ .SetColumns(it => new GenTableColumn()
+ {
+ ColumnComment = item.ColumnComment,
+ CsharpField = item.CsharpField,
+ CsharpType = item.CsharpType,
+ IsQuery = item.IsQuery,
+ IsEdit = item.IsEdit,
+ IsInsert = item.IsInsert,
+ IsList = item.IsList,
+ QueryType = item.QueryType,
+ HtmlType = item.HtmlType,
+ IsRequired = item.IsRequired,
+ Sort = item.Sort,
+ Update_time = DateTime.Now,
+ DictType = item.DictType
+ })
+ .Where(f => f.ColumnId == item.ColumnId)
+ .ExecuteCommand();
+ }
+
+ return 1;
+ }
+ }
+}
diff --git a/ZR.Service/IService/IArticleCategoryService.cs b/ZR.Service/System/IService/IArticleCategoryService.cs
similarity index 89%
rename from ZR.Service/IService/IArticleCategoryService.cs
rename to ZR.Service/System/IService/IArticleCategoryService.cs
index 2db0a40..602b228 100644
--- a/ZR.Service/IService/IArticleCategoryService.cs
+++ b/ZR.Service/System/IService/IArticleCategoryService.cs
@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface IArticleCategoryService : IBaseService
{
diff --git a/ZR.Service/IService/IArticleService.cs b/ZR.Service/System/IService/IArticleService.cs
similarity index 77%
rename from ZR.Service/IService/IArticleService.cs
rename to ZR.Service/System/IService/IArticleService.cs
index 9e9dcd7..0f4e7de 100644
--- a/ZR.Service/IService/IArticleService.cs
+++ b/ZR.Service/System/IService/IArticleService.cs
@@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface IArticleService : IBaseService
{
diff --git a/ZR.Service/System/IService/IGenTableService.cs b/ZR.Service/System/IService/IGenTableService.cs
new file mode 100644
index 0000000..7adc936
--- /dev/null
+++ b/ZR.Service/System/IService/IGenTableService.cs
@@ -0,0 +1,34 @@
+using Infrastructure.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ZR.Model.System.Generate;
+
+namespace ZR.Service.System.IService
+{
+ public interface IGenTableService
+ {
+ List SelectDbTableListByNamess(string[] tableNames);
+
+ int ImportGenTable(GenTable tables);
+
+ int DeleteGenTableByIds(long[] tableIds);
+ int DeleteGenTableByTbName(string tableName);
+ PagedInfo GetGenTables(GenTable genTable, Model.PagerInfo pagerInfo);
+ GenTable GetGenTableInfo(long tableId);
+ int UpdateGenTable(GenTable genTable);
+ }
+
+ public interface IGenTableColumnService
+ {
+ int InsertGenTableColumn(List tableColumn);
+
+ int DeleteGenTableColumn(long tableId);
+ int DeleteGenTableColumn(long[] tableIds);
+ int DeleteGenTableColumnByTableName(string tableName);
+ List GenTableColumns(long tableId);
+ int UpdateGenTableColumn(List tableColumn);
+ }
+}
diff --git a/ZR.Service/IService/ISysDeptService.cs b/ZR.Service/System/IService/ISysDeptService.cs
similarity index 95%
rename from ZR.Service/IService/ISysDeptService.cs
rename to ZR.Service/System/IService/ISysDeptService.cs
index 78bc4a0..4e90491 100644
--- a/ZR.Service/IService/ISysDeptService.cs
+++ b/ZR.Service/System/IService/ISysDeptService.cs
@@ -4,7 +4,7 @@ using System.Text;
using ZR.Model.System;
using ZR.Model.Vo.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysDeptService : IBaseService
{
diff --git a/ZR.Service/IService/ISysDictDataService.cs b/ZR.Service/System/IService/ISysDictDataService.cs
similarity index 93%
rename from ZR.Service/IService/ISysDictDataService.cs
rename to ZR.Service/System/IService/ISysDictDataService.cs
index 63b7d29..d048b1a 100644
--- a/ZR.Service/IService/ISysDictDataService.cs
+++ b/ZR.Service/System/IService/ISysDictDataService.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysDictDataService : IBaseService
{
diff --git a/ZR.Service/IService/ISysDictService.cs b/ZR.Service/System/IService/ISysDictService.cs
similarity index 97%
rename from ZR.Service/IService/ISysDictService.cs
rename to ZR.Service/System/IService/ISysDictService.cs
index 0bdb274..6d99e7a 100644
--- a/ZR.Service/IService/ISysDictService.cs
+++ b/ZR.Service/System/IService/ISysDictService.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
///
///
diff --git a/ZR.Service/IService/ISysFileService.cs b/ZR.Service/System/IService/ISysFileService.cs
similarity index 78%
rename from ZR.Service/IService/ISysFileService.cs
rename to ZR.Service/System/IService/ISysFileService.cs
index d1deeb4..f223bff 100644
--- a/ZR.Service/IService/ISysFileService.cs
+++ b/ZR.Service/System/IService/ISysFileService.cs
@@ -1,7 +1,7 @@
using Infrastructure.Attribute;
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysFileService : IBaseService
{
diff --git a/ZR.Service/IService/ISysLoginService.cs b/ZR.Service/System/IService/ISysLoginService.cs
similarity index 94%
rename from ZR.Service/IService/ISysLoginService.cs
rename to ZR.Service/System/IService/ISysLoginService.cs
index 22272e2..d80d99c 100644
--- a/ZR.Service/IService/ISysLoginService.cs
+++ b/ZR.Service/System/IService/ISysLoginService.cs
@@ -2,10 +2,10 @@
using System.Collections.Generic;
using System.Text;
using ZR.Model;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysLoginService
{
diff --git a/ZR.Service/IService/ISysMenuService.cs b/ZR.Service/System/IService/ISysMenuService.cs
similarity index 94%
rename from ZR.Service/IService/ISysMenuService.cs
rename to ZR.Service/System/IService/ISysMenuService.cs
index 04c90c4..8928c4e 100644
--- a/ZR.Service/IService/ISysMenuService.cs
+++ b/ZR.Service/System/IService/ISysMenuService.cs
@@ -1,10 +1,10 @@
using System.Collections.Generic;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
using ZR.Model.System.Vo;
using ZR.Model.Vo.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysMenuService: IBaseService
{
diff --git a/ZR.Service/IService/ISysOperLogService.cs b/ZR.Service/System/IService/ISysOperLogService.cs
similarity index 94%
rename from ZR.Service/IService/ISysOperLogService.cs
rename to ZR.Service/System/IService/ISysOperLogService.cs
index eef404e..0029904 100644
--- a/ZR.Service/IService/ISysOperLogService.cs
+++ b/ZR.Service/System/IService/ISysOperLogService.cs
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using ZR.Model;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
using ZR.Service.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysOperLogService : IBaseService
{
diff --git a/ZR.Service/IService/ISysPermissionService.cs b/ZR.Service/System/IService/ISysPermissionService.cs
similarity index 89%
rename from ZR.Service/IService/ISysPermissionService.cs
rename to ZR.Service/System/IService/ISysPermissionService.cs
index 6897396..f0ea833 100644
--- a/ZR.Service/IService/ISysPermissionService.cs
+++ b/ZR.Service/System/IService/ISysPermissionService.cs
@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysPermissionService
{
diff --git a/ZR.Service/IService/ISysPostService.cs b/ZR.Service/System/IService/ISysPostService.cs
similarity index 88%
rename from ZR.Service/IService/ISysPostService.cs
rename to ZR.Service/System/IService/ISysPostService.cs
index 1df4365..9cd098b 100644
--- a/ZR.Service/IService/ISysPostService.cs
+++ b/ZR.Service/System/IService/ISysPostService.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysPostService: IBaseService
{
diff --git a/ZR.Service/IService/ISysRoleService.cs b/ZR.Service/System/IService/ISysRoleService.cs
similarity index 99%
rename from ZR.Service/IService/ISysRoleService.cs
rename to ZR.Service/System/IService/ISysRoleService.cs
index 3a34389..6f039fd 100644
--- a/ZR.Service/IService/ISysRoleService.cs
+++ b/ZR.Service/System/IService/ISysRoleService.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysRoleService: IBaseService
{
diff --git a/ZR.Service/IService/ISysTasksLogService.cs b/ZR.Service/System/IService/ISysTasksLogService.cs
similarity index 90%
rename from ZR.Service/IService/ISysTasksLogService.cs
rename to ZR.Service/System/IService/ISysTasksLogService.cs
index ef0bb09..48dbff4 100644
--- a/ZR.Service/IService/ISysTasksLogService.cs
+++ b/ZR.Service/System/IService/ISysTasksLogService.cs
@@ -1,6 +1,6 @@
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysTasksLogService : IBaseService
{
diff --git a/ZR.Service/IService/ISysTasksQzService.cs b/ZR.Service/System/IService/ISysTasksQzService.cs
similarity index 85%
rename from ZR.Service/IService/ISysTasksQzService.cs
rename to ZR.Service/System/IService/ISysTasksQzService.cs
index a7c60c7..69931d0 100644
--- a/ZR.Service/IService/ISysTasksQzService.cs
+++ b/ZR.Service/System/IService/ISysTasksQzService.cs
@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysTasksQzService: IBaseService
{
diff --git a/ZR.Service/IService/ISysUserPostService.cs b/ZR.Service/System/IService/ISysUserPostService.cs
similarity index 89%
rename from ZR.Service/IService/ISysUserPostService.cs
rename to ZR.Service/System/IService/ISysUserPostService.cs
index 2335b17..0514047 100644
--- a/ZR.Service/IService/ISysUserPostService.cs
+++ b/ZR.Service/System/IService/ISysUserPostService.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysUserPostService: IBaseService
{
diff --git a/ZR.Service/IService/ISysUserRoleService.cs b/ZR.Service/System/IService/ISysUserRoleService.cs
similarity index 95%
rename from ZR.Service/IService/ISysUserRoleService.cs
rename to ZR.Service/System/IService/ISysUserRoleService.cs
index 55d4b01..6dc8125 100644
--- a/ZR.Service/IService/ISysUserRoleService.cs
+++ b/ZR.Service/System/IService/ISysUserRoleService.cs
@@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysUserRoleService
{
diff --git a/ZR.Service/IService/ISysUserService.cs b/ZR.Service/System/IService/ISysUserService.cs
similarity index 98%
rename from ZR.Service/IService/ISysUserService.cs
rename to ZR.Service/System/IService/ISysUserService.cs
index ad65cb1..f49e926 100644
--- a/ZR.Service/IService/ISysUserService.cs
+++ b/ZR.Service/System/IService/ISysUserService.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
using ZR.Model;
using ZR.Model.System;
-namespace ZR.Service.IService
+namespace ZR.Service.System.IService
{
public interface ISysUserService : IBaseService
{
diff --git a/ZR.Service/System/SysDeptService.cs b/ZR.Service/System/SysDeptService.cs
index 1f325ec..a99c541 100644
--- a/ZR.Service/System/SysDeptService.cs
+++ b/ZR.Service/System/SysDeptService.cs
@@ -10,7 +10,7 @@ using ZR.Common;
using ZR.Model.System;
using ZR.Model.Vo.System;
using ZR.Repository.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/SysDictDataService.cs b/ZR.Service/System/SysDictDataService.cs
index 4911ecc..92c7a01 100644
--- a/ZR.Service/System/SysDictDataService.cs
+++ b/ZR.Service/System/SysDictDataService.cs
@@ -5,7 +5,7 @@ using System.Text;
using ZR.Common;
using ZR.Model.System;
using ZR.Repository.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/SysDictService.cs b/ZR.Service/System/SysDictService.cs
index 84afc67..cf8c849 100644
--- a/ZR.Service/System/SysDictService.cs
+++ b/ZR.Service/System/SysDictService.cs
@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Text;
using ZR.Model.System;
using ZR.Repository.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/SysFileService.cs b/ZR.Service/System/SysFileService.cs
index df1182d..5098a88 100644
--- a/ZR.Service/System/SysFileService.cs
+++ b/ZR.Service/System/SysFileService.cs
@@ -1,6 +1,6 @@
using Infrastructure.Attribute;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/SysLoginService.cs b/ZR.Service/System/SysLoginService.cs
index 8758e1b..3a8056e 100644
--- a/ZR.Service/System/SysLoginService.cs
+++ b/ZR.Service/System/SysLoginService.cs
@@ -4,10 +4,10 @@ using System;
using System.Collections.Generic;
using ZR.Common;
using ZR.Model;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
using ZR.Repository.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/SysMenuService.cs b/ZR.Service/System/SysMenuService.cs
index c4d702e..780a468 100644
--- a/ZR.Service/System/SysMenuService.cs
+++ b/ZR.Service/System/SysMenuService.cs
@@ -1,13 +1,13 @@
using Infrastructure.Attribute;
using System.Collections.Generic;
using System.Linq;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
using ZR.Model.System.Vo;
using ZR.Model.Vo;
using ZR.Model.Vo.System;
using ZR.Repository.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service
{
diff --git a/ZR.Service/System/SysOperLogService.cs b/ZR.Service/System/SysOperLogService.cs
index 668accd..4fa5ec3 100644
--- a/ZR.Service/System/SysOperLogService.cs
+++ b/ZR.Service/System/SysOperLogService.cs
@@ -2,10 +2,10 @@
using System.Collections.Generic;
using ZR.Common;
using ZR.Model;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
using ZR.Repository.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/SysPermissionService.cs b/ZR.Service/System/SysPermissionService.cs
index e946098..607d3f9 100644
--- a/ZR.Service/System/SysPermissionService.cs
+++ b/ZR.Service/System/SysPermissionService.cs
@@ -4,7 +4,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/SysPostService.cs b/ZR.Service/System/SysPostService.cs
index 56534c0..39808a5 100644
--- a/ZR.Service/System/SysPostService.cs
+++ b/ZR.Service/System/SysPostService.cs
@@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/SysRoleService.cs b/ZR.Service/System/SysRoleService.cs
index 8591f92..c42b5fd 100644
--- a/ZR.Service/System/SysRoleService.cs
+++ b/ZR.Service/System/SysRoleService.cs
@@ -7,8 +7,7 @@ using System.Linq;
using System.Text;
using ZR.Model.System;
using ZR.Repository.System;
-using ZR.Service.IService;
-using ZR.Service.System;
+using ZR.Service.System.IService;
namespace ZR.Service
{
diff --git a/ZR.Service/System/SysTasksLogService.cs b/ZR.Service/System/SysTasksLogService.cs
index 4d83262..25f56e4 100644
--- a/ZR.Service/System/SysTasksLogService.cs
+++ b/ZR.Service/System/SysTasksLogService.cs
@@ -1,7 +1,7 @@
using Infrastructure.Attribute;
using System;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/SysTasksQzService.cs b/ZR.Service/System/SysTasksQzService.cs
index 1ecbc13..1569287 100644
--- a/ZR.Service/System/SysTasksQzService.cs
+++ b/ZR.Service/System/SysTasksQzService.cs
@@ -1,6 +1,6 @@
using Infrastructure.Attribute;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/SysUserPostService.cs b/ZR.Service/System/SysUserPostService.cs
index cf24642..c312d31 100644
--- a/ZR.Service/System/SysUserPostService.cs
+++ b/ZR.Service/System/SysUserPostService.cs
@@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using ZR.Model.System;
using ZR.Repository.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/SysUserRoleService.cs b/ZR.Service/System/SysUserRoleService.cs
index a42cbf4..94bdfc1 100644
--- a/ZR.Service/System/SysUserRoleService.cs
+++ b/ZR.Service/System/SysUserRoleService.cs
@@ -2,10 +2,10 @@
using System;
using System.Collections.Generic;
using System.Text;
-using ZR.Model.Dto.System;
+using ZR.Model.System.Dto;
using ZR.Model.System;
using ZR.Repository.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service.System
{
diff --git a/ZR.Service/System/SysUserService.cs b/ZR.Service/System/SysUserService.cs
index c3a0af0..23b972e 100644
--- a/ZR.Service/System/SysUserService.cs
+++ b/ZR.Service/System/SysUserService.cs
@@ -6,7 +6,7 @@ using System.Text;
using ZR.Model;
using ZR.Model.System;
using ZR.Repository.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Service
{
diff --git a/ZR.Tasks/TaskScheduler/JobBase.cs b/ZR.Tasks/TaskScheduler/JobBase.cs
index 3d5b9cd..5ed8fed 100644
--- a/ZR.Tasks/TaskScheduler/JobBase.cs
+++ b/ZR.Tasks/TaskScheduler/JobBase.cs
@@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using ZR.Model.System;
-using ZR.Service.IService;
+using ZR.Service.System.IService;
namespace ZR.Tasks
{
diff --git a/ZR.Vue/src/api/gendemo.js b/ZR.Vue/src/api/gendemo.js
deleted file mode 100644
index a7c6c3d..0000000
--- a/ZR.Vue/src/api/gendemo.js
+++ /dev/null
@@ -1,59 +0,0 @@
-import request from '@/utils/request'
-
-/**
- * 分页查询
- * @param {查询条件} data
- */
-export function listGendemo(data) {
- return request({
- url: '/bus/Gendemo/list',
- method: 'get',
- params: data,
- })
-}
-
-/**
- * 新增
- * @param data
- */
-export function addGendemo(data) {
- return request({
- url: '/bus/Gendemo',
- method: 'post',
- data: data,
- })
-}
-
-/**
- * 修改
- * @param data
- */
-export function updateGendemo(data) {
- return request({
- url: '/bus/Gendemo',
- method: 'PUT',
- data: data,
- })
-}
-
-/**
- * 获取详情
- * @param {Id} Id
- */
-export function getGendemo(id) {
- return request({
- url: '/bus/Gendemo/' + id,
- method: 'get'
- })
-}
-
-/**
- * 删除
- * @param {主键} pid
- */
-export function delGendemo(pid) {
- return request({
- url: '/bus/Gendemo/' + pid,
- method: 'delete'
- })
-}
diff --git a/ZR.Vue/src/api/tool/gen.js b/ZR.Vue/src/api/tool/gen.js
index 93d7a27..14bbcb1 100644
--- a/ZR.Vue/src/api/tool/gen.js
+++ b/ZR.Vue/src/api/tool/gen.js
@@ -30,7 +30,7 @@ export function codeGetDBList() {
/**
* 获取数据库表
*/
-export function codeGetTableList(data) {
+export function listDbTable(data) {
return request({
url: 'tool/gen/getTableList',
method: 'get',
@@ -53,14 +53,48 @@ export async function codeGenerator(data) {
* @param {*} data
* @returns
*/
-export function queryColumnInfo(data) {
+export function queryColumnInfo(tableId) {
return request({
- url: 'tool/gen/getColumnInfo',
+ url: 'tool/gen/Column/' + tableId,
method: 'GET',
- params: data,
})
}
+
+// 查询表详细信息
+export function getGenTable(params) {
+ return request({
+ url: 'tool/gen/listGenTable',
+ method: 'get',
+ params: params
+ })
+}
+// 导入表
+export function importTable(data) {
+ return request({
+ url: '/tool/gen/importTable',
+ method: 'post',
+ params: data
+ })
+}
+// 删除表数据
+export function delTable(tableId) {
+ return request({
+ url: '/tool/gen/' + tableId,
+ method: 'delete'
+ })
+}
+
+// 修改代码生成表信息
+export function updateGenTable(data) {
+ return request({
+ url: '/tool/gen/',
+ method: 'put',
+ data: data
+ })
+}
+
+
// /**
// *
// * 数据库解密
diff --git a/ZR.Vue/src/components/Zr/Git/index.vue b/ZR.Vue/src/components/Zr/Git/index.vue
index 88d511f..7369a17 100644
--- a/ZR.Vue/src/components/Zr/Git/index.vue
+++ b/ZR.Vue/src/components/Zr/Git/index.vue
@@ -9,7 +9,7 @@ export default {
name: 'IZoryGit',
data() {
return {
- url: 'https://gitee.com/izhaorui/ZrAdminNetCore'
+ url: 'https://gitee.com/izory/ZrAdminNetCore'
}
},
methods: {
diff --git a/ZR.Vue/src/layout/components/Navbar.vue b/ZR.Vue/src/layout/components/Navbar.vue
index 1e36156..446502d 100644
--- a/ZR.Vue/src/layout/components/Navbar.vue
+++ b/ZR.Vue/src/layout/components/Navbar.vue
@@ -14,6 +14,9 @@
+
+
+