添加代码生成模块
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Template.Abstracts
|
||||
{
|
||||
public abstract class AbstractTemplateProvider : ITemplateProvider
|
||||
{
|
||||
public virtual string? BuildPath { get; set; }
|
||||
public string? TemplatePath { get; set; }
|
||||
public string? BakPath { get; set; }
|
||||
protected Dictionary<string, string> TemplateDic { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
public abstract void Bak();
|
||||
|
||||
public abstract void Build();
|
||||
|
||||
|
||||
protected virtual string GetTemplateData()
|
||||
{
|
||||
if (TemplatePath is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(TemplatePath));
|
||||
}
|
||||
return File.ReadAllText(TemplatePath);
|
||||
}
|
||||
|
||||
protected void AddTemplateDic(string oldStr, string newStr)
|
||||
{
|
||||
|
||||
TemplateDic.Add(oldStr, newStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Template.Abstracts
|
||||
{
|
||||
public interface ITemplateProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建生成路径
|
||||
/// </summary>
|
||||
string? BuildPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模板文件路径
|
||||
/// </summary>
|
||||
string? TemplatePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备份文件路径
|
||||
/// </summary>
|
||||
string? BakPath { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 开始构建
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
void Build();
|
||||
|
||||
/// <summary>
|
||||
/// 生成备份
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
void Bak();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Template.ConstClasses;
|
||||
|
||||
namespace Yi.Framework.Template.Abstracts
|
||||
{
|
||||
public abstract class ModelTemplateProvider : ProgramTemplateProvider
|
||||
{
|
||||
|
||||
public ModelTemplateProvider(string modelName, string entityName) : base(modelName, entityName)
|
||||
{
|
||||
AddIgnoreEntityField("Id", "TenantId");
|
||||
}
|
||||
|
||||
private string entityPath=string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 实体路径,该类生成需要实体与模板两个同时构建成
|
||||
/// </summary>
|
||||
public string EntityPath
|
||||
{
|
||||
get => this.entityPath;
|
||||
set
|
||||
{
|
||||
value = value!.Replace(TemplateConst.EntityName, EntityName);
|
||||
value = value.Replace(TemplateConst.ModelName, ModelName);
|
||||
this.entityPath = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成模板忽略实体字段
|
||||
/// </summary>
|
||||
private List<string> IgnoreEntityFields { get; set; } = new();
|
||||
|
||||
public override void Build()
|
||||
{
|
||||
if (BuildPath is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(BuildPath));
|
||||
}
|
||||
//模板信息
|
||||
var templateData = GetTemplateData();
|
||||
|
||||
//实体信息
|
||||
var enetityDatas = GetEntityData().ToList();
|
||||
|
||||
//获取全部属性字段
|
||||
for (var i = enetityDatas.Count() - 1; i >= 0; i--)
|
||||
{
|
||||
//不是字段属性直接删除跳过
|
||||
if (!enetityDatas[i].Contains("{ get; set; }"))
|
||||
{
|
||||
enetityDatas.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
//是字段属性,同时还包含忽略字段
|
||||
foreach (var IgnoreEntityField in IgnoreEntityFields)
|
||||
{
|
||||
if (enetityDatas[i].Contains(IgnoreEntityField))
|
||||
{
|
||||
enetityDatas.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//以}结尾,不包含get不是属性,代表类结尾
|
||||
if (enetityDatas[i].EndsWith("}") && !enetityDatas[i].Contains("get"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//拼接实体字段
|
||||
var entityFieldsbuild = string.Join("\r\n", enetityDatas);
|
||||
|
||||
|
||||
//模板替换属性字段
|
||||
templateData = templateData.Replace(TemplateConst.EntityField, entityFieldsbuild);
|
||||
|
||||
templateData = base.ReplaceTemplateDic(templateData);
|
||||
|
||||
if (!Directory.Exists(Path.GetDirectoryName(BuildPath)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(BuildPath)!);
|
||||
}
|
||||
File.WriteAllText(BuildPath, templateData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public virtual string[] GetEntityData()
|
||||
{
|
||||
if (TemplatePath is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(entityPath));
|
||||
}
|
||||
if (!File.Exists(entityPath))
|
||||
{
|
||||
throw new FileNotFoundException($"请检查路径:{entityPath}\r\n未包含实体:{EntityName}");
|
||||
}
|
||||
|
||||
return File.ReadAllLines(entityPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加忽略实体字段
|
||||
/// </summary>
|
||||
/// <param name="field"></param>
|
||||
public void AddIgnoreEntityField(params string[] field)
|
||||
{
|
||||
IgnoreEntityFields.AddRange(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Template.ConstClasses;
|
||||
|
||||
namespace Yi.Framework.Template.Abstracts
|
||||
{
|
||||
|
||||
public abstract class ProgramTemplateProvider : AbstractTemplateProvider
|
||||
{
|
||||
public ProgramTemplateProvider(string modelName, string entityName)
|
||||
{
|
||||
ModelName = modelName;
|
||||
EntityName = entityName;
|
||||
base.AddTemplateDic(TemplateConst.EntityName, EntityName);
|
||||
base.AddTemplateDic(TemplateConst.ModelName, ModelName);
|
||||
base.AddTemplateDic(TemplateConst.LowerEntityName, EntityName.Substring(0, 1).ToLower() + EntityName.Substring(1));
|
||||
base.AddTemplateDic(TemplateConst.LowerModelName, ModelName.ToLower());
|
||||
}
|
||||
/// <summary>
|
||||
/// 实体名称
|
||||
/// </summary>
|
||||
public string EntityName { get; set; }
|
||||
/// <summary>
|
||||
/// 模块名称
|
||||
/// </summary>
|
||||
public string ModelName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 重写构建路径,替换实体名称与模块名称
|
||||
/// </summary>
|
||||
public override string? BuildPath
|
||||
{
|
||||
get => base.BuildPath;
|
||||
set
|
||||
{
|
||||
value = ReplaceTemplateDic(value!);
|
||||
|
||||
base.BuildPath = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string ReplaceTemplateDic(string str)
|
||||
{
|
||||
foreach (var ky in TemplateDic)
|
||||
{
|
||||
str = str.Replace(ky.Key, ky.Value);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
public override void Build()
|
||||
{
|
||||
if (BuildPath is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(BuildPath));
|
||||
}
|
||||
var templateData = GetTemplateData();
|
||||
templateData = ReplaceTemplateDic(templateData);
|
||||
if (!Directory.Exists(Path.GetDirectoryName(BuildPath)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(BuildPath)!);
|
||||
}
|
||||
File.WriteAllText(BuildPath, templateData);
|
||||
}
|
||||
|
||||
public override void Bak()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Template.ConstClasses
|
||||
{
|
||||
public class TemplateConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 模块名称大写
|
||||
/// </summary>
|
||||
public const string ModelName = "#ModelName#";
|
||||
|
||||
/// <summary>
|
||||
/// 模块名称小写
|
||||
/// </summary>
|
||||
public const string LowerModelName = "#LowerModelName#";
|
||||
|
||||
/// <summary>
|
||||
/// 实体名称大驼峰
|
||||
/// </summary>
|
||||
public const string EntityName = "#EntityName#";
|
||||
|
||||
/// <summary>
|
||||
/// 实体名称小驼峰
|
||||
/// </summary>
|
||||
public const string LowerEntityName = "#LowerEntityName#";
|
||||
|
||||
/// <summary>
|
||||
/// 实体字段
|
||||
/// </summary>
|
||||
public const string EntityField = "#EntityField#";
|
||||
|
||||
public const string BuildRootPath = "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Yi.Framework.Template;
|
||||
using Yi.Framework.Template.Provider.Server;
|
||||
using Yi.Framework.Template.Provider.Site;
|
||||
|
||||
TemplateFactory templateFactory = new();
|
||||
|
||||
//选择需要生成的模板提供者
|
||||
|
||||
string modelName = "";
|
||||
List<string> entityNames = new() { "_" };
|
||||
|
||||
foreach (var entityName in entityNames)
|
||||
{
|
||||
templateFactory.CreateTemplateProviders((option) =>
|
||||
{
|
||||
option.Add(new ServiceTemplateProvider(modelName, entityName));
|
||||
option.Add(new IServiceTemplateProvider(modelName, entityName));
|
||||
|
||||
|
||||
option.Add(new CreateInputVoTemplateProvider(modelName, entityName));
|
||||
option.Add(new UpdateInputVoTemplateProvider(modelName, entityName));
|
||||
option.Add(new GetListInputVoTemplateProvider(modelName, entityName));
|
||||
option.Add(new GetListOutputDtoTemplateProvider(modelName, entityName));
|
||||
|
||||
option.Add(new ConstTemplateProvider(modelName, entityName));
|
||||
option.Add(new ProfileTemplateProvider(modelName, entityName));
|
||||
|
||||
|
||||
option.Add(new ApiTemplateProvider(modelName, entityName));
|
||||
});
|
||||
//开始构建模板
|
||||
templateFactory.BuildTemplate();
|
||||
Console.WriteLine($"Yi.Framework.Template:{entityName}构建完成!");
|
||||
}
|
||||
|
||||
Console.WriteLine("Yi.Framework.Template:模板全部生成完成!");
|
||||
Console.ReadKey();
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Template.Abstracts;
|
||||
using Yi.Framework.Template.ConstClasses;
|
||||
|
||||
namespace Yi.Framework.Template.Provider.Server
|
||||
{
|
||||
internal class ConstTemplateProvider : ProgramTemplateProvider
|
||||
{
|
||||
public ConstTemplateProvider(string modelName, string entityName) : base(modelName, entityName)
|
||||
{
|
||||
BuildPath = $@"..\..\..\..\Yi.Framework.DtoModel\{TemplateConst.ModelName}\{TemplateConst.EntityName}\ConstConfig\{TemplateConst.EntityName}Const.cs";
|
||||
TemplatePath = $@"..\..\..\Template\Server\ConstTemplate.txt";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Template.Abstracts;
|
||||
using Yi.Framework.Template.ConstClasses;
|
||||
|
||||
namespace Yi.Framework.Template.Provider.Server
|
||||
{
|
||||
public class CreateInputVoTemplateProvider : ModelTemplateProvider
|
||||
{
|
||||
public CreateInputVoTemplateProvider(string modelName, string entityName) : base(modelName, entityName)
|
||||
{
|
||||
BuildPath = $@"..\..\..\..\Yi.Framework.DtoModel\{TemplateConst.ModelName}\{TemplateConst.EntityName}\{TemplateConst.EntityName}CreateInput.cs";
|
||||
TemplatePath = $@"..\..\..\Template\Server\CreateInputTemplate.txt";
|
||||
EntityPath = $@"..\..\..\..\Yi.Framework.Model\{TemplateConst.ModelName}\Entitys\{TemplateConst.EntityName}Entity.cs";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Template.Abstracts;
|
||||
using Yi.Framework.Template.ConstClasses;
|
||||
|
||||
namespace Yi.Framework.Template.Provider.Server
|
||||
{
|
||||
public class GetListInputTemplateProvider : ModelTemplateProvider
|
||||
{
|
||||
public GetListInputTemplateProvider(string modelName, string entityName) : base(modelName, entityName)
|
||||
{
|
||||
BuildPath = $@"..\..\..\..\Yi.Framework.DtoModel\{TemplateConst.ModelName}\{TemplateConst.EntityName}\{TemplateConst.EntityName}GetListInput.cs";
|
||||
TemplatePath = $@"..\..\..\Template\Server\GetListInputTemplate.txt";
|
||||
EntityPath = $@"..\..\..\..\Yi.Framework.Model\{TemplateConst.ModelName}\Entitys\{TemplateConst.EntityName}Entity.cs";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Template.Abstracts;
|
||||
using Yi.Framework.Template.ConstClasses;
|
||||
|
||||
namespace Yi.Framework.Template.Provider.Server
|
||||
{
|
||||
public class GetListOutputTemplateProvider : ModelTemplateProvider
|
||||
{
|
||||
public GetListOutputTemplateProvider(string modelName, string entityName) : base(modelName, entityName)
|
||||
{
|
||||
BuildPath = $@"..\..\..\..\Yi.Framework.DtoModel\{TemplateConst.ModelName}\{TemplateConst.EntityName}\{TemplateConst.EntityName}GetListOutput.cs";
|
||||
TemplatePath = $@"..\..\..\Template\Server\GetListOutputTemplate.txt";
|
||||
EntityPath = $@"..\..\..\..\Yi.Framework.Model\{TemplateConst.ModelName}\Entitys\{TemplateConst.EntityName}Entity.cs";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Template.Abstracts;
|
||||
using Yi.Framework.Template.ConstClasses;
|
||||
|
||||
namespace Yi.Framework.Template.Provider.Server
|
||||
{
|
||||
public class GetOutputDtoTemplateProvider : ModelTemplateProvider
|
||||
{
|
||||
public GetOutputDtoTemplateProvider(string modelName, string entityName) : base(modelName, entityName)
|
||||
{
|
||||
BuildPath = $@"..\..\..\..\Yi.Framework.DtoModel\{TemplateConst.ModelName}\{TemplateConst.EntityName}\{TemplateConst.EntityName}GetOutputDto.cs";
|
||||
TemplatePath = $@"..\..\..\Template\Server\GetOutputDtoTemplate.txt";
|
||||
EntityPath = $@"..\..\..\..\Yi.Framework.Model\{TemplateConst.ModelName}\Entitys\{TemplateConst.EntityName}Entity.cs";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Template.Abstracts;
|
||||
using Yi.Framework.Template.ConstClasses;
|
||||
|
||||
namespace Yi.Framework.Template.Provider.Server
|
||||
{
|
||||
public class IServiceTemplateProvider : ProgramTemplateProvider
|
||||
{
|
||||
public IServiceTemplateProvider(string modelName, string entityName) : base(modelName, entityName)
|
||||
{
|
||||
BuildPath = $@"..\..\..\..\Yi.Framework.Interface\{TemplateConst.ModelName}\I{TemplateConst.EntityName}Service.cs";
|
||||
TemplatePath = $@"..\..\..\Template\Server\IServiceTemplate.txt";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Template.Abstracts;
|
||||
using Yi.Framework.Template.ConstClasses;
|
||||
|
||||
namespace Yi.Framework.Template.Provider.Server
|
||||
{
|
||||
public class ProfileTemplateProvider : ProgramTemplateProvider
|
||||
{
|
||||
public ProfileTemplateProvider(string modelName, string entityName) : base(modelName, entityName)
|
||||
{
|
||||
BuildPath = $@"..\..\..\..\Yi.Framework.DtoModel\{TemplateConst.ModelName}\{TemplateConst.EntityName}\MapperConfig\{TemplateConst.EntityName}Profile.cs";
|
||||
TemplatePath = $@"..\..\..\Template\Server\ProfileTemplate.txt";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Template.Abstracts;
|
||||
using Yi.Framework.Template.ConstClasses;
|
||||
|
||||
namespace Yi.Framework.Template.Provider.Server
|
||||
{
|
||||
public class ServiceTemplateProvider : ProgramTemplateProvider
|
||||
{
|
||||
public ServiceTemplateProvider(string modelName, string entityName) : base(modelName, entityName)
|
||||
{
|
||||
BuildPath = $@"..\..\..\..\Yi.Framework.Service\{TemplateConst.ModelName}\{TemplateConst.EntityName}Service.cs";
|
||||
TemplatePath = $@"..\..\..\Template\Server\ServiceTemplate.txt";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Template.Abstracts;
|
||||
using Yi.Framework.Template.ConstClasses;
|
||||
|
||||
namespace Yi.Framework.Template.Provider.Server
|
||||
{
|
||||
public class UpdateInputVoTemplateProvider : ModelTemplateProvider
|
||||
{
|
||||
public UpdateInputVoTemplateProvider(string modelName, string entityName) : base(modelName, entityName)
|
||||
{
|
||||
BuildPath = $@"..\..\..\..\Yi.Framework.DtoModel\{TemplateConst.ModelName}\{TemplateConst.EntityName}\{TemplateConst.EntityName}UpdateInputVo.cs";
|
||||
TemplatePath = $@"..\..\..\Template\Server\UpdateInputVoTemplate.txt";
|
||||
EntityPath = $@"..\..\..\..\Yi.Framework.Model\{TemplateConst.ModelName}\Entitys\{TemplateConst.EntityName}Entity.cs";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Template.Abstracts;
|
||||
using Yi.Framework.Template.ConstClasses;
|
||||
|
||||
namespace Yi.Framework.Template.Provider.Site
|
||||
{
|
||||
public class ApiTemplateProvider : ProgramTemplateProvider
|
||||
{
|
||||
public ApiTemplateProvider(string modelName, string entityName) : base(modelName, entityName)
|
||||
{
|
||||
BuildPath = $@"..\..\..\Code_Site\src\api\{TemplateConst.LowerModelName}\{TemplateConst.LowerEntityName}Api.js";
|
||||
TemplatePath = $@"..\..\..\Template\Site\ApiTemplate.txt";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.DtoModel.#ModelName#.#EntityName#.ConstConfig
|
||||
{
|
||||
public class #EntityName#Const
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
|
||||
namespace Yi.Framework.DtoModel.#ModelName#.#EntityName#
|
||||
{
|
||||
public class #EntityName#CreateUpdateInput : EntityDto<long>
|
||||
{
|
||||
#EntityField#
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
|
||||
namespace Yi.Framework.DtoModel.#ModelName#.#EntityName#
|
||||
{
|
||||
public class #EntityName#GetListInput
|
||||
{
|
||||
#EntityField#
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
|
||||
namespace Yi.Framework.DtoModel.#ModelName#.#EntityName#
|
||||
{
|
||||
public class #EntityName#GetListOutput: EntityDto<long>
|
||||
{
|
||||
#EntityField#
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
|
||||
namespace Yi.Framework.DtoModel.#ModelName#.#EntityName#
|
||||
{
|
||||
public class #EntityName#GetListOutput: EntityDto<long>
|
||||
{
|
||||
#EntityField#
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.#ModelName#.#EntityName#;
|
||||
using Yi.Framework.Interface.Base.Crud;
|
||||
|
||||
namespace Yi.Framework.Interface.#ModelName#
|
||||
{
|
||||
public interface I#EntityName#Service : ICrudAppService<#EntityName#GetListOutput, long, #EntityName#CreateUpdateInput>
|
||||
{
|
||||
Task<PageModel<List<#EntityName#GetListOutput>>> PageListAsync(#EntityName#GetListInput input, PageParModel page);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.#ModelName#.Entitys;
|
||||
|
||||
namespace Yi.Framework.DtoModel.#ModelName#.#EntityName#.MapperConfig
|
||||
{
|
||||
public class Suppli#ModelName#rofile:Profile
|
||||
{
|
||||
public Suppli#ModelName#rofile()
|
||||
{
|
||||
CreateMap<#EntityName#CreateUpdateInput, #EntityName#Entity>();
|
||||
CreateMap<#EntityName#Entity, #EntityName#GetListOutput>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using AutoMapper;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.#ModelName#.#EntityName#;
|
||||
using Yi.Framework.Interface.#ModelName#;
|
||||
using Yi.Framework.Model.#ModelName#.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.Service.Base.Crud;
|
||||
|
||||
namespace Yi.Framework.Service.#ModelName#
|
||||
{
|
||||
public class #EntityName#Service : CrudAppService<#EntityName#Entity, #EntityName#GetListOutput, long, #EntityName#CreateUpdateInput>, I#EntityName#Service
|
||||
{
|
||||
public async Task<PageModel<List<#EntityName#GetListOutput>>> PageListAsync(#EntityName#GetListInput input, PageParModel page)
|
||||
{
|
||||
RefAsync<int> totalNumber = 0;
|
||||
var data = await Repository._DbQueryable
|
||||
.WhereIF(input.Code is not null,u=>u.Code.Contains(input.Code))
|
||||
.WhereIF(input.Name is not null, u => u.Name.Contains(input.Name))
|
||||
.ToPageListAsync(page.PageNum, page.PageSize, totalNumber);
|
||||
return new PageModel<List<#EntityName#GetListOutput>> { Total = totalNumber.Value, Data = await MapToGetListOutputDtosAsync(data) };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
|
||||
namespace Yi.Framework.DtoModel.#ModelName#.#EntityName#
|
||||
{
|
||||
public class #EntityName#CreateUpdateInput : EntityDto<long>
|
||||
{
|
||||
#EntityField#
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 分页查询
|
||||
export function listData(query) {
|
||||
return request({
|
||||
url: '/#LowerEntityName#/pageList',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// id查询
|
||||
export function getData(code) {
|
||||
return request({
|
||||
url: '/#LowerEntityName#/getById/' + code,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增
|
||||
export function addData(data) {
|
||||
return request({
|
||||
url: '/#LowerEntityName#/create',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改
|
||||
export function updateData(id,data) {
|
||||
return request({
|
||||
url: `/#LowerEntityName#/update/${id}`,
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除
|
||||
export function delData(code) {
|
||||
return request({
|
||||
url: '/#LowerEntityName#/del',
|
||||
method: 'delete',
|
||||
data:"string"==typeof(code)?[code]:code
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Template.Abstracts;
|
||||
using Yi.Framework.Template.Provider;
|
||||
|
||||
namespace Yi.Framework.Template
|
||||
{
|
||||
public class TemplateFactory
|
||||
{
|
||||
private List<ITemplateProvider> _templateProviders=new List<ITemplateProvider>();
|
||||
|
||||
public void CreateTemplateProviders(Action<List<ITemplateProvider>> action)
|
||||
{
|
||||
action(_templateProviders);
|
||||
}
|
||||
|
||||
public void BuildTemplate()
|
||||
{
|
||||
foreach (var provider in _templateProviders)
|
||||
{
|
||||
provider.Build();
|
||||
}
|
||||
}
|
||||
|
||||
public void BakTemplate()
|
||||
{
|
||||
foreach (var provider in _templateProviders)
|
||||
{
|
||||
provider.Bak();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<OutputType>Exe</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Template\Server\ConstTemplate.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Template\Server\ControllerTemplate.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Template\Server\CreateUpdateInputTemplate.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Template\Server\GetListInputTemplate.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Template\Server\GetListOutputTemplate.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Template\Server\IServiceTemplate.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Template\Server\ProfileTemplate.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Template\Server\ServiceTemplate.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Template\Site\ApiTemplate.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Framework.Application.Contracts</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Yi.Framework.Application.Contracts.Student.Dtos.StudentCreateInputVo">
|
||||
<summary>
|
||||
Student输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.Application.Contracts.Student.Dtos.StudentGetListOutputDto.IsDeleted">
|
||||
<summary>
|
||||
想看一下结果
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.Application.Contracts.Student.IStudentService">
|
||||
<summary>
|
||||
服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Application.Contracts.Student.Dtos
|
||||
{
|
||||
/// <summary>
|
||||
/// Student输入创建对象
|
||||
/// </summary>
|
||||
public class StudentCreateInputVo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public long Number { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Ddd.Dtos;
|
||||
|
||||
namespace Yi.Framework.Application.Contracts.Student.Dtos
|
||||
{
|
||||
public class StudentGetListInputVo : PagedAndSortedResultRequestDto
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public long? Number { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Ddd.Dtos;
|
||||
|
||||
namespace Yi.Framework.Application.Contracts.Student.Dtos
|
||||
{
|
||||
public class StudentGetListOutputDto : IEntityDto<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public long Number { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 想看一下结果
|
||||
/// </summary>
|
||||
public bool IsDeleted { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Ddd.Dtos;
|
||||
|
||||
namespace Yi.Framework.Application.Contracts.Student.Dtos
|
||||
{
|
||||
public class StudentGetOutputDto : IEntityDto<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public long Number { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Application.Contracts.Student.Dtos
|
||||
{
|
||||
public class StudentUpdateInputVo
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public long? Number { get; set; }
|
||||
|
||||
public bool IsDeleted { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Application.Contracts.Student.Dtos;
|
||||
using Yi.Framework.Ddd.Services.Abstract;
|
||||
|
||||
namespace Yi.Framework.Application.Contracts.Student
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务抽象
|
||||
/// </summary>
|
||||
public interface IStudentService : ICrudAppService<StudentGetOutputDto, StudentGetListOutputDto, long, StudentGetListInputVo, StudentCreateInputVo, StudentUpdateInputVo>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<DocumentationFile>./ApplicationContractsSwaggerDoc.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Domain.Shared\Yi.Framework.Domain.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="ApplicationContractsSwaggerDoc.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,27 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StartupModules;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Domain.Shared;
|
||||
|
||||
namespace Yi.Framework.Application.Contracts
|
||||
{
|
||||
[DependsOn(
|
||||
typeof(YiFrameworkDomainSharedModule)
|
||||
)]
|
||||
public class YiFrameworkApplicationContractsModule : IStartupModule
|
||||
{
|
||||
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
||||
{
|
||||
}
|
||||
|
||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Framework.Application</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Yi.Framework.Application.Student.StudentService">
|
||||
<summary>
|
||||
服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Application.Student.StudentService.GetDataFiterTestAsync(Yi.Framework.Application.Contracts.Student.Dtos.StudentGetListInputVo)">
|
||||
<summary>
|
||||
数据过滤测试
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Application.Student.StudentService.GetToken">
|
||||
<summary>
|
||||
测试token
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Application.Student.StudentService.PostUow">
|
||||
<summary>
|
||||
Uow
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,23 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Application.Contracts.Student.Dtos;
|
||||
using Yi.Framework.Domain.Student.Entities;
|
||||
|
||||
namespace Yi.Framework.Application.Student.MapperConfig
|
||||
{
|
||||
public class StudentProfile: Profile
|
||||
{
|
||||
public StudentProfile()
|
||||
{
|
||||
CreateMap<StudentGetListInputVo, StudentEntity>();
|
||||
CreateMap<StudentCreateInputVo, StudentEntity>();
|
||||
CreateMap<StudentUpdateInputVo, StudentEntity>();
|
||||
CreateMap<StudentEntity, StudentGetListOutputDto>();
|
||||
CreateMap<StudentEntity, StudentGetOutputDto>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Application.Contracts.Student;
|
||||
using Yi.Framework.Domain.Student;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NET.AutoWebApi.Setting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Yi.Framework.Ddd.Services.Abstract;
|
||||
using Yi.Framework.Application.Contracts.Student.Dtos;
|
||||
using Yi.Framework.Domain.Student.Entities;
|
||||
using Yi.Framework.Ddd.Services;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Uow;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Yi.Framework.Auth.JwtBearer.Authentication;
|
||||
using Yi.Framework.Core.Const;
|
||||
using Yi.Framework.Core.CurrentUsers;
|
||||
using Yi.Framework.Auth.JwtBearer.Authorization;
|
||||
using Yi.Framework.Domain.Shared.Student.ConstClasses;
|
||||
using Yi.Framework.Domain.Student.Repositories;
|
||||
using Yi.Framework.Data.Filters;
|
||||
using Yi.Framework.Data.Entities;
|
||||
using Yi.Framework.Ddd.Dtos;
|
||||
|
||||
namespace Yi.Framework.Application.Student
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务实现
|
||||
/// </summary>
|
||||
|
||||
[AppService]
|
||||
public class StudentService : CrudAppService<StudentEntity, StudentGetOutputDto, StudentGetListOutputDto, long, StudentGetListInputVo, StudentCreateInputVo, StudentUpdateInputVo>,
|
||||
IStudentService, IAutoApiService
|
||||
{
|
||||
private readonly IStudentRepository _studentRepository;
|
||||
private readonly StudentManager _studentManager;
|
||||
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
||||
private readonly JwtTokenManager _jwtTokenManager;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
private readonly IDataFilter _dataFilter;
|
||||
public StudentService(IStudentRepository studentRepository, StudentManager studentManager, IUnitOfWorkManager unitOfWorkManager, JwtTokenManager jwtTokenManager, ICurrentUser currentUser, IDataFilter dataFilter)
|
||||
{
|
||||
_studentRepository = studentRepository;
|
||||
_studentManager = studentManager;
|
||||
_unitOfWorkManager = unitOfWorkManager;
|
||||
_jwtTokenManager = jwtTokenManager;
|
||||
_currentUser = currentUser;
|
||||
_dataFilter = dataFilter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据过滤测试
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PagedResultDto<StudentGetListOutputDto>> GetDataFiterTestAsync(StudentGetListInputVo input)
|
||||
{
|
||||
PagedResultDto<StudentGetListOutputDto> res = new();
|
||||
using (_dataFilter.Disable<ISoftDelete>())
|
||||
{
|
||||
|
||||
res = await base.GetListAsync(input);
|
||||
|
||||
|
||||
}
|
||||
|
||||
var p = await base.GetListAsync(input);
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测试token
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetToken()
|
||||
{
|
||||
var claimDic = new Dictionary<string, object>() { { TokenTypeConst.Id, "123" }, { TokenTypeConst.UserName, "cc" } };
|
||||
return _jwtTokenManager.CreateToken(claimDic);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uow
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
[Permission(AuthStudentConst.查询)]
|
||||
public async Task<StudentGetOutputDto> PostUow()
|
||||
{
|
||||
var o = _currentUser;
|
||||
StudentGetOutputDto res = new();
|
||||
using (var uow = _unitOfWorkManager.CreateContext())
|
||||
{
|
||||
var studentRepository = uow.GetRepository<StudentEntity>();
|
||||
res = await base.CreateAsync(new StudentCreateInputVo { Name = $"老杰哥{DateTime.Now.ToString("ffff")}", Number = 2023 });
|
||||
if (new Random().Next(0, 2) == 0) throw new NotImplementedException();
|
||||
uow.Commit();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<DocumentationFile>./ApplicationSwaggerDoc.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\framework\Yi.Framework.Auth.JwtBearer\Yi.Framework.Auth.JwtBearer.csproj" />
|
||||
<ProjectReference Include="..\..\src\framework\Yi.Framework.Uow\Yi.Framework.Uow.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Application.Contracts\Yi.Framework.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Domain\Yi.Framework.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,35 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StartupModules;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Application.Contracts;
|
||||
using Yi.Framework.Application.Contracts.Student;
|
||||
using Yi.Framework.Application.Student;
|
||||
using Yi.Framework.Auth.JwtBearer;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Data;
|
||||
using Yi.Framework.Ddd;
|
||||
using Yi.Framework.Domain;
|
||||
|
||||
namespace Yi.Framework.Application
|
||||
{
|
||||
[DependsOn(
|
||||
typeof(YiFrameworkApplicationContractsModule),
|
||||
typeof(YiFrameworkDomainModule),
|
||||
typeof(YiFrameworkAuthJwtBearerModule)
|
||||
)]
|
||||
public class YiFrameworkApplicationModule : IStartupModule
|
||||
{
|
||||
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
||||
{
|
||||
}
|
||||
|
||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
global using Yi.Framework.Core.Attributes;
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Domain.Shared.Student.ConstClasses
|
||||
{
|
||||
public class AuthStudentConst
|
||||
{
|
||||
public const string 查询 = "student:student:list";
|
||||
public const string 添加 = "student:student:add";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Domain.Shared.Student.ConstClasses
|
||||
{
|
||||
/// <summary>
|
||||
/// 常量定义
|
||||
/// </summary>
|
||||
|
||||
public class StudentConst
|
||||
{
|
||||
public const string 学生已重复 = "失败!学生已经重复";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\framework\Yi.Framework.Ddd\Yi.Framework.Ddd.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,27 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StartupModules;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Ddd;
|
||||
|
||||
namespace Yi.Framework.Domain.Shared
|
||||
{
|
||||
[DependsOn(
|
||||
typeof(YiFrameworkDddModule)
|
||||
)]
|
||||
public class YiFrameworkDomainSharedModule : IStartupModule
|
||||
{
|
||||
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
||||
{
|
||||
}
|
||||
|
||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Framework.Domain</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Yi.Framework.Domain.Student.Entities.StudentEntity">
|
||||
<summary>
|
||||
学生实体
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.Domain.Student.Entities.StudentEntity.Name">
|
||||
<summary>
|
||||
学生名称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.Domain.Student.Entities.StudentEntity.Number">
|
||||
<summary>
|
||||
学号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.Domain.Student.Entities.StudentEntity.IsDeleted">
|
||||
<summary>
|
||||
软删除
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.Domain.Student.Repositories.IStudentRepository">
|
||||
<summary>
|
||||
仓储抽象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.Domain.Student.StudentManager">
|
||||
<summary>
|
||||
领域服务
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,36 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Data.Entities;
|
||||
using Yi.Framework.Ddd.Entities;
|
||||
|
||||
namespace Yi.Framework.Domain.Student.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 学生实体
|
||||
/// </summary>
|
||||
[SugarTable("Student")]
|
||||
public class StudentEntity : IEntity<long>, ISoftDelete
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 学生名称
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 学号
|
||||
/// </summary>
|
||||
public long Number { get;set ; }
|
||||
|
||||
/// <summary>
|
||||
/// 软删除
|
||||
/// </summary>
|
||||
public bool IsDeleted { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Ddd.Repositories;
|
||||
using Yi.Framework.Domain.Student.Entities;
|
||||
|
||||
namespace Yi.Framework.Domain.Student.Repositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 仓储抽象
|
||||
/// </summary>
|
||||
public interface IStudentRepository : IRepository<StudentEntity>
|
||||
{
|
||||
Task<List<StudentEntity>> GetMyListAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Domain.Student.Repositories;
|
||||
|
||||
namespace Yi.Framework.Domain.Student
|
||||
{
|
||||
/// <summary>
|
||||
/// 领域服务
|
||||
/// </summary>
|
||||
public class StudentManager
|
||||
{
|
||||
private readonly IStudentRepository _studentRepository;
|
||||
public StudentManager(IStudentRepository studentRepository)
|
||||
{
|
||||
_studentRepository=studentRepository;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<DocumentationFile>./DomainSwaggerDoc.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\framework\Yi.Framework.Data\Yi.Framework.Data.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Domain.Shared\Yi.Framework.Domain.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="DomainSwaggerDoc.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,31 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StartupModules;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Data;
|
||||
using Yi.Framework.Domain.Shared;
|
||||
using Yi.Framework.Domain.Student;
|
||||
|
||||
namespace Yi.Framework.Domain
|
||||
{
|
||||
[DependsOn(
|
||||
typeof(YiFrameworkDomainSharedModule),
|
||||
typeof(YiFrameworkDataModule)
|
||||
)]
|
||||
public class YiFrameworkDomainModule : IStartupModule
|
||||
{
|
||||
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
||||
{
|
||||
}
|
||||
|
||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
||||
{
|
||||
services.AddTransient<StudentManager>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Core.Sqlsugar.Repositories;
|
||||
using Yi.Framework.Domain.Student.Entities;
|
||||
using Yi.Framework.Domain.Student.Repositories;
|
||||
|
||||
namespace Yi.Framework.Sqlsugar.Student
|
||||
{
|
||||
/// <summary>
|
||||
/// 仓储实现方式
|
||||
/// </summary>
|
||||
public class StudentRepository : SqlsugarRepository<StudentEntity>, IStudentRepository
|
||||
{
|
||||
public StudentRepository(ISqlSugarClient context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<StudentEntity>> GetMyListAsync()
|
||||
{
|
||||
return await _DbQueryable.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\framework\Yi.Framework.Core.Sqlsugar\Yi.Framework.Core.Sqlsugar.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Domain\Yi.Framework.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,30 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StartupModules;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Core.Sqlsugar;
|
||||
using Yi.Framework.Domain;
|
||||
using Yi.Framework.Domain.Student.Repositories;
|
||||
using Yi.Framework.Sqlsugar.Student;
|
||||
|
||||
namespace Yi.Framework.Sqlsugar
|
||||
{
|
||||
[DependsOn(typeof(YiFrameworkCoreSqlsugarModule),
|
||||
typeof(YiFrameworkDomainModule))]
|
||||
public class YiFrameworkSqlsugarModule : IStartupModule
|
||||
{
|
||||
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
||||
{
|
||||
}
|
||||
|
||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
||||
{
|
||||
services.AddTransient<IStudentRepository, StudentRepository>();
|
||||
}
|
||||
}
|
||||
}
|
||||
34
Yi.Framework.Net6/src/project/Yi.Framework.Web/Program.cs
Normal file
34
Yi.Framework.Net6/src/project/Yi.Framework.Web/Program.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using AspNetCore.Microsoft.AspNetCore.Hosting;
|
||||
using Yi.Framework.Core.Autofac.Extensions;
|
||||
using Yi.Framework.Core.Autofac.Modules;
|
||||
using Yi.Framework.Core.Extensions;
|
||||
using Yi.Framework.Web;
|
||||
|
||||
TimeTest.Start();
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>url
|
||||
builder.WebHost.UseStartUrlsServer(builder.Configuration);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
builder.UseYiModules(typeof(YiFrameworkWebModule));
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>autofacģ<63><C4A3>,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
builder.Host.ConfigureAutoFacContainer(container =>
|
||||
{
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, typeof(YiFrameworkWebModule).Assembly);
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
var t = app.Services.GetService<Test2Entity>();
|
||||
|
||||
//ȫ<>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
app.UseErrorHandlingServer();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"Yi.Framework.Web": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:19002",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using Yi.Framework.Core.DependencyInjection;
|
||||
|
||||
namespace Yi.Framework.Web
|
||||
{
|
||||
public class Test2Entity: ITransientDependency
|
||||
{
|
||||
[Autowired]
|
||||
public TestEntity testEntity { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Yi.Framework.Core.DependencyInjection;
|
||||
|
||||
namespace Yi.Framework.Web
|
||||
{
|
||||
public class TestEntity: ITransientDependency
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
26
Yi.Framework.Net6/src/project/Yi.Framework.Web/TimeTest.cs
Normal file
26
Yi.Framework.Net6/src/project/Yi.Framework.Web/TimeTest.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Yi.Framework.Web
|
||||
{
|
||||
public class TimeTest
|
||||
{
|
||||
public static Stopwatch Stopwatch { get; set; }
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
Stopwatch=new Stopwatch();
|
||||
Stopwatch.Start();
|
||||
}
|
||||
public static void Result()
|
||||
{
|
||||
|
||||
Stopwatch.Stop();
|
||||
string time = Stopwatch.ElapsedMilliseconds.ToString();
|
||||
Stopwatch.Restart();
|
||||
string res = $"{DateTime.Now.ToString("yyyy:MM:dd-HH:mm:ss")}本次运行启动时间为:{time}毫秒\r\n";
|
||||
Console.WriteLine(res);
|
||||
File.AppendAllText("./TimeTest.txt", res);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
77
Yi.Framework.Net6/src/project/Yi.Framework.Web/TimeTest.txt
Normal file
77
Yi.Framework.Net6/src/project/Yi.Framework.Web/TimeTest.txt
Normal file
@@ -0,0 +1,77 @@
|
||||
2023:01:16-22:36:40本次运行启动时间为:2089毫秒
|
||||
2023:01:16-22:36:49本次运行启动时间为:2021毫秒
|
||||
2023:01:16-22:37:01本次运行启动时间为:2072毫秒
|
||||
2023:01:16-22:39:23本次运行启动时间为:2075毫秒
|
||||
2023:01:16-22:40:48本次运行启动时间为:2172毫秒
|
||||
2023:01:16-22:41:12本次运行启动时间为:2142毫秒
|
||||
2023:01:16-22:42:05本次运行启动时间为:2008毫秒
|
||||
2023:01:16-22:43:22本次运行启动时间为:1910毫秒
|
||||
2023:01:16-22:44:33本次运行启动时间为:2017毫秒
|
||||
2023:01:17-17:30:46本次运行启动时间为:23171毫秒
|
||||
2023:01:17-17:45:11本次运行启动时间为:4771毫秒
|
||||
2023:01:17-17:45:54本次运行启动时间为:1917毫秒
|
||||
2023:01:17-17:48:04本次运行启动时间为:2138毫秒
|
||||
2023:01:17-17:57:41本次运行启动时间为:1907毫秒
|
||||
2023:01:17-17:58:29本次运行启动时间为:1895毫秒
|
||||
2023:01:17-17:58:43本次运行启动时间为:1937毫秒
|
||||
2023:01:17-17:59:38本次运行启动时间为:1856毫秒
|
||||
2023:01:17-21:06:57本次运行启动时间为:2285毫秒
|
||||
2023:01:17-21:09:32本次运行启动时间为:2007毫秒
|
||||
2023:01:17-21:10:16本次运行启动时间为:1862毫秒
|
||||
2023:01:17-21:12:25本次运行启动时间为:2055毫秒
|
||||
2023:01:17-21:13:46本次运行启动时间为:5606毫秒
|
||||
2023:01:17-21:14:35本次运行启动时间为:4824毫秒
|
||||
2023:01:17-21:18:17本次运行启动时间为:8985毫秒
|
||||
2023:01:17-21:19:48本次运行启动时间为:1859毫秒
|
||||
2023:01:17-21:21:32本次运行启动时间为:1786毫秒
|
||||
2023:01:17-22:41:17本次运行启动时间为:1901毫秒
|
||||
2023:01:17-22:42:21本次运行启动时间为:1946毫秒
|
||||
2023:01:17-22:42:55本次运行启动时间为:1970毫秒
|
||||
2023:01:17-22:43:56本次运行启动时间为:2023毫秒
|
||||
2023:01:17-22:45:25本次运行启动时间为:1803毫秒
|
||||
2023:01:17-22:45:52本次运行启动时间为:1877毫秒
|
||||
2023:01:17-23:24:07本次运行启动时间为:1836毫秒
|
||||
2023:01:17-23:29:20本次运行启动时间为:1958毫秒
|
||||
2023:01:17-23:45:25本次运行启动时间为:2016毫秒
|
||||
2023:01:18-19:34:47本次运行启动时间为:2631毫秒
|
||||
2023:01:18-19:36:58本次运行启动时间为:2551毫秒
|
||||
2023:01:18-19:40:12本次运行启动时间为:1978毫秒
|
||||
2023:01:19-13:52:51本次运行启动时间为:2600毫秒
|
||||
2023:01:19-13:54:09本次运行启动时间为:2180毫秒
|
||||
2023:01:19-13:54:43本次运行启动时间为:2122毫秒
|
||||
2023:01:19-13:55:58本次运行启动时间为:2355毫秒
|
||||
2023:01:19-14:03:10本次运行启动时间为:2144毫秒
|
||||
2023:01:19-14:08:44本次运行启动时间为:2279毫秒
|
||||
2023:01:19-14:13:40本次运行启动时间为:2188毫秒
|
||||
2023:01:19-14:28:11本次运行启动时间为:2207毫秒
|
||||
2023:01:19-14:31:37本次运行启动时间为:2216毫秒
|
||||
2023:01:19-14:35:15本次运行启动时间为:2428毫秒
|
||||
2023:01:19-14:38:41本次运行启动时间为:2141毫秒
|
||||
2023:01:19-14:40:57本次运行启动时间为:2220毫秒
|
||||
2023:01:19-14:47:12本次运行启动时间为:2234毫秒
|
||||
2023:01:19-14:49:25本次运行启动时间为:2202毫秒
|
||||
2023:01:19-14:51:18本次运行启动时间为:2175毫秒
|
||||
2023:01:19-14:53:52本次运行启动时间为:2250毫秒
|
||||
2023:01:19-14:54:38本次运行启动时间为:2145毫秒
|
||||
2023:01:19-14:55:21本次运行启动时间为:2123毫秒
|
||||
2023:01:19-15:20:38本次运行启动时间为:2486毫秒
|
||||
2023:01:19-15:22:37本次运行启动时间为:2251毫秒
|
||||
2023:01:19-15:26:31本次运行启动时间为:2182毫秒
|
||||
2023:01:19-15:28:47本次运行启动时间为:2187毫秒
|
||||
2023:01:19-15:29:07本次运行启动时间为:2163毫秒
|
||||
2023:01:19-15:29:57本次运行启动时间为:2307毫秒
|
||||
2023:01:19-15:35:21本次运行启动时间为:3172毫秒
|
||||
2023:01:19-17:47:34本次运行启动时间为:2598毫秒
|
||||
2023:01:19-17:52:49本次运行启动时间为:1940毫秒
|
||||
2023:01:19-17:54:41本次运行启动时间为:1861毫秒
|
||||
2023:01:19-17:57:37本次运行启动时间为:1945毫秒
|
||||
2023:01:20-18:25:59本次运行启动时间为:43382毫秒
|
||||
2023:01:20-18:29:09本次运行启动时间为:2173毫秒
|
||||
2023:01:20-18:32:14本次运行启动时间为:2397毫秒
|
||||
2023:01:20-18:34:14本次运行启动时间为:2126毫秒
|
||||
2023:01:20-18:38:36本次运行启动时间为:2152毫秒
|
||||
2023:01:20-18:45:15本次运行启动时间为:7203毫秒
|
||||
2023:01:20-18:50:46本次运行启动时间为:6513毫秒
|
||||
2023:01:20-18:53:16本次运行启动时间为:5186毫秒
|
||||
2023:01:20-19:01:36本次运行启动时间为:5194毫秒
|
||||
2023:01:21-15:04:00本次运行启动时间为:7763毫秒
|
||||
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\framework\Yi.Framework.Core.Autofac\Yi.Framework.Core.Autofac.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Application\Yi.Framework.Application.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Sqlsugar\Yi.Framework.Sqlsugar.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="key.pem">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="public.pem">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,46 @@
|
||||
using AspNetCore.Microsoft.AspNetCore.Builder;
|
||||
using StartupModules;
|
||||
using Yi.Framework.Application;
|
||||
using Yi.Framework.Auth.JwtBearer;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Sqlsugar;
|
||||
|
||||
namespace Yi.Framework.Web
|
||||
{
|
||||
[DependsOn(
|
||||
typeof(YiFrameworkSqlsugarModule),
|
||||
typeof(YiFrameworkApplicationModule)
|
||||
)]
|
||||
public class YiFrameworkWebModule : IStartupModule
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
||||
{
|
||||
//添加控制器与动态api
|
||||
services.AddControllers();
|
||||
services.AddAutoApiService(opt =>
|
||||
{
|
||||
//NETServiceTest所在程序集添加进动态api配置
|
||||
opt.CreateConventional(typeof(YiFrameworkApplicationModule).Assembly, option => option.RootPath = string.Empty);
|
||||
});
|
||||
|
||||
//添加swagger
|
||||
services.AddSwaggerServer<YiFrameworkApplicationModule>();
|
||||
}
|
||||
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
||||
{
|
||||
//if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwaggerServer();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseRouting();
|
||||
TimeTest.Result();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
|
||||
//程序启动地址,*代表全部网口
|
||||
"StartUrl": "http://*:19002",
|
||||
|
||||
//数据库类型列表
|
||||
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
|
||||
|
||||
"DbConnOptions": {
|
||||
"Url": "DataSource=yi-sqlsugar-dev.db",
|
||||
"DbType": "Sqlite",
|
||||
"EnabledDbSeed": false,
|
||||
"EnabledReadWrite": false,
|
||||
"EnabledCodeFirst": false,
|
||||
"EntityAssembly": null,
|
||||
"ReadUrl": [
|
||||
"DataSource=[xxxx]", //sqlite
|
||||
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]", //mysql
|
||||
"Data Source=[xxxx];Initial Catalog=[xxxx];User ID=[xxxx];password=[xxxx]" //sqlserver
|
||||
]
|
||||
},
|
||||
|
||||
"JwtTokenOptions": {
|
||||
"Audience": "yi",
|
||||
"Issuer": "localhost:19002",
|
||||
"Subject": "yiframwork",
|
||||
"ExpSecond": 3600
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
28
Yi.Framework.Net6/src/project/Yi.Framework.Web/key.pem
Normal file
28
Yi.Framework.Net6/src/project/Yi.Framework.Web/key.pem
Normal file
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC7VJTUt9Us8cKj
|
||||
MzEfYyjiWA4R4/M2bS1GB4t7NXp98C3SC6dVMvDuictGeurT8jNbvJZHtCSuYEvu
|
||||
NMoSfm76oqFvAp8Gy0iz5sxjZmSnXyCdPEovGhLa0VzMaQ8s+CLOyS56YyCFGeJZ
|
||||
qgtzJ6GR3eqoYSW9b9UMvkBpZODSctWSNGj3P7jRFDO5VoTwCQAWbFnOjDfH5Ulg
|
||||
p2PKSQnSJP3AJLQNFNe7br1XbrhV//eO+t51mIpGSDCUv3E0DDFcWDTH9cXDTTlR
|
||||
ZVEiR2BwpZOOkE/Z0/BVnhZYL71oZV34bKfWjQIt6V/isSMahdsAASACp4ZTGtwi
|
||||
VuNd9tybAgMBAAECggEBAKTmjaS6tkK8BlPXClTQ2vpz/N6uxDeS35mXpqasqskV
|
||||
laAidgg/sWqpjXDbXr93otIMLlWsM+X0CqMDgSXKejLS2jx4GDjI1ZTXg++0AMJ8
|
||||
sJ74pWzVDOfmCEQ/7wXs3+cbnXhKriO8Z036q92Qc1+N87SI38nkGa0ABH9CN83H
|
||||
mQqt4fB7UdHzuIRe/me2PGhIq5ZBzj6h3BpoPGzEP+x3l9YmK8t/1cN0pqI+dQwY
|
||||
dgfGjackLu/2qH80MCF7IyQaseZUOJyKrCLtSD/Iixv/hzDEUPfOCjFDgTpzf3cw
|
||||
ta8+oE4wHCo1iI1/4TlPkwmXx4qSXtmw4aQPz7IDQvECgYEA8KNThCO2gsC2I9PQ
|
||||
DM/8Cw0O983WCDY+oi+7JPiNAJwv5DYBqEZB1QYdj06YD16XlC/HAZMsMku1na2T
|
||||
N0driwenQQWzoev3g2S7gRDoS/FCJSI3jJ+kjgtaA7Qmzlgk1TxODN+G1H91HW7t
|
||||
0l7VnL27IWyYo2qRRK3jzxqUiPUCgYEAx0oQs2reBQGMVZnApD1jeq7n4MvNLcPv
|
||||
t8b/eU9iUv6Y4Mj0Suo/AU8lYZXm8ubbqAlwz2VSVunD2tOplHyMUrtCtObAfVDU
|
||||
AhCndKaA9gApgfb3xw1IKbuQ1u4IF1FJl3VtumfQn//LiH1B3rXhcdyo3/vIttEk
|
||||
48RakUKClU8CgYEAzV7W3COOlDDcQd935DdtKBFRAPRPAlspQUnzMi5eSHMD/ISL
|
||||
DY5IiQHbIH83D4bvXq0X7qQoSBSNP7Dvv3HYuqMhf0DaegrlBuJllFVVq9qPVRnK
|
||||
xt1Il2HgxOBvbhOT+9in1BzA+YJ99UzC85O0Qz06A+CmtHEy4aZ2kj5hHjECgYEA
|
||||
mNS4+A8Fkss8Js1RieK2LniBxMgmYml3pfVLKGnzmng7H2+cwPLhPIzIuwytXywh
|
||||
2bzbsYEfYx3EoEVgMEpPhoarQnYPukrJO4gwE2o5Te6T5mJSZGlQJQj9q4ZB2Dfz
|
||||
et6INsK0oG8XVGXSpQvQh3RUYekCZQkBBFcpqWpbIEsCgYAnM3DQf3FJoSnXaMhr
|
||||
VBIovic5l0xFkEHskAjFTevO86Fsz1C2aSeRKSqGFoOQ0tmJzBEs1R6KqnHInicD
|
||||
TQrKhArgLXX4v3CddjfTRJkFWDbE/CkvKZNOrcf1nhaGCPspRJj2KUkj1Fhl9Cnc
|
||||
dn/RsYEONbwQSjIfMPkvxF+8HQ==
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -0,0 +1,9 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu1SU1LfVLPHCozMxH2Mo
|
||||
4lgOEePzNm0tRgeLezV6ffAt0gunVTLw7onLRnrq0/IzW7yWR7QkrmBL7jTKEn5u
|
||||
+qKhbwKfBstIs+bMY2Zkp18gnTxKLxoS2tFczGkPLPgizskuemMghRniWaoLcyeh
|
||||
kd3qqGElvW/VDL5AaWTg0nLVkjRo9z+40RQzuVaE8AkAFmxZzow3x+VJYKdjykkJ
|
||||
0iT9wCS0DRTXu269V264Vf/3jvredZiKRkgwlL9xNAwxXFg0x/XFw005UWVRIkdg
|
||||
cKWTjpBP2dPwVZ4WWC+9aGVd+Gyn1o0CLelf4rEjGoXbAAEgAqeGUxrcIlbjXfbc
|
||||
mwIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
Binary file not shown.
Reference in New Issue
Block a user