//public async Task<HttpResponseMessage> Get() //{ // return await Task<HttpResponseMessage>.Factory.StartNew(() => // { // return Request.CreateResponse(HttpStatusCode.OK, "aa"); // }); ////} //public IHttpActionResult GetUsers(string v1, string include = "") //{ // try // { // if (string.IsNullOrEmpty(include)) // { // IEnumerable<_User> list = bll.QueryList(0); // //return result<IEnumerable<_User>>(list); // return ok(list); // } // else // { // //非空时,解析所有列 // Dictionary<string, string[]> columns = new Dictionary<string, string[]>(); // string includeInit = include.Substring(0, include.Count() - 1); // string[] cols = includeInit.Split(new string[] { "]," }, StringSplitOptions.None); // foreach (var col in cols) // { // string[] cols1 = col.Split('['); // columns.Add(cols1[0], cols1[1].Split('|')); // } // IEnumerable<Dictionary<string, object>> list = bll.QueryListX(0, 10, columns); // //return result<IEnumerable<Dictionary<string, object>>>(list); // return ok(list); // } // } // catch (Exception e) // { // return execept(e.Message); // } //} // GET api/values/5 获取指定id信息 public IHttpActionResult GetUser(string v1, string objectId, string include = "") { try { if (string.IsNullOrEmpty(objectId)) { return(invildRequest("用户ID不能为空")); } if (string.IsNullOrEmpty(include)) { _User model = bll.QuerySingleById(objectId); return(ok(model)); } else { Dictionary <string, string[]> columns = new Dictionary <string, string[]>(); string includeInit = include.Substring(0, include.Count() - 1); string[] cols = includeInit.Split(new string[] { "]," }, StringSplitOptions.None); foreach (var col in cols) { string[] cols1 = col.Split('['); columns.Add(cols1[0], cols1[1].Split(',')); } Dictionary <string, object> model = bll.QuerySingleByIdX(objectId, columns); //IEnumerable<Dictionary<string, object>> model = bll.QueryListX(0, 1, columns, new List<Wheres> { new Wheres("objectId", "=", objectId) }); //if (model == null||model.Count()<1) { // return notFound("查询失败"); //} //return ok(model.First()); if (model == null) { return(notFound("查询失败")); } return(ok(model)); } } catch (Exception e) { return(execept(e.Message)); } }