@ranger-01
2019-06-15T15:24:01.000000Z
字数 4057
阅读 744
django angular deploy mimi_program

| Filed | Type | introduction |
|---|---|---|
| user | User | oneToOne filed to user |
| unionId | charField | id from weixin |
| nickName | charField | wechat nickname from weixin |
| avatarUrl | charField | wechat img from weixin |
| type | inteter | choice from: visitor, employee, admin |
2. Book
| Filed | Type | introduction |
|---|---|---|
| created | datetime | the time when this item added in database |
| doubanId | integer | the book id from douban |
| status | integer | choice form: market, wishlist, library, borrowed |
| owner | user | ForeignKey to pyuser; who has the owership of the book |
| wisher | user | ManyToManyField to pyuser; who wish to buy this book |
login
# login from backend uiURL: /api/v1/ologin/method: POSTData:{'username': 'name','password': 'password'}ret:{access_token: "Ro6yB0jLu7xubC6zTbAox4cEb9eXgy"expires_in: 36000refresh_token: "7O7jpcl0HgC8quMD8WbfwdPm7DO3Qd"scope: "read write"token_type: "Bearer"}# login from mini programURL: /api/v1/wxlogin/method: POSTData:{'code': 'xxxxxxx','userinfo': {{"nickName": "NICKNAME","gender": GENDER,"city": "CITY","province": "PROVINCE","country": "COUNTRY","avatarUrl": "AVATARURL",}}ret:{"token": token.token,"token_type": "Bearer","user_type": pu.type,"user_id": u.id}
user operation
# operation on a userURL: /api/v1/pyuser/method: POSTData:{'uid': 'user id','operation': 'join, leave'}ret:{'id': u.id,'nickname': u.pyuser.nickname,'avatarUrl': u.pyuser.avatarUrl,'type': u.pyuser.type,'date_joined': u.date_joined,'borrowed_num': Book.objects.filter(owner=u, status=BOOK_STATUS_BORROWED).count()}# get pyuser list infoURL: /api/v1/pyusers/method: GETData:{}ret:{data: [{'id': py_user.user.id,'nickname': py_user.nickname,'avatarUrl': py_user.avatarUrl,'type': py_user.type,'date_joined': py_user.user.date_joined,'borrowed_num': Book.objects.filter(owner=py_user.user, status=BOOK_STATUS_BORROWED).count()},]}
book operation
# operation on a bookURL: /api/v1/book/method: POSTData:{'operation': 'wish, buy, borrow, return','book_id': '123'}ret:{'book_info': book_info,'status': book.status,'owner': book_owner,'wishers': book.wishers.all().values('id', 'pyuser__nickname', 'pyuser__avatarUrl')}# get book list infoURL: /api/v1/books/method: GETData:{'type': 'wish, all',}ret:{data: [{'book_info': str_book_info,'status': book.status,'owner': {'id': book.owner.id,'nickname': book.owner.pyuser.nickname,'avatarUrl': book.owner.pyuser.avatarUrl},'wishers': book.wishers.all().values('id', 'pyuser__nickname', 'pyuser__avatarUrl')},]}
Book status
Book operation
borrow the book
return the book