using Gs.Entity.BaseInfo;
|
using Gs.Entity.Sys;
|
using Gs.Toolbox;
|
using Gs.Toolbox.ApiCore.Abstract.Mvc;
|
using Gs.Toolbox.ApiCore.Common.Mvc;
|
using Gs.Toolbox.ApiCore.Group;
|
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Mvc;
|
using SqlSugar;
|
using System.Data;
|
using System.Data.SqlClient;
|
using System.Dynamic;
|
using System.Text;
|
|
namespace Gs.BaseInfo.Services;
|
|
[ApiGroup(ApiGroupNames.BaseInfo)]
|
public class MesStaffManager : Repository<MesStaff>, IRomteService
|
{
|
private readonly IHttpContextAccessor _http;
|
|
private readonly string _userCode, _userGuid, _orgFids;
|
public MesStaffManager(IHttpContextAccessor httpContextAccessor)
|
{
|
_http = httpContextAccessor;
|
(_userCode, _userGuid, _orgFids) =
|
UtilityHelper.GetUserGuidAndOrgGuid(_http);
|
}
|
|
/// <summary>
|
/// 查询列表,支持分页
|
/// </summary>
|
/// <param name="query"></param>
|
/// <returns></returns>
|
[RequestMethod(RequestMethods.POST)]
|
public ReturnDto<PageList<MesStaff>> GetListPage(PageQuery query)
|
{
|
var pageList = new PageList<MesStaff>();
|
try
|
{
|
var _sbWhere = new StringBuilder(" 1=1" + query.keyWhere);
|
var _sbBy =
|
new StringBuilder(query.sortName + " " + query.sortOrder);
|
var totalCount = 0;
|
var itemsList = Db.Queryable<MesStaff, SysOrganization, MesPosition>((a, org, c) =>
|
new object[]
|
{
|
JoinType.Left, a.FSubsidiary == org.Fid,
|
JoinType.Left, a.PositionCode == c.Id.ToString()
|
}).Select((a, org, c) => new MesStaff
|
{
|
FSubsidiary = "(" + org.FNumber + ")" + org.Name,
|
PositionName = c.PositionName,
|
FforbidStatus = a.FforbidStatus + ":" + (a.FforbidStatus == "A" ? "正常" : "禁用"),
|
DataType = a.DataType + ":"
|
+ SqlFunc.IF(a.DataType == "Z").Return("暂存")
|
.ElseIF(a.DataType == "A").Return("创建")
|
.ElseIF(a.DataType == "B").Return("审核中")
|
.ElseIF(a.DataType == "C").Return("已审核")
|
.ElseIF(a.DataType == "D").Return("重新审核")
|
.End(a.DataType)
|
}, true)
|
.Where(_sbWhere.ToString())
|
.OrderBy(_sbBy.ToString())
|
.ToPageList(query.currentPage, query.everyPageSize,
|
ref totalCount);
|
|
pageList = new PageList<MesStaff>(itemsList, totalCount,
|
query.everyPageSize);
|
return ReturnDto<PageList<MesStaff>>.QuickReturn(pageList,
|
ReturnCode.Success, "读取成功");
|
}
|
catch (Exception ex)
|
{
|
return ReturnDto<PageList<MesStaff>>.QuickReturn(pageList,
|
ReturnCode.Default, ex.Message);
|
}
|
}
|
|
/// <summary>
|
/// 读取
|
/// </summary>
|
/// <param name="guid"></param>
|
/// <returns></returns>
|
[RequestMethod(RequestMethods.POST)]
|
//public ReturnDto<MesStaff> GetModel([FromBody] MesStaff model)
|
//{
|
// var m = base.GetById(model.Guid);
|
// if (m != null)
|
// return ReturnDto<MesStaff>.QuickReturn(m, ReturnCode.Success,
|
// "读取成功!");
|
// return ReturnDto<MesStaff>.QuickReturn(m, ReturnCode.Default, "读取失败!");
|
//}
|
|
public ReturnDto<ExpandoObject> GetModel([FromBody] dynamic model)
|
{
|
string guid = model.guid.ToString();
|
dynamic m = new ExpandoObject();
|
m.list = new List<dynamic>();
|
m.list2 = new List<dynamic>();
|
SqlParameter[] parameters =
|
{
|
new("@inMainGuid", guid),
|
new("@inP1", ""),
|
new("@inP2", ""),
|
new("@inP3", ""),
|
new("@inP4", "")
|
};
|
var dset = new DataSet();
|
try
|
{
|
dset = DbHelperSQL.RunProcedure("[prc_staff_mx]", parameters, "0");
|
if (dset != null && dset.Tables.Count > 0 &&
|
dset.Tables[0].Rows.Count > 0)
|
{
|
var dr = dset.Tables[0].Rows[0];
|
m = dr.RowToDynamic();
|
var _tb = dset.Tables[1].TableToDynamicList();
|
m.list = _tb;
|
//var _tb2 = dset.Tables[2].TableToDynamicList();
|
//m.list2 = _tb2;
|
}
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Debug(ToString(), ex.Message);
|
}
|
|
if (m != null)
|
return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success,
|
"读取成功!");
|
return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, "读取失败!");
|
}
|
|
|
|
}
|