请求参数检查

usertest
嵇文龙 6 months ago
parent 51886aaf15
commit c8ff2a9c56

@ -1,6 +1,5 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Data; using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface; using DS.WMS.Core.Fee.Interface;
@ -20,7 +19,6 @@ namespace DS.WMS.FeeApi.Controllers
/// 构造函数 /// 构造函数
/// </summary> /// </summary>
/// <param name="feeService"></param> /// <param name="feeService"></param>
/// <param name="flowService"></param>
public FeeRecordController(IFeeRecordService feeService) public FeeRecordController(IFeeRecordService feeService)
{ {
_feeService = feeService; _feeService = feeService;
@ -65,7 +63,7 @@ namespace DS.WMS.FeeApi.Controllers
[HttpPost, Route("Submit")] [HttpPost, Route("Submit")]
public async Task<DataResult> SubmitAsync([FromBody] FeeRecordSubmit recordSubmit) public async Task<DataResult> SubmitAsync([FromBody] FeeRecordSubmit recordSubmit)
{ {
if (recordSubmit == null || recordSubmit.Items.IsNullOrEmpty()) if (recordSubmit == null || recordSubmit.Items == null)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest); return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
if (recordSubmit.Items.Any(x => x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission)) if (recordSubmit.Items.Any(x => x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission))
@ -88,7 +86,7 @@ namespace DS.WMS.FeeApi.Controllers
[HttpPost, Route("CreateByTemplate")] [HttpPost, Route("CreateByTemplate")]
public async Task<DataResult> CreateByTemplateAsync([FromBody] FeeRecordByTemplate request) public async Task<DataResult> CreateByTemplateAsync([FromBody] FeeRecordByTemplate request)
{ {
if (request == null || request.TemplateIdList.Length == 0) if (request == null || request.TemplateIdList?.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest); return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _feeService.CreateByTemplateAsync(request.BusinessId, request.BusinessType, request.TemplateIdList); return await _feeService.CreateByTemplateAsync(request.BusinessId, request.BusinessType, request.TemplateIdList);
@ -102,7 +100,7 @@ namespace DS.WMS.FeeApi.Controllers
[HttpPost, Route("Delete")] [HttpPost, Route("Delete")]
public async Task<DataResult> DeleteAsync([FromBody] IdModel model) public async Task<DataResult> DeleteAsync([FromBody] IdModel model)
{ {
if (model == null || model.Ids.Length == 0) if (model == null || model.Ids?.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest); return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _feeService.DeleteAsync(model.Ids); return await _feeService.DeleteAsync(model.Ids);
@ -116,7 +114,7 @@ namespace DS.WMS.FeeApi.Controllers
[HttpPost, Route("ApplyAudit")] [HttpPost, Route("ApplyAudit")]
public async Task<DataResult> ApplyAuditAsync([FromBody] IdModel model) public async Task<DataResult> ApplyAuditAsync([FromBody] IdModel model)
{ {
if (model == null || model.Ids.Length == 0) if (model == null || model.Ids?.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest); return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _feeService.SubmitForApprovalAsync(FeeAuditType.ApplyAudit, model.Remark, model.Ids); return await _feeService.SubmitForApprovalAsync(FeeAuditType.ApplyAudit, model.Remark, model.Ids);
@ -130,7 +128,7 @@ namespace DS.WMS.FeeApi.Controllers
[HttpPost, Route("ApplyDeletion")] [HttpPost, Route("ApplyDeletion")]
public async Task<DataResult> ApplyDeletionAsync([FromBody] IdModel model) public async Task<DataResult> ApplyDeletionAsync([FromBody] IdModel model)
{ {
if (model == null || model.Ids.Length == 0) if (model == null || model.Ids?.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest); return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _feeService.SubmitForApprovalAsync(FeeAuditType.ApplyDeletion, model.Remark, model.Ids); return await _feeService.SubmitForApprovalAsync(FeeAuditType.ApplyDeletion, model.Remark, model.Ids);
@ -144,7 +142,7 @@ namespace DS.WMS.FeeApi.Controllers
[HttpPost, Route("ApplyModification")] [HttpPost, Route("ApplyModification")]
public async Task<DataResult> ApplyModificationAsync([FromBody] IEnumerable<FeeModification> items) public async Task<DataResult> ApplyModificationAsync([FromBody] IEnumerable<FeeModification> items)
{ {
if (items.IsNullOrEmpty()) if (items == null || !items.Any())
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest); return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _feeService.SubmitForModificationAsync(items); return await _feeService.SubmitForModificationAsync(items);
@ -158,7 +156,7 @@ namespace DS.WMS.FeeApi.Controllers
[HttpPost, Route("Withdraw")] [HttpPost, Route("Withdraw")]
public async Task<DataResult> WithdrawAsync([FromBody] IdModel model) public async Task<DataResult> WithdrawAsync([FromBody] IdModel model)
{ {
if (model == null || model.Ids.Length == 0) if (model == null || model.Ids?.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest); return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _feeService.WithdrawAsync(model.Ids); return await _feeService.WithdrawAsync(model.Ids);
@ -186,7 +184,7 @@ namespace DS.WMS.FeeApi.Controllers
[HttpPost, Route("GetPrintInfo")] [HttpPost, Route("GetPrintInfo")]
public async Task<DataResult<CostAccountingForm>> GetPrintInfoAsync(IdModel model) public async Task<DataResult<CostAccountingForm>> GetPrintInfoAsync(IdModel model)
{ {
if (model == null || model.Ids.Length == 0) if (model == null || model.Ids?.Length == 0)
return DataResult<CostAccountingForm>.Failed("参数无效", MultiLanguageConst.IllegalRequest); return DataResult<CostAccountingForm>.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _feeService.GetPrintInfoAsync((BusinessType)model.BusinessType, model.Ids); return await _feeService.GetPrintInfoAsync((BusinessType)model.BusinessType, model.Ids);
@ -200,7 +198,7 @@ namespace DS.WMS.FeeApi.Controllers
[HttpPost, Route("SetInvoiceEnabled")] [HttpPost, Route("SetInvoiceEnabled")]
public async Task<DataResult> SetInvoiceEnabledAsync(IdModel model) public async Task<DataResult> SetInvoiceEnabledAsync(IdModel model)
{ {
if (model == null || model.Ids.Length == 0) if (model == null || model.Ids?.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest); return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
bool enabled = Convert.ToBoolean(model.Value); bool enabled = Convert.ToBoolean(model.Value);

Loading…
Cancel
Save