using Asp.Versioning;
using LearningOfficer.OA.Common.Dtos.Classes;
using LearningOfficer.OA.Common.Dtos.LoginMobile;
using LearningOfficer.OA.Common.Dtos.User;
using LearningOfficer.OA.Common.Exceptions;
using LearningOfficer.OA.Common.Helpers;
using LearningOfficer.OA.Core.ServicesInterfaces;
using LearningOfficer.OA.Core.ServicesInterfaces.ClassTask;
using LearningOfficer.OA.Core.ServicesInterfaces.LoginMobile;
using Meeting.Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace LearningOfficer.OA.Mobile.Api.Controllers.V1
{
///
/// 工作台
///
[Authorize]
[Route($@"{RoutePrefix}/[controller]/[action]")]
[ApiVersion(1.0)]
public class FollowStudentInfoController : BaseApiController
{
IUserService _userService;
ITask_checklistService _ChecklistService;
ILoginMobilAppService _loginMobilAppService;
public FollowStudentInfoController(ILoginMobilAppService loginMobilAppService,
ITask_checklistService ChecklistService, IUserService userService)
{
_userService = userService;
_ChecklistService = ChecklistService;
_loginMobilAppService = loginMobilAppService;
}
///
/// 普通用户登录
///
/// 登录信息
///
[HttpPost]
[AllowAnonymous]
public async Task> userLogin([FromQuery] LoginRequest request)
{
request.Pwd = MD5EncryptionHelper.MD5Encryption(request.Pwd).ToUpper();
UserResult model = await _loginMobilAppService.userLogin(request);
return Ok(model);
}
///
/// 获取【本人管理班级】列表
///
///
///
///
[HttpGet]
[AllowAnonymous]
public async Task> GetBindClassesByUserId(long userId)
{
//获取本人信息
var userInfo = await _userService.GetByIdAsync(userId);
if (userInfo == null)
{
throw new BusinessException("用户信息不存在");
}
//获取管理的所有学校
var classResults = await _ChecklistService.GetBindClassesBySchoolId(userId);
return classResults;
}
///
/// 工作台-获取班级学生列表
///
///
/// 是否返回退学学生,默认0不返回, 1返回
///
///
[HttpGet]
[AllowAnonymous]
public async Task> GetStudents(long classId, int IsBackOutStudent = 0)
{
if (classId <= 0)
{
throw new BusinessException("参数错误");
}
//获取该班的学生职级
//var Position = await _classesService.GetPosition(classId);
var result = await _userService.GetStudentResults(classId, IsBackOutStudent);
return result;
}
///
/// 重置学生密码为123456
///
/// 学生id
///
[HttpPost]
[AllowAnonymous]
public async Task ResetStudentPwd(long userId)
{
return await _userService.ResetStudentPwd(userId);
}
}
}