157 lines
6.0 KiB
C#
157 lines
6.0 KiB
C#
using AutoMapper;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using VOL.Business.IRepositories;
|
|
using VOL.Business.IServices;
|
|
using VOL.Business.Repositories;
|
|
using VOL.Core.CacheManager;
|
|
using VOL.Core.Extensions;
|
|
using VOL.Core.Extensions.AutofacManager;
|
|
using VOL.Core.ManageUser;
|
|
using VOL.Core.Utilities;
|
|
using VOL.Entity.DomainModels;
|
|
using VOL.Entity.Enum;
|
|
using VOL.Model;
|
|
using VOL.Model.Ai;
|
|
using VOL.Model.HomeWork;
|
|
using VOL.Model.Norm.Request;
|
|
using VOL.Model.Norm.Response;
|
|
using VOL.System.IRepositories;
|
|
using VOL.System.Repositories;
|
|
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
|
|
|
|
namespace VOL.Business.Services.Norm
|
|
{
|
|
public class S_HomeWorkService : IS_HomeWorkService, IDependency
|
|
{
|
|
#region 初始化
|
|
private readonly IMapper _mapper;
|
|
private readonly IS_HomeWorkRepository _homeWorkRepository;
|
|
private readonly IS_SubmittedAssignmentsRepository _submittedAssignmentsRepository;
|
|
private readonly S_HomeWorkStudentsRepository _homeWorkStudentsRepository;
|
|
|
|
[ActivatorUtilitiesConstructor]
|
|
public S_HomeWorkService(IMapper mapper,
|
|
IS_HomeWorkRepository homeWorkRepository, IS_SubmittedAssignmentsRepository submittedAssignmentsRepository, S_HomeWorkStudentsRepository homeWorkStudentsRepository)
|
|
{
|
|
_mapper = mapper;
|
|
_homeWorkRepository = homeWorkRepository;
|
|
_submittedAssignmentsRepository = submittedAssignmentsRepository;
|
|
_homeWorkStudentsRepository = homeWorkStudentsRepository;
|
|
}
|
|
|
|
#endregion
|
|
|
|
public async Task<PageDataDto<HomeWorkListModel>> GetHomeWorkPageList(HomeWorkPageListParam paramDto)
|
|
{
|
|
var res = new PageDataDto<HomeWorkListModel>();
|
|
|
|
var query = from s in _homeWorkRepository.FindAsIQueryable(x => x.SchoolCode.Equals(UserContext.Current.TenantId))
|
|
select new HomeWorkListModel()
|
|
{
|
|
WorkId = s.Id,
|
|
TeacherId = s.TeacherId,
|
|
StudentScope = s.StudentScope,
|
|
WorkStatus = s.WorkStatus,
|
|
TeacherName = s.TeacherName,
|
|
WorkName = s.WorkName,
|
|
WorkText = s.WorkText,
|
|
WorkType = s.WorkType,
|
|
StartTime = s.StartTime,
|
|
EndTime = s.EndTime,
|
|
StudentScopeStr = s.StudentScope.GetDescription(),
|
|
WorkStatusStr = s.WorkStatus.GetDescription(),
|
|
WorkTypeStr = s.WorkType.GetDescription()
|
|
};
|
|
|
|
if (paramDto.WorkType > 0)
|
|
{
|
|
query = query.Where(x => x.WorkType == paramDto.WorkType);
|
|
}
|
|
|
|
if (paramDto.StudentScope > 0)
|
|
{
|
|
query = query.Where(x => x.StudentScope == paramDto.StudentScope);
|
|
}
|
|
|
|
if (paramDto.WorkStatus > 0)
|
|
{
|
|
query = query.Where(x => x.WorkStatus == paramDto.WorkStatus);
|
|
}
|
|
|
|
if (paramDto.StartTime.HasValue)
|
|
{
|
|
DateTime detectionDate = paramDto.StartTime.Value.Date;
|
|
query = query.Where(x => x.StartTime.HasValue && x.StartTime.Value.Date >= detectionDate);
|
|
}
|
|
|
|
if (paramDto.EndTime.HasValue)
|
|
{
|
|
DateTime detectionDate = paramDto.EndTime.Value.Date;
|
|
query = query.Where(x => x.EndTime.HasValue && x.EndTime.Value.Date < detectionDate);
|
|
}
|
|
|
|
res.Total = await query.CountAsync();
|
|
|
|
var list = await query
|
|
.Skip((paramDto.PageIndex - 1) * paramDto.PageSize)
|
|
.Take(paramDto.PageSize)
|
|
.ToListAsync();
|
|
res.Datas = list;
|
|
|
|
return res;
|
|
}
|
|
|
|
public async Task<PageDataDto<HomeWorkStudentsModel>> GetHomeWorkStudents(HomeWorkStudentsParam paramDto)
|
|
{
|
|
var res = new PageDataDto<HomeWorkStudentsModel>();
|
|
|
|
var query = from s in _homeWorkStudentsRepository.FindAsIQueryable(x => x.SchoolCode.Equals(UserContext.Current.TenantId) && x.HomeWorkId == paramDto.HomeWorkId)
|
|
select new HomeWorkStudentsModel()
|
|
{
|
|
WorkId = s.HomeWorkId,
|
|
StudentNo = s.StudentNo,
|
|
StudentName = s.StudentName,
|
|
Photo = s.Photo,
|
|
WorkStatus = s.WorkStatus,
|
|
WorkStatusStr = s.WorkStatus.GetDescription()
|
|
};
|
|
|
|
res.Total = await query.CountAsync();
|
|
|
|
var list = await query
|
|
.Skip((paramDto.PageIndex - 1) * paramDto.PageSize)
|
|
.Take(paramDto.PageSize)
|
|
.ToListAsync();
|
|
res.Datas = list;
|
|
|
|
return res;
|
|
}
|
|
|
|
public async Task<List<SubmittedAssignmentsModel>> GetSubmittedAssignments(int homeWorkId, string studentNo)
|
|
{
|
|
var res = await _submittedAssignmentsRepository
|
|
.FindAsIQueryable(x => x.SchoolCode.Equals(UserContext.Current.TenantId) &&
|
|
x.HomeWorkId == homeWorkId &&
|
|
x.StudentNo == studentNo)
|
|
.Select(x => new SubmittedAssignmentsModel()
|
|
{
|
|
HomeWorkId = x.HomeWorkId,
|
|
StudentNo = x.StudentNo,
|
|
FileName = x.FileName,
|
|
FilePath = x.FilePath,
|
|
FileSize = x.FileSize,
|
|
FileType = x.FileType
|
|
}).ToListAsync();
|
|
|
|
return res;
|
|
}
|
|
}
|
|
} |