CompetitionAPI_dotnet/CompetitionAPI/Controllers/unity/study/GetStudyFileController.cs

45 lines
1.3 KiB
C#

using Competition.Common.Util;
using CompetitionAPI.api.unity;
using CompetitionAPI.Util;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Text;
namespace CompetitionAPI.Controllers.unity.study
{
[Route("unity/[controller]")]
[ApiController]
public class GetStudyFileController : Controller
{
Competition.Mysql.BLL.pow_study_file study_file_bll = new Competition.Mysql.BLL.pow_study_file();
public GetStudyFileController()
{
}
/// <summary>
/// 获取学习资源接口
/// </summary>
/// <param name="StudyId">学习id</param>
/// <returns></returns>
[Authorize]
[HttpPost]
[APIFilter]
public JsonResult Index([FromForm] GetStudyFileRequest req)
{
try
{
var list = study_file_bll.GetModelList(string.Format(" StudyId='{0}' ", req.StudyId));
return Json(Tool.GetJsonWithCode(APICode.Success, list));
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
}
}
}
}