add: 师傅实体和服务类型
This commit is contained in:
		| @ -15,5 +15,6 @@ public class AdminApplicationAutoMapperProfile : Profile | ||||
|         CreateMap<Order, OrderDto>(); | ||||
|         //CreateMap<CreateOrderDto, Order>(); | ||||
|         CreateMap<AddressDto, AddressInfo>(); | ||||
|         CreateMap<ServiceCategoryDto, ServiceCategory>(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -78,7 +78,7 @@ namespace KonSoft.Admin.ApplicationServices | ||||
|             // 生成订单号 TODO | ||||
|             var orderSN = "SN001"; | ||||
|             var address = ObjectMapper.Map<AddressDto, AddressInfo>(input.Address); | ||||
|             var order = new Order(Guid.NewGuid(), orderSN, input.CustomerId, input.ServiceId, input.ServiceTime, input.Amount, address, input.Remark); | ||||
|             var order = new Order(Guid.NewGuid(), orderSN, input.CustomerId, input.ServiceCategoryId, input.ServiceTime, input.Amount, address, input.Remark); | ||||
|  | ||||
|             await _orderRepository.InsertAsync(order); | ||||
|             return ObjectMapper.Map<Order, OrderDto>(order); | ||||
|  | ||||
| @ -0,0 +1,75 @@ | ||||
| using KonSoft.Admin.Dtos; | ||||
| using KonSoft.Admin.Entities; | ||||
| using KonSoft.Admin.IApplicationServices; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
| using Volo.Abp.Application.Services; | ||||
| using Volo.Abp.Domain.Repositories; | ||||
|  | ||||
| namespace KonSoft.Admin.ApplicationServices | ||||
| { | ||||
|     public class ServiceCategoryAppService : ApplicationService, IServiceCategoryAppService | ||||
|     { | ||||
|         private readonly IRepository<ServiceCategory, Guid> _repository; | ||||
|  | ||||
|  | ||||
|         public ServiceCategoryAppService(IRepository<ServiceCategory, Guid> repository) | ||||
|         { | ||||
|             _repository = repository; | ||||
|         } | ||||
|  | ||||
|         public async Task<ServiceCategoryDto> CreateAsync(CreateServiceCategoryDto input) | ||||
|         { | ||||
|             ServiceCategory parent = null; | ||||
|             if (input.ParentId.HasValue) | ||||
|             { | ||||
|                 parent = await _repository.GetAsync(input.ParentId.Value); | ||||
|             } | ||||
|  | ||||
|             var category = new ServiceCategory(Guid.NewGuid(), input.Name); | ||||
|             category.SetParent(parent); | ||||
|  | ||||
|  | ||||
|             await _repository.InsertAsync(category); | ||||
|  | ||||
|  | ||||
|             return ObjectMapper.Map<ServiceCategory, ServiceCategoryDto>(category); | ||||
|         } | ||||
|  | ||||
|         public async Task DeleteAsync(Guid id) | ||||
|         { | ||||
|             var hasChildren = await _repository.AnyAsync(c => c.ParentId == id); | ||||
|             if (hasChildren) throw new InvalidOperationException("存在子节点无法删除!"); | ||||
|  | ||||
|  | ||||
|             await _repository.DeleteAsync(o => o.Id == id); | ||||
|         } | ||||
|  | ||||
|         public async Task<List<ServiceCategoryDto>> GetTreeAsync() | ||||
|         { | ||||
|             var allCategories = await _repository.GetListAsync(); | ||||
|  | ||||
|             // 构建树 | ||||
|             var lookup = allCategories.ToDictionary(c => c.Id, c => ObjectMapper.Map<ServiceCategory, ServiceCategoryDto>(c)); | ||||
|             var rootList = new List<ServiceCategoryDto>(); | ||||
|  | ||||
|  | ||||
|             foreach (var dto in lookup.Values) | ||||
|             { | ||||
|                 if (dto.ParentId.HasValue && lookup.ContainsKey(dto.ParentId.Value)) | ||||
|                 { | ||||
|                     lookup[dto.ParentId.Value].Children.Add(dto); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     rootList.Add(dto); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return rootList.OrderBy(c => c.Name).ToList(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,20 @@ | ||||
| using KonSoft.Admin.Dtos; | ||||
| using KonSoft.Admin.Entities; | ||||
| using KonSoft.Admin.IApplicationServices; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
| using Volo.Abp.Application.Services; | ||||
| using Volo.Abp.Domain.Repositories; | ||||
|  | ||||
| namespace KonSoft.Admin.ApplicationServices | ||||
| { | ||||
|     public class WorkerAppService : CrudAppService<Worker, WorkerDto, Guid>, IWorkerAppService | ||||
|     { | ||||
|         public WorkerAppService(IRepository<Worker, Guid> repository) : base(repository) | ||||
|         { | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,27 @@ | ||||
| using KonSoft.Admin.Entities; | ||||
| using KonSoft.Admin.IApplicationServices; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
| using Volo.Abp.Application.Services; | ||||
| using Volo.Abp.Domain.Repositories; | ||||
|  | ||||
| namespace KonSoft.Admin.ApplicationServices | ||||
| { | ||||
|     /// <summary> | ||||
|     /// 分配家政人员 TODO | ||||
|     /// </summary> | ||||
|     public class WorkerAssignmentService : ApplicationService, IWorkerAssignmentService | ||||
|     { | ||||
|         private readonly IRepository<Worker, Guid> _workerRepository; | ||||
|         private readonly IRepository<Order, Guid> _orderRepository; | ||||
|  | ||||
|         public WorkerAssignmentService(IRepository<Worker, Guid> workerRepository, IRepository<Order, Guid> orderRepository) | ||||
|         { | ||||
|             _workerRepository = workerRepository; | ||||
|             _orderRepository = orderRepository; | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 于鹏
					于鹏