Эх сурвалжийг харах

😒精简自带应用实例代码

zuohuaijun 3 жил өмнө
parent
commit
ebaea87450

+ 0 - 6
Admin.NET/Admin.NET.Application/Admin.NET.Application.csproj

@@ -63,12 +63,6 @@
     <None Update="Configuration\Wechat.json">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
-    <None Update="Temp\CovidReport.html">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
-    <None Update="Temp\logo.png">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
   </ItemGroup>
 
 </Project>

+ 3 - 3
Admin.NET/Admin.NET.Application/Const/ApplicationConst.cs

@@ -1,14 +1,14 @@
-namespace Admin.NET.Application.Const;
+namespace Admin.NET.Application;
 
 /// <summary>
-/// 类名说明:辅助代码生成,以项目名.分割的最后一个单词+Const命名
+/// 应用常量
 /// </summary>
 public class ApplicationConst
 {
     /// <summary>
     /// API分组名称
     /// </summary>
-    public const string GroupName = "我的业务";
+    public const string GroupName = "测试业务";
 
     /// <summary>
     /// 数据库标识

+ 0 - 27
Admin.NET/Admin.NET.Application/Entity/Business.cs

@@ -1,27 +0,0 @@
-namespace Admin.NET.Application.Entity;
-
-/// <summary>
-/// 租户业务分库表
-/// </summary>
-[SugarTable(null, "租户业务分库表")]
-public class TenantBusiness : EntityTenant
-{
-    /// <summary>
-    /// 姓名
-    /// </summary>
-    [SugarColumn(ColumnDescription = "姓名", Length = 32)]
-    [Required, MaxLength(32)]
-    public virtual string Name { get; set; }
-
-    /// <summary>
-    /// 年龄
-    /// </summary>
-    [SugarColumn(ColumnDescription = "年龄")]
-    public int Age { get; set; }
-
-    /// <summary>
-    /// 出生日期
-    /// </summary>
-    [SugarColumn(ColumnDescription = "出生日期")]
-    public DateTime BirthDate { get; set; }
-}

+ 0 - 30
Admin.NET/Admin.NET.Application/Entity/Student.cs

@@ -1,30 +0,0 @@
-using Admin.NET.Application.Const;
-
-namespace Admin.NET.Application.Entity;
-
-/// <summary>
-/// 多库代码生成测试学生表
-/// </summary>
-[SugarTable(null, "多库代码生成测试学生表")]
-[Tenant(ApplicationConst.ConfigId)]
-public class Student : EntityBase
-{
-    /// <summary>
-    /// 姓名
-    /// </summary>
-    [SugarColumn(ColumnDescription = "姓名", Length = 32)]
-    [Required, MaxLength(32)]
-    public virtual string Name { get; set; }
-
-    /// <summary>
-    /// 年龄
-    /// </summary>
-    [SugarColumn(ColumnDescription = "年龄")]
-    public int Age { get; set; }
-
-    /// <summary>
-    /// 出生日期
-    /// </summary>
-    [SugarColumn(ColumnDescription = "出生日期")]
-    public DateTime BirthDate { get; set; }
-}

+ 4 - 6
Admin.NET/Admin.NET.Application/Entity/Test.cs

@@ -1,11 +1,9 @@
-using Admin.NET.Application.Const;
-
-namespace Admin.NET.Application.Entity;
+namespace Admin.NET.Application;
 
 /// <summary>
-/// 自己业务数据
+/// 测试
 /// </summary>
-[SugarTable(null, "自己业务数据表")]
+[SugarTable(null, "测试表")]
 [Tenant(ApplicationConst.ConfigId)]
 public class Test : EntityBase
 {
@@ -26,5 +24,5 @@ public class Test : EntityBase
     /// 出生日期
     /// </summary>
     [SugarColumn(ColumnDescription = "出生日期")]
-    public DateTime BirthDate { get; set; }
+    public DateTime? BirthDate { get; set; }
 }

+ 0 - 27
Admin.NET/Admin.NET.Application/Entity/TreeTest.cs

@@ -1,27 +0,0 @@
-using Admin.NET.Application.Const;
-
-namespace Admin.NET.Application.Entity;
-
-/// <summary>
-/// 多库代码生成树形测试表
-/// </summary>
-[SugarTable(null, "多库代码生成树形测试表")]
-[Tenant(ApplicationConst.ConfigId)]
-public class TreeTest : EntityBase
-{
-    /// <summary>
-    /// 名称
-    /// </summary>
-    public string Name { get; set; }
-
-    /// <summary>
-    /// 父级
-    /// </summary>
-    public long ParentId { get; set; }//父级字段
-
-    /// <summary>
-    /// Child
-    /// </summary>
-    [SqlSugar.SugarColumn(IsIgnore = true)]
-    public List<TreeTest> Child { get; set; }
-}

+ 2 - 2
Admin.NET/Admin.NET.Application/GlobalUsings.cs

@@ -1,8 +1,8 @@
-global using Admin.NET.Application.Entity;
-global using Admin.NET.Core;
+global using Admin.NET.Core;
 global using Furion;
 global using Furion.DependencyInjection;
 global using Furion.DynamicApiController;
+global using Microsoft.AspNetCore.Authorization;
 global using Microsoft.AspNetCore.Mvc;
 global using Microsoft.Extensions.DependencyInjection;
 global using SqlSugar;

+ 2 - 2
Admin.NET/Admin.NET.Application/SeedData/SysMenuSeedData.cs

@@ -13,8 +13,8 @@ public class SysMenuSeedData : ISqlSugarEntitySeedData<SysMenu>
     {
         return new[]
         {
-            new SysMenu{ Id=252885263002200, Pid=0, Title="业务测试", Path="/test", Name="test", Component="Layout", Redirect="/test/tenant", Icon="ele-Position", Type=MenuTypeEnum.Dir, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=20 },
-            new SysMenu{ Id=252885263002201, Pid=252885263002200, Title="租户业务", Path="/test/tenant", Name="testTenant", Component="/test/tenant/index", Icon="ele-OfficeBuilding", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
+            new SysMenu{ Id=252885263002200, Pid=0, Title="业务测试", Path="/test", Name="test", Component="Layout", Redirect="/test/XXX", Icon="ele-Position", Type=MenuTypeEnum.Dir, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=20 },
+            new SysMenu{ Id=252885263002201, Pid=252885263002200, Title="XXX业务", Path="/test/XXX", Name="XXX", Component="/test/XXX/index", Icon="ele-OfficeBuilding", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
         };
     }
 }

+ 2 - 2
Admin.NET/Admin.NET.Application/SeedData/TestSeedData.cs

@@ -11,7 +11,7 @@ public class TestSeedData : ISqlSugarEntitySeedData<Test>
     /// <returns></returns>
     public IEnumerable<Test> HasData()
     {
-        yield return new Test { Id = 252885263003800, Name = "123", Age = 20, CreateTime = DateTime.Parse("2022-04-12 00:00:00") };
-        yield return new Test { Id = 252885263003801, Name = "456", Age = 30, CreateTime = DateTime.Parse("2022-04-12 00:00:00") };
+        yield return new Test { Id = 252885263003800, Name = "张三", Age = 20, CreateTime = DateTime.Parse("2022-04-12 00:00:00") };
+        yield return new Test { Id = 252885263003801, Name = "李四", Age = 30, CreateTime = DateTime.Parse("2022-04-12 00:00:00") };
     }
 }

+ 0 - 34
Admin.NET/Admin.NET.Application/Service/TenantBusinessService.cs

@@ -1,34 +0,0 @@
-namespace Admin.NET.Application.Service;
-
-/// <summary>
-/// 租户业务服务
-/// </summary>
-[ApiDescriptionSettings("租户业务服务", Order = 200)]
-public class TenantBusinessService : IDynamicApiController, ITransient
-{
-    private readonly SqlSugarRepository<TenantBusiness> _tenantBusinessRep;
-
-    public TenantBusinessService(SqlSugarRepository<TenantBusiness> businessRep)
-    {
-        _tenantBusinessRep = businessRep;
-    }
-
-    /// <summary>
-    /// 增加租户业务数据
-    /// </summary>
-    /// <returns></returns>
-    public async Task<bool> AddBusiness()
-    {
-        var tenantBusiness = new TenantBusiness() { Name = "zuohuaijun" };
-        return await _tenantBusinessRep.InsertAsync(tenantBusiness);
-    }
-
-    /// <summary>
-    /// 查询租户业务数据
-    /// </summary>
-    /// <returns></returns>
-    public async Task<List<TenantBusiness>> GetBusinessList()
-    {
-        return await _tenantBusinessRep.GetListAsync();
-    }
-}

+ 0 - 89
Admin.NET/Admin.NET.Application/Service/Test2Service.cs

@@ -1,89 +0,0 @@
-using Admin.NET.Application.Const;
-using Magicodes.ExporterAndImporter.Core;
-using Magicodes.ExporterAndImporter.Pdf;
-using Microsoft.AspNetCore.Authorization;
-using System.IO;
-
-namespace Admin.NET.Application.Service;
-
-/// <summary>
-/// 自己业务服务
-/// </summary>
-[ApiDescriptionSettings(ApplicationConst.GroupName, Order = 200)]
-[AllowAnonymous]
-public class Test2Service : IDynamicApiController, ITransient
-{
-    public Test2Service()
-    {
-    }
-
-    /// <summary>
-    /// 生成PDF文件
-    /// </summary>
-    /// <returns></returns>
-    public async Task<dynamic> CreatePDFReport()
-    {
-        var tpl = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "temp/CovidReport.html"));
-        var exporter = new PdfExporter();
-        var pdfAtt = new PdfExporterAttribute();
-        pdfAtt.Orientation = WkHtmlToPdfDotNet.Orientation.Portrait;
-        pdfAtt.PaperKind = WkHtmlToPdfDotNet.PaperKind.A4;
-        var result = await exporter.ExportBytesByTemplate(new ReportData
-        {
-            Name = "张三",
-            IdNo = "130430xxxxxxxxxxxx",
-            Sex = "男",
-            Age = 35,
-            TudeNo = "12345678901",
-            CollectTime = "2022-08-01 12:33:33",
-            ReceiveTime = "2022-08-01 18:33:33",
-            CheckTime = "2022-08-02 18:33:33"
-        }, pdfAtt, tpl);
-
-        return new FileStreamResult(new MemoryStream(result), "application/octet-stream") { FileDownloadName = "核酸.PDF" };
-    }
-}
-
-[Exporter(Name = "核酸报告")]
-public class ReportData
-{
-    /// <summary>
-    /// 姓名
-    /// </summary>
-    public string Name { get; set; }
-
-    /// <summary>
-    /// 身份证
-    /// </summary>
-    public string IdNo { get; set; }
-
-    /// <summary>
-    /// 性别
-    /// </summary>
-    public string Sex { get; set; }
-
-    /// <summary>
-    /// 年龄
-    /// </summary>
-    public int Age { get; set; }
-
-    /// <summary>
-    /// 试管编号
-    /// </summary>
-    public string TudeNo { get; set; }
-
-    /// <summary>
-    /// 采样时间
-    /// </summary>
-    public string CollectTime { get; set; }
-
-    /// <summary>
-    /// 收样时间
-    /// </summary>
-    public string ReceiveTime { get; set; }
-
-    /// <summary>
-    /// 检测时间
-    /// </summary>
-    public string CheckTime { get; set; }
-}

+ 1 - 63
Admin.NET/Admin.NET.Application/Service/TestService.cs

@@ -1,14 +1,7 @@
-using Admin.NET.Application.Const;
-using Furion.DatabaseAccessor;
-using Furion.FriendlyException;
-using Furion.Localization;
-using Furion.Logging.Extensions;
-using Microsoft.AspNetCore.Authorization;
-
 namespace Admin.NET.Application.Service;
 
 /// <summary>
-/// 自己业务服务
+/// 测试服务
 /// </summary>
 [ApiDescriptionSettings(ApplicationConst.GroupName, Order = 200)]
 [AllowAnonymous]
@@ -38,59 +31,4 @@ public class TestService : IDynamicApiController, ITransient
     {
         return await _testRep.GetListAsync();
     }
-
-    /// <summary>
-    /// 异常测试
-    /// </summary>
-    /// <returns></returns>
-    public void TestException()
-    {
-        throw new Exception("异常");
-
-        throw Oops.Oh("异常").WithData("数据");
-    }
-
-    /// <summary>
-    /// 事务和工作单元测试
-    /// </summary>
-    /// <returns></returns>
-    [HttpGet("/test/list2")]
-    [UnitOfWork]
-    public async Task<List<Test>> TestUnitOfWork()
-    {
-        await _testRep.InsertAsync(new Test() { Name = "admin" });
-        var a = 1;
-        var b = 0;
-        var c = a / b;
-        return await _testRep.GetListAsync();
-    }
-
-    /// <summary>
-    /// 多语言测试
-    /// </summary>
-    /// <returns></returns>
-    public string TestCulture()
-    {
-        "ddd".LogWarning();
-        //L.SetCulture("zh-CN");
-        //var a = L.GetSelectCulture();
-        //var a1 = L.Text["API Interfaces"];
-        //return $"当前语言【{a.Culture.Name}】 {a1}";
-
-        L.SetCulture("en-US");
-        var b = L.GetSelectCulture();
-        var b1 = L.Text["API 接口"];
-
-        return $"当前语言【{b.Culture.Name}】 {b1}";
-    }
-
-    /// <summary>
-    /// 自定义规范化结果
-    /// </summary>
-    /// <returns></returns>
-    [CustomUnifyResult("APP")]
-    public string CustomUnifyResult()
-    {
-        return "Furion";
-    }
 }

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 92
Admin.NET/Admin.NET.Application/Temp/CovidReport.html


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно