using Competition.Common.Util; using CompetitionAPI.Util; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace CompetitionAPI.Controllers.back.system { [Route("api/[controller]")] [ApiController] public class GetFieldController : Controller { Competition.Mysql.BLL.admin_user user_bll = new Competition.Mysql.BLL.admin_user(); public GetFieldController() { } /// /// 获取所在市、工作单位、部门、工作岗位接口 /// /// 字段名称 /// [Authorize] [HttpGet] [APIFilter] public JsonResult Index(string FieldName) { try { if (string.IsNullOrEmpty(FieldName)) { return Json(Tool.GetJsonWithCode(APICode.Fail, "字段名称不能为空")); } if (FieldName != "OwnCity" && FieldName != "unit_name" && FieldName != "dep_name" && FieldName != "GZGW") { return Json(Tool.GetJsonWithCode(APICode.Fail, "值不在规定范围内")); } var array = user_bll.GetFieldValues(FieldName); return Json(Tool.GetJsonWithCode(APICode.Success, array)); } catch (Exception ex) { LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace); return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。")); } } } }