fix 移除离线时参数校验
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
|
||||
namespace Dlhis.Middle.Request;
|
||||
|
||||
public class OrderAddRequest : IValidatableObject
|
||||
public class OrderAddRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否离线数据
|
||||
@@ -24,19 +22,13 @@ public class OrderAddRequest : IValidatableObject
|
||||
/// <summary>
|
||||
/// 档案号/QrCode/学工号
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "人员档案号/QrCode/学工号/userId 不能为空")]
|
||||
public string UserUniqueNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来源
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(BalanceRecordSourceEnumType))]
|
||||
public BalanceRecordSourceEnumType Source { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 金额
|
||||
/// </summary>
|
||||
[Range(0.01, double.MaxValue)]
|
||||
public decimal Amount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -44,20 +36,5 @@ public class OrderAddRequest : IValidatableObject
|
||||
/// </summary>
|
||||
public DateTime? CostDateTime { get; set; }
|
||||
|
||||
|
||||
public string Image { get; set; }
|
||||
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
//处理金额
|
||||
Amount = -Math.Abs(Amount);
|
||||
|
||||
CostDateTime ??= DateTime.Now;
|
||||
|
||||
if (DeviceUniqueNo.IsEmpty())
|
||||
{
|
||||
yield return new ValidationResult("设备号不能为空", new[] { nameof(DeviceUniqueNo) });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class RemoteOrderService : IRemoteOrderService
|
||||
|
||||
var content = new StringContent(request.ToJson(), Encoding.UTF8, "application/json");
|
||||
|
||||
var response = await httpClient.PostAsync($"https://{_hostName}/api/Canteen/Orders/device", content);
|
||||
var response = await httpClient.PostAsync($"https://{_hostName}/api/canteen/orders", content);
|
||||
|
||||
var responseJson = await response.Content.ReadAsStringAsync();
|
||||
return responseJson.ToObject<DefaultApiResult<OrderResultResponse>>();
|
||||
|
||||
Reference in New Issue
Block a user