using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Volo.Abp.Caching; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Domain; using Win_in.Sfs.Basedata.Domain.Shared; namespace Win_in.Sfs.Basedata.Application; [Authorize] [Route($"{BasedataConsts.RootPath}purchase-price-sheet")] public class PurchasePriceSheetAppService : SfsBaseDataAppServiceBase, IPurchasePriceSheetAppService { private readonly IPurchasePriceSheetRepository _repository; public PurchasePriceSheetAppService(IPurchasePriceSheetRepository repository, IDistributedCache cache) : base(repository, cache) { _repository = repository; base.CreatePolicyName = PurchasePriceSheetPermissions.Create; base.UpdatePolicyName = PurchasePriceSheetPermissions.Update; base.DeletePolicyName = PurchasePriceSheetPermissions.Delete; } /// /// 根据供应零件号查询 /// /// /// /// [HttpGet("by-item-code")] public virtual async Task GetByItemCodeAsync(string itemCode,string supplierCode) { var entity = await _repository.FindAsync(p => p.ItemCode== itemCode&&p.SupplierCode== supplierCode).ConfigureAwait(false); var dto = ObjectMapper.Map(entity); return dto; } [HttpPost("upsert-interface")] public virtual async Task UpsertAsyncByInterface(PurchasePriceSheetEditInput input) { var entity = ObjectMapper.Map(input); await _repository.UpsertAsyncByInterface(entity).ConfigureAwait(false); } /// /// 判断是否有采购价格 /// /// [HttpPost("check-purprice")] public virtual async Task CheckPurPriceAsync( string supplierCode, string itemCode) { bool result = false; var entitys = await _repository.GetListAsync(p => p.SupplierCode == supplierCode && p.ItemCode == itemCode).ConfigureAwait(false); if (entitys.Count == 0) result = true; return result; } }