课堂
This commit is contained in:
parent
c6551e5eab
commit
1e9fe3fb09
@ -91,10 +91,10 @@ namespace YD_WeChatApplet.Controllers
|
||||
/// <returns></returns>
|
||||
[HttpPost("RemoveUniqueIdentity")]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> RemoveUniqueIdentity(string userId)
|
||||
public async Task<bool> RemoveUniqueIdentity(string userId)
|
||||
{
|
||||
await _userService.RemoveUniqueIdentity(userId);
|
||||
return Ok("移除成功");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -326,58 +326,76 @@ namespace YD_WeChatApplet.Services
|
||||
{
|
||||
var res = new PageDataDto<ClassRoomRecordPageDto>();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dto.StudentNo))
|
||||
IQueryable<ClassRoomRecordPageDto> query;
|
||||
|
||||
// 如果传了学生学号,按学号查
|
||||
if (!string.IsNullOrWhiteSpace(dto.StudentNo))
|
||||
{
|
||||
var phoneNo = UserLoginContext.Current.PhoneNo;
|
||||
|
||||
var teacherId = await _sportsContext.Teacher.Where(x => x.TeacherPhoneNo == phoneNo).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
var query = from td in _sportsContext.Ai_ClassRoomRecord
|
||||
where td.TeacherId == teacherId
|
||||
select new ClassRoomRecordPageDto()
|
||||
{
|
||||
Id = td.Id,
|
||||
ClassId = td.ClassId,
|
||||
Name = td.Name,
|
||||
StartingEndingTime = $"{(td.StartTime.HasValue ? td.StartTime.Value.ToString("yyyy-MM-dd HH:mm") : string.Empty)}{(td.EndTime.HasValue ? " - " + td.EndTime.Value.ToString("yyyy-MM-dd HH:mm") : string.Empty)}"
|
||||
};
|
||||
|
||||
res.Total = await query.CountAsync();
|
||||
|
||||
var list = await query
|
||||
.OrderByDescending(c => c.Id)
|
||||
.Skip((dto.PageIndex - 1) * dto.PageSize)
|
||||
.Take(dto.PageSize)
|
||||
.ToListAsync();
|
||||
|
||||
res.Datas = list;
|
||||
query = from s in _sportsContext.Ai_ClassroomStudentRecord
|
||||
join c in _sportsContext.Ai_ClassRoomRecord on s.ClassRoomRecordId equals c.Id
|
||||
where s.StudentNo == dto.StudentNo
|
||||
select new ClassRoomRecordPageDto
|
||||
{
|
||||
Id = c.Id,
|
||||
ClassId = c.ClassId,
|
||||
Name = c.Name,
|
||||
StartingEndingTime = (c.StartTime.HasValue ? c.StartTime.Value.ToString("yyyy-MM-dd HH:mm") : "") +
|
||||
(c.EndTime.HasValue ? " - " + c.EndTime.Value.ToString("yyyy-MM-dd HH:mm") : "")
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var query = from s in _sportsContext.Ai_ClassroomStudentRecord
|
||||
var roleId = UserLoginContext.Current.RoleId;
|
||||
|
||||
if (roleId == 3 || roleId == 5) // 学生
|
||||
{
|
||||
var studentNo = UserLoginContext.Current.UserNo;
|
||||
|
||||
query = from s in _sportsContext.Ai_ClassroomStudentRecord
|
||||
join c in _sportsContext.Ai_ClassRoomRecord on s.ClassRoomRecordId equals c.Id
|
||||
where s.StudentNo == dto.StudentNo
|
||||
select new ClassRoomRecordPageDto()
|
||||
where s.StudentNo == studentNo
|
||||
select new ClassRoomRecordPageDto
|
||||
{
|
||||
Id = c.Id,
|
||||
ClassId = c.ClassId,
|
||||
Name = c.Name,
|
||||
StartingEndingTime = $"{(c.StartTime.HasValue ? c.StartTime.Value.ToString("yyyy-MM-dd HH:mm") : string.Empty)}{(c.EndTime.HasValue ? " - " + c.EndTime.Value.ToString("yyyy-MM-dd HH:mm") : string.Empty)}"
|
||||
StartingEndingTime = (c.StartTime.HasValue ? c.StartTime.Value.ToString("yyyy-MM-dd HH:mm") : "") +
|
||||
(c.EndTime.HasValue ? " - " + c.EndTime.Value.ToString("yyyy-MM-dd HH:mm") : "")
|
||||
};
|
||||
}
|
||||
else // 教师
|
||||
{
|
||||
var phoneNo = UserLoginContext.Current.PhoneNo;
|
||||
var teacherId = await _sportsContext.Teacher
|
||||
.Where(x => x.TeacherPhoneNo == phoneNo)
|
||||
.Select(x => x.Id)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
res.Total = await query.CountAsync();
|
||||
|
||||
var list = await query
|
||||
.OrderByDescending(c => c.Id)
|
||||
.Skip((dto.PageIndex - 1) * dto.PageSize)
|
||||
.Take(dto.PageSize)
|
||||
.ToListAsync();
|
||||
|
||||
res.Datas = list;
|
||||
query = _sportsContext.Ai_ClassRoomRecord
|
||||
.Where(x => x.TeacherId == teacherId)
|
||||
.Select(c => new ClassRoomRecordPageDto
|
||||
{
|
||||
Id = c.Id,
|
||||
ClassId = c.ClassId,
|
||||
Name = c.Name,
|
||||
StartingEndingTime = (c.StartTime.HasValue ? c.StartTime.Value.ToString("yyyy-MM-dd HH:mm") : "") +
|
||||
(c.EndTime.HasValue ? " - " + c.EndTime.Value.ToString("yyyy-MM-dd HH:mm") : "")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
res.Total = await query.CountAsync();
|
||||
res.Datas = await query
|
||||
.OrderByDescending(x => x.Id)
|
||||
.Skip((dto.PageIndex - 1) * dto.PageSize)
|
||||
.Take(dto.PageSize)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 课堂详情
|
||||
/// </summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user