GithubHelp home page GithubHelp logo

wechatbackend's Introduction

WeChatBackEnd

API

For All Members

Login

Supported method: POST

Registered at /account/login/

{
    "name": "David",
    "app_id": "aljsd8asdabsdb728d1djhasbkdjb",
    "app_secret": "dasdasdasdabsdb728d1djhasbkdjb",
    "code": "sdasdasdasda"
}

return value

{
    "msg": "login!",
    "token": "kjdagsjhdkanbcajgscjdgajhsbcjhagsc"
}

to remain login state, add followering to your request header

header: {
    'Authorization': 'JWT <str:token>'
}
example:

header: {
    'Authorization': 'JWT lakshdkjagsdjkgaskjdgkjasgdkjakjabsdkjasd'
}

Ever since the first login, one wechat union id will be bound with a name in the member name list. If login fail, the backend will retrun

{
    "msg": "Error information"
}

and you may show the message directly to user

Abesence Application

Supported method: POST

Registered at /absence/

{
    "reason": "reasons",
    "time_absence": "2018-01-22",
    "type": "全体排练"
}

error response

{
    "msg": "error reasons"
}

type choices: 全体排练, 弦乐分排, 管乐分排, 弦乐重奏, 管乐重奏, 全体排练+弦乐分排, 全体排练+管乐分排 times reach upper bound

{
    "msg": "You have used up all of your chances."
}

Change Abesence Application

Supported method: PUT

Registered at /absence/<int:absence_id>/

{
    "reason": "reasons",
    "time_absence": "2018-01-22",
    "type": "A"
}

type choices: 全体排练, 弦乐分排, 管乐分排, 弦乐重奏, 管乐重奏, 全体排练+弦乐分排, 全体排练+管乐分排

Delete Abesence Application

Supported method: DELETE

Registered at /absence/<int:absence_id>/

401 status code
no return data

Abesence Information

Supported method: GET

Registered at /absence/

[
    {
        "id": 1,
        "applier": "David",
        "processor": null,
        "reason": "testReason",
        "time_absence": "2019-11-10",
        "time_apply": "2019-11-10",
        "result": "Not processed yet!",
        "permission": false,
        "type": "全体"
    }
]

For Managers

any student try access these information will get code 401

All Absence Information

Supported method: GET

Registered at /manager/

[
    {
        "id": 4,
        "applier": "David",
        "processor": null,
        "reason": "testReason",
        "time_absence": "2019-11-10",
        "time_apply": "2019-11-10",
        "result": "Not processed yet!",
        "permission": false,
        "type": "全体"
    }
]

All Absence Information

Supported method: PUT

Registered at /manager/<int:absence_id>/
id is the pk of absence

  {
    "processor": "David"
    "result": "Reason for allowing/not allowing absence",
    "permission": false
  }

return data

  {
    "msg": "xxxxxxxx"
  }

Members Absent

Supported method: GET

Registered at /manager/<str:time>/present/ time in YYYY-MM-DD formate example: ('2020-3-12')

{
  "time": "2018-01-22",
  "members":[
    {
        "name": "David",
        "state": "absent"
    },
    {
        "name": "John",
        "state": "absent"
    }
  ]
}

Members Absent in Next Rehearsal

filtered by the closest time anyone applied for absence.

Supported method: GET

Registered at /manager/next/

{
    "time": "2020-03-24",
    "stringed": [
        {
            "id": 23340,
            "applier": "赵乘风",
            "processor": null,
            "reason": "test2",
            "time_absence": "2020-03-24",
            "type": "全体排练",
            "time_apply": "2020-02-08",
            "result": "Not processed yet!",
            "permission": false
        }
    ]
    "wind": [
       {
            "id": 23340,
            "applier": "赵乘风",
            "processor": null,
            "reason": "test2",
            "time_absence": "2020-03-24",
            "type": "全体排练",
            "time_apply": "2020-02-08",
            "result": "Not processed yet!",
            "permission": false
        }
    ],
    "percussion": [
          {
            "id": 23340,
            "applier": "赵乘风",
            "processor": null,
            "reason": "test2",
            "time_absence": "2020-03-24",
            "type": "全体排练",
            "time_apply": "2020-02-08",
            "result": "Not processed yet!",
            "permission": false
        }
    ],
}

Members Absent Before the Current Date

Supported method: GET

Registered at /manager/history/

[
    {
        "id": 4,
        "applier": "David",
        "processor": null,
        "reason": "testReason",
        "time_absence": "2019-11-10",
        "time_apply": "2019-11-10",
        "result": "Not processed yet!",
        "permission": false,
        "type": "全体"
    }
]

Members Absent After the Current Date

Supported method: GET

Registered at /manager/future/

[
    {
        "id": 4,
        "applier": "David",
        "processor": null,
        "reason": "testReason",
        "time_absence": "2019-11-10",
        "time_apply": "2019-11-10",
        "result": "Not processed yet!",
        "permission": false,
        "type": "全体"
    }
]

Depoly(Only the part I remember)

start virtual environment

cd /env:root_dir source bin/activate

install requirement library

pip3 install -r requirements.txt

tips: (sudo pip3 install -r requirements.txt) will install teh library to the system's environment instead of env's

update database(abandoned, merged into script)

python3 manage.py makemigrations python3 manage.py migrate

start uwsgi

sudo bash update.sh (the script is set up)

wechatbackend's People

Contributors

artanic30 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.