/// <summary> /// 用户列表 /// </summary> /// <param name="request"></param> /// <returns></returns> public static BasePageResponse <Sys_DepartInfoModel> GetDepartList(DepartistRequest request) { var response = new BasePageResponse <Sys_DepartInfoModel>(); var whereSql = string.Empty; if (request.IsValid >= 0) { whereSql += $" AND DIIsValid = {request.IsValid}"; } if (!String.IsNullOrEmpty(request.Name)) { whereSql += $" AND DIName Like '%{request.Name.Replace("'", string.Empty).Replace(" ", string.Empty).Trim()}%' "; } var totalSql = $" SELECT Count(1) FROM Sys_DepartInfo WHERE 1=1 {whereSql}; "; var total = MysqlHelper.GetScalar <int>(totalSql); if (total > 0) { response.IsSuccess = 1; response.Total = total; var sql = $" SELECT * FROM Sys_DepartInfo WHERE 1=1 {whereSql} "; sql += MysqlHelper.GetPageSql(request.PageIndex, request.PageSize); response.List = MysqlHelper.GetList <Sys_DepartInfoModel>(sql) ?? new List <Sys_DepartInfoModel>(); } return(response); }
/// <summary> /// 用户详情 /// </summary> /// <param name="request"></param> /// <returns></returns> public static UserModel GetUserModel(int id, string account) { if (id <= 0 && string.IsNullOrEmpty(account)) { return(null); } var model = new UserModel(); var para = new DynamicParameters(); var sql = "SELECT * FROM Sys_UserInfo "; if (id > 0) { sql += " WHERE id=@id LIMIT 1; "; para.Add("@id", id); } else if (!string.IsNullOrEmpty(account)) { sql += " WHERE UIAccount=@account LIMIT 1; "; para.Add("@account", account); } var data = MysqlHelper.GetModel <Sys_UserInfoModel>(sql, para); if (data != null && data.Id > 0) { model = new UserModel { Account = data.UIAccount, DepartId = data.UIDepartId, DepartName = data.UIDepartName, Id = data.Id, IsValid = data.UIIsValid, Name = data.UIName, R = data.UIResponsibility, Responsibility = GetResponsibility(data.UIResponsibility), Pwd = data.UIPassWord }; return(model); } return(null); }