public HttpResponseMessage GetOpenId(string code) { if (string.IsNullOrEmpty(code)) { return(Request.CreateResponse(HttpStatusCode.OK, new { status = "error", error = "code参数错误" }, Configuration.Formatters.JsonFormatter)); } var responseStr = GetHttpRequest( "https://api.weixin.qq.com/sns/jscode2session?appid=" + AppId + "&secret=" + Secret + "&js_code=" + code + "&grant_type=authorization_code", "GET"); var obj = JsonConvert.DeserializeObject <OpenIdModel>(responseStr); //查询是否存在 obj.IsExist = WechatDapper.GetCount(" openId=@openId ", obj) == 1; HttpResponseMessage result = Request.CreateResponse(HttpStatusCode.OK, new { status = "OK", data = obj }, 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)); }