Ver código fonte

final

master
Max 2 anos atrás
pai
commit
98a8131d71
51 arquivos alterados com 73 adições e 21 exclusões
  1. BIN
      .coverage
  2. BIN
      be/__pycache__/__init__.cpython-39.pyc
  3. BIN
      be/__pycache__/serve.cpython-39.pyc
  4. BIN
      be/model/__pycache__/__init__.cpython-39.pyc
  5. BIN
      be/model/__pycache__/buyer.cpython-39.pyc
  6. BIN
      be/model/__pycache__/creatTB.cpython-39.pyc
  7. BIN
      be/model/__pycache__/db_conn.cpython-39.pyc
  8. BIN
      be/model/__pycache__/error.cpython-39.pyc
  9. BIN
      be/model/__pycache__/postgreSQLORM.cpython-39.pyc
  10. BIN
      be/model/__pycache__/seller.cpython-39.pyc
  11. BIN
      be/model/__pycache__/user.cpython-39.pyc
  12. +5
    -5
      be/model/postgreSQLORM.py
  13. BIN
      be/view/__pycache__/__init__.cpython-39.pyc
  14. BIN
      be/view/__pycache__/auth.cpython-39.pyc
  15. BIN
      be/view/__pycache__/buyer.cpython-39.pyc
  16. BIN
      be/view/__pycache__/seller.cpython-39.pyc
  17. BIN
      be/view/__pycache__/testconn.cpython-39.pyc
  18. BIN
      fe/__pycache__/__init__.cpython-39.pyc
  19. BIN
      fe/__pycache__/conf.cpython-39.pyc
  20. BIN
      fe/__pycache__/conftest.cpython-39-pytest-7.2.0.pyc
  21. BIN
      fe/access/__pycache__/__init__.cpython-39.pyc
  22. BIN
      fe/access/__pycache__/auth.cpython-39.pyc
  23. BIN
      fe/access/__pycache__/book.cpython-39.pyc
  24. BIN
      fe/access/__pycache__/buyer.cpython-39.pyc
  25. BIN
      fe/access/__pycache__/new_buyer.cpython-39.pyc
  26. BIN
      fe/access/__pycache__/new_seller.cpython-39.pyc
  27. BIN
      fe/access/__pycache__/seller.cpython-39.pyc
  28. BIN
      fe/bench/__pycache__/__init__.cpython-39.pyc
  29. BIN
      fe/bench/__pycache__/run.cpython-39.pyc
  30. BIN
      fe/bench/__pycache__/session.cpython-39.pyc
  31. BIN
      fe/bench/__pycache__/workload.cpython-39.pyc
  32. BIN
      fe/test/__pycache__/gen_book_data.cpython-39.pyc
  33. BIN
      fe/test/__pycache__/test_add_book.cpython-39-pytest-7.2.0.pyc
  34. BIN
      fe/test/__pycache__/test_add_funds.cpython-39-pytest-7.2.0.pyc
  35. BIN
      fe/test/__pycache__/test_add_stock_level.cpython-39-pytest-7.2.0.pyc
  36. BIN
      fe/test/__pycache__/test_bench.cpython-39-pytest-7.2.0.pyc
  37. BIN
      fe/test/__pycache__/test_create_store.cpython-39-pytest-7.2.0.pyc
  38. BIN
      fe/test/__pycache__/test_history_order.cpython-39-pytest-7.2.0.pyc
  39. BIN
      fe/test/__pycache__/test_login.cpython-39-pytest-7.2.0.pyc
  40. BIN
      fe/test/__pycache__/test_new_order.cpython-39-pytest-7.2.0.pyc
  41. BIN
      fe/test/__pycache__/test_order_cancel.cpython-39-pytest-7.2.0.pyc
  42. BIN
      fe/test/__pycache__/test_password.cpython-39-pytest-7.2.0.pyc
  43. BIN
      fe/test/__pycache__/test_payment.cpython-39-pytest-7.2.0.pyc
  44. BIN
      fe/test/__pycache__/test_register.cpython-39-pytest-7.2.0.pyc
  45. BIN
      fe/test/__pycache__/test_search.cpython-39-pytest-7.2.0.pyc
  46. BIN
      fe/test/__pycache__/test_send_out.cpython-39-pytest-7.2.0.pyc
  47. BIN
      fe/test/__pycache__/test_take_over.cpython-39-pytest-7.2.0.pyc
  48. BIN
      figure_require/route_test01.png
  49. BIN
      figure_require/route_test02.png
  50. BIN
      figure_require/route_test03.png
  51. +68
    -16
      实验报告.md

BIN
.coverage Ver arquivo


BIN
be/__pycache__/__init__.cpython-39.pyc Ver arquivo


BIN
be/__pycache__/serve.cpython-39.pyc Ver arquivo


BIN
be/model/__pycache__/__init__.cpython-39.pyc Ver arquivo


BIN
be/model/__pycache__/buyer.cpython-39.pyc Ver arquivo


BIN
be/model/__pycache__/creatTB.cpython-39.pyc Ver arquivo


BIN
be/model/__pycache__/db_conn.cpython-39.pyc Ver arquivo


BIN
be/model/__pycache__/error.cpython-39.pyc Ver arquivo


BIN
be/model/__pycache__/postgreSQLORM.cpython-39.pyc Ver arquivo


BIN
be/model/__pycache__/seller.cpython-39.pyc Ver arquivo


BIN
be/model/__pycache__/user.cpython-39.pyc Ver arquivo


+ 5
- 5
be/model/postgreSQLORM.py Ver arquivo

@ -16,7 +16,7 @@ class con:
'''Returns a connection and a metadata object'''
# We connect with the help of the PostgreSQL URL
url = 'postgresql://stu10205501415:Stu10205501415@dase-cdms-2022-pub.pg.rds.aliyuncs.com:5432/stu10205501415'
url = 'postgresql://stu10205501436:Stu10205501436@dase-cdms-2022-pub.pg.rds.aliyuncs.com:5432/stu10205501436'
# The return value of create_engine() is our connection object
con = create_engine(url, client_encoding='utf8')
@ -298,7 +298,7 @@ DBSession = sessionmaker(bind=engine)
session = DBSession()
insert_tags(session=session)
insert_author(session=session)
insert_title(session=session)
insert_book_intro(session=session)
# insert_tags(session=session)
# insert_author(session=session)
# insert_title(session=session)
# insert_book_intro(session=session)

BIN
be/view/__pycache__/__init__.cpython-39.pyc Ver arquivo


BIN
be/view/__pycache__/auth.cpython-39.pyc Ver arquivo


BIN
be/view/__pycache__/buyer.cpython-39.pyc Ver arquivo


BIN
be/view/__pycache__/seller.cpython-39.pyc Ver arquivo


BIN
be/view/__pycache__/testconn.cpython-39.pyc Ver arquivo


BIN
fe/__pycache__/__init__.cpython-39.pyc Ver arquivo


BIN
fe/__pycache__/conf.cpython-39.pyc Ver arquivo


BIN
fe/__pycache__/conftest.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/access/__pycache__/__init__.cpython-39.pyc Ver arquivo


BIN
fe/access/__pycache__/auth.cpython-39.pyc Ver arquivo


BIN
fe/access/__pycache__/book.cpython-39.pyc Ver arquivo


BIN
fe/access/__pycache__/buyer.cpython-39.pyc Ver arquivo


BIN
fe/access/__pycache__/new_buyer.cpython-39.pyc Ver arquivo


BIN
fe/access/__pycache__/new_seller.cpython-39.pyc Ver arquivo


BIN
fe/access/__pycache__/seller.cpython-39.pyc Ver arquivo


BIN
fe/bench/__pycache__/__init__.cpython-39.pyc Ver arquivo


BIN
fe/bench/__pycache__/run.cpython-39.pyc Ver arquivo


BIN
fe/bench/__pycache__/session.cpython-39.pyc Ver arquivo


BIN
fe/bench/__pycache__/workload.cpython-39.pyc Ver arquivo


BIN
fe/test/__pycache__/gen_book_data.cpython-39.pyc Ver arquivo


BIN
fe/test/__pycache__/test_add_book.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_add_funds.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_add_stock_level.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_bench.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_create_store.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_history_order.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_login.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_new_order.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_order_cancel.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_password.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_payment.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_register.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_search.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_send_out.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
fe/test/__pycache__/test_take_over.cpython-39-pytest-7.2.0.pyc Ver arquivo


BIN
figure_require/route_test01.png Ver arquivo

Antes Depois
Largura: 718  |  Altura: 437  |  Tamanho: 47 KiB Largura: 782  |  Altura: 987  |  Tamanho: 78 KiB

BIN
figure_require/route_test02.png Ver arquivo

Antes Depois
Largura: 1026  |  Altura: 955  |  Tamanho: 58 KiB

BIN
figure_require/route_test03.png Ver arquivo

Antes Depois
Largura: 888  |  Altura: 475  |  Tamanho: 28 KiB

+ 68
- 16
实验报告.md Ver arquivo

@ -6,7 +6,7 @@
| **上机实践名称** :BookStore ||**上机实践日期**:2022.11.28 —— 2022.12.10 |
| **上机实践编号** : | **组号 :21** |**上机实践时间**:2022.11.28 —— 2022.12.10 |
$\color{red}{报告你就写一下下面我标红字的那些地方,顺便注意下排版之类的,补充实现思路的那个就参考后面我单独发的那个readme里面的实现思路,就简单看着代码说说在那些表上查什么就行}$
### 实验过程
@ -258,8 +258,16 @@ $\color{red}{报告你就写一下下面我标红字的那些地方,顺便注
![avatar](./figure_require/register_test.png)
7. 另外对于auth路由中的其他功能接口(注销、登录、登出、更改密码)进行类似上述注册接口的修改,此处不在单独贴出代码,只是给出postman的测试截图,至此auth中的路由全部实现(2022.11.30 17:50 杨舜)
$\color{red}{补充各个接口的实现思路}$
(1)注册接口思路:
首先查找库中的user表对用户输入的id查重之后根据terminal和id生成一个token,之后为用户建立一个新对象并插入到表user中
(2)登陆接口思路:
首先调用check_password函数对用户输入的密码进行判断得到code和message,先对code判断密码是否正确,之后根据不同的错误返回相应的不同的code和message并返回,若无错误则code返回200,message返回ok
(3)登出接口思路:
根据id查看是否已登录,之后更新token和terminal
(4)注销接口思路:
通过check_password函数检查该用户是否已存在账户,之后从表中删除该条目
(5)更改密码接口思路:
首先根据id获取用户的旧密码,与用户输入的旧密码对比,若符合则更新新密码
![avatar](./figure_require/unregister_test.png)
![avatar](./figure_require/login_test.png)
@ -336,8 +344,30 @@ $\color{red}{补充各个接口的实现思路}$
return 530, "{}".format(str(e))
return 200, "ok"
```
$\color{red}{补充实现思路}$
$\color{red}{顺便将这部分的下面这种接口说明移动到doc目录下的文件夹里面}$
(1)创建商铺接口实现:
首先检查user_id和store_id是否已存在,若未存在则创建新对象,并插入表user_store中
(2)添加书本信息接口实现:
首先检查user_id和store_id是否存在,再检查book_id是否已有对应的书本,最后将书本信息创建新对象插入表store_book中
(3)添加库存接口实现:
首先检查user_id和store_id和book_id是否存在,之后根据store_id和book_id找到对应店铺的对应书本库存并进行更新
(4)商家发货接口实现:
首先检查user_id是否存在,之后检查order_id是否有效,对new_order表进行更新
(5)买家下单接口实现:
首先检查user_id和store_id是否存在,之后检查对应店铺的所要买的书本库存是否足够,若足够则减去对应库存,生成order_id,对表new_order_detail更新
(6)买家充值接口实现:
首先根据user_id获取对应密码,与用户输入密码对比,相符合则在表user中更新余额
(7)买家付款接口实现:
首先检查order_id是否存在,若存在则根据user_id获取密码,与用户输入密码对比,之后检查store_id与卖家的user_id是否存在,若存在则比较买家余额和订单价格,若余额足够则扣除买家相应价格,在卖家余额上等额增加,更新user表
(8)买家收货接口实现:
首先检查user_id是否存在,检查order_id是否有效,之后更新new_order表
(9)买家取消订单接口实现:
首先检查user_id是否存在,之后根据订单信息查找对应的订单,将查找到的订单从表new_order中删去,更新
(10)买家查看历史订单接口实现:
首先检查user_id是否存在,之后根据user_id查找表new_order,之后根据order_id列出订单
(11)自动取消订单接口实现:
首先根据order_id查找表new_order,之后根据当前时间计算订单处于未付款状态的持续时长,若超过30s处于未付款状态则自动删去该条目,更新表new_order
商家发货
@ -595,9 +625,11 @@ order_id | string | 订单号,只有返回200时才有效 | N
![avatar](./figure_require/route_test01.png)
7. 为实现书店的搜索图书的功能,稍微修改数据库的结构,为书籍添加数据表,搜索标题表,搜索标签表,搜索作者表,搜索书本内容表
$$\color{red}{看着postgreSQLORM里面Class Book以及后面的几个class写一下几个table的表头,参照我写的一个}$$
Book
|book_id|title|author|publisher|original_title|translator|pub_year|pages|original_price|currency_unit|binding|isbn|author_intro|book_intro|content|tags|picture|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
主键(book_id)
Search_title
|search_id|title|book_id|
@ -605,10 +637,25 @@ $$\color{red}{看着postgreSQLORM里面Class Book以及后面的几个class写
联合主键(search_id,book_id)
外键(book_id)
8. 修改seller中的add_book的路由
$\color{red}{补充实现思路}$
Search_tags
|search_id|tags|book_id|
|---|---|---|
联合主键(search_id,book_id)
外键(book_id)
Search_author
|search_id|author|book_id|
|---|---|---|
联合主键(search_id,author)
外键(book_id)
Search_book_intro
|search_id|book_intro|book_id|
|---|---|---|
联合主键(search_id,book_id)
外键(book_id)
8. 修改seller中的add_book的路由
9. 在auth中添加搜索的路由(只包含全局搜索,没有店铺内搜索)
```python
@bp_auth.route("/search_author", methods=["POST"])
@ -645,14 +692,19 @@ def search_title():
```
10. 为搜索编写测试接口
$$ \color{red}{测试截图,需要终端里面的那些截图和导出的html文件(htmlcov目录中index.html)截图}$$
![avatar](./figure_require/route_test01.png)
![avatar](./figure_require/route_test02.png)
![avatar](./figure_require/route_test03.png)
### 测试结果
```bash
bash script/test.sh
```
首先针对要实现的功能编写相应test,再进行功能实现,符合测试驱动开发的方法,最后输入上述命令,从上面的图中可以看出绝大部分的测试都能够通过,代码覆盖率为54%,作为核心组件的buyer.py、seller.py和user.py的代码覆盖率均在50%-65%之间
$\color{red}{交给你了( ᗜ ‸ ᗜ )}$
### 总结
$\color{red}{交给你了( ᗜ ‸ ᗜ )}$
本次书店project结合了这学期目前为止所学的许多知识,er图、ORM的使用与查询等,是一个比较大的挑战,在本次大项目中在构思方面帮助我们更好的理解和掌握了er图的绘制,在代码方面帮助我们对orm的增删改查操作有了较多的熟悉,同时,由于本次为合作作业,也让我们对git的使用变得更加流畅与顺手,相信在下次的大项目中能有比较大的提升
### 分工
ys:代码、报告撰写、代码测试、git版本控制、数据库整合
yjh:代码、报告撰写、代码测试
$\color{red}{交给你了( ᗜ ‸ ᗜ )}$

Carregando…
Cancelar
Salvar