From 0d8a8d43f8562d3121e1e710e597ab182f7dc450 Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Tue, 29 Jul 2025 11:24:17 +0800 Subject: [PATCH] dd --- .../Services/Impl/ClientSideService.cs | 20 ++++++++++++------- .../Y_CurricularPurchaseRecord.cs | 3 +++ WeChatApplet/Startup.cs | 14 ++++++------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/WeChatApplet/Services/Impl/ClientSideService.cs b/WeChatApplet/Services/Impl/ClientSideService.cs index f216df8..f140e02 100644 --- a/WeChatApplet/Services/Impl/ClientSideService.cs +++ b/WeChatApplet/Services/Impl/ClientSideService.cs @@ -142,12 +142,16 @@ namespace YD_WeChatApplet.Api.Services.Impl var paidCourses = await _sportsContext.CurricularPurchaseRecord.Where(x => x.UserId == userId).ToListAsync(); - var res = await _sportsContext.CurricularTaxonomy.Where(x => x.CurricularType == 2).Select(x => new PaidCoursesListDto() - { - Id = x.Id, - Name = x.TaxonomyName, - IsPurchase = paidCourses.Any(x => x.TaxonomyId == x.Id) - }).ToListAsync(); + var purchasedIds = paidCourses.Select(x => x.TaxonomyId).ToHashSet(); + + var res = await _sportsContext.CurricularTaxonomy + .Where(x => x.CurricularType == 2) + .Select(x => new PaidCoursesListDto + { + Id = x.Id, + Name = x.TaxonomyName, + IsPurchase = purchasedIds.Contains(x.Id) + }).ToListAsync(); return res; } @@ -162,12 +166,14 @@ namespace YD_WeChatApplet.Api.Services.Impl var paidCourses = await _sportsContext.CurricularTaxonomy.Where(x => x.CurricularType == 2).ToListAsync(); + var userId = UserLoginContext.Current.UserId; + foreach (var paidCourse in paidCourses) { paidCoursesList.Add(new Y_CurricularPurchaseRecord() { TaxonomyId = paidCourse.Id, - UserId = UserLoginContext.Current.UserId, + UserId = userId, RedeemCode = redeemCode, Remarks = "", CreateDate = DateTime.Now diff --git a/WeChatApplet/SmartSportsEntitys/Y_CurricularPurchaseRecord.cs b/WeChatApplet/SmartSportsEntitys/Y_CurricularPurchaseRecord.cs index d47e2ff..41f5a33 100644 --- a/WeChatApplet/SmartSportsEntitys/Y_CurricularPurchaseRecord.cs +++ b/WeChatApplet/SmartSportsEntitys/Y_CurricularPurchaseRecord.cs @@ -6,6 +6,9 @@ using System.ComponentModel.DataAnnotations.Schema; namespace YD_WeChatApplet.Api.SmartSportsEntitys { + /// + /// 课程购买记录表 + /// [Table("Y_CurricularPurchaseRecord")] public class Y_CurricularPurchaseRecord { diff --git a/WeChatApplet/Startup.cs b/WeChatApplet/Startup.cs index 42e862b..d45cdc4 100644 --- a/WeChatApplet/Startup.cs +++ b/WeChatApplet/Startup.cs @@ -281,13 +281,13 @@ namespace YD_WeChatApplet //配置HttpContext app.UseStaticHttpContext(); - //app.UseSwagger(); - //app.UseSwaggerUI(c => - //{ - // //2个下拉框选项 选择对应的文档 - // c.SwaggerEndpoint("/swagger/v1/swagger.json", "YD_WeChatApplet.Api"); - // c.RoutePrefix = ""; - //}); + app.UseSwagger(); + app.UseSwaggerUI(c => + { + //2个下拉框选项 选择对应的文档 + c.SwaggerEndpoint("/swagger/v1/swagger.json", "YD_WeChatApplet.Api"); + c.RoutePrefix = ""; + }); app.UseRouting(); app.UseCors();