using Competition.Common.Util; using CompetitionAPI.api.unity; using CompetitionAPI.Util; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace CompetitionAPI.Controllers.unity { [Route("unity/[controller]")] [ApiController] public class UpdateElectricityController : Controller { Competition.Mysql.BLL.pow_user_exam user_exam_bll = new Competition.Mysql.BLL.pow_user_exam(); public UpdateElectricityController() { } /// /// 更新验电接口 /// /// /// [Authorize] [HttpPost] [APIFilter] public JsonResult Index([FromForm] UpdateElectricityRequest req) { try { var user_exam_model = user_exam_bll.GetModelList(" ExamId='" + req.ExamId + "' and UserId='" + req.UserId + "' ").FirstOrDefault(); if (user_exam_model != null) { if (user_exam_model.Status == "已结束") { return Json(Tool.GetJsonWithCode(APICode.Fail, "考生考试已结束")); } if (req.Type == "巡线") { if (user_exam_bll.UpdateExamLineElectricity(user_exam_model.UserExamId)) { return Json(Tool.GetJsonWithCode(APICode.Success, "成功")); } else { return Json(Tool.GetJsonWithCode(APICode.Fail, "失败")); } } else if (req.Type == "排故") { if (user_exam_bll.UpdateExamFaultElectricity(user_exam_model.UserExamId)) { return Json(Tool.GetJsonWithCode(APICode.Success, "成功")); } else { return Json(Tool.GetJsonWithCode(APICode.Fail, "失败")); } } 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, "发生错误,请联系管理员。")); } } } }