/// <summary> /// 根据条件获取单个用户信息 /// </summary> /// <param name="request"></param> /// <returns></returns> public UserInfoViewModel GetUserByIdOrUserName(GetUserByIdOrUserName request) { using (var db = DbFactory.Open()) { if (string.IsNullOrEmpty(request.UserName) && request.userID == null) { throw new Exception("至少输入一个条件"); } var builder = db.From <UserInfo>(); builder.LeftJoin <UserInfo, UserRoleInfo>((x, y) => x.Id == y.UserID); if (!string.IsNullOrEmpty(request.UserName)) { builder.Where(x => x.UserName == request.UserName); } if (request.userID != null) { builder.Where(x => x.Id == request.userID); } builder.Select("UserInfo.*,UserRoleInfo.RoleID"); var info = db.Single <UserInfoViewModel>(builder); if (info != null) { info.PassWord = DESHelper.DESDecrypt(info.PassWord); info.Country = db.Single <ADCDInfo>(x => x.adcd == info.adcd.Substring(0, 4) + "00000000000").adnm; info.City = db.Single <ADCDInfo>(x => x.adcd == info.adcd.Substring(0, 6) + "000000000").adnm; } return(info); } }
/// <summary> /// 根据添加查询单个用户 /// </summary> /// <param name="request"></param> /// <returns></returns> public UserInfoViewModel GET(GetUserByIdOrUserName request) { return(SysManager.GetUserByIdOrUserName(request)); }