Browse Source

[fix]如果发生错误,返回400

master
贾荣国Home 3 years ago
parent
commit
c8a755abd9
  1. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Parts/IPartAppService.cs
  2. 3
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/PurchaseOrders/IPurchaseOrderAppService.cs
  3. 3
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Receipts/IReceiptAppService.cs
  4. 3
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Suppliers/ISupplierAppService.cs
  5. 3
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/UnplannedReceipts/IUnplannedReceiptAppService.cs
  6. 1
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Win_in.Sfs.Scp.WebApi.Application.Contracts.csproj
  7. 6
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Parts/PartAppService.cs
  8. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/PurchaseOrders/PurchaseOrderAppService.cs
  9. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Receipts/ReceiptAppService.cs
  10. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Suppliers/SuppliersAppService.cs
  11. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/UnplannedReceipts/UnplannedReceiptAppService.cs
  12. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Validator.cs
  13. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.DbMigrator/Win_in.Sfs.Scp.WebApi.DbMigrator.csproj
  14. 2913
      WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Migrations/20220312074749_Update.Designer.cs
  15. 50
      WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Migrations/20220312074749_Update.cs
  16. 8
      WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Migrations/WebApiDbContextModelSnapshot.cs
  17. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/appsettings.json
  18. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TbPoDetailRepository.cs

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Parts/IPartAppService.cs

@ -1,4 +1,5 @@
using System; using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
@ -12,7 +13,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// </summary> /// </summary>
public interface IPartAppService : IReadOnlyAppService<PartDTO,Guid,RequestDTO> public interface IPartAppService : IReadOnlyAppService<PartDTO,Guid,RequestDTO>
{ {
Task<PartDTO> CreateAsync(PartCreateDto partCreateDTO); Task<ActionResult<PartDTO>> CreateAsync(PartCreateDto partCreateDTO);
} }

3
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/PurchaseOrders/IPurchaseOrderAppService.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Validation; using Volo.Abp.Validation;
@ -12,7 +13,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// </summary> /// </summary>
public interface IPurchaseOrderAppService : IReadOnlyAppService<PurchaseOrderDTO, Guid, RequestDTO> public interface IPurchaseOrderAppService : IReadOnlyAppService<PurchaseOrderDTO, Guid, RequestDTO>
{ {
Task<PurchaseOrderDTO> CreateAsync(PurchaseOrderCreateDTO poCreateDTO); Task<ActionResult<PurchaseOrderDTO>> CreateAsync(PurchaseOrderCreateDTO poCreateDTO);
} }

3
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Receipts/IReceiptAppService.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Validation; using Volo.Abp.Validation;
@ -8,6 +9,6 @@ namespace Win_in.Sfs.Scp.WebApi
{ {
public interface IReceiptAppService : IReadOnlyAppService<ReceiptDTO,Guid,RequestDTO> public interface IReceiptAppService : IReadOnlyAppService<ReceiptDTO,Guid,RequestDTO>
{ {
Task<ReceiptDTO> CreateAsync(ReceiptCreateDTO receiptCreateDTO); Task<ActionResult<ReceiptDTO>> CreateAsync(ReceiptCreateDTO receiptCreateDTO);
} }
} }

3
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Suppliers/ISupplierAppService.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Validation; using Volo.Abp.Validation;
@ -8,6 +9,6 @@ namespace Win_in.Sfs.Scp.WebApi
{ {
public interface ISupplierAppService : IReadOnlyAppService<SupplierDTO,Guid,RequestDTO> public interface ISupplierAppService : IReadOnlyAppService<SupplierDTO,Guid,RequestDTO>
{ {
Task<SupplierDTO> CreateAsync(SupplierCreateDTO supplierCreateDTO); Task<ActionResult<SupplierDTO>> CreateAsync(SupplierCreateDTO supplierCreateDTO);
} }
} }

3
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/UnplannedReceipts/IUnplannedReceiptAppService.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Validation; using Volo.Abp.Validation;
@ -8,6 +9,6 @@ namespace Win_in.Sfs.Scp.WebApi
{ {
public interface IUnplannedReceiptAppService : IReadOnlyAppService<UnplannedReceiptDTO,Guid,RequestDTO> public interface IUnplannedReceiptAppService : IReadOnlyAppService<UnplannedReceiptDTO,Guid,RequestDTO>
{ {
Task<UnplannedReceiptDTO> CreateAsync(UnplannedReceiptCreateDTO receiptCreateDTO); Task<ActionResult<UnplannedReceiptDTO>> CreateAsync(UnplannedReceiptCreateDTO receiptCreateDTO);
} }
} }

1
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Win_in.Sfs.Scp.WebApi.Application.Contracts.csproj

@ -17,6 +17,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Volo.Abp.FluentValidation" Version="4.4.2" /> <PackageReference Include="Volo.Abp.FluentValidation" Version="4.4.2" />
<PackageReference Include="Volo.Abp.ObjectExtending" Version="4.4.2" /> <PackageReference Include="Volo.Abp.ObjectExtending" Version="4.4.2" />

6
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Parts/PartAppService.cs

@ -71,7 +71,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("")] [Route("")]
public virtual async Task<PartDTO> CreateAsync(PartCreateDto partCreateDTO) public virtual async Task<ActionResult<PartDTO>> CreateAsync(PartCreateDto partCreateDTO)
{ {
var entity = ObjectMapper.Map<PartCreateDto, Part>(partCreateDTO); var entity = ObjectMapper.Map<PartCreateDto, Part>(partCreateDTO);
@ -91,9 +91,9 @@ namespace Win_in.Sfs.Scp.WebApi
var ret = await _partRepository.InsertAsync(entity); var ret = await _partRepository.InsertAsync(entity);
var dto = ObjectMapper.Map<Part, PartDTO>(ret); var dto = ObjectMapper.Map<Part, PartDTO>(ret);
return dto;
return dto.ErrorCode != 0 ? new BadRequestObjectResult(dto) : new OkObjectResult(dto);
} }
private async Task UpsertTaPartAsync(Part entity) private async Task UpsertTaPartAsync(Part entity)

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/PurchaseOrders/PurchaseOrderAppService.cs

@ -72,7 +72,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("")] [Route("")]
public virtual async Task<PurchaseOrderDTO> CreateAsync(PurchaseOrderCreateDTO poCreateDTO) public virtual async Task<ActionResult<PurchaseOrderDTO>> CreateAsync(PurchaseOrderCreateDTO poCreateDTO)
{ {
var entity = ObjectMapper.Map<PurchaseOrderCreateDTO, PurchaseOrder>(poCreateDTO); var entity = ObjectMapper.Map<PurchaseOrderCreateDTO, PurchaseOrder>(poCreateDTO);
@ -102,7 +102,7 @@ namespace Win_in.Sfs.Scp.WebApi
} }
var ret = await _purchaseOrderRepository.InsertAsync(entity); var ret = await _purchaseOrderRepository.InsertAsync(entity);
var dto = ObjectMapper.Map<PurchaseOrder, PurchaseOrderDTO>(ret); var dto = ObjectMapper.Map<PurchaseOrder, PurchaseOrderDTO>(ret);
return dto; return dto.ErrorCode != 0 ? new BadRequestObjectResult(dto) : new OkObjectResult(dto);
} }
private async Task UpsertTbPoAndTbPoDetailAsync(PurchaseOrder entity) private async Task UpsertTbPoAndTbPoDetailAsync(PurchaseOrder entity)

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Receipts/ReceiptAppService.cs

@ -76,7 +76,7 @@ namespace Win_in.Sfs.Scp.WebApi
[HttpPost] [HttpPost]
[Route("")] [Route("")]
public virtual async Task<ReceiptDTO> CreateAsync(ReceiptCreateDTO receiptCreateDTO) public virtual async Task<ActionResult<ReceiptDTO>> CreateAsync(ReceiptCreateDTO receiptCreateDTO)
{ {
var entity = ObjectMapper.Map<ReceiptCreateDTO, Receipt>(receiptCreateDTO); var entity = ObjectMapper.Map<ReceiptCreateDTO, Receipt>(receiptCreateDTO);
@ -97,7 +97,8 @@ namespace Win_in.Sfs.Scp.WebApi
var ret = await _receiptRepository.InsertAsync(entity); var ret = await _receiptRepository.InsertAsync(entity);
var dto = ObjectMapper.Map<Receipt, ReceiptDTO>(ret); var dto = ObjectMapper.Map<Receipt, ReceiptDTO>(ret);
return dto; return dto.ErrorCode != 0 ? new BadRequestObjectResult(dto) : new OkObjectResult(dto);
} }
private async Task UpsertTbReceiptAndTbReceiptDetailAsync(Receipt entity) private async Task UpsertTbReceiptAndTbReceiptDetailAsync(Receipt entity)

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Suppliers/SuppliersAppService.cs

@ -70,7 +70,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// <returns>供应商DTO(Supplier DTO)</returns> /// <returns>供应商DTO(Supplier DTO)</returns>
[HttpPost] [HttpPost]
[Route("")] [Route("")]
public virtual async Task<SupplierDTO> CreateAsync(SupplierCreateDTO supplierCreateDTO) public virtual async Task<ActionResult<SupplierDTO>> CreateAsync(SupplierCreateDTO supplierCreateDTO)
{ {
var entity = ObjectMapper.Map<SupplierCreateDTO, Supplier>(supplierCreateDTO); var entity = ObjectMapper.Map<SupplierCreateDTO, Supplier>(supplierCreateDTO);
@ -90,7 +90,8 @@ namespace Win_in.Sfs.Scp.WebApi
var ret = await _supplierRepository.InsertAsync(entity); var ret = await _supplierRepository.InsertAsync(entity);
var dto = ObjectMapper.Map<Supplier, SupplierDTO>(ret); var dto = ObjectMapper.Map<Supplier, SupplierDTO>(ret);
return dto; return dto.ErrorCode != 0 ? new BadRequestObjectResult(dto) : new OkObjectResult(dto);
} }
private async Task UpsertTaVenderAsync(Supplier entity) private async Task UpsertTaVenderAsync(Supplier entity)

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/UnplannedReceipts/UnplannedReceiptAppService.cs

@ -75,7 +75,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("")] [Route("")]
public virtual async Task<UnplannedReceiptDTO> CreateAsync(UnplannedReceiptCreateDTO receiptCreateDTO) public virtual async Task<ActionResult<UnplannedReceiptDTO>> CreateAsync(UnplannedReceiptCreateDTO receiptCreateDTO)
{ {
var entity = ObjectMapper.Map<UnplannedReceiptCreateDTO, UnplannedReceipt>(receiptCreateDTO); var entity = ObjectMapper.Map<UnplannedReceiptCreateDTO, UnplannedReceipt>(receiptCreateDTO);
@ -98,7 +98,8 @@ namespace Win_in.Sfs.Scp.WebApi
var ret = await _unplannedReceiptRepository.InsertAsync(entity); var ret = await _unplannedReceiptRepository.InsertAsync(entity);
var dto = ObjectMapper.Map<UnplannedReceipt, UnplannedReceiptDTO>(ret); var dto = ObjectMapper.Map<UnplannedReceipt, UnplannedReceiptDTO>(ret);
return dto; return dto.ErrorCode != 0 ? new BadRequestObjectResult(dto) : new OkObjectResult(dto);
} }
private async Task UpsertTbReceiptAndTbReceiptDetailAsync(UnplannedReceipt entity) private async Task UpsertTbReceiptAndTbReceiptDetailAsync(UnplannedReceipt entity)

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Validator.cs

@ -22,7 +22,7 @@ public static class Validator
{ {
if (!taVenderRepository.Any(p =>p.Site==site && p.VendId == supplierCode)) if (!taVenderRepository.Any(p =>p.Site==site && p.VendId == supplierCode))
{ {
throw new UserFriendlyException($"Wrong supplier code: '{supplierCode}' of Site : '{site}'"); throw new UserFriendlyException($"Wrong supplier code: [{supplierCode}] of Site: [{site}]");
} }
} }
} }

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.DbMigrator/Win_in.Sfs.Scp.WebApi.DbMigrator.csproj

@ -40,4 +40,6 @@
<None Remove="Logs\**" /> <None Remove="Logs\**" />
</ItemGroup> </ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project> </Project>

2913
WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Migrations/20220312074749_Update.Designer.cs

File diff suppressed because it is too large

50
WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Migrations/20220312074749_Update.cs

@ -0,0 +1,50 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win_in.Sfs.Scp.WebApi.Migrations
{
public partial class Update : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Address",
table: "WebApi_UnplannedReceipt",
type: "nvarchar(8)",
maxLength: 8,
nullable: true);
migrationBuilder.AlterColumn<decimal>(
name: "TaxRate",
table: "WebApi_PO",
type: "decimal(18,6)",
precision: 18,
scale: 6,
nullable: true,
oldClrType: typeof(decimal),
oldType: "decimal(18,6)",
oldPrecision: 18,
oldScale: 6);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Address",
table: "WebApi_UnplannedReceipt");
migrationBuilder.AlterColumn<decimal>(
name: "TaxRate",
table: "WebApi_PO",
type: "decimal(18,6)",
precision: 18,
scale: 6,
nullable: false,
defaultValue: 0m,
oldClrType: typeof(decimal),
oldType: "decimal(18,6)",
oldPrecision: 18,
oldScale: 6,
oldNullable: true);
}
}
}

8
WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Migrations/WebApiDbContextModelSnapshot.cs

@ -18,7 +18,7 @@ namespace Win_in.Sfs.Scp.WebApi.Migrations
modelBuilder modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.14") .HasAnnotation("ProductVersion", "5.0.15")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b => modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b =>
@ -2113,7 +2113,7 @@ namespace Win_in.Sfs.Scp.WebApi.Migrations
.HasMaxLength(64) .HasMaxLength(64)
.HasColumnType("nvarchar(64)"); .HasColumnType("nvarchar(64)");
b.Property<decimal>("TaxRate") b.Property<decimal?>("TaxRate")
.HasPrecision(18, 6) .HasPrecision(18, 6)
.HasColumnType("decimal(18,6)"); .HasColumnType("decimal(18,6)");
@ -2431,6 +2431,10 @@ namespace Win_in.Sfs.Scp.WebApi.Migrations
b.Property<Guid>("Id") b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Address")
.HasMaxLength(8)
.HasColumnType("nvarchar(8)");
b.Property<string>("Company") b.Property<string>("Company")
.IsRequired() .IsRequired()
.HasMaxLength(8) .HasMaxLength(8)

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/appsettings.json

@ -35,5 +35,5 @@
} }
}, },
"AlwaysAllowAuthorization": true, "AlwaysAllowAuthorization": true,
"ValidSites":"T8," "ValidSites": "T8,JZ1"
} }

2
WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TbPoDetailRepository.cs

@ -17,8 +17,6 @@ namespace Win_in.Sfs.Scp.v1.EntityFrameworkCore
{ {
TB_PO_DETAIL ret; TB_PO_DETAIL ret;
var dbSet = await GetDbSetAsync(); var dbSet = await GetDbSetAsync();
if(dbSet==null)
Console.WriteLine("11");
var current = await dbSet.FirstOrDefaultAsync(p => p.Site == tbPoDetail.Site var current = await dbSet.FirstOrDefaultAsync(p => p.Site == tbPoDetail.Site
&& p.PoBillNum == tbPoDetail.PoBillNum && p.PoBillNum == tbPoDetail.PoBillNum
&& p.PoLine ==tbPoDetail.PoLine); && p.PoLine ==tbPoDetail.PoLine);

Loading…
Cancel
Save