15 changed files with 177 additions and 286 deletions
-
4src/Shentun.Peis.Application/Shentun.Peis.Application.csproj
-
40src/Shentun.Peis.Domain/GuideTypes/GuideTypeManager.cs
-
39src/Shentun.Peis.Domain/ItemTypes/ItemTypeManager.cs
-
8src/Shentun.Peis.Domain/Models/GuideType.cs
-
12src/Shentun.Peis.Domain/Models/ItemType.cs
-
77src/Shentun.Peis.Domain/Models/Pbcatcol.cs
-
41src/Shentun.Peis.Domain/Models/Pbcatedt.cs
-
33src/Shentun.Peis.Domain/Models/Pbcatfmt.cs
-
87src/Shentun.Peis.Domain/Models/Pbcattbl.cs
-
38src/Shentun.Peis.Domain/Models/Pbcatvld.cs
-
6src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/PeisDbContext.cs
-
5src/Shentun.Peis.EntityFrameworkCore/Shentun.Peis.EntityFrameworkCore.csproj
-
32test/Shentun.Peis.Domain.Tests/GuideTypeManagerTest.cs
-
32test/Shentun.Peis.Domain.Tests/ItemTypeManagerTest.cs
-
9test/Shentun.Peis.Domain.Tests/PeisDomainTestBase.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 |
|||
|
|||
); |
|||
} |
|||
} |
|||
} |
|||
@ -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 |
|||
|
|||
); |
|||
} |
|||
} |
|||
} |
|||
@ -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 };
|
|||
//}
|
|||
} |
|||
} |
|||
@ -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 };
|
|||
//}
|
|||
} |
|||
} |
|||
@ -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 };
|
|||
//}
|
|||
} |
|||
} |
|||
@ -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 };
|
|||
//}
|
|||
} |
|||
} |
|||
@ -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 };
|
|||
//}
|
|||
} |
|||
} |
|||
@ -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()); |
|||
} |
|||
} |
|||
} |
|||
@ -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); |
|||
} |
|||
} |
|||
} |
|||
@ -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> |
|||
{ |
|||
|
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue