diff --git a/README.md b/README.md
index 93f9a2d..91bf80e 100644
--- a/README.md
+++ b/README.md
@@ -63,8 +63,6 @@ Vue版前端技术栈 :基于vue、vuex、vue-router 、vue-cli 、axios 和 e
ZRAdmin解决方案包含:
-Infrastructure[基础类库]:包框架的核心组件,包含一系列快速开发中经常用到的Utility辅助工具功能,部分核心功能的实现;
-
ZR.Service[服务层类库]:提供WebApi接口调用;
ZR.Tasks[定时任务类库]:提供项目定时任务实现功能;
diff --git a/ZR.Admin.WebApi/Controllers/CodeGeneratorController.cs b/ZR.Admin.WebApi/Controllers/CodeGeneratorController.cs
index c504bf6..d6a4f55 100644
--- a/ZR.Admin.WebApi/Controllers/CodeGeneratorController.cs
+++ b/ZR.Admin.WebApi/Controllers/CodeGeneratorController.cs
@@ -94,7 +94,7 @@ namespace ZR.Admin.WebApi.Controllers
//生成代码
CodeGeneratorTool.Generate(genTableInfo, dto);
//下载文件
- CodeGeneratorTool.ZipGenCode(dto);
+ FileHelper.ZipGenCode(dto);
//HttpContext.Response.Headers.Add("Content-disposition", $"attachment; filename={zipFileName}");
return SUCCESS(new { zipPath = "/Generatecode/" + dto.ZipFileName, fileName = dto.ZipFileName });
@@ -145,7 +145,7 @@ namespace ZR.Admin.WebApi.Controllers
}
///
- /// 导入表
+ /// 导入表结构(保存)
///
///
///
@@ -218,5 +218,32 @@ namespace ZR.Admin.WebApi.Controllers
}
return SUCCESS(rows);
}
+
+ ///
+ /// 预览代码
+ ///
+ ///
+ ///
+ [HttpGet("preview/{tableId}")]
+ [ActionPermissionFilter(Permission = "tool:gen:preview")]
+ public IActionResult Preview(long tableId)
+ {
+ if (tableId <= 0)
+ {
+ throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
+ }
+ var genTableInfo = GenTableService.GetGenTableInfo(tableId);
+ genTableInfo.Columns = GenTableColumnService.GenTableColumns(tableId);
+ GenerateDto dto = new();
+ dto.GenTable = genTableInfo;
+ dto.ZipPath = Path.Combine(WebHostEnvironment.WebRootPath, "Generatecode");
+ dto.GenCodePath = Path.Combine(dto.ZipPath, DateTime.Now.ToString("yyyyMMdd"));
+ dto.IsPreview = 1;
+ dto.GenCodeFiles = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };
+ //生成代码
+ CodeGeneratorTool.Generate(genTableInfo, dto);
+
+ return SUCCESS(dto.GenCodes);
+ }
}
}
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ControllersTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ControllersTemplate.txt
index af2cc5c..24973ce 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ControllersTemplate.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ControllersTemplate.txt
@@ -18,14 +18,17 @@ using ZR.Common;
namespace {ApiControllerNamespace}.Controllers
{
///
- /// 代码自动生成
+ /// {FunctionName}Controller
+ ///
+ /// @author {Author}
+ /// @date {DateTime}
///
[Verify]
[Route("{ModuleName}/{ModelName}")]
public class {ModelName}Controller: BaseController
- {
+ {
///
- /// {TableDesc}接口
+ /// {FunctionName}接口
///
private readonly I{ModelName}Service _{ModelName}Service;
@@ -35,7 +38,7 @@ namespace {ApiControllerNamespace}.Controllers
}
///
- /// 查询{TableDesc}列表
+ /// 查询{FunctionName}列表
///
///
[HttpGet("list")]
@@ -54,7 +57,7 @@ namespace {ApiControllerNamespace}.Controllers
}
///
- /// 查询{TableDesc}详情
+ /// 查询{FunctionName}详情
///
///
///
@@ -68,7 +71,7 @@ namespace {ApiControllerNamespace}.Controllers
}
///
- /// 添加{TableDesc}
+ /// 添加{FunctionName}
///
///
[HttpPost]
@@ -90,7 +93,7 @@ namespace {ApiControllerNamespace}.Controllers
}
///
- /// 更新{TableDesc}
+ /// 更新{FunctionName}
///
///
[HttpPut]
@@ -115,7 +118,7 @@ namespace {ApiControllerNamespace}.Controllers
}
///
- /// 删除{TableDesc}
+ /// 删除{FunctionName}
///
///
[HttpDelete("{ids}")]
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/IServiceTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/IServiceTemplate.txt
index 8e3692b..b64fd98 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/IServiceTemplate.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/IServiceTemplate.txt
@@ -4,7 +4,10 @@ using {ModelsNamespace}.Models;
namespace {IServicsNamespace}.Business
{
///
- /// 定义{TableNameDesc}服务接口
+ /// {FunctionName}service接口
+ ///
+ /// @author {Author}
+ /// @date {DateTime}
///
public interface I{ModelTypeName}Service: IBaseService<{ModelTypeName}>
{
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/InputDtoTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/InputDtoTemplate.txt
index 0398c07..ded802d 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/InputDtoTemplate.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/InputDtoTemplate.txt
@@ -6,7 +6,7 @@ using {ModelsNamespace}.Models;
namespace {DtosNamespace}.Dto
{
///
- /// {TableNameDesc}输入对象模型
+ /// {FunctionName}输入对象模型
///
public class {ModelTypeName}Dto
{
@@ -14,7 +14,7 @@ namespace {DtosNamespace}.Dto
}
///
- /// {TableNameDesc}查询对象模型
+ /// {FunctionName}查询对象模型
///
public class {ModelTypeName}QueryDto: PagerInfo
{
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ModelTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ModelTemplate.txt
index 7d9a00a..66bbcce 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ModelTemplate.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ModelTemplate.txt
@@ -4,7 +4,10 @@ using System.Collections.Generic;
namespace {ModelsNamespace}.Models
{
///
- /// {TableNameDesc},数据实体对象
+ /// {FunctionName},数据实体对象
+ ///
+ /// @author {Author}
+ /// @date {DateTime}
///
[SqlSugar.SugarTable("{TableName}")]
public class {ModelTypeName}
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/RepositoryTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/RepositoryTemplate.txt
index e39f922..db312b9 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/RepositoryTemplate.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/RepositoryTemplate.txt
@@ -6,20 +6,15 @@ using {ModelsNamespace}.Models;
namespace {RepositoriesNamespace}
{
///
- /// 代码生成器生成
- /// {TableNameDesc}仓储接口的实现
+ /// {FunctionName}仓储接口的实现
+ ///
+ /// @author {Author}
+ /// @date {DateTime}
///
[AppService(ServiceLifetime = LifeTime.Transient)]
public class {ModelTypeName}Repository : BaseRepository
{
- public {ModelTypeName}Repository()
- {
- }
-
#region 业务逻辑代码
-
-
-
#endregion
}
}
\ No newline at end of file
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ServiceTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ServiceTemplate.txt
index 340390a..c42b2eb 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ServiceTemplate.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/ServiceTemplate.txt
@@ -13,15 +13,18 @@ using {IRepositoriesNamespace};
namespace {ServicesNamespace}.Business
{
///
- /// 代码生成器生成
+ /// {FunctionName}Service业务层处理
+ ///
+ /// @author {Author}
+ /// @date {DateTime}
///
[AppService(ServiceType = typeof(I{ModelTypeName}Service), ServiceLifetime = LifeTime.Transient)]
public class {ModelTypeName}Service: BaseService<{ModelTypeName}>, I{ModelTypeName}Service
{
- private readonly {ModelTypeName}Repository _repository;
+ private readonly {ModelTypeName}Repository _repository;
public {ModelTypeName}Service({ModelTypeName}Repository repository)
{
- _repository = repository;
+ _repository = repository;
}
#region 业务逻辑代码
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueJsTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueJsTemplate.txt
index d4efae3..3d37ec0 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueJsTemplate.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueJsTemplate.txt
@@ -1,7 +1,7 @@
import request from '@/utils/request'
/**
- * {ModelTypeDesc}分页查询
+ * {FunctionName}分页查询
* @param {查询条件} data
*/
export function list{ModelTypeName}(query) {
@@ -13,7 +13,7 @@ export function list{ModelTypeName}(query) {
}
/**
- * 新增{ModelTypeDesc}
+ * 新增{FunctionName}
* @param data
*/
export function add{ModelTypeName}(data) {
@@ -25,7 +25,7 @@ export function add{ModelTypeName}(data) {
}
/**
- * 修改{ModelTypeDesc}
+ * 修改{FunctionName}
* @param data
*/
export function update{ModelTypeName}(data) {
@@ -37,7 +37,7 @@ export function update{ModelTypeName}(data) {
}
/**
- * 获取{ModelTypeDesc}详情
+ * 获取{FunctionName}详情
* @param {Id} {ModelTypeDesc}Id
*/
export function get{ModelTypeName}(id) {
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueTemplate.txt
index bca90fa..d6b050a 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueTemplate.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/VueTemplate.txt
@@ -2,8 +2,7 @@
- {vueQueryFormHtml}
-
+{vueQueryFormHtml}
搜索
重置
@@ -27,7 +26,7 @@
- {VueViewListContent}
+{VueViewListContent}
编辑
@@ -42,7 +41,7 @@
- {VueViewFormContent}
+{VueViewFormContent}