Browse Source

测试

bjmzak
DESKTOP-G961P6V\Zhh 3 years ago
parent
commit
3decd58cb3
  1. 4
      src/Shentun.Peis.Application/Shentun.Peis.Application.csproj
  2. 40
      src/Shentun.Peis.Domain/GuideTypes/GuideTypeManager.cs
  3. 39
      src/Shentun.Peis.Domain/ItemTypes/ItemTypeManager.cs
  4. 8
      src/Shentun.Peis.Domain/Models/GuideType.cs
  5. 12
      src/Shentun.Peis.Domain/Models/ItemType.cs
  6. 77
      src/Shentun.Peis.Domain/Models/Pbcatcol.cs
  7. 41
      src/Shentun.Peis.Domain/Models/Pbcatedt.cs
  8. 33
      src/Shentun.Peis.Domain/Models/Pbcatfmt.cs
  9. 87
      src/Shentun.Peis.Domain/Models/Pbcattbl.cs
  10. 38
      src/Shentun.Peis.Domain/Models/Pbcatvld.cs
  11. 6
      src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/PeisDbContext.cs
  12. 5
      src/Shentun.Peis.EntityFrameworkCore/Shentun.Peis.EntityFrameworkCore.csproj
  13. 32
      test/Shentun.Peis.Domain.Tests/GuideTypeManagerTest.cs
  14. 32
      test/Shentun.Peis.Domain.Tests/ItemTypeManagerTest.cs
  15. 9
      test/Shentun.Peis.Domain.Tests/PeisDomainTestBase.cs

4
src/Shentun.Peis.Application/Shentun.Peis.Application.csproj

@ -26,4 +26,8 @@
<PackageReference Include="Volo.Abp.SettingManagement.Application" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="ItemTypes\" />
</ItemGroup>
</Project>

40
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<GuideType, Guid> _repository;
public GuideTypeManager(IRepository<GuideType, Guid> repository)
{
_repository = repository;
}
public async Task<GuideType> 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
);
}
}
}

39
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<ItemType, Guid> _repository;
public ItemTypeManager(IRepository<ItemType,Guid> repository)
{
_repository = repository;
}
public async Task<ItemType> 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
);
}
}
}

8
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<ItemType>();
}
internal GuideType(Guid id,
[NotNull] string name):base(id)
{
GuideTypeName = name;
ItemTypes = new HashSet<ItemType>();
}
[Column("guide_type_name")]
[StringLength(20)]
public string GuideTypeName { get; set; } = null!;

12
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
/// </summary>
[Table("item_type")]
[Index(nameof(ItemTypeName), nameof(ParentId), Name = "ix_item_type", IsUnique = true)]
public class ItemType : FullAuditedEntity<Guid>
public class ItemType : AuditedEntity<Guid>
{
public ItemType()
internal ItemType(
Guid id,
[NotNull] string name)
: base(id)
{
ItemTypeName= name;
Asbitems = new HashSet<Asbitem>();
BigtextResultTypes = new HashSet<BigtextResultType>();
Diagnoses = new HashSet<Diagnosis>();
@ -24,7 +30,7 @@ namespace Shentun.Peis.Models
Rooms = new HashSet<Room>();
UserItemTypes = new HashSet<UserItemType>();
}
[Column("item_type_name")]
[StringLength(20)]
public string ItemTypeName { get; set; } = null!;

77
src/Shentun.Peis.Domain/Models/Pbcatcol.cs

@ -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<Guid>
{
[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 };
//}
}
}

41
src/Shentun.Peis.Domain/Models/Pbcatedt.cs

@ -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<Guid>
{
[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 };
//}
}
}

33
src/Shentun.Peis.Domain/Models/Pbcatfmt.cs

@ -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<Guid>
{
[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 };
//}
}
}

87
src/Shentun.Peis.Domain/Models/Pbcattbl.cs

@ -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<Guid>
{
[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 };
//}
}
}

38
src/Shentun.Peis.Domain/Models/Pbcatvld.cs

@ -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<Guid>
{
[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 };
//}
}
}

6
src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/PeisDbContext.cs

@ -161,11 +161,7 @@ public class PeisDbContext :
public DbSet<PatientRegister> PatientRegisters { get; set; } = null!;
public DbSet<PatientSymptom> PatientSymptoms { get; set; } = null!;
public DbSet<PayMode> PayModes { get; set; } = null!;
public DbSet<Pbcatcol> Pbcatcols { get; set; } = null!;
public DbSet<Pbcatedt> Pbcatedts { get; set; } = null!;
public DbSet<Pbcatfmt> Pbcatfmts { get; set; } = null!;
public DbSet<Pbcattbl> Pbcattbls { get; set; } = null!;
public DbSet<Pbcatvld> Pbcatvlds { get; set; } = null!;
public DbSet<PersonnelType> PersonnelTypes { get; set; } = null!;
public DbSet<PhoneFollow> PhoneFollows { get; set; } = null!;
public DbSet<Poison> Poisons { get; set; } = null!;

5
src/Shentun.Peis.EntityFrameworkCore/Shentun.Peis.EntityFrameworkCore.csproj

@ -9,6 +9,7 @@
<ItemGroup>
<ProjectReference Include="..\Shentun.Peis.Domain\Shentun.Peis.Domain.csproj" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" Version="6.0.0" />
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="6.0.0" />
@ -27,4 +28,8 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Models2\" />
</ItemGroup>
</Project>

32
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<GuideType, Guid> _repository;
private readonly GuideTypeManager _manager;
public GuideTypeManagerTest()
{
_repository = GetRequiredService<IRepository<GuideType, Guid>>();
_manager = GetRequiredService<GuideTypeManager>();
}
[Fact]
public async Task Should_Set_CanAdd()
{
var item = await _manager.CreateAsync("普通");
item = await _repository.UpdateAsync(item);
Console.WriteLine(item.Id.ToString());
}
}
}

32
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<ItemType, Guid> _repository;
private readonly ItemTypeManager _manager;
public ItemTypeManagerTest()
{
_repository = GetRequiredService<IRepository<ItemType, Guid>>();
_manager = GetRequiredService<ItemTypeManager>();
}
[Fact]
public async Task Should_Set_CanAdd()
{
var item = await _manager.CreateAsync("检验");
item = await _repository.UpdateAsync(item);
}
}
}

9
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<PeisDomainTestModule>
{
}
public abstract class PeisDomainEfTestBase : PeisTestBase<PeisEntityFrameworkCoreTestModule>
{
}
Loading…
Cancel
Save