Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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));
        }