diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt index 60182ac..011f34c 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt @@ -11,14 +11,11 @@ using ${options.ApiControllerNamespace}.Extensions; using ${options.ApiControllerNamespace}.Filters; using ${options.BaseNamespace}Common; +//创建时间:${replaceDto.AddTime} namespace ${options.ApiControllerNamespace}.Controllers { /// - /// ${genTable.functionName}Controller - /// - /// @tableName ${genTable.TableName} - /// @author ${replaceDto.Author} - /// @date ${replaceDto.AddTime} + /// ${genTable.functionName} /// [Verify] [Route("${genTable.ModuleName}/${genTable.BusinessName}")] @@ -120,7 +117,7 @@ $if(replaceDto.ShowBtnEdit) } $end -$if(replaceDto.ShowBtnDelete) +$if(replaceDto.ShowBtnDelete || replaceDto.ShowBtnMultiDel) /// /// 删除${genTable.FunctionName} /// @@ -169,15 +166,13 @@ $if(replaceDto.ShowBtnTruncate) [Log(Title = "${genTable.FunctionName}", BusinessType = BusinessType.CLEAN)] [ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:delete")] [HttpDelete("clean")] - public ApiResult Clear() + public IActionResult Clear() { if (!HttpContextExtension.IsAdmin(HttpContext)) { - return ApiResult.Error("操作失败"); + return ToResponse(ResultCode.FAIL, "操作失败"); } - _${replaceDto.ModelTypeName}Service.Truncate${replaceDto.ModelTypeName}(); - - return ToJson(1); + return SUCCESS(_${replaceDto.ModelTypeName}Service.Truncate${replaceDto.ModelTypeName}()); } $end @@ -196,7 +191,6 @@ $if(showCustomInput) if (id <= 0) { return ToResponse(ApiResult.Error(101, "请求参数错误")); } var response = _${replaceDto.ModelTypeName}Service.Update(w => w.${replaceDto.PKName} == id, it => new ${replaceDto.ModelTypeName}() { - //Update 字段映射 $foreach(item in genTable.Columns) $if((item.htmlType == "customInput")) $item.CsharpField = value, diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplIService.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplIService.txt index 0359963..a48f27b 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplIService.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplIService.txt @@ -8,9 +8,6 @@ namespace ${options.IServicsNamespace}.${options.SubNamespace}.I${options.SubNam { /// /// ${genTable.FunctionName}service接口 - /// - /// @author ${replaceDto.Author} - /// @date ${replaceDto.AddTime} /// public interface I${replaceDto.ModelTypeName}Service : IBaseService<${replaceDto.ModelTypeName}> { @@ -23,7 +20,7 @@ $end int Update${replaceDto.ModelTypeName}(${replaceDto.ModelTypeName} parm); $if(replaceDto.ShowBtnTruncate) - void Truncate${replaceDto.ModelTypeName}(); + bool Truncate${replaceDto.ModelTypeName}(); $end } } diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplModel.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplModel.txt index 7994a80..172a316 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplModel.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplModel.txt @@ -9,8 +9,6 @@ namespace ${options.ModelsNamespace}.${options.SubNamespace} { /// /// ${genTable.FunctionName} - /// @author ${replaceDto.Author} - /// @date ${replaceDto.AddTime} /// [SugarTable("${genTable.TableName}")] public class ${replaceDto.ModelTypeName} diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplRepository.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplRepository.txt index f020491..04fee57 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplRepository.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplRepository.txt @@ -5,9 +5,6 @@ namespace ${options.RepositoriesNamespace} { /// /// ${genTable.FunctionName}仓储 - /// - /// @author ${replaceDto.Author} - /// @date ${replaceDto.AddTime} /// [AppService(ServiceLifetime = LifeTime.Transient)] public class ${replaceDto.ModelTypeName}Repository : BaseRepository<${replaceDto.ModelTypeName}> diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplService.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplService.txt index bc21298..b486b6d 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplService.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplService.txt @@ -15,9 +15,6 @@ namespace ${options.ServicesNamespace}.${options.SubNamespace} { /// /// ${genTable.FunctionName}Service业务层处理 - /// - /// @author ${replaceDto.Author} - /// @date ${replaceDto.AddTime} /// [AppService(ServiceType = typeof(I${replaceDto.ModelTypeName}Service), ServiceLifetime = LifeTime.Transient)] public class ${replaceDto.ModelTypeName}Service : BaseService<${replaceDto.ModelTypeName}>, I${replaceDto.ModelTypeName}Service @@ -124,9 +121,15 @@ $if(replaceDto.ShowBtnTruncate) /// 清空${genTable.FunctionName} /// /// - public void Truncate${replaceDto.ModelTypeName}() + public bool Truncate${replaceDto.ModelTypeName}() { - Truncate(); + var newTableName = $"${genTable.TableName}_{DateTime.Now:yyyyMMdd}"; + if (Queryable().Any() && !Context.DbMaintenance.IsAnyTable(newTableName)) + { + Context.DbMaintenance.BackupTable("${genTable.TableName}", newTableName); + } + + return Truncate(); } $end } diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt index e015218..422bbde 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt @@ -73,7 +73,7 @@ export function get${genTable.BusinessName}(id) { }) } -$if(replaceDto.ShowBtnDelete) +$if(replaceDto.ShowBtnDelete || replaceDto.ShowBtnMultiDel) /** * 删除${genTable.functionName} * @param {主键} pid diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/sql/MySqlTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/sql/MySqlTemplate.txt index 3c0d5d4..5d1703c 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/sql/MySqlTemplate.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/sql/MySqlTemplate.txt @@ -17,8 +17,10 @@ VALUES ('新增', @menuId, 2, '#', NULL, 0, 0, 'F', '0', '0', '${replaceDto.Perm INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by, create_time) VALUES ('删除', @menuId, 3, '#', NULL, 0, 0, 'F', '0', '0', '${replaceDto.PermissionPrefix}:delete', '', 'system', sysdate()); +$if(replaceDto.ShowBtnEdit) INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by, create_time) VALUES ('修改', @menuId, 4, '#', NULL, 0, 0, 'F', '0', '0', '${replaceDto.PermissionPrefix}:edit', '', 'system', sysdate()); +$end $if(replaceDto.ShowBtnExport) INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by, create_time) diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/sql/SqlTemplate.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/sql/SqlTemplate.txt index 20e0718..7067db0 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/sql/SqlTemplate.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/sql/SqlTemplate.txt @@ -17,9 +17,10 @@ VALUES ('新增', @menuId, 2, '#', NULL, 0, 0, 'F', '0', '0', '${replaceDto.Perm INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time) VALUES ('删除', @menuId, 3, '#', NULL, 0, 0, 'F', '0', '0', '${replaceDto.PermissionPrefix}:delete', '', 'system', GETDATE()); +$if(replaceDto.ShowBtnEdit) INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time) VALUES ('修改', @menuId, 4, '#', NULL, 0, 0, 'F', '0', '0', '${replaceDto.PermissionPrefix}:edit', '', 'system', GETDATE()); - +$end $if(replaceDto.ShowBtnExport) INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time) VALUES ('导出', @menuId, 5, '#', NULL, 0, 0, 'F', '0', '0', '${replaceDto.PermissionPrefix}:export', '', 'system', GETDATE()); diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt index b36852a..f0beb2e 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt @@ -1,10 +1,7 @@