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 DeleteStudyClassController : Controller { Competition.Mysql.BLL.pow_study_class study_class_bll = new Competition.Mysql.BLL.pow_study_class(); Competition.Mysql.BLL.pow_study study_bll = new Competition.Mysql.BLL.pow_study(); public DeleteStudyClassController() { } /// /// 删除学习分类接口 /// /// 学习分类id /// [Authorize] [HttpGet] [APIFilter] public JsonResult Index(string StudyClassId) { try { if (string.IsNullOrEmpty(StudyClassId)) { return Json(Tool.GetJsonWithCode(APICode.Fail, "学习分类id不能为空")); } var count = study_bll.GetRecordCount(string.Format(" StudyClassId='{0}' ", StudyClassId)); if (count > 0) { return Json(Tool.GetJsonWithCode(APICode.Fail, "该学习分类有被学习使用,不能删除")); } var ret = study_class_bll.Delete(StudyClassId); if (ret) { return Json(Tool.GetJsonWithCode(APICode.Success, "删除成功")); } else { return Json(Tool.GetJsonWithCode(APICode.Fail, "删除失败")); } } catch (Exception ex) { LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace); return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。")); } } } }