using Competition.Common.Util; using CompetitionAPI.Util; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace CompetitionAPI.Controllers.back { [Route("api/[controller]")] [ApiController] public class GetToolsController : Controller { Competition.Mysql.BLL.pow_tool tool_bll = new Competition.Mysql.BLL.pow_tool(); Competition.Mysql.BLL.pow_exam_tool exam_tool_bll = new Competition.Mysql.BLL.pow_exam_tool(); public GetToolsController() { } /// /// 获取工器具接口 /// /// 考试id /// 类型 巡线、排故 /// [Authorize] [HttpGet] [APIFilter] public JsonResult Index(string ExamId, string Type) { try { var tool_list = tool_bll.GetModelList(" Purpose='" + Type + "' "); var exam_tool_list = exam_tool_bll.GetModelList(" ExamId='" + ExamId + "' and Purpose='" + Type + "' ").Select(a => a.ToolId).ToList(); return Json(Tool.GetJsonWithCode(APICode.Success, new { ToolList = tool_list, SelectToolList = exam_tool_list })); } catch (Exception ex) { LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace); return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。")); } } } }