public Models.ResponseResult register([FromBody] JObject json)
        {
            try {
                int id = new Cook.BLL.load().register(json["phone"].ToString(), json["pwd"].ToString());
                if (id != 0)
                {
                    Models.ResponseResult obj = new Models.ResponseResult();

                    string Token = common.GetMd5_16(Guid.NewGuid().ToString());
                    var    dtNow = DateTime.Now;
                    new Cook.BLL.load().AddByUserId(id.ToString(), Token, dtNow.ToString(), dtNow.AddDays(7).ToString());
                    //返回信息
                    obj.status  = true;
                    obj.message = "用户注册成功";
                    JObject jo = new JObject();
                    jo.Add("token", Token);
                    obj.info = jo;
                    return(obj);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception) {
                return(null);
            }
        }
Beispiel #2
0
        public static ResponseResult <T> CreateResult <T>(T data, string message)
        {
            ResponseResult <T> result = new Models.ResponseResult <T>();

            result.data    = data;
            result.success = true;
            result.message = message;
            return(result);
        }