110 lines
3.8 KiB
C#
110 lines
3.8 KiB
C#
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
|
||
{
|
||
/// <summary>
|
||
/// 工作台
|
||
/// </summary>
|
||
[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;
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 普通用户登录
|
||
/// </summary>
|
||
/// <param name="request">登录信息</param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[AllowAnonymous]
|
||
public async Task<ActionResult<userLoginResult>> userLogin([FromQuery] LoginRequest request)
|
||
{
|
||
request.Pwd = MD5EncryptionHelper.MD5Encryption(request.Pwd).ToUpper();
|
||
UserResult model = await _loginMobilAppService.userLogin(request);
|
||
|
||
return Ok(model);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取【本人管理班级】列表
|
||
/// </summary>
|
||
/// <param name="userId"></param>
|
||
/// <returns></returns>
|
||
/// <exception cref="BusinessException"></exception>
|
||
[HttpGet]
|
||
[AllowAnonymous]
|
||
public async Task<List<ClassesResult>> GetBindClassesByUserId(long userId)
|
||
{
|
||
//获取本人信息
|
||
var userInfo = await _userService.GetByIdAsync(userId);
|
||
if (userInfo == null)
|
||
{
|
||
throw new BusinessException("用户信息不存在");
|
||
}
|
||
//获取管理的所有学校
|
||
var classResults = await _ChecklistService.GetBindClassesBySchoolId(userId);
|
||
return classResults;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 工作台-获取班级学生列表
|
||
/// </summary>
|
||
/// <param name="classId"></param>
|
||
/// <param name="IsBackOutStudent">是否返回退学学生,默认0不返回, 1返回</param>
|
||
/// <returns></returns>
|
||
/// <exception cref="BusinessException"></exception>
|
||
[HttpGet]
|
||
[AllowAnonymous]
|
||
public async Task<List<StudentResult>> 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;
|
||
}
|
||
/// <summary>
|
||
/// 重置学生密码为123456
|
||
/// </summary>
|
||
/// <param name="userId">学生id</param>
|
||
/// <param name="pwd"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[AllowAnonymous]
|
||
public async Task<bool> ResetStudentPwd(long userId, string pwd)
|
||
{
|
||
return await _userService.ResetStudentPwd(userId, pwd);
|
||
}
|
||
}
|
||
}
|