This commit is contained in:
tanglong 2025-07-29 11:24:17 +08:00
parent 7f681c37df
commit 0d8a8d43f8
3 changed files with 23 additions and 14 deletions

View File

@ -142,12 +142,16 @@ namespace YD_WeChatApplet.Api.Services.Impl
var paidCourses = await _sportsContext.CurricularPurchaseRecord.Where(x => x.UserId == userId).ToListAsync(); 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() var purchasedIds = paidCourses.Select(x => x.TaxonomyId).ToHashSet();
{
Id = x.Id, var res = await _sportsContext.CurricularTaxonomy
Name = x.TaxonomyName, .Where(x => x.CurricularType == 2)
IsPurchase = paidCourses.Any(x => x.TaxonomyId == x.Id) .Select(x => new PaidCoursesListDto
}).ToListAsync(); {
Id = x.Id,
Name = x.TaxonomyName,
IsPurchase = purchasedIds.Contains(x.Id)
}).ToListAsync();
return res; return res;
} }
@ -162,12 +166,14 @@ namespace YD_WeChatApplet.Api.Services.Impl
var paidCourses = await _sportsContext.CurricularTaxonomy.Where(x => x.CurricularType == 2).ToListAsync(); var paidCourses = await _sportsContext.CurricularTaxonomy.Where(x => x.CurricularType == 2).ToListAsync();
var userId = UserLoginContext.Current.UserId;
foreach (var paidCourse in paidCourses) foreach (var paidCourse in paidCourses)
{ {
paidCoursesList.Add(new Y_CurricularPurchaseRecord() paidCoursesList.Add(new Y_CurricularPurchaseRecord()
{ {
TaxonomyId = paidCourse.Id, TaxonomyId = paidCourse.Id,
UserId = UserLoginContext.Current.UserId, UserId = userId,
RedeemCode = redeemCode, RedeemCode = redeemCode,
Remarks = "", Remarks = "",
CreateDate = DateTime.Now CreateDate = DateTime.Now

View File

@ -6,6 +6,9 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace YD_WeChatApplet.Api.SmartSportsEntitys namespace YD_WeChatApplet.Api.SmartSportsEntitys
{ {
/// <summary>
/// 课程购买记录表
/// </summary>
[Table("Y_CurricularPurchaseRecord")] [Table("Y_CurricularPurchaseRecord")]
public class Y_CurricularPurchaseRecord public class Y_CurricularPurchaseRecord
{ {

View File

@ -281,13 +281,13 @@ namespace YD_WeChatApplet
//配置HttpContext //配置HttpContext
app.UseStaticHttpContext(); app.UseStaticHttpContext();
//app.UseSwagger(); app.UseSwagger();
//app.UseSwaggerUI(c => app.UseSwaggerUI(c =>
//{ {
// //2个下拉框选项 选择对应的文档 //2个下拉框选项 选择对应的文档
// c.SwaggerEndpoint("/swagger/v1/swagger.json", "YD_WeChatApplet.Api"); c.SwaggerEndpoint("/swagger/v1/swagger.json", "YD_WeChatApplet.Api");
// c.RoutePrefix = ""; c.RoutePrefix = "";
//}); });
app.UseRouting(); app.UseRouting();
app.UseCors(); app.UseCors();