51 lines
1.7 KiB
C#
51 lines
1.7 KiB
C#
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()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取所在市、工作单位、部门、工作岗位接口
|
|
/// </summary>
|
|
/// <param name="FieldName">字段名称</param>
|
|
/// <returns></returns>
|
|
[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, "发生错误,请联系管理员。"));
|
|
}
|
|
}
|
|
}
|
|
}
|