From 3decd58cb363e0ded1513ffb29a1be257a486c7c Mon Sep 17 00:00:00 2001 From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com> Date: Fri, 14 Apr 2023 20:48:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Shentun.Peis.Application.csproj | 4 + .../GuideTypes/GuideTypeManager.cs | 40 +++++++++ .../ItemTypes/ItemTypeManager.cs | 39 +++++++++ src/Shentun.Peis.Domain/Models/GuideType.cs | 8 +- src/Shentun.Peis.Domain/Models/ItemType.cs | 12 ++- src/Shentun.Peis.Domain/Models/Pbcatcol.cs | 77 ---------------- src/Shentun.Peis.Domain/Models/Pbcatedt.cs | 41 --------- src/Shentun.Peis.Domain/Models/Pbcatfmt.cs | 33 ------- src/Shentun.Peis.Domain/Models/Pbcattbl.cs | 87 ------------------- src/Shentun.Peis.Domain/Models/Pbcatvld.cs | 38 -------- .../EntityFrameworkCore/PeisDbContext.cs | 6 +- .../Shentun.Peis.EntityFrameworkCore.csproj | 5 ++ .../GuideTypeManagerTest.cs | 32 +++++++ .../ItemTypeManagerTest.cs | 32 +++++++ .../PeisDomainTestBase.cs | 9 +- 15 files changed, 177 insertions(+), 286 deletions(-) create mode 100644 src/Shentun.Peis.Domain/GuideTypes/GuideTypeManager.cs create mode 100644 src/Shentun.Peis.Domain/ItemTypes/ItemTypeManager.cs delete mode 100644 src/Shentun.Peis.Domain/Models/Pbcatcol.cs delete mode 100644 src/Shentun.Peis.Domain/Models/Pbcatedt.cs delete mode 100644 src/Shentun.Peis.Domain/Models/Pbcatfmt.cs delete mode 100644 src/Shentun.Peis.Domain/Models/Pbcattbl.cs delete mode 100644 src/Shentun.Peis.Domain/Models/Pbcatvld.cs create mode 100644 test/Shentun.Peis.Domain.Tests/GuideTypeManagerTest.cs create mode 100644 test/Shentun.Peis.Domain.Tests/ItemTypeManagerTest.cs diff --git a/src/Shentun.Peis.Application/Shentun.Peis.Application.csproj b/src/Shentun.Peis.Application/Shentun.Peis.Application.csproj index af2b1f6..ebc3f71 100644 --- a/src/Shentun.Peis.Application/Shentun.Peis.Application.csproj +++ b/src/Shentun.Peis.Application/Shentun.Peis.Application.csproj @@ -26,4 +26,8 @@ + + + + diff --git a/src/Shentun.Peis.Domain/GuideTypes/GuideTypeManager.cs b/src/Shentun.Peis.Domain/GuideTypes/GuideTypeManager.cs new file mode 100644 index 0000000..11b320f --- /dev/null +++ b/src/Shentun.Peis.Domain/GuideTypes/GuideTypeManager.cs @@ -0,0 +1,40 @@ +using Shentun.Peis.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; +using Volo.Abp; +using Volo.Abp.Domain.Services; +using System.Diagnostics.CodeAnalysis; + +namespace Shentun.Peis.GuidTypes +{ + public class GuideTypeManager : DomainService + { + private readonly IRepository _repository; + public GuideTypeManager(IRepository repository) + { + _repository = repository; + } + public async Task CreateAsync( + [NotNull] string name + ) + { + Check.NotNullOrWhiteSpace(name, nameof(name)); + var existEntity = await _repository.FindAsync(o => o.GuideTypeName == name); + + if (existEntity != null) + { + throw new UserFriendlyException($"{name}名称已存在"); ; + } + + return new GuideType( + GuidGenerator.Create(), + name + + ); + } + } +} diff --git a/src/Shentun.Peis.Domain/ItemTypes/ItemTypeManager.cs b/src/Shentun.Peis.Domain/ItemTypes/ItemTypeManager.cs new file mode 100644 index 0000000..f6b5202 --- /dev/null +++ b/src/Shentun.Peis.Domain/ItemTypes/ItemTypeManager.cs @@ -0,0 +1,39 @@ +using JetBrains.Annotations; +using Shentun.Peis.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Domain.Services; +namespace Shentun.Peis.ItemTypes +{ + public class ItemTypeManager: DomainService + { + private readonly IRepository _repository; + public ItemTypeManager(IRepository repository) + { + _repository = repository; + } + public async Task CreateAsync( + [NotNull] string name + ) + { + Check.NotNullOrWhiteSpace(name, nameof(name)); + var existEntity = await _repository.FindAsync(o => o.ItemTypeName == name); + + if (existEntity != null) + { + throw new UserFriendlyException($"{name}名称已存在"); ; + } + + return new ItemType( + GuidGenerator.Create(), + name + + ); + } + } +} diff --git a/src/Shentun.Peis.Domain/Models/GuideType.cs b/src/Shentun.Peis.Domain/Models/GuideType.cs index 53e13f9..e8eeac4 100644 --- a/src/Shentun.Peis.Domain/Models/GuideType.cs +++ b/src/Shentun.Peis.Domain/Models/GuideType.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities.Auditing; @@ -18,7 +19,12 @@ namespace Shentun.Peis.Models { ItemTypes = new HashSet(); } - + internal GuideType(Guid id, + [NotNull] string name):base(id) + { + GuideTypeName = name; + ItemTypes = new HashSet(); + } [Column("guide_type_name")] [StringLength(20)] public string GuideTypeName { get; set; } = null!; diff --git a/src/Shentun.Peis.Domain/Models/ItemType.cs b/src/Shentun.Peis.Domain/Models/ItemType.cs index 9dc3e69..4620647 100644 --- a/src/Shentun.Peis.Domain/Models/ItemType.cs +++ b/src/Shentun.Peis.Domain/Models/ItemType.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities.Auditing; @@ -13,10 +14,15 @@ namespace Shentun.Peis.Models /// [Table("item_type")] [Index(nameof(ItemTypeName), nameof(ParentId), Name = "ix_item_type", IsUnique = true)] - public class ItemType : FullAuditedEntity + public class ItemType : AuditedEntity { - public ItemType() + + internal ItemType( + Guid id, + [NotNull] string name) + : base(id) { + ItemTypeName= name; Asbitems = new HashSet(); BigtextResultTypes = new HashSet(); Diagnoses = new HashSet(); @@ -24,7 +30,7 @@ namespace Shentun.Peis.Models Rooms = new HashSet(); UserItemTypes = new HashSet(); } - + [Column("item_type_name")] [StringLength(20)] public string ItemTypeName { get; set; } = null!; diff --git a/src/Shentun.Peis.Domain/Models/Pbcatcol.cs b/src/Shentun.Peis.Domain/Models/Pbcatcol.cs deleted file mode 100644 index 49e8931..0000000 --- a/src/Shentun.Peis.Domain/Models/Pbcatcol.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Domain.Entities; -using Volo.Abp.Domain.Entities.Auditing; - -namespace Shentun.Peis.Models -{ - [Keyless] - [Table("pbcatcol")] - [Index(nameof(PbcTnam), nameof(PbcOwnr), nameof(PbcCnam), Name = "pbcatc_x")] - public class Pbcatcol : FullAuditedEntity - { - - - - [Column("pbc_tnam")] - [StringLength(129)] - public string PbcTnam { get; set; } = null!; - [Column("pbc_tid")] - public int? PbcTid { get; set; } - [Column("pbc_ownr")] - [StringLength(129)] - public string PbcOwnr { get; set; } = null!; - [Column("pbc_cnam")] - [StringLength(129)] - public string PbcCnam { get; set; } = null!; - [Column("pbc_cid")] - public short? PbcCid { get; set; } - [Column("pbc_labl")] - [StringLength(254)] - public string? PbcLabl { get; set; } - [Column("pbc_lpos")] - public short? PbcLpos { get; set; } - [Column("pbc_hdr")] - [StringLength(254)] - public string? PbcHdr { get; set; } - [Column("pbc_hpos")] - public short? PbcHpos { get; set; } - [Column("pbc_jtfy")] - public short? PbcJtfy { get; set; } - [Column("pbc_mask")] - [StringLength(31)] - public string? PbcMask { get; set; } - [Column("pbc_case")] - public short? PbcCase { get; set; } - [Column("pbc_hght")] - public short? PbcHght { get; set; } - [Column("pbc_wdth")] - public short? PbcWdth { get; set; } - [Column("pbc_ptrn")] - [StringLength(31)] - public string? PbcPtrn { get; set; } - [Column("pbc_bmap")] - [StringLength(1)] - public string? PbcBmap { get; set; } - [Column("pbc_init")] - [StringLength(254)] - public string? PbcInit { get; set; } - [Column("pbc_cmnt")] - [StringLength(254)] - public string? PbcCmnt { get; set; } - [Column("pbc_edit")] - [StringLength(31)] - public string? PbcEdit { get; set; } - [Column("pbc_tag")] - [StringLength(254)] - public string? PbcTag { get; set; } - - //public override object[] GetKeys() - //{ - // return new object[] { PbcatcolId }; - //} - } -} diff --git a/src/Shentun.Peis.Domain/Models/Pbcatedt.cs b/src/Shentun.Peis.Domain/Models/Pbcatedt.cs deleted file mode 100644 index 417a21a..0000000 --- a/src/Shentun.Peis.Domain/Models/Pbcatedt.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Domain.Entities; -using Volo.Abp.Domain.Entities.Auditing; - -namespace Shentun.Peis.Models -{ - [Keyless] - [Table("pbcatedt")] - [Index(nameof(PbeName), nameof(PbeSeqn), Name = "pbcate_x")] - public class Pbcatedt: FullAuditedEntity - { - - - [Column("pbe_name")] - [StringLength(30)] - public string PbeName { get; set; } = null!; - [Column("pbe_edit")] - [StringLength(254)] - public string? PbeEdit { get; set; } - [Column("pbe_type")] - public short? PbeType { get; set; } - [Column("pbe_cntr")] - public int? PbeCntr { get; set; } - [Column("pbe_seqn")] - public short PbeSeqn { get; set; } - [Column("pbe_flag")] - public int? PbeFlag { get; set; } - [Column("pbe_work")] - [StringLength(32)] - public string? PbeWork { get; set; } - - //public override object[] GetKeys() - //{ - // return new object[] { PbcatedtId }; - //} - } -} diff --git a/src/Shentun.Peis.Domain/Models/Pbcatfmt.cs b/src/Shentun.Peis.Domain/Models/Pbcatfmt.cs deleted file mode 100644 index 1054325..0000000 --- a/src/Shentun.Peis.Domain/Models/Pbcatfmt.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Domain.Entities; -using Volo.Abp.Domain.Entities.Auditing; - -namespace Shentun.Peis.Models -{ - [Keyless] - [Table("pbcatfmt")] - [Index(nameof(PbfName), Name = "pbcatf_x")] - public class Pbcatfmt: FullAuditedEntity - { - - [Column("pbf_name")] - [StringLength(30)] - public string PbfName { get; set; } = null!; - [Column("pbf_frmt")] - [StringLength(254)] - public string? PbfFrmt { get; set; } - [Column("pbf_type")] - public short? PbfType { get; set; } - [Column("pbf_cntr")] - public int? PbfCntr { get; set; } - - //public override object[] GetKeys() - //{ - // return new object[] { PbcatfmtId }; - //} - } -} diff --git a/src/Shentun.Peis.Domain/Models/Pbcattbl.cs b/src/Shentun.Peis.Domain/Models/Pbcattbl.cs deleted file mode 100644 index a41fd8e..0000000 --- a/src/Shentun.Peis.Domain/Models/Pbcattbl.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Domain.Entities; -using Volo.Abp.Domain.Entities.Auditing; - -namespace Shentun.Peis.Models -{ - [Keyless] - [Table("pbcattbl")] - [Index(nameof(PbtTnam), nameof(PbtOwnr), Name = "pbcatt_x")] - public class Pbcattbl : FullAuditedEntity - { - - - - [Column("pbt_tnam")] - [StringLength(129)] - public string PbtTnam { get; set; } = null!; - [Column("pbt_tid")] - public int? PbtTid { get; set; } - [Column("pbt_ownr")] - [StringLength(129)] - public string PbtOwnr { get; set; } = null!; - [Column("pbd_fhgt")] - public short? PbdFhgt { get; set; } - [Column("pbd_fwgt")] - public short? PbdFwgt { get; set; } - [Column("pbd_fitl")] - [StringLength(1)] - public string? PbdFitl { get; set; } - [Column("pbd_funl")] - [StringLength(1)] - public string? PbdFunl { get; set; } - [Column("pbd_fchr")] - public short? PbdFchr { get; set; } - [Column("pbd_fptc")] - public short? PbdFptc { get; set; } - [Column("pbd_ffce")] - [StringLength(18)] - public string? PbdFfce { get; set; } - [Column("pbh_fhgt")] - public short? PbhFhgt { get; set; } - [Column("pbh_fwgt")] - public short? PbhFwgt { get; set; } - [Column("pbh_fitl")] - [StringLength(1)] - public string? PbhFitl { get; set; } - [Column("pbh_funl")] - [StringLength(1)] - public string? PbhFunl { get; set; } - [Column("pbh_fchr")] - public short? PbhFchr { get; set; } - [Column("pbh_fptc")] - public short? PbhFptc { get; set; } - [Column("pbh_ffce")] - [StringLength(18)] - public string? PbhFfce { get; set; } - [Column("pbl_fhgt")] - public short? PblFhgt { get; set; } - [Column("pbl_fwgt")] - public short? PblFwgt { get; set; } - [Column("pbl_fitl")] - [StringLength(1)] - public string? PblFitl { get; set; } - [Column("pbl_funl")] - [StringLength(1)] - public string? PblFunl { get; set; } - [Column("pbl_fchr")] - public short? PblFchr { get; set; } - [Column("pbl_fptc")] - public short? PblFptc { get; set; } - [Column("pbl_ffce")] - [StringLength(18)] - public string? PblFfce { get; set; } - [Column("pbt_cmnt")] - [StringLength(254)] - public string? PbtCmnt { get; set; } - - //public override object[] GetKeys() - //{ - // return new object[] { PbcattblId }; - //} - } -} diff --git a/src/Shentun.Peis.Domain/Models/Pbcatvld.cs b/src/Shentun.Peis.Domain/Models/Pbcatvld.cs deleted file mode 100644 index 73ef47b..0000000 --- a/src/Shentun.Peis.Domain/Models/Pbcatvld.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Domain.Entities; -using Volo.Abp.Domain.Entities.Auditing; - -namespace Shentun.Peis.Models -{ - [Keyless] - [Table("pbcatvld")] - [Index(nameof(PbvName), Name = "pbcatv_x")] - public class Pbcatvld: FullAuditedEntity - { - - - - [Column("pbv_name")] - [StringLength(30)] - public string PbvName { get; set; } = null!; - [Column("pbv_vald")] - [StringLength(254)] - public string? PbvVald { get; set; } - [Column("pbv_type")] - public short? PbvType { get; set; } - [Column("pbv_cntr")] - public int? PbvCntr { get; set; } - [Column("pbv_msg")] - [StringLength(254)] - public string? PbvMsg { get; set; } - - //public override object[] GetKeys() - //{ - // return new object[] { PbcatvldId }; - //} - } -} diff --git a/src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/PeisDbContext.cs b/src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/PeisDbContext.cs index 08bc298..ee8c157 100644 --- a/src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/PeisDbContext.cs +++ b/src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/PeisDbContext.cs @@ -161,11 +161,7 @@ public class PeisDbContext : public DbSet PatientRegisters { get; set; } = null!; public DbSet PatientSymptoms { get; set; } = null!; public DbSet PayModes { get; set; } = null!; - public DbSet Pbcatcols { get; set; } = null!; - public DbSet Pbcatedts { get; set; } = null!; - public DbSet Pbcatfmts { get; set; } = null!; - public DbSet Pbcattbls { get; set; } = null!; - public DbSet Pbcatvlds { get; set; } = null!; + public DbSet PersonnelTypes { get; set; } = null!; public DbSet PhoneFollows { get; set; } = null!; public DbSet Poisons { get; set; } = null!; diff --git a/src/Shentun.Peis.EntityFrameworkCore/Shentun.Peis.EntityFrameworkCore.csproj b/src/Shentun.Peis.EntityFrameworkCore/Shentun.Peis.EntityFrameworkCore.csproj index f249e94..df89e55 100644 --- a/src/Shentun.Peis.EntityFrameworkCore/Shentun.Peis.EntityFrameworkCore.csproj +++ b/src/Shentun.Peis.EntityFrameworkCore/Shentun.Peis.EntityFrameworkCore.csproj @@ -9,6 +9,7 @@ + @@ -27,4 +28,8 @@ + + + + diff --git a/test/Shentun.Peis.Domain.Tests/GuideTypeManagerTest.cs b/test/Shentun.Peis.Domain.Tests/GuideTypeManagerTest.cs new file mode 100644 index 0000000..df1f766 --- /dev/null +++ b/test/Shentun.Peis.Domain.Tests/GuideTypeManagerTest.cs @@ -0,0 +1,32 @@ +using Shentun.Peis.GuidTypes; +using Shentun.Peis.ItemTypes; +using Shentun.Peis.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; +using Xunit; + +namespace Shentun.Peis +{ + public class GuideTypeManagerTest : PeisDomainEfTestBase + { + private readonly IRepository _repository; + private readonly GuideTypeManager _manager; + + public GuideTypeManagerTest() + { + _repository = GetRequiredService>(); + _manager = GetRequiredService(); + } + [Fact] + public async Task Should_Set_CanAdd() + { + var item = await _manager.CreateAsync("普通"); + item = await _repository.UpdateAsync(item); + Console.WriteLine(item.Id.ToString()); + } + } +} diff --git a/test/Shentun.Peis.Domain.Tests/ItemTypeManagerTest.cs b/test/Shentun.Peis.Domain.Tests/ItemTypeManagerTest.cs new file mode 100644 index 0000000..5b629ff --- /dev/null +++ b/test/Shentun.Peis.Domain.Tests/ItemTypeManagerTest.cs @@ -0,0 +1,32 @@ +using Shentun.Peis.ItemTypes; +using Shentun.Peis.Models; +using Shouldly; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Identity; +using Xunit; + +namespace Shentun.Peis +{ + public class ItemTypeManagerTest : PeisDomainTestBase + { + private readonly IRepository _repository; + private readonly ItemTypeManager _manager; + + public ItemTypeManagerTest() + { + _repository = GetRequiredService>(); + _manager = GetRequiredService(); + } + [Fact] + public async Task Should_Set_CanAdd() + { + var item = await _manager.CreateAsync("检验"); + item = await _repository.UpdateAsync(item); + } + } +} diff --git a/test/Shentun.Peis.Domain.Tests/PeisDomainTestBase.cs b/test/Shentun.Peis.Domain.Tests/PeisDomainTestBase.cs index 37d35d2..634d68d 100644 --- a/test/Shentun.Peis.Domain.Tests/PeisDomainTestBase.cs +++ b/test/Shentun.Peis.Domain.Tests/PeisDomainTestBase.cs @@ -1,6 +1,13 @@ -namespace Shentun.Peis; +using Shentun.Peis.EntityFrameworkCore; + +namespace Shentun.Peis; public abstract class PeisDomainTestBase : PeisTestBase { } + +public abstract class PeisDomainEfTestBase : PeisTestBase +{ + +} \ No newline at end of file