CompetitionAPI_dotnet/CompetitionAPI/Controllers/back/analysis/GetTrainController.cs

45 lines
1.4 KiB
C#

using Competition.Common.Util;
using CompetitionAPI.Util;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace CompetitionAPI.Controllers.back.analysis
{
[Route("api/[controller]")]
[ApiController]
public class GetTrainController : Controller
{
Competition.Mysql.BLL.admin_user user_bll = new Competition.Mysql.BLL.admin_user();
Competition.Mysql.BLL.pow_train_record record_bll = new Competition.Mysql.BLL.pow_train_record();
public GetTrainController()
{
}
/// <summary>
/// 获取已发布各个实训的已实训学生数量和未实训学生数量接口
/// </summary>
/// <returns></returns>
[Authorize]
[HttpGet]
[APIFilter]
public JsonResult Index()
{
try
{
var student_count = user_bll.GetRecordCount(" role_id='2' ");
var list = record_bll.GetStudyList();
return Json(Tool.GetJsonWithCode(APICode.Success, new { total = student_count, list = list }));
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
}
}
}
}