public HttpResponseMessage Post([FromBody] WeChatUser model) { var m = WechatDapper.Query("select * from WechatUser where openid=@openId", new { openId = model.OpenId }).FirstOrDefault(); if (m == null) { WechatDapper.Add(model); } HttpResponseMessage result = Request.CreateResponse(HttpStatusCode.OK, new { status = "OK" }, Configuration.Formatters.JsonFormatter); return(result); }
public HttpResponseMessage GetIntegral(string openId) { var model = WechatDapper.Query("select * from WeChatUser where openId=@openId", new { openId }).FirstOrDefault(); var integral = -1; if (model != null) { integral = model.Integral; } HttpResponseMessage result = Request.CreateResponse(HttpStatusCode.OK, new { status = "OK", data = new { integral, carId = model.CarId } }, Configuration.Formatters.JsonFormatter); return(result); }
public IHttpActionResult Post([FromBody] NewPageModel pagemodel) { pagemodel.Search = "%" + pagemodel.Search + "%"; var modelList = WechatDapper.Query("select * from (select row_number()over(order by id) as rownumber,* from WechatUser where IsDel=0 ) a " + " where rownumber between @minnum and @maxNum", pagemodel).OrderByDescending(o => o.CreateTime); var count = WechatDapper.GetCount(); JsonSerializerSettings settings = new JsonSerializerSettings(); settings.ContractResolver = new CamelCasePropertyNamesContractResolver(); string str = JsonConvert.SerializeObject(modelList, settings); var obj = JsonConvert.DeserializeObject(str); //返回参数集合 Dictionary <string, object> map = new Dictionary <string, object>(); map.Add("iTotalRecords", pagemodel.Start); map.Add("iTotalDisplayRecords", count);//总数据个数 map.Add("aData", obj); return(Json(map)); }