From 836a9ca2258d92f27a749cb93fc12604dd420545 Mon Sep 17 00:00:00 2001 From: lingling <kety1122@163.com> Date: 星期三, 19 三月 2025 14:30:59 +0800 Subject: [PATCH] 添加filter --- LifePayment/LifePayment.Domain/Common/ChannelHelper.cs | 2 +- LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs | 6 +++--- LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs | 1 + LifePayment/LifePayment.Domain/Common/UserChannle.cs | 4 ++-- LifePayment/LifePayment.Domain/Common/ChannelFilter.cs | 38 +++++++++++++++++++++++++------------- 5 files changed, 32 insertions(+), 19 deletions(-) diff --git a/LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs b/LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs index ce5c054..4c7efd3 100644 --- a/LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs +++ b/LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs @@ -14,12 +14,12 @@ { public abstract class AbstractChannelFilter { - public abstract Task<IQueryable<TEntity>> GetPolicyFilter<TEntity, TKey>(IQueryable<TEntity> query) - where TEntity : class, IChannelData, IMayHaveCreator, IEntity<TKey>; + public abstract Task<IQueryable<ChannelsBase>> GetChannelFilter(IQueryable<ChannelsBase> query); + public IAbpLazyServiceProvider LazyServiceProvider { get; set; } protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetRequiredService<ICurrentUser>(); - protected IRepository<User> UserDepartmentRepository => LazyServiceProvider.LazyGetRequiredService<IRepository<User>>(); + protected IRepository<UserChannle> UserChannleRepository => LazyServiceProvider.LazyGetRequiredService<IRepository<UserChannle>>(); } } diff --git a/LifePayment/LifePayment.Domain/Common/ChannelFilter.cs b/LifePayment/LifePayment.Domain/Common/ChannelFilter.cs index 91ae58b..f4d0a5e 100644 --- a/LifePayment/LifePayment.Domain/Common/ChannelFilter.cs +++ b/LifePayment/LifePayment.Domain/Common/ChannelFilter.cs @@ -1,21 +1,33 @@ -锘縰sing System; +锘縰sing LifePayment.Application.Contracts; +using LifePayment.Domain; +using LifePayment.Domain.Models; +using Microsoft.EntityFrameworkCore; +using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Entities; +using Volo.Abp.Domain.Repositories; +using Z.EntityFramework.Plus; +using ZeroD.Util; namespace LifePayment.Domain.Common { - //public class ChannelFilter : AbstractChannelFilter - //{ - // public async Task<IQueryable<ChannelsBase>> GetPolicyFilter<ChannelsBase, TKey>(IQueryable<ChannelsBase> query) - // { - // throw new NotImplementedException(); - // } - //} + public class ChannelFilter : AbstractChannelFilter + { + public async override Task<IQueryable<ChannelsBase>> GetChannelFilter(IQueryable<ChannelsBase> query) + { + var queryUser = UserChannleRepository.Where(r => r.UserId == CurrentUser.Id).Select(s => s.ChannleId).ToList(); + var queryResult = query.Where(s => queryUser.Contains(s.ChannleId)); + return queryResult; + } + } - //public class ChannelsBase:IChannelFilter - //{ - // // public Guid ChannelId { get; set; } - //} + public class ChannelsBase : Entity<Guid> + { + public Guid ChannleId { get; set; } + + } } diff --git a/LifePayment/LifePayment.Domain/Common/ChannelHelper.cs b/LifePayment/LifePayment.Domain/Common/ChannelHelper.cs index bb7107a..cff865d 100644 --- a/LifePayment/LifePayment.Domain/Common/ChannelHelper.cs +++ b/LifePayment/LifePayment.Domain/Common/ChannelHelper.cs @@ -36,7 +36,7 @@ public interface IChannelData { - Guid ChannelId { get; set; } + public Guid ChannleId { get; set; } } public class ChannelFilterInput diff --git a/LifePayment/LifePayment.Domain/Common/UserChannle.cs b/LifePayment/LifePayment.Domain/Common/UserChannle.cs index b4b9c3d..770adbd 100644 --- a/LifePayment/LifePayment.Domain/Common/UserChannle.cs +++ b/LifePayment/LifePayment.Domain/Common/UserChannle.cs @@ -8,12 +8,12 @@ /// <summary> /// 鐢ㄦ埛Id /// </summary> - public virtual Guid UserId { get; set; } + public Guid UserId { get; set; } /// <summary> /// 娓犻亾Id /// </summary> - public virtual Guid ChannleId { get; set; } + public Guid ChannleId { get; set; } public virtual User User { get; set; } } } \ No newline at end of file diff --git a/LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs b/LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs index 73175b7..9759f0f 100644 --- a/LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs +++ b/LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs @@ -149,6 +149,7 @@ cacheOptions.KeyPrefix = "LifePaymentServices_"; cacheOptions.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromMinutes(20); }); + this.Configure<OssSettings>(configuration.GetSection("ossSettings")); this.Configure<ACOOLYOption>(configuration.GetSection("ACOOLY")); this.Configure<Config>("AliPayEcsign", configuration.GetSection("AliPayEcsign")); this.Configure<InformationOption>(configuration.GetSection("WeiXinCgi")); -- Gitblit v1.9.1