|
@@ -1,15 +1,24 @@
|
|
|
-using Hotline.Application.Snapshot;
|
|
|
+using Hotline.Application.Orders;
|
|
|
+using Hotline.Application.Snapshot;
|
|
|
+using Hotline.File;
|
|
|
using Hotline.Orders;
|
|
|
using Hotline.Settings;
|
|
|
using Hotline.Share.Dtos;
|
|
|
using Hotline.Share.Dtos.Article;
|
|
|
+using Hotline.Share.Dtos.Order;
|
|
|
using Hotline.Share.Dtos.Settings;
|
|
|
using Hotline.Share.Dtos.Snapshot;
|
|
|
+using Hotline.Share.Enums.Order;
|
|
|
+using Hotline.Share.Enums.Snapshot;
|
|
|
+using Hotline.Share.Tools;
|
|
|
+using Hotline.Snapshot;
|
|
|
+using Hotline.Tools;
|
|
|
using Mapster;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
using System.Reflection;
|
|
|
+using XF.Domain.Exceptions;
|
|
|
using XF.Domain.Repository;
|
|
|
|
|
|
namespace Hotline.Api.Controllers.Snapshot;
|
|
@@ -22,12 +31,18 @@ public class SnapshotController : BaseController
|
|
|
private readonly IRepository<Order> _orderRepository;
|
|
|
private readonly ISnapshotApplication _snapshotApplication;
|
|
|
private readonly ISystemAreaDomainService _systemAreaDomainService;
|
|
|
+ private readonly IIndustryRepository _industryRepository;
|
|
|
+ private readonly IOrderDomainService _orderDomainService;
|
|
|
+ private readonly IFileRepository _fileRepository;
|
|
|
|
|
|
- public SnapshotController(IRepository<Order> orderRepository, ISnapshotApplication snapshotApplication, ISystemAreaDomainService systemAreaDomainService)
|
|
|
+ public SnapshotController(IRepository<Order> orderRepository, ISnapshotApplication snapshotApplication, ISystemAreaDomainService systemAreaDomainService, IIndustryRepository industryRepository, IOrderDomainService orderDomainService, IFileRepository fileRepository)
|
|
|
{
|
|
|
_orderRepository = orderRepository;
|
|
|
_snapshotApplication = snapshotApplication;
|
|
|
_systemAreaDomainService = systemAreaDomainService;
|
|
|
+ _industryRepository = industryRepository;
|
|
|
+ _orderDomainService = orderDomainService;
|
|
|
+ _fileRepository = fileRepository;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -50,6 +65,34 @@ public class SnapshotController : BaseController
|
|
|
public async Task<IndustryBaseOutDto> GetIndustryBaseAsync(string id)
|
|
|
=> await _snapshotApplication.GetIndustryBaseAsync(id, HttpContext.RequestAborted);
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 添加工单
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("order")]
|
|
|
+ public async Task<AddSnapshotOrderOutDto> AddOrderAsync([FromBody] AddSnapshotOrderInDto dto)
|
|
|
+ {
|
|
|
+ var order = dto.Adapt<Order>();
|
|
|
+ dto.ValidateObject();
|
|
|
+ var industry = await _industryRepository.GetAsync(dto.IndustryId, HttpContext.RequestAborted)
|
|
|
+ ?? throw UserFriendlyException.SameMessage("行业不存在:" + dto.IndustryId); ;
|
|
|
+ order.AcceptTypeCode = industry.AcceptTypeCode;
|
|
|
+ order.AcceptType = industry.AcceptType;
|
|
|
+ order.FromGender = EGender.Unknown;
|
|
|
+ if (industry.IndustryType == EIndustryType.Declare)
|
|
|
+ {
|
|
|
+ order.Title = dto.GetTitle(industry.IndustryType, industry.AcceptType);
|
|
|
+ order.Content = dto.GetContent(industry.IndustryType);
|
|
|
+ }
|
|
|
+ order.InitId();
|
|
|
+ await _orderDomainService.AddAsync(order);
|
|
|
+ if (dto.Files.NotNullOrEmpty())
|
|
|
+ order.FileJson = await _fileRepository.AddFileAsync(dto.Files, order.Id, HttpContext.RequestAborted);
|
|
|
+
|
|
|
+
|
|
|
+ return order.Adapt<AddSnapshotOrderOutDto>();
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 获取小程序公告列表
|
|
|
/// </summary>
|