80 lines
2.9 KiB
C#
80 lines
2.9 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;
|
|
|
|
namespace CompetitionAPI.Controllers.unity
|
|
{
|
|
[Route("unity/[controller]")]
|
|
[ApiController]
|
|
public class UpdateUserExamTimeController : Controller
|
|
{
|
|
Competition.Mysql.BLL.pow_user_exam user_exam_bll = new Competition.Mysql.BLL.pow_user_exam();
|
|
|
|
public UpdateUserExamTimeController()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取并更新考生考试时间接口
|
|
/// </summary>
|
|
/// <param name="req"></param>
|
|
/// <returns></returns>
|
|
[Authorize]
|
|
[HttpPost]
|
|
[APIFilter]
|
|
public JsonResult Index([FromForm] UpdateUserExamTimeRequest req)
|
|
{
|
|
try
|
|
{
|
|
var user_exam_model = user_exam_bll.GetModelList(" UserId='" + req.UserId + "' and ExamId='" + req.ExamId + "' ").FirstOrDefault();
|
|
if (user_exam_model != null)
|
|
{
|
|
var Last = user_exam_model.UpdateTime.HasValue ? user_exam_model.UpdateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
|
if (req.Read == "1")
|
|
{
|
|
var data = new
|
|
{
|
|
last = Last,
|
|
now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
msg = "查询考试时间成功!"
|
|
};
|
|
return Json(Tool.GetJsonWithCode(APICode.Success, data));
|
|
}
|
|
else
|
|
{
|
|
|
|
if (user_exam_bll.UpdateUserExamTime(user_exam_model.UserExamId))
|
|
{
|
|
return Json(Tool.GetJsonWithCode(APICode.Success, "更新考试时间成功!"));
|
|
}
|
|
else
|
|
{
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "更新场景设备状态失败"));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Write(APICode.Fail, "考生考试信息不存在");
|
|
var data = new
|
|
{
|
|
last = "",
|
|
now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
msg = "考生考试信息不存在"
|
|
};
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, data));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
|
|
}
|
|
}
|
|
}
|
|
}
|