mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-15 23:13:40 +08:00
🐛fix: #ICL05Q 代码生成命名空间设置无效
This commit is contained in:
parent
d83a40e07e
commit
f980fc5afc
@ -337,6 +337,7 @@ namespace OpenAuth.App
|
|||||||
.Replace("{ModuleCode}", sysTableInfo.ModuleCode)
|
.Replace("{ModuleCode}", sysTableInfo.ModuleCode)
|
||||||
.Replace("{ModuleName}", sysTableInfo.ModuleName)
|
.Replace("{ModuleName}", sysTableInfo.ModuleName)
|
||||||
.Replace("{ClassName}", sysTableInfo.ClassName)
|
.Replace("{ClassName}", sysTableInfo.ClassName)
|
||||||
|
.Replace("{Namespace}", sysTableInfo.Namespace)
|
||||||
.Replace("{UpdateColumns}", updateColumns)
|
.Replace("{UpdateColumns}", updateColumns)
|
||||||
.Replace("{InsertColumns}", insertColumns)
|
.Replace("{InsertColumns}", insertColumns)
|
||||||
.Replace("{StartName}", StratName);
|
.Replace("{StartName}", StratName);
|
||||||
@ -370,6 +371,7 @@ namespace OpenAuth.App
|
|||||||
.Replace("{ModuleCode}", sysTableInfo.ModuleCode)
|
.Replace("{ModuleCode}", sysTableInfo.ModuleCode)
|
||||||
.Replace("{ModuleName}", sysTableInfo.ModuleName)
|
.Replace("{ModuleName}", sysTableInfo.ModuleName)
|
||||||
.Replace("{ClassName}", sysTableInfo.ClassName)
|
.Replace("{ClassName}", sysTableInfo.ClassName)
|
||||||
|
.Replace("{Namespace}", sysTableInfo.Namespace)
|
||||||
.Replace("{SubForeignKey}", subTable.ForeignKey)
|
.Replace("{SubForeignKey}", subTable.ForeignKey)
|
||||||
.Replace("{SubClassName}", subTable.ClassName)
|
.Replace("{SubClassName}", subTable.ClassName)
|
||||||
.Replace("{SubModuleCode}", subTable.ModuleCode)
|
.Replace("{SubModuleCode}", subTable.ModuleCode)
|
||||||
@ -508,6 +510,7 @@ namespace OpenAuth.App
|
|||||||
domainContent = FileHelper.ReadFile(@"Template\\BuildControllerApi.html")
|
domainContent = FileHelper.ReadFile(@"Template\\BuildControllerApi.html")
|
||||||
.Replace("{TableName}", sysTableInfo.TableName)
|
.Replace("{TableName}", sysTableInfo.TableName)
|
||||||
.Replace("{ModuleCode}", sysTableInfo.ModuleCode)
|
.Replace("{ModuleCode}", sysTableInfo.ModuleCode)
|
||||||
|
.Replace("{Namespace}", sysTableInfo.Namespace)
|
||||||
.Replace("{ModuleName}", sysTableInfo.ModuleName)
|
.Replace("{ModuleName}", sysTableInfo.ModuleName)
|
||||||
.Replace("{ClassName}", sysTableInfo.ClassName)
|
.Replace("{ClassName}", sysTableInfo.ClassName)
|
||||||
.Replace("{StartName}", StratName);
|
.Replace("{StartName}", StratName);
|
||||||
@ -607,6 +610,7 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
domainContent = domainContent.Replace("{ClassName}", tableInfo.ClassName)
|
domainContent = domainContent.Replace("{ClassName}", tableInfo.ClassName)
|
||||||
.Replace("{AttributeList}", attributeBuilder.ToString())
|
.Replace("{AttributeList}", attributeBuilder.ToString())
|
||||||
|
.Replace("{Namespace}", tableInfo.Namespace)
|
||||||
.Replace("{Construction}", constructionBuilder.ToString());
|
.Replace("{Construction}", constructionBuilder.ToString());
|
||||||
|
|
||||||
|
|
||||||
@ -621,10 +625,29 @@ namespace OpenAuth.App
|
|||||||
tableAttr.Append(" [Table(\"" + tableInfo.TableName + "\")]");
|
tableAttr.Append(" [Table(\"" + tableInfo.TableName + "\")]");
|
||||||
domainContent = domainContent.Replace("{AttributeManager}", tableAttr.ToString());
|
domainContent = domainContent.Replace("{AttributeManager}", tableAttr.ToString());
|
||||||
|
|
||||||
FileHelper.WriteFile(
|
// 检查命名空间是否以OpenAuth.Repository开头
|
||||||
mapPath +
|
if (!tableInfo.Namespace.StartsWith("OpenAuth.Repository"))
|
||||||
$"\\OpenAuth.Repository\\Domain\\", tableInfo.ClassName + ".cs",
|
{
|
||||||
domainContent);
|
throw new Exception("命名空间必须以OpenAuth.Repository开头!");
|
||||||
|
}
|
||||||
|
// 获取OpenAuth.Repository后面的部分
|
||||||
|
var subNamespace = tableInfo.Namespace.Substring("OpenAuth.Repository".Length).TrimStart('.');
|
||||||
|
// 构建目录层级
|
||||||
|
var domainPath = Path.Combine(mapPath, "OpenAuth.Repository");
|
||||||
|
if (!string.IsNullOrEmpty(subNamespace))
|
||||||
|
{
|
||||||
|
foreach (var part in subNamespace.Split('.'))
|
||||||
|
{
|
||||||
|
domainPath = Path.Combine(domainPath, part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 确保目录存在
|
||||||
|
if (!Directory.Exists(domainPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(domainPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
FileHelper.WriteFile(domainPath, tableInfo.ClassName + ".cs", domainContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, Type> PrimitiveTypes = new Dictionary<string, Type>()
|
Dictionary<string, Type> PrimitiveTypes = new Dictionary<string, Type>()
|
||||||
|
@ -38,7 +38,7 @@ namespace OpenAuth.App.Test
|
|||||||
|
|
||||||
//模拟路径
|
//模拟路径
|
||||||
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
|
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
|
||||||
.Replace("\\OpenAuth.App\\bin\\Debug\\netcoreapp3.1","");
|
.Replace("\\OpenAuth.App\\bin\\Debug\\net9.0","");
|
||||||
var mockPathProvider = new Mock<IPathProvider>();
|
var mockPathProvider = new Mock<IPathProvider>();
|
||||||
mockPathProvider.Setup(x => x.MapPath("",false)).Returns(path);
|
mockPathProvider.Setup(x => x.MapPath("",false)).Returns(path);
|
||||||
services.AddScoped(x => mockHttpFac.Object);
|
services.AddScoped(x => mockHttpFac.Object);
|
||||||
|
@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using OpenAuth.App;
|
using OpenAuth.App;
|
||||||
using OpenAuth.App.Request;
|
using OpenAuth.App.Request;
|
||||||
using OpenAuth.App.Response;
|
using OpenAuth.App.Response;
|
||||||
using OpenAuth.Repository.Domain;
|
using {Namespace};
|
||||||
|
|
||||||
namespace OpenAuth.WebApi.Controllers
|
namespace OpenAuth.WebApi.Controllers
|
||||||
{
|
{
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
//------------------------------------------------------------------------------
|
/*
|
||||||
// This code was generated by a CodeSmith Template.
|
* @Author: yubaolee <yubaolee@163.com> | ahfu~ <954478625@qq.com>
|
||||||
//
|
* @Description: 实体类
|
||||||
// DO NOT MODIFY contents of this file. Changes to this
|
* Copyright (c) 2025 by yubaolee | ahfu~ , All Rights Reserved.
|
||||||
// file will be lost if the code is regenerated.
|
*/
|
||||||
// Author:Yubao Li
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using OpenAuth.Repository.Core;
|
using OpenAuth.Repository.Core;
|
||||||
|
|
||||||
namespace OpenAuth.Repository.Domain
|
namespace {Namespace}
|
||||||
{
|
{
|
||||||
{AttributeManager}
|
{AttributeManager}
|
||||||
public class {ClassName} : {BaseEntityName}
|
public class {ClassName} : {BaseEntityName}
|
||||||
|
@ -5,7 +5,7 @@ using Infrastructure;
|
|||||||
using OpenAuth.App.Interface;
|
using OpenAuth.App.Interface;
|
||||||
using OpenAuth.App.Request;
|
using OpenAuth.App.Request;
|
||||||
using OpenAuth.App.Response;
|
using OpenAuth.App.Response;
|
||||||
using OpenAuth.Repository.Domain;
|
using {Namespace};
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
namespace OpenAuth.App
|
namespace OpenAuth.App
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ using Infrastructure;
|
|||||||
using OpenAuth.App.Interface;
|
using OpenAuth.App.Interface;
|
||||||
using OpenAuth.App.Request;
|
using OpenAuth.App.Request;
|
||||||
using OpenAuth.App.Response;
|
using OpenAuth.App.Response;
|
||||||
using OpenAuth.Repository.Domain;
|
using {Namespace};
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
namespace OpenAuth.App
|
namespace OpenAuth.App
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@ using Infrastructure;
|
|||||||
using OpenAuth.App.Interface;
|
using OpenAuth.App.Interface;
|
||||||
using OpenAuth.App.Request;
|
using OpenAuth.App.Request;
|
||||||
using OpenAuth.App.Response;
|
using OpenAuth.App.Response;
|
||||||
using OpenAuth.Repository.Domain;
|
using {Namespace};
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ using Infrastructure;
|
|||||||
using OpenAuth.App.Interface;
|
using OpenAuth.App.Interface;
|
||||||
using OpenAuth.App.Request;
|
using OpenAuth.App.Request;
|
||||||
using OpenAuth.App.Response;
|
using OpenAuth.App.Response;
|
||||||
using OpenAuth.Repository.Domain;
|
using {Namespace};
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user