From 657d76d97654545db9429de4b807809d6ab0eb43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?old=E6=98=93?= <156663459@qq.com> Date: Wed, 20 Sep 2023 10:12:38 +0800 Subject: [PATCH] =?UTF-8?q?--=E5=85=B3=E8=81=94=E9=99=A2=E6=A0=A1=20bug=20?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- New_College.Api/New_College.Model.xml | 2 +- New_College.Model/Models/D_University.cs | 2 +- .../ViewModels/Query/MajorQuery.cs | 4 +- New_College.Services/D_LongIdMapServices.cs | 49 ++++++++++++------- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/New_College.Api/New_College.Model.xml b/New_College.Api/New_College.Model.xml index 6afac3c..cc2c6c8 100644 --- a/New_College.Api/New_College.Model.xml +++ b/New_College.Api/New_College.Model.xml @@ -542,7 +542,7 @@ - 办学性质 1、公办,2、民办,3中外合作,4 港澳台 + 办学性质 0、公办,1、民办,2中外合作,3 港澳台 diff --git a/New_College.Model/Models/D_University.cs b/New_College.Model/Models/D_University.cs index 7df8d22..4cf863d 100644 --- a/New_College.Model/Models/D_University.cs +++ b/New_College.Model/Models/D_University.cs @@ -35,7 +35,7 @@ namespace New_College.Model.Models public string Build_Date { get; set; } /// - /// 办学性质 1、公办,2、民办,3中外合作,4 港澳台 + /// 办学性质 0、公办,1、民办,2中外合作,3 港澳台 /// [SugarColumn(IsNullable = true)] public int Nature { get; set; } diff --git a/New_College.Model/ViewModels/Query/MajorQuery.cs b/New_College.Model/ViewModels/Query/MajorQuery.cs index ce1fcf8..00d5571 100644 --- a/New_College.Model/ViewModels/Query/MajorQuery.cs +++ b/New_College.Model/ViewModels/Query/MajorQuery.cs @@ -28,7 +28,7 @@ namespace New_College.Model.ViewModels /// /// 办学性质 /// - public int Nature { get; set; } = 1; + public int Nature { get; set; } = -1; /// /// 学校类型 @@ -121,7 +121,7 @@ namespace New_College.Model.ViewModels /// public string SubjectClaim { get; set; } - + /// /// 高考年份 diff --git a/New_College.Services/D_LongIdMapServices.cs b/New_College.Services/D_LongIdMapServices.cs index aeb5e9f..0a43ee3 100644 --- a/New_College.Services/D_LongIdMapServices.cs +++ b/New_College.Services/D_LongIdMapServices.cs @@ -17,7 +17,8 @@ using New_College.Common.Helper; using New_College.Common; using New_College.Common.HttpRestSharp; using System.Text; - +using SqlSugar; +using System.Linq.Expressions; namespace New_College.Services { @@ -168,7 +169,7 @@ namespace New_College.Services { var majorcategories = (await d_MajorCategoryRepository.Query(x => x.Type == query.SchoolLevel && x.IsDelete == false)).Select(x => new uniMajorSelect() { Id = x.Id, Name = x.Name }); ; var majorclasses = (await d_MajorClassRepository.Query(x => x.IsDelete == false)).Select(x => new uniMajorClassSelect() { Id = x.Id, Name = x.Name, TradeId = x.TradeId }); - var majorinfo = (await d_MajorRepository.Query(x => x.IsDelete == false&&x.Type!=3)).Select(s => new uniMajorSelect() { Id = s.CategoryClass_Id, Name = s.Name }).ToList(); + var majorinfo = (await d_MajorRepository.Query(x => x.IsDelete == false && x.Type != 3)).Select(s => new uniMajorSelect() { Id = s.CategoryClass_Id, Name = s.Name }).ToList(); List list = new List() { }; foreach (var item in majorcategories) { @@ -395,23 +396,35 @@ namespace New_College.Services if (majorinfo.Count <= 0) return new PageModel() { }; var universityids = majorinfo.Select(x => x.Universityid).ToList(); - var wheres = PredicateBuilder.New(); - wheres = wheres.And(x => x.IsDelete == false && universityids.Contains(x.Id)); - if (!string.IsNullOrEmpty(query.AreaName) && query.AreaName != "全国") - wheres = wheres.And(x => x.Area_Name.Contains(query.AreaName)); - if (query.SubjectLevel > 0) - wheres = wheres.And(x => x.Subject_Level == query.SubjectLevel); - if (query.Type >= 0) - wheres = wheres.And(x => x.Type == query.Type); - if (query.Nhef >= 0) - wheres = wheres.And(x => x.Nhef == query.Nhef); - if (query.Sff >= 0) - wheres = wheres.And(x => x.Sff == query.Sff); - if (query.Syl >= 0) - wheres = wheres.And(x => x.Syl == query.Syl); - wheres = wheres.And(x => x.Nature == query.Nature); + //var wheres = PredicateBuilder.New(); + //wheres = wheres.And(x => x.IsDelete == false && universityids.Contains(x.Id)); - var info = await d_UniversityRepository.QueryPage(wheres, query.PageIndex, query.PageSize, "Rank Asc"); + //if (query.SubjectLevel > 0) + // wheres = wheres.And(x => x.Subject_Level == query.SubjectLevel); + //if (query.Type >= 0) + // wheres = wheres.And(x => x.Type == query.Type); + //if (query.Nhef >= 0) + // wheres = wheres.And(x => x.Nhef == query.Nhef); + //if (query.Sff >= 0) + // wheres = wheres.And(x => x.Sff == query.Sff); + //if (query.Syl >= 0) + // wheres = wheres.And(x => x.Syl == query.Syl); + //wheres = wheres.And(x => x.Nature == query.Nature); + + Expression> exp = Expressionable.Create() //创建表达式 + .AndIF(!string.IsNullOrEmpty(query.AreaName) && query.AreaName != "全国", x => x.Area_Name.Contains(query.AreaName)) + .And(x => x.IsDelete == false && universityids.Contains(x.Id)) + .AndIF(query.SubjectLevel > 0, x => x.Subject_Level == query.SubjectLevel) + .AndIF(query.Type >= 0, x => x.Type == query.Type) + .AndIF(query.Nhef >= 0, x => x.Nhef == query.Nhef) + .AndIF(query.Sff >= 0, x => x.Sff == query.Sff) + .AndIF(query.Syl >= 0, x => x.Syl == query.Syl) + .AndIF(query.Nature >= 0, x => x.Nature == query.Nature) + .ToExpression();//注意 这一句 不能少 + + // var templist = await d_UniversityRepository.Query(c => universityids.Contains(c.Id)); + + var info = await d_UniversityRepository.QueryPage(exp, query.PageIndex, query.PageSize, "Rank Asc"); if (info.data.Count() <= 0) return new PageModel() { }; List list = new List() { };