public class TagAppService : CurdAppServiceBase<Tag, TagDto, TagDto, long, GetAllTagInput, GetAllTagInput, CreateTagInput, CreateTagInput>, ITagAppService { ... }
配置AutoMapper
在CommonApplicationAutoMapperProfile中添加Tag的映射配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
public class CommonApplicationAutoMapperProfile : Profile { public CommonApplicationAutoMapperProfile() { /* You can configure your AutoMapper mapping configuration here. * Alternatively, you can split your mapping configurations * into multiple profile classes for a better organization. */ CreateMap<Tag.Tag, TagDto>();
public class CommonDbContext : AbpDbContext<CommonDbContext>, ICommonDbContext { /* Add DbSet for each Aggregate Root here. Example: * public DbSet<Question> Questions { get; set; } */ public DbSet<Tag.Tag> Tag { get; set; }
public static class CommonDbContextModelCreatingExtensions { public static void ConfigureCommon( this ModelBuilder builder) { Check.NotNull(builder, nameof(builder));
public static List<Tag> tags = new List<Tag>() { new Tag() { Title = "医术高明" }, new Tag() { Title = "救死扶伤" }, new Tag() { Title = "心地仁慈" }, new Tag() { Title = "百治百效" }, new Tag() { Title = "白衣天使" }, new Tag() { Title = "手到病除" }, new Tag() { Title = "妙手回春" }, };
在CommonServiceDataSeeder创建种子数据
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
public class CommonServiceDataSeeder : IDataSeedContributor, ITransientDependency { private readonly IRepository<Tag.Tag, long> _tagRepository;
public CommonServiceDataSeeder( IRepository<Tag.Tag, long> tagRepository) { _tagRepository = tagRepository;