public BsTableDataSource <VillageWorkingGroupViewModel> GET(NoVerifyGetPersonLiableList request) { return(NoVerifyVillageWorkingGroupManage.GetPsersonLiableList(request)); }
public BsTableDataSource <VillageWorkingGroupViewModel> GetPsersonLiableList(NoVerifyGetPersonLiableList request) { using (var db = DbFactory.Open()) { //if (string.IsNullOrEmpty(adcd)) //{ throw new Exception("请重新登录"); } //取镇下面的所有行政村 var builder = db.From <VillageWorkingGroup>(); builder.LeftJoin <VillageWorkingGroup, ADCDInfo>((x, y) => x.VillageADCD == y.adcd); if (adcd.Length == 15 && adcd.IndexOf("000000") > 0)//登陆的是乡镇用户 { builder.Where(x => x.VillageADCD.StartsWith(adcd.Substring(0, 9)) && x.VillageADCD != adcd.ToString()); } else if (adcd.Length == 6 && adcd.IndexOf("00") < 0)//登陆的是县级用户 { builder.Where(x => x.VillageADCD.StartsWith(adcd.Substring(0, 6))); } else { throw new Exception("登陆用户的所属行政区划编码不正确"); } if (!string.IsNullOrEmpty(request.key)) { builder.Where <ADCDInfo>(w => w.adnm.Contains(request.key)); } var _year = null != request.year && !string.IsNullOrEmpty(request.year.ToString()) ? request.year : System.DateTime.Now.Year; builder.Where <VillageWorkingGroup>(y => y.VillageADCD != null && y.Year == _year); builder.Select <VillageWorkingGroup, ADCDInfo>((x, y) => new { adcd = x.VillageADCD, adnm = y.adnm, id = x.ID, PersonLiable = x.PersonLiable, Position = x.Position, Post = x.Post, HandPhone = x.HandPhone, Remarks = x.Remarks, AddTime = x.AddTime, Year = x.Year }); var count = db.Select(builder).Count; if (!string.IsNullOrEmpty(request.Sort) && !string.IsNullOrEmpty(request.Order) && request.Order == "asc") { builder.OrderBy(o => request.Sort); } else if (!string.IsNullOrEmpty(request.Sort) && !string.IsNullOrEmpty(request.Order) && request.Order == "desc") { builder.OrderByDescending(o => request.Sort); } else { builder.OrderBy(o => o.ID); } var PageSize = request.PageSize == 0 ? 15 : request.PageSize; var PageIndex = request.PageIndex == 0 ? 0 : (request.PageIndex) * PageSize; builder.Limit(PageIndex, PageSize); var RList = db.Select <VillageWorkingGroupViewModel>(builder); return(new BsTableDataSource <VillageWorkingGroupViewModel>() { rows = RList, total = count }); } }