[关闭]
@ranger-01 2019-06-15T23:24:01.000000Z 字数 4057 阅读 649

Design Puya mini program

django angular deploy mimi_program


PRD

  1. Record the books we bought;
  2. Employee can 'wish' the book which they want to buy;
  3. Employee can 'borrow' the book we bought
  4. Library administrator can buy the book is wished by employee
  5. Library administrator can recruit and kick out people
  6. Statistics employee redading status

SRS

Structure

image_1br1fb5eu1im4g0q9b3d1d1gsu9.png-120.9kB

DB schema

  1. PyUser
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

API spec

  1. login

    1. # login from backend ui
    2. URL: /api/v1/ologin/
    3. method: POST
    4. Data:
    5. {
    6. 'username': 'name',
    7. 'password': 'password'
    8. }
    9. ret:
    10. {
    11. access_token: "Ro6yB0jLu7xubC6zTbAox4cEb9eXgy"
    12. expires_in: 36000
    13. refresh_token: "7O7jpcl0HgC8quMD8WbfwdPm7DO3Qd"
    14. scope: "read write"
    15. token_type: "Bearer"
    16. }
    17. # login from mini program
    18. URL: /api/v1/wxlogin/
    19. method: POST
    20. Data:
    21. {
    22. 'code': 'xxxxxxx',
    23. 'userinfo': {
    24. {
    25. "nickName": "NICKNAME",
    26. "gender": GENDER,
    27. "city": "CITY",
    28. "province": "PROVINCE",
    29. "country": "COUNTRY",
    30. "avatarUrl": "AVATARURL",
    31. }
    32. }
    33. ret:
    34. {
    35. "token": token.token,
    36. "token_type": "Bearer",
    37. "user_type": pu.type,
    38. "user_id": u.id
    39. }
  2. user operation

    1. # operation on a user
    2. URL: /api/v1/pyuser/
    3. method: POST
    4. Data:
    5. {
    6. 'uid': 'user id',
    7. 'operation': 'join, leave'
    8. }
    9. ret:
    10. {
    11. 'id': u.id,
    12. 'nickname': u.pyuser.nickname,
    13. 'avatarUrl': u.pyuser.avatarUrl,
    14. 'type': u.pyuser.type,
    15. 'date_joined': u.date_joined,
    16. 'borrowed_num': Book.objects.filter(owner=u, status=BOOK_STATUS_BORROWED).count()
    17. }
    18. # get pyuser list info
    19. URL: /api/v1/pyusers/
    20. method: GET
    21. Data:
    22. {}
    23. ret:
    24. {
    25. data: [
    26. {
    27. 'id': py_user.user.id,
    28. 'nickname': py_user.nickname,
    29. 'avatarUrl': py_user.avatarUrl,
    30. 'type': py_user.type,
    31. 'date_joined': py_user.user.date_joined,
    32. 'borrowed_num': Book.objects.filter(owner=py_user.user, status=BOOK_STATUS_BORROWED).count()
    33. },
    34. ]
    35. }
  3. book operation

    1. # operation on a book
    2. URL: /api/v1/book/
    3. method: POST
    4. Data:
    5. {
    6. 'operation': 'wish, buy, borrow, return',
    7. 'book_id': '123'
    8. }
    9. ret:
    10. {
    11. 'book_info': book_info,
    12. 'status': book.status,
    13. 'owner': book_owner,
    14. 'wishers': book.wishers.all().values(
    15. 'id', 'pyuser__nickname', 'pyuser__avatarUrl'
    16. )
    17. }
    18. # get book list info
    19. URL: /api/v1/books/
    20. method: GET
    21. Data:
    22. {
    23. 'type': 'wish, all',
    24. }
    25. ret:
    26. {
    27. data: [
    28. {
    29. 'book_info': str_book_info,
    30. 'status': book.status,
    31. 'owner': {
    32. 'id': book.owner.id,
    33. 'nickname': book.owner.pyuser.nickname,
    34. 'avatarUrl': book.owner.pyuser.avatarUrl
    35. },
    36. 'wishers': book.wishers.all().values(
    37. 'id', 'pyuser__nickname', 'pyuser__avatarUrl'
    38. )
    39. },
    40. ]
    41. }

User types

  1. Visitor
    • browse all the books in the market and library
    • Can not do action on the book, for example: wish, borrow, return
  2. Employee
    • browse all the books in the market and library
    • Do action on the book, for example: wish, borrow, return
  3. Admin
    • recruit and kick out employee (user type from visitor to employee; from employee to visitor)
    • buy the book wished by employee

User management

  1. User register
    • library admin is created by default
    • every people register from mini program
  2. User login
    • library admin can only login from admin UI
    • other user login from mini program
  3. Recruit and kick out people
    • library admin login backend, can transfer the user type from visitor to employee and reverse this operation

Book management

  1. Book status

    • in the market
    • in the library
    • borrowed
  2. Book operation

    1. get the book list from douban
      • user login from mini program, the mini program get the book list from douban directly
    2. wish the book
      • employee login from mini program
      • mini program get the book info from backend (need the check the book status)
      • add this book info in db:
        • the book status is "in the market",
        • add this user in wisher filed of book item
    3. buy the book
      • admin login backend ui
      • list the books in the backend
      • transfer book status from "in the market" to "in the library", and the owner is admin, clear up wihser field
    4. borrow the book

      • employee login from mini program
      • mini program get the book info from backend
      • transfer the books status from "in the library" to borrowed and the owner is the employee if the book status is "in the library"
    5. return the book

      • employee login from mini program
      • mini program get the book info from backend
      • transfer the books status from borrowed to "in the library" and the owner is admin if the book status is "borrowed" and owner is himeself
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注