Merge branch 'development' of https://git.dlhis.com/liguoyang/jinko.yikatong into development

This commit is contained in:
cheche
2024-01-26 09:27:17 +08:00
10 changed files with 129 additions and 98 deletions

View File

@@ -50,7 +50,7 @@ public class SettingController : ControllerBase
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPut("enable")]
[HttpPost("enable")]
public async Task SetEnableAsync(CanteenSettingSetEnableRequest request)
{
await _settingService.SetEnableAsync(request);

View File

@@ -1,38 +1,48 @@
using System.ComponentModel.DataAnnotations;
using System;
using System.ComponentModel.DataAnnotations;
using Dlhis.Entity.Canteen.Enums;
using Kurisu.AspNetCore.Utils.Extensions;
using Org.BouncyCastle.Asn1.X509.SigI;
namespace Dlhis.Canteen.Setting.Request;
public class CanteenSettingSaveRequest
public class CanteenSettingSaveRequest : IValidatableObject
{
public long? Id { get; set; }
/// <summary>
/// 配置生效范围
/// 配置生效范围类型 CanteenSettingUnqiueEnumType
/// </summary>
[EnumDataType(typeof(CanteenSettingUnqiueEnumType))]
public CanteenSettingUnqiueEnumType UniqueType { get; set; }
/// <summary>
/// 唯一值 eg:UniqueType = 1时,传入非空字符串
/// 配置生效范围
/// </summary>
[Required(ErrorMessage = "值不能为空")]
public string UniqueValue { get; set; }
/// <summary>
/// 自定义分类分类
/// 自定义分类
/// </summary>
[Required(ErrorMessage = "分类不能为空")]
public string Catalog { get; set; }
/// <summary>
/// 参数 CanteenSettingItemEnumType
/// 就餐配置 CanteenSettingItemEnumType
/// </summary>
[EnumDataType(typeof(CanteenSettingItemEnumType))]
public CanteenSettingItemEnumType Item { get; set; }
/// <summary>
/// 值
/// 参数值
/// </summary>
public string Value { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (UniqueType != CanteenSettingUnqiueEnumType.Tenant && UniqueValue.IsEmpty())
{
yield return new ValidationResult($"配置{UniqueType.GetDescription()}值不能为空", new string[] { nameof(UniqueValue) });
}
}
}

View File

@@ -5,6 +5,9 @@ namespace Dlhis.Canteen.Setting.Response;
public class CanteenSettingResponse
{
public long Id { get; set; }
public CanteenSettingUnqiueEnumType UniqueType { get; set; }
public string UniqueTypeDesc => UniqueType.GetDescription();

View File

@@ -33,12 +33,12 @@ public class CanteenSettingService : ICanteenSettingService
.LeftJoin<CanteenUserEntity>((setting, user) => setting.UniqueValue == user.UserNo)
.WhereIF(request.UniqueType.HasValue, setting => setting.UniqueType == request.UniqueType)
.WhereIF(request.Item.HasValue, setting => setting.Item == request.Item)
.WhereIF(request.Search.IsPresent(), setting => setting.UniqueValue.Contains(request.Search))
.WhereIF(request.Search.IsPresent(), setting => setting.Catalog.Contains(request.Search))
.Select((setting, user) => new CanteenSettingResponse
{
Id = setting.Id,
UniqueType = setting.UniqueType,
UniqueValue = setting.UniqueValue,
//UniqueValueDesc = user.UserName,
Catalog = setting.Catalog,
Enable = setting.Enable,
Item = setting.Item,
@@ -90,7 +90,7 @@ public class CanteenSettingService : ICanteenSettingService
//bool
CanteenSettingItemEnumType.AllowSendAtMeal => IsValidFormat<bool>(value, request.Item),
CanteenSettingItemEnumType.AllowRepeatInOneShift => IsValidFormat<bool>(value,request.Item),
CanteenSettingItemEnumType.AllowRepeatInOneShift => IsValidFormat<bool>(value, request.Item),
CanteenSettingItemEnumType.AllowCrossTenant => IsValidFormat<bool>(value, request.Item),
_ => throw new NotImplementedException(),
};
@@ -177,15 +177,15 @@ public class CanteenSettingService : ICanteenSettingService
{
return false;
}
}
if(type == CanteenSettingItemEnumType.BusinessSwitchTime)
}
if (type == CanteenSettingItemEnumType.BusinessSwitchTime)
{
var timeOnly = value.Adapt<TimeOnly>();
return timeOnly.Minute == 0 && timeOnly.Second == 0;
}
//mapster
value.Adapt<T>();
value.Adapt<T>();
}
catch (Exception)
{
@@ -194,5 +194,5 @@ public class CanteenSettingService : ICanteenSettingService
return true;
}
}