新增代码生成到指定菜单目录下下

This commit is contained in:
izory
2021-09-27 17:38:09 +08:00
parent 56a04bbf73
commit d5087a1725
20 changed files with 87 additions and 52 deletions

View File

@@ -5,6 +5,7 @@ using Mapster;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -89,7 +90,8 @@ namespace ZR.Admin.WebApi.Controllers
var genTableInfo = GenTableService.GetGenTableInfo(dto.TableId);
genTableInfo.Columns = GenTableColumnService.GenTableColumns(dto.TableId);
Dictionary<string, object> options = JsonConvert.DeserializeObject<Dictionary<string, object>>(genTableInfo.Options);
dto.ParentMenuId = (long)options.GetValueOrDefault("parentMenuId", 0);
dto.GenTable = genTableInfo;
//生成代码
CodeGeneratorTool.Generate(genTableInfo, dto);
@@ -211,6 +213,7 @@ namespace ZR.Admin.WebApi.Controllers
if (genTableDto == null) throw new CustomException("请求参数错误");
var genTable = genTableDto.Adapt<GenTable>().ToUpdate(HttpContext);
genTable.Options = JsonConvert.SerializeObject(new { parentMenuId = genTableDto.ParentMenuId });
int rows = GenTableService.UpdateGenTable(genTable);
if (rows > 0)
{

View File

@@ -20,8 +20,8 @@ namespace ZR.Admin.WebApi.Controllers
/// <summary>
/// 代码生成演示Controller
///
/// @author zhaorui
/// @date 2021-09-24
/// @author zr
/// @date 2021-09-27
/// </summary>
[Verify]
[Route("business/Gendemo")]

View File

@@ -1,6 +1,6 @@
-- 菜单
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', '#', '', sysdate(), '', NULL, '{ModelTypeDesc}菜单');
VALUES ('{FunctionName}', 0, 1, '/{ModuleName}/{ModelTypeName}', '{ModuleName}/{ViewsFileName}/index', 0, 0, 'C', '0', '0', '{Permission}:list', '#', '', sysdate(), '', NULL, '{FunctionName}菜单');
-- 按钮父菜单id
SELECT @menuId := LAST_INSERT_ID();

View File

@@ -12,7 +12,7 @@ namespace {RepositoriesNamespace}
/// @date {DateTime}
/// </summary>
[AppService(ServiceLifetime = LifeTime.Transient)]
public class {ModelTypeName}Repository : BaseRepository
public class {ModelTypeName}Repository : BaseRepository<ModelTypeName>
{
#region 业务逻辑代码
#endregion

View File

@@ -21,10 +21,10 @@ namespace {ServicesNamespace}.Business
[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 _{ModelTypeName}repository;
public {ModelTypeName}Service({ModelTypeName}Repository repository)
{
_repository = repository;
_{ModelTypeName}repository = repository;
}
#region 业务逻辑代码

View File

@@ -1,6 +1,6 @@
-- 菜单
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}');
VALUES ('{FunctionName}', {ParentId}, 1, '/{ModuleName}/{ModelTypeName}', '{ModuleName}/{ViewsFileName}/index', 0, 0, 'C', '0', '0', '{Permission}:list', '#', '', GETDATE(), '', NULL, '{FunctionName}');
-- 按钮父菜单id
declare @menuId int = @@identity
@@ -19,5 +19,5 @@ INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isC
VALUES ('修改', @menuId, 3, '#', NULL, 0, 0, 'F', '0', '0', '{Permission}:update', '', '', GETDATE(), '', NULL, NULL);
GO
SELECT * FROM sys_menu WHERE parentId = @menuId;
SELECT * FROM sys_menu WHERE parentId = {ParentId};
SELECT * FROM sys_menu WHERE menuId = @menuId;

View File

@@ -38,7 +38,7 @@ export function update{ModelTypeName}(data) {
/**
* 获取{FunctionName}详情
* @param {Id} {ModelTypeDesc}Id
* @param {Id} {FunctionName}Id
*/
export function get{ModelTypeName}(id) {
return request({