/// <summary> /// 查询员工列表 /// </summary> /// <returns></returns> public async Task <ApiResult <Page <SysPersonModel> > > GetPagesAsync(SysPersonPost parm) { var res = new ApiResult <Page <SysPersonModel> >(); try { var query = Db.Queryable <SysPerson>() .WhereIF(!string.IsNullOrEmpty(parm.key), m => m.TrueName.Contains(parm.key) || m.LoginName.Contains(parm.key) || m.Mobile == parm.key || m.Email == parm.key) .Where(m => m.PostStatus == parm.poststatus) .OrderBy(m => m.EditTime, OrderByType.Desc).Select(m => new SysPersonModel() { guid = m.Guid, loginName = m.LoginName, trueName = m.TrueName, codes = m.Codes, companyName = SqlFunc.Subqueryable <SysCompany>().Where(s => s.Guid == m.CompayGuid).Select(s => s.Name), departmentName = SqlFunc.Subqueryable <SysDepartment>().Where(s => s.Guid == m.DepartmentGuid).Select(s => s.Name), postName = "高级软件工程师", sex = m.Sex, mobile = m.Mobile, email = m.Email, }).ToPage(parm.page, parm.limit); res.success = true; res.message = "获取成功!"; res.data = query; } catch (Exception ex) { res.message = ApiEnum.Error.GetEnumText() + ex.Message; res.statusCode = (int)ApiEnum.Error; } return(await Task.Run(() => res)); }
public async Task <JsonResult> GetPages(SysPersonPost request) { var res = await _sysPersonService.GetPagesAsync(request); return(Json(new { code = 0, msg = "success", count = res.data.TotalItems, data = res.data.Items })); }