75 lines
2.7 KiB
C#
75 lines
2.7 KiB
C#
using Competition.Common.Util;
|
|
using CompetitionAPI.api.back;
|
|
using CompetitionAPI.Util;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using NPOI.HPSF;
|
|
|
|
namespace CompetitionAPI.Controllers.back.study
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class GetStudyDetailsController : Controller
|
|
{
|
|
Competition.Mysql.BLL.pow_study study_bll = new Competition.Mysql.BLL.pow_study();
|
|
|
|
Competition.Mysql.BLL.pow_study_file study_file_bll = new Competition.Mysql.BLL.pow_study_file();
|
|
|
|
public GetStudyDetailsController()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取单条学习数据接口
|
|
/// </summary>
|
|
/// <param name="Id">学习id</param>
|
|
/// <returns></returns>
|
|
[Authorize]
|
|
[HttpGet]
|
|
[APIFilter]
|
|
public JsonResult Index(string Id)
|
|
{
|
|
try
|
|
{
|
|
var res = new EditStudyRequest();
|
|
var model = study_bll.GetModel(Id);
|
|
if (model != null)
|
|
{
|
|
res.StudyId = model.StudyId;
|
|
res.StudyName = model.StudyName;
|
|
res.StudySynopsis = model.StudySynopsis;
|
|
res.StudyClass = model.StudyClass;
|
|
res.StudyClassId = model.StudyClassId;
|
|
var list = study_file_bll.GetModelList(" StudyId='" + model.StudyId + "' ");
|
|
var video_list = list.Where(a => a.FileType == "视频").ToList();
|
|
var file_list = list.Where(a => a.FileType == "文档").ToList();
|
|
res.VideoData = (from v in video_list
|
|
select new FileData
|
|
{
|
|
FileName = v.FileName,
|
|
FilePath = v.FilePath
|
|
}).ToList();
|
|
res.FileData = (from f in file_list
|
|
select new FileData
|
|
{
|
|
FileName = f.FileName,
|
|
FilePath = f.FilePath
|
|
}).ToList();
|
|
}
|
|
else
|
|
{
|
|
res = null;
|
|
}
|
|
return Json(Tool.GetJsonWithCode(APICode.Success, res));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
|
|
}
|
|
}
|
|
}
|
|
}
|