Exemple #1
0
        public HttpResponseMessage register([FromBody] USER u)
        {
            Result <USER> ru     = new Result <USER>();
            int           result = 0;
            string        id;
            List <USER>   lu = new List <USER>();


            try
            {
                result = DB_User.register(u, out id);

                if (result == 1)
                {
                    ru.code    = "2010";
                    ru.success = "true";
                    ru.message = "注册成功!";
                    u.id       = id;
                }
                else if (result == -1)
                {
                    ru.code    = "2013";
                    ru.success = "false";
                    ru.message = "用户名已存在";
                }
                else
                {
                    ru.code    = "2011";
                    ru.success = "false";
                    ru.message = "注册失败";
                }
            }
            catch (Exception e) {
                ru.code    = "2012";
                ru.success = "false";
                ru.message = e.Message;
            }
            lu.Add(u);
            ru.systemTime = Conn.GetTimeStamp();
            ru.data       = lu;

            return(Conn.toJson(ru));
        }