fix 代码生成选择上级菜单bug
This commit is contained in:
parent
81a91f13b6
commit
aaff546de4
@ -231,7 +231,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成代码
|
/// 生成代码(下载方式)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dto">数据传输对象</param>
|
/// <param name="dto">数据传输对象</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@ -249,12 +249,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
|
|
||||||
var genTableInfo = GenTableService.GetGenTableInfo(dto.TableId);
|
var genTableInfo = GenTableService.GetGenTableInfo(dto.TableId);
|
||||||
genTableInfo.Columns = GenTableColumnService.GenTableColumns(dto.TableId);
|
genTableInfo.Columns = GenTableColumnService.GenTableColumns(dto.TableId);
|
||||||
//附加参数,key,value格式
|
|
||||||
if (!string.IsNullOrEmpty(genTableInfo.Options))
|
|
||||||
{
|
|
||||||
Dictionary<string, object> options = JsonConvert.DeserializeObject<Dictionary<string, object>>(genTableInfo.Options);
|
|
||||||
dto.ParentMenuId = (long)options.GetValueOrDefault("parentMenuId", 0);
|
|
||||||
}
|
|
||||||
dto.GenTable = genTableInfo;
|
dto.GenTable = genTableInfo;
|
||||||
//生成代码
|
//生成代码
|
||||||
CodeGeneratorTool.Generate(genTableInfo, dto);
|
CodeGeneratorTool.Generate(genTableInfo, dto);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
-- 菜单
|
-- 菜单
|
||||||
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by, create_time, remark)
|
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by, create_time, remark)
|
||||||
VALUES ('{FunctionName}', 0, 1, '{ModuleName}/{ModelTypeName}', '{ModuleName}/{ViewsFileName}/index', 0, 0, 'C', '0', '0', '{Permission}:list', 'icon1', '', sysdate(), '{FunctionName}菜单');
|
VALUES ('{FunctionName}', {ParentId}, 1, '{ModuleName}/{ModelTypeName}', '{ModuleName}/{ViewsFileName}/index', 0, 0, 'C', '0', '0', '{Permission}:list', 'icon1', '', sysdate(), '{FunctionName}菜单');
|
||||||
|
|
||||||
-- 按钮父菜单id
|
-- 按钮父菜单id
|
||||||
SELECT @menuId := LAST_INSERT_ID();
|
SELECT @menuId := LAST_INSERT_ID();
|
||||||
|
|||||||
@ -408,7 +408,7 @@ namespace ZR.CodeGenerator
|
|||||||
.Replace("{Permission}", replaceDto.Permission)
|
.Replace("{Permission}", replaceDto.Permission)
|
||||||
.Replace("{ModuleName}", generateDto.GenTable.ModuleName)
|
.Replace("{ModuleName}", generateDto.GenTable.ModuleName)
|
||||||
.Replace("{ViewsFileName}", replaceDto.ViewsFileName)
|
.Replace("{ViewsFileName}", replaceDto.ViewsFileName)
|
||||||
.Replace("{ParentId}", generateDto.ParentMenuId.ToString())
|
.Replace("{ParentId}", generateDto.GenTable.ParentMenuId.ToString())
|
||||||
.Replace("{FunctionName}", generateDto.GenTable.FunctionName);
|
.Replace("{FunctionName}", generateDto.GenTable.FunctionName);
|
||||||
|
|
||||||
generateDto.GenCodes.Add(new GenCode(8, "sql", fullPath, content));
|
generateDto.GenCodes.Add(new GenCode(8, "sql", fullPath, content));
|
||||||
|
|||||||
@ -45,10 +45,6 @@ namespace ZR.CodeGenerator.Model
|
|||||||
/// 代码生成压缩包名称
|
/// 代码生成压缩包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ZipFileName { get; set; }
|
public string ZipFileName { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// 父级菜单id
|
|
||||||
/// </summary>
|
|
||||||
public long ParentMenuId { get; set; }
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -72,7 +72,7 @@ namespace ZR.CodeGenerator.Model
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询条件
|
/// 查询条件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string QueryCondition { get; set; }
|
public string QueryCondition { get; set; } = "";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询属性
|
/// 查询属性
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -69,8 +69,12 @@ namespace ZR.Model.System.Generate
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Options { get; set; }
|
public string Options { get; set; }
|
||||||
|
|
||||||
|
#region 表额外字段
|
||||||
/** 表列信息 */
|
/** 表列信息 */
|
||||||
[SqlSugar.SugarColumn(IsIgnore = true)]
|
[SqlSugar.SugarColumn(IsIgnore = true)]
|
||||||
public List<GenTableColumn> Columns { get; set; }
|
public List<GenTableColumn> Columns { get; set; }
|
||||||
|
[SqlSugar.SugarColumn(IsIgnore = true)]
|
||||||
|
public string ParentMenuId { get; set; }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using Infrastructure.Extensions;
|
using Infrastructure.Extensions;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -53,7 +54,24 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public GenTable GetGenTableInfo(long tableId)
|
public GenTable GetGenTableInfo(long tableId)
|
||||||
{
|
{
|
||||||
return GenTableRepository.GetId(tableId);
|
var info = GenTableRepository.GetId(tableId);
|
||||||
|
SetTableFromOptions(info);
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置代码生成其他参数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="genTable"></param>
|
||||||
|
private void SetTableFromOptions(GenTable genTable)
|
||||||
|
{
|
||||||
|
//附加参数,key,value格式
|
||||||
|
if (!string.IsNullOrEmpty(genTable?.Options))
|
||||||
|
{
|
||||||
|
Dictionary<string, object> options = JsonConvert.DeserializeObject<Dictionary<string, object>>(genTable.Options);
|
||||||
|
genTable.ParentMenuId = Convert.ToString(options.GetValueOrDefault("parentMenuId"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -170,7 +170,6 @@ export default {
|
|||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
this.preview.open = true;
|
this.preview.open = true;
|
||||||
this.preview.data = res.data;
|
this.preview.data = res.data;
|
||||||
console.log(res);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user