public IHttpActionResult PutPassword(string v1, string username, string password, string code) { try { if (isNUll(username, password, code)) { return(invildRequest("参数不能为空")); } //objectId var dir = bll.QuerySingleByWheres(new List <Wheres> { new Wheres("username", "=", username) }); if (dir == null) { return(notFound("用户不存在")); } string objectId = dir.objectId; //验证手机验证码 MvcApplication1.Utility.HttpClient client = new MvcApplication1.Utility.HttpClient("https://webapi.sms.mob.com"); string postUri = "sms/verify?appkey=1ad08332b2ac0&phone=" + username + "&zone=86&code=" + code; //string userJson = @"{""appkey"":""1ad08332b2ac0"",""phone"":" + username + @",""zone"":""86"",""code"":" + code + "}"; //请求验证 string postResponse = client.Get(postUri); if (!string.IsNullOrEmpty(postResponse)) { JObject jo = JsonHelper.DeserializeObject(postResponse); string status = jo["status"].ToString(); if (!status.Equals("200")) { return(notFound("验证码错误" + postResponse)); } } else { return(notFound("验证码请求验证失败")); } //更新时间 DateTime dt = DateTime.Now; //更新 bool result = bll.UpdateByWheres(new Wheres("username", "=", username), new Dictionary <string, object> { { "password", (password + objectId).Md5() }, { "updatedAt", dt } }); if (result) { return(ok(new { updateAt = dt.ToString("yyyy-MM-dd HH:mm:ss") })); } return(notFound("修改失败")); } catch (Exception e) { return(execept(e.Message)); } }
public IHttpActionResult GetUpdateAllUser(string v1) { try { bool result = bll.UpdateByWheres(null, new Dictionary <String, object> { { "sign_in", true }, { "shake_times", 3 } }); DateTime dt = DateTime.Now; if (result) { return(create(new { updateAt = dt.ToString("yyyy-MM-dd HH:mm:ss") })); } else { return(invildRequest("失败")); } } catch (Exception e) { return(error(e.Message)); } }