111 lines
4.7 KiB
C#
111 lines
4.7 KiB
C#
using Competition.Common.Util;
|
|
using CompetitionAPI.Util;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using NPOI.POIFS.Crypt.Dsig;
|
|
using System.Text;
|
|
|
|
namespace CompetitionAPI.Controllers.back.system
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class GetUserListController : Controller
|
|
{
|
|
Competition.Mysql.BLL.admin_user user_bll = new Competition.Mysql.BLL.admin_user();
|
|
|
|
Competition.Mysql.BLL.admin_unit unit_bll = new Competition.Mysql.BLL.admin_unit();
|
|
|
|
public GetUserListController()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取考试列表接口
|
|
/// </summary>
|
|
/// <param name="RealName">姓名</param>
|
|
/// <param name="PlayerCode">选手编号</param>
|
|
/// <param name="PageIndex">页码/param>
|
|
/// <param name="PageSize">每页数量/param>
|
|
/// <returns></returns>
|
|
[Authorize]
|
|
[HttpGet]
|
|
[APIFilter]
|
|
public JsonResult Index(int PageIndex, int PageSize, string RealName = "", string PlayerCode = "")
|
|
{
|
|
try
|
|
{
|
|
var query = new StringBuilder(" role_id ='2' ");
|
|
var total_query = new StringBuilder(" role_id ='2' ");
|
|
if (!string.IsNullOrWhiteSpace(RealName))
|
|
{
|
|
query.AppendFormat(" AND real_name LIKE '%{0}%' ", RealName);
|
|
total_query.AppendFormat(" AND real_name LIKE '%{0}%' ", RealName);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(PlayerCode))
|
|
{
|
|
query.AppendFormat(" AND login_name = '{0}' ", PlayerCode);
|
|
total_query.AppendFormat(" AND login_name = '{0}' ", PlayerCode);
|
|
}
|
|
var offset = (PageIndex - 1) * PageSize;
|
|
query.AppendFormat(" order by create_time desc LIMIT {0} OFFSET {1} ", PageSize, offset);
|
|
var total = user_bll.GetRecordCount(total_query.ToString());
|
|
var list = user_bll.GetModelList(query.ToString());
|
|
var data = new List<Competition.Mysql.Model.admin_user>();
|
|
foreach (var user in list)
|
|
{
|
|
user.role_name_dsc = Tool.DicRole.ContainsKey(user.role_id) ? Tool.DicRole[user.role_id] : "";
|
|
if (!user_bll.IsAdministrator(user))
|
|
{
|
|
user.IsAdministrator = false;
|
|
|
|
if (!string.IsNullOrEmpty(user.unit_id) && string.IsNullOrEmpty(user.unit_name))
|
|
{
|
|
var unit = unit_bll.GetModel(user.unit_id);
|
|
if (null != unit)
|
|
{
|
|
user.unit_name = unit.unit_name;
|
|
user.province = unit.province;
|
|
user.city = unit.city;
|
|
}
|
|
}
|
|
data.Add(user);
|
|
}
|
|
else
|
|
{
|
|
user.IsAdministrator = true;
|
|
}
|
|
}
|
|
var new_data = (from l in data
|
|
select new
|
|
{
|
|
UserId = l.user_id,
|
|
RealName = l.real_name,
|
|
PlayerCode = l.login_name,
|
|
OwnCity = l.OwnCity,
|
|
ErpCode = l.ErpCode,
|
|
UnitId = l.unit_id,
|
|
UnitName = l.unit_name,
|
|
DepName = l.dep_name,
|
|
GZGW = l.GZGW,
|
|
Mobile = l.mobile,
|
|
WorkDate = l.WorkDate,
|
|
Education = l.Education,
|
|
NowMajorGrade = l.NowMajorGrade,
|
|
NowJobGrade = l.NowJobGrade,
|
|
IdCard = l.id_card,
|
|
Sex = l.sex,
|
|
Remark = l.r1
|
|
}).ToList();
|
|
return Json(Tool.GetJsonWithCode(APICode.Success, new { total = total, list = new_data }));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
|
|
}
|
|
}
|
|
}
|
|
}
|