50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using MiAssessment.Core.Interfaces;
|
|
using MiAssessment.Model.Data;
|
|
using MiAssessment.Model.Models.Team;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace MiAssessment.Core.Services;
|
|
|
|
/// <summary>
|
|
/// 团队服务实现
|
|
/// </summary>
|
|
public class TeamService : ITeamService
|
|
{
|
|
private readonly MiAssessmentDbContext _dbContext;
|
|
private readonly ILogger<TeamService> _logger;
|
|
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="dbContext">数据库上下文</param>
|
|
/// <param name="logger">日志记录器</param>
|
|
public TeamService(
|
|
MiAssessmentDbContext dbContext,
|
|
ILogger<TeamService> logger)
|
|
{
|
|
_dbContext = dbContext;
|
|
_logger = logger;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async Task<TeamInfoDto> GetInfoAsync()
|
|
{
|
|
_logger.LogDebug("获取团队介绍信息");
|
|
|
|
var images = await _dbContext.Promotions
|
|
.AsNoTracking()
|
|
.Where(p => p.Position == 2 && p.Status == 1 && !p.IsDeleted)
|
|
.OrderByDescending(p => p.Sort)
|
|
.Select(p => p.ImageUrl)
|
|
.ToListAsync();
|
|
|
|
_logger.LogDebug("获取到 {Count} 张团队介绍图片", images.Count);
|
|
|
|
return new TeamInfoDto
|
|
{
|
|
Images = images
|
|
};
|
|
}
|
|
}
|