Skip to content
freedom7 edited this page Aug 3, 2013 · 8 revisions

REST 请求成功,response status说明

方法 返回状态 说明
GET 200 请求成功
POST 201 创建成功
PUT 204 请求成功,但无返回数据
DELETE 204 请求成功,但无返回数据

登录

URL /login/
POST {username,password}
response[‘Auth_Response’] 0:登录成功,1:用户不存在,2:密码错误
response[‘API_Key’] 用户的key

请求数据

请求资源时应当附带两个参数,username,api_key 例如 http://127.0.0.1:8800/api/data/account/?username=ihkey&api_key=176e5a657152c75287bbd03a4da2da29f84d13ed

请求用户账户资料

URL /api/data/account/ 返回数据示例

{

    "meta": {
        "limit": 20,
        "next": null,
        "offset": 0,
        "previous": null,
        "total_count": 1
    },
    "objects": [
        {
            "hobby": "打篮球",
            "id": 1,
            "resource_uri": "/api/data/account/1/",
            "user": {
                "date_joined": "2013-07-23T00:08:59.376840",
                "email": "",
                "first_name": "",
                "id": 2,
                "last_login": "2013-07-23T00:08:59.376828",
                "last_name": "",
                "resource_uri": "/api/data/user/2/",
                "username": "user1"
            }
        }
    ]

}

字段说明

字段 说明 例子
“hobby” 爱好 “aaaa”
“id” 在数据库ID 5
“resource_uri” 请求url api/data/account/5
“user” 外键指向User
“date_joined” 注册日期 “2013-07-21T21:28:46.987886”
“email” 邮件 ””
“first_name” ””
“id” userID 6
“last_login” 上次登录时间 “2013-07-21T21:50:48.651590”
“last_name” ””
“resource_uri” user对应请求url api/data/user/6
“username” 用户名 “ihkey”

字段说明日后补上

请求时间段

URL /api/data/timedetail/

返回数据示例

{

    "meta": {
        "limit": 20,
        "next": null,
        "offset": 0,
        "previous": null,
        "total_count": 2
    },
    "objects": [
        {
            "end_time": "10:00:00",
            "free": true,
            "id": 1,
            "level": 3,
            "resource_uri": "/api/data/timedetail/1/",
            "start_time": "08:00:00",
            "weekday": "1"
        },
        {
            "end_time": "16:00:00",
            "free": false,
            "id": 2,
            "level": 3,
            "resource_uri": "/api/data/timedetail/2/",
            "start_time": "14:00:00",
            "weekday": "1"
        }
    ]

}

请求假期时间

URL /api/data/datedetail/

返回数据示例

{

    "meta": {
        "limit": 20,
        "next": null,
        "offset": 0,
        "previous": null,
        "total_count": 1
    },
    "objects": [
        {
            "account": "/api/data/account/2/",
            "end_date": "2013-10-07",
            "id": 1,
            "level": 3,
            "resource_uri": "/api/data/datedetail/1/",
            "start_date": "2013-10-01"
        }
    ]

}

请求朋友圈

URL /api/data/usergroup/

返回数据示例

{

    "meta": {
        "limit": 20,
        "next": null,
        "offset": 0,
        "previous": null,
        "total_count": 1
    },
    "objects": [
        {
            "account": "/api/data/account/2/",
            "group_name": "狐朋狗友",
            "id": 1,
            "member": [
                "/api/data/user/3/",
                "/api/data/user/4/"
            ],
            "resource_uri": "/api/data/usergroup/1/"
        }
    ]

}

请求时间公开方案

URL /api/data/showmethod/

返回数据示例

{

    "meta": {
        "limit": 20,
        "next": null,
        "offset": 0,
        "previous": null,
        "total_count": 1
    },
    "objects": [
        {
            "account": "/api/data/account/2/",
            "id": 1,
            "resource_uri": "/api/data/showmethod/1/",
            "showmethod_name": "默认"
        }
    ]

}

请求好友圈中所有好友共同自由时间

URL /api/data/freetimelist/group/ 附带参数 group_name

返回数据示例

{

    "meta": {
        "limit": 20,
        "next": null,
        "offset": 0,
        "previous": null,
        "total_count": 1
    },
    "objects": [
        {
            "freelist": [
                {
                    "freelist_time": [
                        {
                            "count": 1,
                            "time": "12:00:00-14:00:00",
                            "userlist": [
                                "user1"
                            ]
                        },
                        {
                            "count": 1,
                            "time": "08:00:00-10:00:00",
                            "userlist": [
                                "user1"
                            ]
                        },
                        {
                            "count": 2,
                            "time": "08:00:00-09:00:00",
                            "userlist": [
                                "user1",
                                "user2"
                            ]
                        },
                        {
                            "count": 1,
                            "time": "10:00:00-13:00:00",
                            "userlist": [
                                "user3"
                            ]
                        },
                        {
                            "count": 1,
                            "time": "12:00:00-13:00:00",
                            "userlist": [
                                "user1"
                            ]
                        }
                    ],
                    "weekday": 1
                },
                {
                    "freelist_time": [
                        {
                            "count": 1,
                            "time": "10:00:00-12:00:00",
                            "userlist": [
                                "user2"
                            ]
                        },
                        {
                            "count": 2,
                            "time": "10:00:00-11:00:00",
                            "userlist": [
                                "user2",
                                "user3"
                            ]
                        }
                    ],
                    "weekday": 2
                },
                {
                    "freelist_time": [ ],
                    "weekday": 3
                },
                {
                    "freelist_time": [ ],
                    "weekday": 4
                },
                {
                    "freelist_time": [ ],
                    "weekday": 5
                },
                {
                    "freelist_time": [ ],
                    "weekday": 6
                },
                {
                    "freelist_time": [ ],
                    "weekday": 7
                }
            ],
            "hobby": "",
            "id": 1,
            "resource_uri": "/api/data/freetimelist/group/1/",
            "user": "/api/data/user/2/"
        }
    ]

}