diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1ff0c423..00000000 --- a/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/WebFirst/database/sqlite.db b/WebFirst/database/sqlite.db deleted file mode 100644 index eec321e3..00000000 Binary files a/WebFirst/database/sqlite.db and /dev/null differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml index 7842f01f..3e639770 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml @@ -181,6 +181,40 @@ + + + 分页查 + + + + + + 单查 + + + + + + 增 + + + + + + + 更 + + + + + + + + 删 + + + + 账户管理 diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ERP/SupplierController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ERP/SupplierController.cs new file mode 100644 index 00000000..1a10baf5 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ERP/SupplierController.cs @@ -0,0 +1,81 @@ +using Microsoft.AspNetCore.Mvc; +using Yi.Framework.Common.Models; +using Yi.Framework.DtoModel.ERP.Supplier; +using Yi.Framework.Interface.ERP; + +namespace Yi.Framework.ApiMicroservice.Controllers.ERP +{ + [ApiController] + [Route("api/[controller]/[action]")] + public class SupplierController : ControllerBase + { + private readonly ILogger _logger; + private readonly ISupplierService _supplierService; + public SupplierController(ILogger logger, ISupplierService supplierService) + { + _logger = logger; + _supplierService = supplierService; + } + + /// + /// 分页查 + /// + /// + [HttpGet] + public async Task PageList([FromQuery] SupplierCreateUpdateInput input, [FromQuery] PageParModel page) + { + var result = await _supplierService.PageListAsync(input, page); + return Result.Success().SetData(result); + } + + /// + /// 单查 + /// + /// + [HttpGet] + [Route("{id}")] + public async Task GetById(long id) + { + var result = await _supplierService.GetByIdAsync(id); + return Result.Success().SetData(result); + } + + /// + /// 增 + /// + /// + /// + [HttpPost] + public async Task Create(SupplierCreateUpdateInput input) + { + var result = await _supplierService.CreateAsync(input); + return Result.Success().SetData(result); + } + + /// + /// 更 + /// + /// + /// + /// + [HttpPut] + [Route("{id}")] + public async Task Update(long id, SupplierCreateUpdateInput input) + { + var result = await _supplierService.UpdateAsync(id, input); + return Result.Success().SetData(result); + } + + /// + /// 删 + /// + /// + /// + [HttpDelete] + public async Task Del(List ids) + { + await _supplierService.DeleteAsync(ids); + return Result.Success(); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/StudentController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/StudentController.cs index 6417b387..b436afe9 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/StudentController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/StudentController.cs @@ -1,10 +1,9 @@ - using Microsoft.AspNetCore.Mvc; using Yi.Framework.Common.Models; using Yi.Framework.DtoModel.RABC.Student; using Yi.Framework.Interface.RABC; -namespace Brick.IFServer.Controllers +namespace Yi.Framework.ApiMicroservice.Controllers.ERP { [ApiController] [Route("[controller]")] diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index ccd667bb..41e9f4b6 100644 Binary files a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db differ diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/FileHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/FileHelper.cs index 4e13d382..7ae1c0c4 100644 --- a/Yi.Framework.Net6/Yi.Framework.Common/Helper/FileHelper.cs +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/FileHelper.cs @@ -407,6 +407,84 @@ namespace Yi.Framework.Common.Helper return folder.Select(x => x.Name).ToList(); } + /// + /// 文件内容替换 + /// + public static string FileContentReplace(string path, string oldStr, string newStr) + { + var content = File.ReadAllText(path); + if (content.Contains(oldStr)) + { + File.Delete(path); + File.WriteAllText(path, content.Replace(oldStr, newStr)); + } + + return path; + } + /// + /// 文件名称 + /// + public static string FileNameReplace(string path, string oldStr, string newStr) + { + string fileName = Path.GetFileName(path); + if (!fileName.Contains(oldStr)) + { + return path; + } + + string? directoryName = Path.GetDirectoryName(path); + string newFileName = fileName.Replace(oldStr, newStr); + string newPath = Path.Combine(directoryName ?? "", newFileName); + File.Move(path, newPath); + + return newPath; + } + /// + /// 目录名替换 + /// + public static string DirectoryNameReplace(string path, string oldStr, string newStr) + { + string fileName = Path.GetFileName(path); + if (!fileName.Contains(oldStr)) + { + return path; + } + + string? directoryName = Path.GetDirectoryName(path); + string newFileName = fileName.Replace(oldStr, newStr); + string newPath = Path.Combine(directoryName ?? "", newFileName); + Directory.Move(path, newPath); + return newPath; + } + + /// + /// 全部信息递归替换 + /// + /// + /// + /// + public static void AllInfoReplace(string dirPath, string oldStr, string newStr) + { + var path = DirectoryNameReplace(dirPath, oldStr, newStr); + var dirInfo = new DirectoryInfo(path); + var files = dirInfo.GetFiles(); + var dirs = dirInfo.GetDirectories(); + if (files.Length > 0) + { + foreach (var f in files) + { + FileContentReplace(f.FullName, oldStr, newStr); + FileNameReplace(f.FullName, oldStr, newStr); + } + } + if (dirs.Length > 0) + { + foreach (var d in dirs) + { + AllInfoReplace(d.FullName, oldStr, newStr); + } + } + } } } diff --git a/Yi.Framework.Net6/Yi.Framework.DtoModel/ERP/Supplier/ConstConfig/SupplierConst.cs b/Yi.Framework.Net6/Yi.Framework.DtoModel/ERP/Supplier/ConstConfig/SupplierConst.cs new file mode 100644 index 00000000..a923042a --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DtoModel/ERP/Supplier/ConstConfig/SupplierConst.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.DtoModel.ERP.Supplier.ConstConfig +{ + public class SupplierConst + { + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DtoModel/ERP/Supplier/MapperConfig/SupplierProfile.cs b/Yi.Framework.Net6/Yi.Framework.DtoModel/ERP/Supplier/MapperConfig/SupplierProfile.cs new file mode 100644 index 00000000..decb6804 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DtoModel/ERP/Supplier/MapperConfig/SupplierProfile.cs @@ -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.ERP.Entitys; + +namespace Yi.Framework.DtoModel.ERP.Supplier.MapperConfig +{ + public class SupplierProfile:Profile + { + public SupplierProfile() + { + CreateMap(); + CreateMap(); + + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DtoModel/ERP/Supplier/SupplierCreateUpdateInput.cs b/Yi.Framework.Net6/Yi.Framework.DtoModel/ERP/Supplier/SupplierCreateUpdateInput.cs new file mode 100644 index 00000000..abbac95e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DtoModel/ERP/Supplier/SupplierCreateUpdateInput.cs @@ -0,0 +1,41 @@ +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.ERP.Supplier +{ + public class SupplierCreateUpdateInput : EntityDto + { + /// + /// 供应商编码 + /// + public string Code { get; set; } + + /// + /// 供应商名称 + /// + public string Name { get; set; } + + /// + /// 供应商地址 + /// + public string Address { get; set; } + + /// + /// 电话 + /// + public long Phone { get; set; } + /// + /// 传真 + /// + public string Fax { get; set; } + /// + /// 邮箱 + /// + public string Email { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DtoModel/ERP/Supplier/SupplierGetListOutput.cs b/Yi.Framework.Net6/Yi.Framework.DtoModel/ERP/Supplier/SupplierGetListOutput.cs new file mode 100644 index 00000000..7513c005 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DtoModel/ERP/Supplier/SupplierGetListOutput.cs @@ -0,0 +1,40 @@ +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.ERP.Supplier +{ + public class SupplierGetListOutput: EntityDto + { + /// + /// 供应商编码 + /// + public string Code { get; set; } + + /// + /// 供应商名称 + /// + public string Name { get; set; } + + /// + /// 供应商地址 + /// + public string Address { get; set; } + + /// + /// 电话 + /// + public long Phone { get; set; } + /// + /// 传真 + /// + public string Fax { get; set; } + /// + /// 邮箱 + /// + public string Email { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/ERP/ISupplierService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/ERP/ISupplierService.cs new file mode 100644 index 00000000..a9a62ebd --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/ERP/ISupplierService.cs @@ -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.ERP.Supplier; +using Yi.Framework.Interface.Base.Crud; + +namespace Yi.Framework.Interface.ERP +{ + public interface ISupplierService : ICrudAppService + { + Task>> PageListAsync(SupplierCreateUpdateInput input, PageParModel page); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/RABC/SeedData/DictionaryInfoSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/RABC/SeedData/DictionaryInfoSeed.cs index 330cd05b..3cd320f2 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/RABC/SeedData/DictionaryInfoSeed.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/RABC/SeedData/DictionaryInfoSeed.cs @@ -54,7 +54,7 @@ namespace Yi.Framework.Model.RABC.SeedData { Id = SnowFlakeSingle.Instance.NextId(), DictLabel = "显示", - DictValue = "0", + DictValue = "true", DictType = "sys_show_hide", OrderNum = 100, Remark = "显示菜单", @@ -66,7 +66,7 @@ namespace Yi.Framework.Model.RABC.SeedData { Id = SnowFlakeSingle.Instance.NextId(), DictLabel = "隐藏", - DictValue = "1", + DictValue = "false", DictType = "sys_show_hide", OrderNum = 99, Remark = "隐藏菜单", diff --git a/Yi.Framework.Net6/Yi.Framework.Repository/Yi.Framework.Repository.csproj b/Yi.Framework.Net6/Yi.Framework.Repository/Yi.Framework.Repository.csproj index 239ac7ef..4ba9aaad 100644 --- a/Yi.Framework.Net6/Yi.Framework.Repository/Yi.Framework.Repository.csproj +++ b/Yi.Framework.Net6/Yi.Framework.Repository/Yi.Framework.Repository.csproj @@ -6,10 +6,6 @@ disable - - - - diff --git a/Yi.Framework.Net6/Yi.Framework.Service/Base/Crud/AbstractKeyCrudAppService.cs b/Yi.Framework.Net6/Yi.Framework.Service/Base/Crud/AbstractKeyCrudAppService.cs index 00f1585d..f31d825e 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/Base/Crud/AbstractKeyCrudAppService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/Base/Crud/AbstractKeyCrudAppService.cs @@ -68,7 +68,8 @@ namespace Yi.Framework.Service.Base.Crud TryToSetTenantId(entity); - await Repository.InsertAsync(entity); + //这边需要进行判断,实体是什么guid还是雪花id + await Repository.InsertReturnSnowflakeIdAsync(entity); var entitydto = await MapToGetOutputDtoAsync(entity); return entitydto; @@ -80,7 +81,7 @@ namespace Yi.Framework.Service.Base.Crud /// /// /// - public virtual Task DeleteAsync(IEnumerable ids) + public virtual Task DeleteAsync(IEnumerable ids) { throw new NotImplementedException(); } @@ -110,7 +111,7 @@ namespace Yi.Framework.Service.Base.Crud /// /// /// - protected virtual Task UpdateValidAsync(TEntity idEntity, TUpdateInput dto) + protected virtual Task UpdateValidAsync(TEntity idEntity, TUpdateInput dto) { return Task.CompletedTask; } diff --git a/Yi.Framework.Net6/Yi.Framework.Service/ERP/SupplierService.cs b/Yi.Framework.Net6/Yi.Framework.Service/ERP/SupplierService.cs new file mode 100644 index 00000000..1f9cd40e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/ERP/SupplierService.cs @@ -0,0 +1,32 @@ +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.ERP.Supplier; +using Yi.Framework.Interface.ERP; +using Yi.Framework.Model.ERP.Entitys; +using Yi.Framework.Repository; +using Yi.Framework.Service.Base.Crud; + +namespace Yi.Framework.Service.ERP +{ + public class SupplierService : CrudAppService, ISupplierService + { + public SupplierService(IRepository repository, IMapper mapper) : base(repository, mapper) + { + } + public async Task>> PageListAsync(SupplierCreateUpdateInput input, PageParModel page) + { + RefAsync 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> { Total = totalNumber.Value, Data = await MapToGetListOutputDtosAsync(data) }; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Abstract/AbstractTemplateProvider.cs b/Yi.Framework.Net6/Yi.Framework.Template/Abstract/AbstractTemplateProvider.cs new file mode 100644 index 00000000..cf35c614 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Abstract/AbstractTemplateProvider.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Template.Abstract +{ + public abstract class AbstractTemplateProvider : ITemplateProvider + { + public virtual string? BuildPath { get; set; } + public string? TemplatePath { get; set; } + public string? BakPath { get; set; } + protected Dictionary TemplateDic { get; set; } = new Dictionary(); + + 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); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Abstract/ITemplateProvider.cs b/Yi.Framework.Net6/Yi.Framework.Template/Abstract/ITemplateProvider.cs new file mode 100644 index 00000000..5ac81801 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Abstract/ITemplateProvider.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Template.Abstract +{ + public interface ITemplateProvider + { + /// + /// 构建生成路径 + /// + string? BuildPath { get; set; } + + /// + /// 模板文件路径 + /// + string? TemplatePath { get; set; } + + /// + /// 备份文件路径 + /// + string? BakPath { get; set; } + + + /// + /// 开始构建 + /// + /// + void Build(); + + /// + /// 生成备份 + /// + /// + void Bak(); + + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Abstract/ModelTemplateProvider.cs b/Yi.Framework.Net6/Yi.Framework.Template/Abstract/ModelTemplateProvider.cs new file mode 100644 index 00000000..a6f3ef05 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Abstract/ModelTemplateProvider.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Template.Const; + +namespace Yi.Framework.Template.Abstract +{ + public abstract class ModelTemplateProvider : ProgramTemplateProvider + { + + public ModelTemplateProvider(string modelName, string entityName) : base(modelName, entityName) + { + AddIgnoreEntityField("Id", "TenantId"); + } + + private string entityPath; + + /// + /// 实体路径,该类生成需要实体与模板两个同时构建成 + /// + public string EntityPath + { + get => this.entityPath; + set + { + value = value!.Replace(TemplateConst.EntityName, EntityName); + value = value.Replace(TemplateConst.ModelName, ModelName); + this.entityPath = value; + } + } + + + /// + /// 生成模板忽略实体字段 + /// + private List 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; + } + } + } + + //拼接实体字段 + 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); + } + + /// + /// 获取实体信息 + /// + /// + /// + 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); + } + + /// + /// 添加忽略实体字段 + /// + /// + public void AddIgnoreEntityField(params string[] field) + { + IgnoreEntityFields.AddRange(field); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Abstract/ProgramTemplateProvider.cs b/Yi.Framework.Net6/Yi.Framework.Template/Abstract/ProgramTemplateProvider.cs new file mode 100644 index 00000000..8cad5e9a --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Abstract/ProgramTemplateProvider.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Template.Const; + +namespace Yi.Framework.Template.Abstract +{ + + 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()); + } + /// + /// 实体名称 + /// + public string EntityName { get; set; } + /// + /// 模块名称 + /// + public string ModelName { get; set; } + + /// + /// 重写构建路径,替换实体名称与模块名称 + /// + 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(); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Const/TemplateConst.cs b/Yi.Framework.Net6/Yi.Framework.Template/Const/TemplateConst.cs new file mode 100644 index 00000000..5dc0ea9e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Const/TemplateConst.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Template.Const +{ + public class TemplateConst + { + /// + /// 模块名称大写 + /// + public const string ModelName = "#ModelName#"; + + /// + /// 模块名称小写 + /// + public const string LowerModelName = "#LowerModelName#"; + + /// + /// 实体名称大驼峰 + /// + public const string EntityName = "#EntityName#"; + + /// + /// 实体名称小驼峰 + /// + public const string LowerEntityName = "#LowerEntityName#"; + + /// + /// 实体字段 + /// + public const string EntityField = "#EntityField#"; + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Program.cs b/Yi.Framework.Net6/Yi.Framework.Template/Program.cs new file mode 100644 index 00000000..0961099d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Program.cs @@ -0,0 +1,31 @@ +using Yi.Framework.Template; +using Yi.Framework.Template.Provider.Server; +using Yi.Framework.Template.Provider.Site; + +TemplateFactory templateFactory = new(); + +//选择需要生成的模板提供者 + +string modelName = "ERP"; +List entityNames =new (){ "Supplier", "Purchase", "PurchaseDetails" }; + +foreach (var entityName in entityNames) +{ + templateFactory.CreateTemplateProviders((option) => + { + option.Add(new ServceTemplateProvider(modelName, entityName)); + option.Add(new IServceTemplateProvider(modelName, entityName)); + option.Add(new CreateUpdateInputTemplateProvider(modelName, entityName)); + option.Add(new GetListOutputTemplateProvider(modelName, entityName)); + option.Add(new ConstTemplateProvider(modelName, entityName)); + option.Add(new ProfileTemplateProvider(modelName, entityName)); + option.Add(new ControllerTemplateProvider(modelName, entityName)); + option.Add(new ApiTemplateProvider(modelName, entityName)); + }); + //开始构建模板 + templateFactory.BuildTemplate(); + Console.WriteLine($"Yi.Framework.Template:{entityName}构建完成!"); +} + +Console.WriteLine("Yi.Framework.Template:模板全部生成完成!"); +Console.ReadKey(); \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/ConstTemplateProvider.cs b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/ConstTemplateProvider.cs new file mode 100644 index 00000000..8cbed5bd --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/ConstTemplateProvider.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.Abstract; +using Yi.Framework.Template.Const; + +namespace Yi.Framework.Template.Provider.Server +{ + internal class ConstTemplateProvider : ProgramTemplateProvider + { + public ConstTemplateProvider(string modelName, string entityName) : base(modelName, entityName) + { + BuildPath = $@"..\..\..\Code_Server\Yi.Framework.DtoModel\{TemplateConst.ModelName}\{TemplateConst.EntityName}\ConstConfig\{TemplateConst.EntityName}Const.cs"; + TemplatePath = $@"..\..\..\Template\Server\ConstTemplate.txt"; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/ControllerTemplateProvider.cs b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/ControllerTemplateProvider.cs new file mode 100644 index 00000000..1ed12e25 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/ControllerTemplateProvider.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.Abstract; +using Yi.Framework.Template.Const; + +namespace Yi.Framework.Template.Provider.Server +{ + public class ControllerTemplateProvider : ProgramTemplateProvider + { + public ControllerTemplateProvider(string modelName, string entityName) : base(modelName, entityName) + { + BuildPath = $@"..\..\..\Code_Server\Yi.Framework.ApiMicroservice\Controllers\{TemplateConst.ModelName}\{TemplateConst.EntityName}Controller.cs"; + TemplatePath = $@"..\..\..\Template\Server\ControllerTemplate.txt"; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/CreateUpdateInputTemplateProvider.cs b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/CreateUpdateInputTemplateProvider.cs new file mode 100644 index 00000000..b808d7ef --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/CreateUpdateInputTemplateProvider.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.Abstract; +using Yi.Framework.Template.Const; + +namespace Yi.Framework.Template.Provider.Server +{ + public class CreateUpdateInputTemplateProvider : ModelTemplateProvider + { + public CreateUpdateInputTemplateProvider(string modelName, string entityName) : base(modelName, entityName) + { + BuildPath = $@"..\..\..\Code_Server\Yi.Framework.DtoModel\{TemplateConst.ModelName}\{TemplateConst.EntityName}\{TemplateConst.EntityName}CreateUpdateInput.cs"; + TemplatePath = $@"..\..\..\Template\Server\CreateUpdateInputTemplate.txt"; + EntityPath = $@"..\..\..\..\Yi.Framework.Model\{TemplateConst.ModelName}\Entitys\{TemplateConst.EntityName}Entity.cs"; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/GetListOutputTemplateProvider.cs b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/GetListOutputTemplateProvider.cs new file mode 100644 index 00000000..fa6df140 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/GetListOutputTemplateProvider.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.Abstract; +using Yi.Framework.Template.Const; + +namespace Yi.Framework.Template.Provider.Server +{ + public class GetListOutputTemplateProvider : ModelTemplateProvider + { + public GetListOutputTemplateProvider(string modelName, string entityName) : base(modelName, entityName) + { + BuildPath = $@"..\..\..\Code_Server\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"; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/IServceTemplateProvider.cs b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/IServceTemplateProvider.cs new file mode 100644 index 00000000..fa53c8c6 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/IServceTemplateProvider.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.Abstract; +using Yi.Framework.Template.Const; + +namespace Yi.Framework.Template.Provider.Server +{ + public class IServceTemplateProvider : ProgramTemplateProvider + { + public IServceTemplateProvider(string modelName, string entityName) : base(modelName, entityName) + { + BuildPath = $@"..\..\..\Code_Server\Yi.Framework.Interface\{TemplateConst.ModelName}\I{TemplateConst.EntityName}Service.cs"; + TemplatePath = $@"..\..\..\Template\Server\IServiceTemplate.txt"; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/ProfileTemplateProvider.cs b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/ProfileTemplateProvider.cs new file mode 100644 index 00000000..5211c537 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/ProfileTemplateProvider.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.Abstract; +using Yi.Framework.Template.Const; + +namespace Yi.Framework.Template.Provider.Server +{ + public class ProfileTemplateProvider : ProgramTemplateProvider + { + public ProfileTemplateProvider(string modelName, string entityName) : base(modelName, entityName) + { + BuildPath = $@"..\..\..\Code_Server\Yi.Framework.DtoModel\{TemplateConst.ModelName}\{TemplateConst.EntityName}\MapperConfig\{TemplateConst.EntityName}Profile.cs"; + TemplatePath = $@"..\..\..\Template\Server\ProfileTemplate.txt"; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/ServceTemplateProvider.cs b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/ServceTemplateProvider.cs new file mode 100644 index 00000000..79a0695b --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Server/ServceTemplateProvider.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.Abstract; +using Yi.Framework.Template.Const; + +namespace Yi.Framework.Template.Provider.Server +{ + public class ServceTemplateProvider : ProgramTemplateProvider + { + public ServceTemplateProvider(string modelName, string entityName) : base(modelName, entityName) + { + BuildPath = $@"..\..\..\Code_Server\Yi.Framework.Service\{TemplateConst.ModelName}\{TemplateConst.EntityName}Service.cs"; + TemplatePath = $@"..\..\..\Template\Server\ServiceTemplate.txt"; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Provider/Site/ApiTemplateProvider.cs b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Site/ApiTemplateProvider.cs new file mode 100644 index 00000000..8f3afb2e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Provider/Site/ApiTemplateProvider.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.Abstract; +using Yi.Framework.Template.Const; + +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.ModelName}\{TemplateConst.LowerEntityName}Api.js"; + TemplatePath = $@"..\..\..\Template\Site\ApiTemplate.txt"; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/ConstTemplate.txt b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/ConstTemplate.txt new file mode 100644 index 00000000..4c589964 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/ConstTemplate.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 + { + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/ControllerTemplate.txt b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/ControllerTemplate.txt new file mode 100644 index 00000000..2951131e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/ControllerTemplate.txt @@ -0,0 +1,81 @@ +using Microsoft.AspNetCore.Mvc; +using Yi.Framework.Common.Models; +using Yi.Framework.DtoModel.#ModelName#.#EntityName#; +using Yi.Framework.Interface.#ModelName#; + +namespace Yi.Framework.ApiMicroservice.Controllers.#ModelName# +{ + [ApiController] + [Route("api/[controller]/[action]")] + public class #EntityName#Controller : ControllerBase + { + private readonly ILogger<#EntityName#Controller> _logger; + private readonly I#EntityName#Service _#LowerEntityName#Service; + public #EntityName#Controller(ILogger<#EntityName#Controller> logger, I#EntityName#Service #LowerEntityName#Service) + { + _logger = logger; + _#LowerEntityName#Service = #LowerEntityName#Service; + } + + /// + /// 分页查 + /// + /// + [HttpGet] + public async Task PageList([FromQuery] #EntityName#CreateUpdateInput input, [FromQuery] PageParModel page) + { + var result = await _#LowerEntityName#Service.PageListAsync(input, page); + return Result.Success().SetData(result); + } + + /// + /// 单查 + /// + /// + [HttpGet] + [Route("{id}")] + public async Task GetById(long id) + { + var result = await _#LowerEntityName#Service.GetByIdAsync(id); + return Result.Success().SetData(result); + } + + /// + /// 增 + /// + /// + /// + [HttpPost] + public async Task Create(#EntityName#CreateUpdateInput input) + { + var result = await _#LowerEntityName#Service.CreateAsync(input); + return Result.Success().SetData(result); + } + + /// + /// 更 + /// + /// + /// + /// + [HttpPut] + [Route("{id}")] + public async Task Update(long id, #EntityName#CreateUpdateInput input) + { + var result = await _#LowerEntityName#Service.UpdateAsync(id, input); + return Result.Success().SetData(result); + } + + /// + /// 删 + /// + /// + /// + [HttpDelete] + public async Task Del(List ids) + { + await _#LowerEntityName#Service.DeleteAsync(ids); + return Result.Success(); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/CreateUpdateInputTemplate.txt b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/CreateUpdateInputTemplate.txt new file mode 100644 index 00000000..de35e69a --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/CreateUpdateInputTemplate.txt @@ -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 + { +#EntityField# + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/GetListOutputTemplate.txt b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/GetListOutputTemplate.txt new file mode 100644 index 00000000..52e3c644 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/GetListOutputTemplate.txt @@ -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 + { +#EntityField# + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/IServiceTemplate.txt b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/IServiceTemplate.txt new file mode 100644 index 00000000..b1f20b7a --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/IServiceTemplate.txt @@ -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>> PageListAsync(#EntityName#CreateUpdateInput input, PageParModel page); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/ProfileTemplate.txt b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/ProfileTemplate.txt new file mode 100644 index 00000000..f545b835 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/ProfileTemplate.txt @@ -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>(); + + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/ServiceTemplate.txt b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/ServiceTemplate.txt new file mode 100644 index 00000000..fec61106 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/Template/Server/ServiceTemplate.txt @@ -0,0 +1,32 @@ +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 #EntityName#Service(IRepository<#EntityName#Entity> repository, IMapper mapper) : base(repository, mapper) + { + } + public async Task>> PageListAsync(#EntityName#CreateUpdateInput input, PageParModel page) + { + RefAsync 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> { Total = totalNumber.Value, Data = await MapToGetListOutputDtosAsync(data) }; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/vue3-ruoyi/api.tt b/Yi.Framework.Net6/Yi.Framework.Template/Template/Site/ApiTemplate.txt similarity index 51% rename from Yi.Framework.Net6/Yi.Framework.Template/vue3-ruoyi/api.tt rename to Yi.Framework.Net6/Yi.Framework.Template/Template/Site/ApiTemplate.txt index a32440e8..dc12e694 100644 --- a/Yi.Framework.Net6/Yi.Framework.Template/vue3-ruoyi/api.tt +++ b/Yi.Framework.Net6/Yi.Framework.Template/Template/Site/ApiTemplate.txt @@ -1,18 +1,9 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> -<#@ assembly name="System.Core" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Collections.Generic" #> -<#@ output extension=".js" #> -<# -var entityName="article"; -#> import request from '@/utils/request' // 分页查询 export function listData(query) { return request({ - url: '/<#= entityName #>/pageList', + url: '/#LowerEntityName#/pageList', method: 'get', params: query }) @@ -21,7 +12,7 @@ export function listData(query) { // id查询 export function getData(code) { return request({ - url: '/<#= entityName #>/getById/' + code, + url: '/#LowerEntityName#/getById/' + code, method: 'get' }) } @@ -29,16 +20,16 @@ export function getData(code) { // 新增 export function addData(data) { return request({ - url: '/<#= entityName #>/add', + url: '/#LowerEntityName#/create', method: 'post', data: data }) } // 修改 -export function updateData(data) { +export function updateData(id,data) { return request({ - url: '/<#= entityName #>/update', + url: `/#LowerEntityName#/update/${id}`, method: 'put', data: data }) @@ -47,7 +38,7 @@ export function updateData(data) { // 删除 export function delData(code) { return request({ - url: '/<#= entityName #>/delList', + url: '/#LowerEntityName#/del', method: 'delete', data:"string"==typeof(code)?[code]:code }) diff --git a/Yi.Framework.Net6/Yi.Framework.Template/TemplateFactory.cs b/Yi.Framework.Net6/Yi.Framework.Template/TemplateFactory.cs new file mode 100644 index 00000000..76c879fc --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Template/TemplateFactory.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Template.Abstract; +using Yi.Framework.Template.Provider; + +namespace Yi.Framework.Template +{ + public class TemplateFactory + { + private List _templateProviders; + + public void CreateTemplateProviders(Action> action) + { + _templateProviders=new List(); + action(_templateProviders); + } + + public void BuildTemplate() + { + foreach (var provider in _templateProviders) + { + provider.Build(); + } + } + + public void BakTemplate() + { + foreach (var provider in _templateProviders) + { + provider.Bak(); + } + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/Yi.Framework.Template.csproj b/Yi.Framework.Net6/Yi.Framework.Template/Yi.Framework.Template.csproj index 2a3b0053..49318819 100644 --- a/Yi.Framework.Net6/Yi.Framework.Template/Yi.Framework.Template.csproj +++ b/Yi.Framework.Net6/Yi.Framework.Template/Yi.Framework.Template.csproj @@ -4,47 +4,45 @@ net6.0 enable enable + Exe - - - True - True - view.tt - - - - - - True - True - view.tt - - - - - - view.vue - TextTemplatingFileGenerator - - - TextTemplatingFileGenerator - api.js - - - True - True - api.tt - - - True - True - view.tt - - + + + + + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + + Always + + + + Always + + + diff --git a/Yi.Framework.Net6/Yi.Framework.Template/vue3-ruoyi/view.tt b/Yi.Framework.Net6/Yi.Framework.Template/vue3-ruoyi/view.tt deleted file mode 100644 index af02e22f..00000000 --- a/Yi.Framework.Net6/Yi.Framework.Template/vue3-ruoyi/view.tt +++ /dev/null @@ -1,315 +0,0 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> -<#@ assembly name="System.Core" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Collections.Generic" #> -<#@ output extension=".vue" #> -<# -var entityName="article"; -var path="/business/articleApi"; -var entityRemark="文章"; -var perCode="business:article"; -var dataDic=new Dictionary(){ -{"title","文章标题"}, -}; -var isStart=false; -#> -// -<#if(isStart){ - -#> - - - - - -<#} - #> \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.Template/vue3-ruoyi/view.vue b/Yi.Framework.Net6/Yi.Framework.Template/vue3-ruoyi/view.vue deleted file mode 100644 index 6eae1eb0..00000000 --- a/Yi.Framework.Net6/Yi.Framework.Template/vue3-ruoyi/view.vue +++ /dev/null @@ -1 +0,0 @@ -// diff --git a/Yi.Framework.Net6/Yi.Framework.Uow/IUnitOfWork.cs b/Yi.Framework.Net6/Yi.Framework.Uow/IUnitOfWork.cs deleted file mode 100644 index b98951b2..00000000 --- a/Yi.Framework.Net6/Yi.Framework.Uow/IUnitOfWork.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Data; - -namespace Yi.Framework.Uow -{ - public interface IUnitOfWork : IDisposable - { - public void Init(bool isTransactional, IsolationLevel? isolationLevel, int? timeout); - public void BeginTran(); - - public void CommitTran(); - public void RollbackTran(); - } -} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.Uow/Interceptors/UnitOfWorkAttribute.cs b/Yi.Framework.Net6/Yi.Framework.Uow/Interceptors/UnitOfWorkAttribute.cs deleted file mode 100644 index 3d681c2d..00000000 --- a/Yi.Framework.Net6/Yi.Framework.Uow/Interceptors/UnitOfWorkAttribute.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Yi.Framework.Uow.Interceptors -{ - public class UnitOfWorkAttribute : Attribute// : AbstractInterceptorAttribute - { - public UnitOfWorkAttribute(bool isTransactional = true) - { - IsTransactional = isTransactional; - } - public UnitOfWorkAttribute(IsolationLevel isolationLevel, bool isTransactional = true) : this(isTransactional) - { - IsolationLevel = isolationLevel; - } - public UnitOfWorkAttribute(IsolationLevel isolationLevel, int timeout, bool isTransactional = true) : this(isolationLevel, isTransactional) - { - Timeout = timeout; - } - - public bool IsTransactional { get; } - - public IsolationLevel? IsolationLevel { get; } - - /// - /// Milliseconds - /// - public int? Timeout { get; } - public bool IsDisabled { get; } - - - //public override Task Invoke(AspectContext context, AspectDelegate next) - //{ - // if (IsTransactional) - // { - // ServiceLocator.in.getservice() - // } - //} - } -} diff --git a/Yi.Framework.Net6/Yi.Framework.Uow/Interceptors/UnitOfWorkInterceptor.cs b/Yi.Framework.Net6/Yi.Framework.Uow/Interceptors/UnitOfWorkInterceptor.cs deleted file mode 100644 index 912d2d10..00000000 --- a/Yi.Framework.Net6/Yi.Framework.Uow/Interceptors/UnitOfWorkInterceptor.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Castle.DynamicProxy; -using Nest; -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace Yi.Framework.Uow.Interceptors -{ - public class UnitOfWorkInterceptor : IInterceptor - { - private readonly IUnitOfWork _unitOfWork; - public UnitOfWorkInterceptor(IUnitOfWork unitOfWork) - { - _unitOfWork = unitOfWork; - } - - public void Intercept(IInvocation invocation) - { - if (!IsUnitOfWorkMethod(invocation.Method, out var uowAttr)) - { - invocation.Proceed(); - return; - } - - try - { - _unitOfWork.BeginTran(); - //执行被拦截的方法 - invocation.Proceed(); - _unitOfWork.CommitTran(); - } - catch (Exception ex) - { - _unitOfWork.RollbackTran(); - throw ex; - } - } - - - public static bool IsUnitOfWorkMethod( MethodInfo methodInfo,out UnitOfWorkAttribute unitOfWorkAttribute) - { - - //Method declaration - var attrs = methodInfo.GetCustomAttributes(true).OfType().ToArray(); - if (attrs.Any()) - { - unitOfWorkAttribute = attrs.First(); - return !unitOfWorkAttribute.IsDisabled; - } - - if (methodInfo.DeclaringType != null) - { - //Class declaration - attrs = methodInfo.DeclaringType.GetTypeInfo().GetCustomAttributes(true).OfType().ToArray(); - if (attrs.Any()) - { - unitOfWorkAttribute = attrs.First(); - return !unitOfWorkAttribute.IsDisabled; - } - - ////Conventional classes - //if (typeof(IUnitOfWorkEnabled).GetTypeInfo().IsAssignableFrom(methodInfo.DeclaringType)) - //{ - // unitOfWorkAttribute = null; - // return true; - //} - } - - unitOfWorkAttribute = null; - return false; - } - - } -} diff --git a/Yi.Framework.Net6/Yi.Framework.Uow/Microsoft/ApsNetCore/Extensions/UowIServiceCollectionExtensions.cs b/Yi.Framework.Net6/Yi.Framework.Uow/Microsoft/ApsNetCore/Extensions/UowIServiceCollectionExtensions.cs deleted file mode 100644 index bd424fdc..00000000 --- a/Yi.Framework.Net6/Yi.Framework.Uow/Microsoft/ApsNetCore/Extensions/UowIServiceCollectionExtensions.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Yi.Framework.Uow; -using Yi.Framework.Uow.Interceptors; - -namespace Microsoft.Extensions.DependencyInjection -{ - public static class UowIServiceCollectionExtensions - { - public static void AddUnitOfWork(this IServiceCollection services) - { - services.AddScoped(typeof(IUnitOfWork), typeof(UnitOfWork)); - - services.AddSingleton(); - } - } -} diff --git a/Yi.Framework.Net6/Yi.Framework.Uow/UnitOfWork.cs b/Yi.Framework.Net6/Yi.Framework.Uow/UnitOfWork.cs deleted file mode 100644 index 84c74df1..00000000 --- a/Yi.Framework.Net6/Yi.Framework.Uow/UnitOfWork.cs +++ /dev/null @@ -1,75 +0,0 @@ -using SqlSugar; -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Yi.Framework.Uow -{ - public class UnitOfWork : IUnitOfWork - { - - public bool IsTransactional { get; protected set; } - - public IsolationLevel? IsolationLevel { get; protected set; } - - /// - /// Milliseconds - /// - public int? Timeout { get; protected set; } - - public void Init(bool isTransactional, IsolationLevel? isolationLevel, int? timeout) - { - IsTransactional = isTransactional; - IsolationLevel = isolationLevel; - Timeout = timeout; - } - - public ISqlSugarClient SugarClient { get; set; } - /// - /// 因为sqlsugarclient的生命周期是作用域的,也就是说一个请求线程内是共用一个client,暂时先直接注入 - /// - /// - public UnitOfWork(ISqlSugarClient sqlSugarClient) - { - this.SugarClient = sqlSugarClient; - } - - - public void Dispose() - { - SugarClient?.Dispose(); - SugarClient?.Close(); - } - - - - public void BeginTran() - { - if (IsTransactional) - { - if (IsolationLevel.HasValue) - { - SugarClient.Ado.BeginTran(IsolationLevel.Value); - } - else - { - SugarClient.Ado.BeginTran(); - } - } - } - - public void CommitTran() - { - if (IsTransactional) - SugarClient.Ado.CommitTran(); - } - public void RollbackTran() - { - if (IsTransactional) - SugarClient.Ado.RollbackTran(); - } - } -} diff --git a/Yi.Framework.Net6/Yi.Framework.Uow/Yi.Framework.Uow.csproj b/Yi.Framework.Net6/Yi.Framework.Uow/Yi.Framework.Uow.csproj deleted file mode 100644 index 8ac127cb..00000000 --- a/Yi.Framework.Net6/Yi.Framework.Uow/Yi.Framework.Uow.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - - - - - diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/AspNetCoreExtensions/SqlsugarExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/AspNetCoreExtensions/SqlsugarExtension.cs index 421b8397..f2d3ac47 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/AspNetCoreExtensions/SqlsugarExtension.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/AspNetCoreExtensions/SqlsugarExtension.cs @@ -118,6 +118,7 @@ namespace Yi.Framework.WebCore.AspNetCoreExtensions { sb.Append($"\r\n参数:{i.ParameterName},参数值:{i.Value}"); } + sb.Append( $"\r\n 完整SQL:{UtilMethods.GetSqlString(DbType.MySql, s, p)}"); _logger?.LogInformation(sb.ToString()); } diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs index bbebf049..8b91d51b 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs @@ -19,11 +19,12 @@ namespace Yi.Framework.WebCore.MiddlewareExtend public class ErrorHandExtension { private readonly RequestDelegate next; + private readonly ILogger _logger; //private readonly IErrorHandle _errorHandle; - public ErrorHandExtension(RequestDelegate next/*, IErrorHandle errorHandle*/) + public ErrorHandExtension(RequestDelegate next, ILoggerFactory loggerFactory /*, IErrorHandle errorHandle*/) { this.next = next; - //this._logger = loggerFactory.CreateLogger(); + this._logger = loggerFactory.CreateLogger(); //_errorHandle = errorHandle; } @@ -40,6 +41,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend } catch (Exception ex) { + _logger.LogError("系统错误",ex); //await _errorHandle.Invoer(context, ex); var statusCode = context.Response.StatusCode; if (ex is ArgumentException) diff --git a/Yi.Vue3.X.RuoYi/src/views/system/menu/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/menu/index.vue index 1990ffef..83f71ca7 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/menu/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/menu/index.vue @@ -258,7 +258,7 @@ {{ dict.label }} diff --git a/Yi.Framework.Net6/Yi.Framework.Template/vue3-ruoyi/api.js b/Yi.Vue3.x.RuoYi/src/api/erp/supplierApi.js similarity index 73% rename from Yi.Framework.Net6/Yi.Framework.Template/vue3-ruoyi/api.js rename to Yi.Vue3.x.RuoYi/src/api/erp/supplierApi.js index 403e94c0..8694b055 100644 --- a/Yi.Framework.Net6/Yi.Framework.Template/vue3-ruoyi/api.js +++ b/Yi.Vue3.x.RuoYi/src/api/erp/supplierApi.js @@ -3,7 +3,7 @@ // 分页查询 export function listData(query) { return request({ - url: '/article/pageList', + url: '/supplier/pageList', method: 'get', params: query }) @@ -12,7 +12,7 @@ export function listData(query) { // id查询 export function getData(code) { return request({ - url: '/article/getById/' + code, + url: '/supplier/getById/' + code, method: 'get' }) } @@ -20,16 +20,16 @@ export function getData(code) { // 新增 export function addData(data) { return request({ - url: '/article/add', + url: '/supplier/create', method: 'post', data: data }) } // 修改 -export function updateData(data) { +export function updateData(id,data) { return request({ - url: '/article/update', + url: `/supplier/update/${id}`, method: 'put', data: data }) @@ -38,7 +38,7 @@ export function updateData(data) { // 删除 export function delData(code) { return request({ - url: '/article/delList', + url: '/supplier/del', method: 'delete', data:"string"==typeof(code)?[code]:code }) diff --git a/Yi.Vue3.x.RuoYi/src/views/ERP/supplier/index.vue b/Yi.Vue3.x.RuoYi/src/views/ERP/supplier/index.vue new file mode 100644 index 00000000..853ced64 --- /dev/null +++ b/Yi.Vue3.x.RuoYi/src/views/ERP/supplier/index.vue @@ -0,0 +1,396 @@ + + + \ No newline at end of file