using Competition.Common.Util; using CompetitionAPI.api.back; 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 GetAllDataController : Controller { Competition.Mysql.BLL.admin_user user_bll = new Competition.Mysql.BLL.admin_user(); Competition.Mysql.BLL.pow_exam exam_bll = new Competition.Mysql.BLL.pow_exam(); Competition.Mysql.BLL.pow_study study_bll = new Competition.Mysql.BLL.pow_study(); public GetAllDataController() { } /// /// 获取学生、学习、实训、考试数量接口 /// /// [Authorize] [HttpGet] [APIFilter] public JsonResult Index() { try { var student_count = user_bll.GetRecordCount(" role_id='2' "); var study_count = study_bll.GetRecordCount(" `Status`='已发布' "); var train_count = exam_bll.GetRecordCount(" `Status`='已发布' and Type='实训' "); var exam_count = exam_bll.GetRecordCount(" `Status`='已发布' and Type='考试' "); return Json(Tool.GetJsonWithCode(APICode.Success, new { StudentCount = student_count, StudyCount = study_count, TrainCount = train_count, ExamCount = exam_count })); } catch (Exception ex) { LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace); return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。")); } } } }