using Dlhis.Entity.Canteen.Enums; using Dlhis.Middle.Entities; using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; namespace Dlhis.Middle.Services.Implements; /// /// 餐饮配置 /// public class CanteenSettingService : ICanteenSettingService { private readonly IDbContext _context; public CanteenSettingService(IDbContext context) { _context = context; } public async Task> GetUserSettingAsync(string userNo, string tenantId) { var settings = await _context.Queryable() .Where(x => x.Enable) .Where(x => x.TenantId == tenantId) .Where(x => x.UniqueType == CanteenSettingUnqiueEnumType.Person && x.UniqueValue == userNo || x.UniqueType == CanteenSettingUnqiueEnumType.Tenant) .ToListAsync(); //从基地 -> 个人,确保下面循环做到覆盖,并且以个人配置为主 settings = settings.OrderBy(x => x.UniqueType).ToList(); var result = new Dictionary(); settings.ForEach(x => { result[x.Item] = x.Value; }); return result; } /// public async Task GetBusinessSwitchTimeAsync(string tenantId) { var setting = await _context.Queryable() .Where(x => x.Enable) .Where(x => x.TenantId == tenantId) .Where(x => x.Item == CanteenSettingItemEnumType.BusinessSwitchTime) .FirstAsync(); try { return TimeOnly.Parse(setting.Value); } catch (Exception) { return null; } } }