CompetitionAPI_dotnet/CompetitionAPI/Controllers/back/study/ReleaseStudyController.cs

57 lines
1.7 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.study
{
[Route("api/[controller]")]
[ApiController]
public class ReleaseStudyController : Controller
{
Competition.Mysql.BLL.pow_study study_bll = new Competition.Mysql.BLL.pow_study();
public ReleaseStudyController()
{
}
/// <summary>
/// 发布学习接口
/// </summary>
/// <param name="StudyId">学习id</param>
/// <returns></returns>
[Authorize]
[HttpGet]
[APIFilter]
public JsonResult Index(string StudyId)
{
try
{
var study_model = study_bll.GetModel(StudyId);
if (study_model != null)
{
if (study_bll.UpdateRelease(StudyId, "已发布"))
{
return Json(Tool.GetJsonWithCode(APICode.Success, "发布成功"));
}
else
{
return Json(Tool.GetJsonWithCode(APICode.Fail, "发布失败"));
}
}
else
{
return Json(Tool.GetJsonWithCode(APICode.Fail, "未找到学习信息"));
}
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
}
}
}
}