from flask import session, render_template, Flask, request, redirect, url_for, current_app, Blueprint, flash, jsonify
import math
import json
from utils.DBUtils import UseDatabase
from datetime import datetime
bp = Blueprint('api', __name__, url_prefix='/api')
@bp.route('/getFood', methods=['GET'])
def getFood() -> 'json':
page_num = request.args.get("page_num", type=str, default=1)
page_num = int(page_num)
page_size = request.args.get("page_size", type=str, default=5)
page_size = int(page_size)
canteen = request.args.get("canteen", type=str)
_SQL = "SELECT food_id, food_name, food_cal, taste, location, recorde, add_time, img, info, canteen FROM tb_food "
params = []
if canteen:
_SQL += "where canteen = %s "
params.append(canteen)
_SQL += """LIMIT %s, %s """
params.append((page_num - 1) * page_size)
params.append(page_size)
with UseDatabase(current_app.config['dbconfig']) as cursor:
cursor.execute(_SQL, tuple(params))
rows = cursor.fetchall()
column_name_list = [i[0] for i in cursor.description]
objs = []
for r in rows:
obj = {}
for i, item in enumerate(r):
obj[column_name_list[i]] = item
objs.append(obj)
# print(objs)
# 查询总记录数
params = []
_SQL = 'select count(food_id) as num from tb_food '
params = []
if canteen:
_SQL += "where canteen = %s "
params.append(canteen)
with UseDatabase(current_app.config['dbconfig']) as cursor:
cursor.execute(_SQL, tuple(params))
datas = cursor.fetchall()
total_count = datas[0][0]
# print('total_count=' + str(total_count))
total_page = total_count / page_size
total_page = math.floor(total_page)
if total_count % page_size != 0:
total_page += 1
total_page = math.ceil(total_page)
page = {'current_page': page_num, 'page_size': page_size, 'total_page': total_page, 'total_count': total_count,
'content': objs}
return jsonify({
'success': True,
'data': page,
})
@bp.route('/getLike', methods=['GET'])
def getLike() -> 'json':
page_num = request.args.get("page_num", type=str, default=1)
page_num = int(page_num)
page_size = request.args.get("page_size", type=str, default=5)
page_size = int(page_size)
user_id = request.args.get("user_id", type=str, default=5)
_SQL = "SELECT food_id, food_name, food_cal, taste, location, recorde, add_time, img, info, canteen FROM tb_food where food_id in ( select DISTINCT food_id from tb_like where user_id = %s)"
params = []
params.append(user_id)
_SQL += """LIMIT %s, %s """
params.append((page_num - 1) * page_size)
params.append(page_size)
with UseDatabase(current_app.config['dbconfig']) as cursor:
cursor.execute(_SQL, tuple(params))
rows = cursor.fetchall()
column_name_list = [i[0] for i in cursor.description]
objs = []
for r in rows:
obj = {}
for i, item in enumerate(r):
obj[column_name_list[i]] = item
objs.append(obj)
# print(objs)
# 查询总记录数
params = []
_SQL = 'select count(food_id) as num from tb_food where food_id in ( select DISTINCT food_id from tb_like where user_id = %s)'
params = []
params.append(user_id)
with UseDatabase(current_app.config['dbconfig']) as cursor:
cursor.execute(_SQL, tuple(params))
datas = cursor.fetchall()
total_count = datas[0][0]
# print('total_count=' + str(total_count))
total_page = total_count / page_size
total_page = math.floor(total_page)
if total_count % page_size != 0:
total_page += 1
total_page = math.ceil(total_page)
page = {'current_page': page_num, 'page_size': page_size, 'total_page': total_page, 'total_count': total_count,
'content': objs}
return jsonify({
'success': True,
'data': page,
})
@bp.route('/getCollect', methods=['GET'])
def getCollect() -> 'json':
page_num = request.args.get("page_num", type=str, default=1)
page_num = int(page_num)
page_size = request.args.get("page_size", type=str, default=5)
page_size = int(page_size)
user_id = request.args.get("user_id", type=str, default=5)
_SQL = "SELECT food_id, food_name, food_cal, taste, location, recorde, add_time, img, info, canteen FROM tb_food where food_id in ( select DISTINCT food_id from tb_collect where user_id = %s) "
params = []
params.append(user_id)
_SQL += """LIMIT %s, %s """
params.append((page_num - 1) * page_size)
params.append(page_size)
with UseDatabase(current_app.config['dbconfig']) as cursor:
cursor.execute(_SQL, tuple(params))
rows = cursor.fetchall()
column_name_list = [i[0] for i in cursor.description]
objs = []
for r in rows:
obj = {}
for i, item in enumerate(r):
obj[column_name_list[i]] = item
objs.append(obj)
# print(objs)
# 查询总记录数
params = []
_SQL = 'select count(food_id) as num from tb_food where food_id in ( select DISTINCT food_id from tb_collect where user_id = %s) '
params = []
params.append(user_id)
with UseDatabase(current_app.config['dbconfig']) as cursor:
cursor.execute(_SQL, tuple(params))
datas = cursor.fetchall()
total_count = datas[0][0]
# print('total_count=' + str(total_count))
total_page = total_count / page_size
total_page = math.floor(total_page)
if total_count % page_size != 0:
total_page += 1
total_page = math.ceil(total_page)
page = {'current_page': page_num, 'page_size': page_size, 'total_page': total_page, 'total_count': total_count,
'content': objs}
return jsonify({
'success': True,
'data': page,
})
@bp.route('/getComment', methods=['GET'])
def getComment() -> 'json':
page_num = request.args.get("page_num", type=str, default=1)
page_num = int(page_num)
page_size = request.args.get("page_size", type=str, default=5)
page_size = int(page_size)
food_id = request.args.get("food_id", type=str)
user_id = request.args.get("user_id", type=str)
_SQL = "SELECT id, comment, user_id, food_id, user_name, avatar_url FROM tb_comment "
params = []
if food_id:
_SQL += "where food_id = %s "
params.append(food_id)
if user_id:
_SQL += "where user_id = %s "
params.append(user_id)
_SQL += """ORDER BY id desc LIMIT %s, %s"""
params.append((page_num - 1) * page_size)
params.append(page_size)
with UseDatabase(current_app.config['dbconfig']) as cursor:
cursor.execute(_SQL, tuple(params))
rows = cursor.fetchall()
column_name_list = [i[0] for i in cursor.description]
objs = []
for r in rows:
obj = {}
for i, item in enumerate(r):
obj[column_name_list[i]] = item
objs.append(obj)
# print(objs)
# 查询总记录数
params = []
_SQL = 'select count(food_id) as num from tb_comment '
params = []
if food_id:
_SQL += "where food_id = %s "
params.append(food_id)
if user_id:
_SQL += "where user_id = %s "
params.append(user_id)
with UseDatabase(current_app.config['dbconfig']) as cursor:
cursor.execute(_SQL, tuple(params))
datas = cursor.fetchall()
total_count = datas[0][0]
# print('total_count=' + str(total_count))
total_page = total_count / page_size
total_page = math.floor(total_page)
if total_count % page_size != 0:
total_page += 1
total_page = math.ceil(total_page)
page = {'current_page': page_num, 'page_size': page_size, 'total_page': total_page, 'total_count': total_count,
'content': objs}
return jsonify({
'success': True,
'data': page,
})
@bp.route('/getUser', methods=['GET'])
def getUser() -> 'json':
ni
没有合适的资源?快使用搜索试试~ 我知道了~
基于python+mysql的食堂食物管理系统(含数据库文件).zip
共619个文件
png:205个
js:159个
gif:128个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 11 下载量 71 浏览量
2022-07-02
22:35:24
上传
评论 4
收藏 4.56MB ZIP 举报
温馨提示
基于python+mysql的食堂食物管理系统(含数据库文件).zip 计算机专业,软件工程专业,通信工程大学生课程设计 自己大三的时候写的 适合大家做课程设计,写毕业设计也可以参考 基于python的课程设计
资源详情
资源评论
资源推荐
收起资源包目录
基于python+mysql的食堂食物管理系统(含数据库文件).zip (619个子文件)
bootstrap.min.css 120KB
ueditor.css 43KB
ueditor.min.css 34KB
font-awesome.min.css 26KB
video-js.css 21KB
image.css 18KB
video.css 15KB
attachment.css 14KB
style.css 12KB
video-js.min.css 11KB
summernote.css 10KB
shCoreDefault.css 7KB
scrawl.css 4KB
codemirror.css 3KB
charts.css 3KB
background.css 2KB
emotion.css 2KB
login.css 2KB
dialogbase.css 2KB
music.css 2KB
edittable.css 1KB
template.css 1KB
webuploader.css 515B
help.css 389B
blogAll.css 274B
iframe.css 41B
fontawesome-webfont.eot 67KB
glyphicons-halflings-regular.eot 20KB
vjs.eot 3KB
wface.gif 49KB
jxface2.gif 40KB
yface.gif 28KB
bface.gif 27KB
left.gif 24KB
baoman_01.gif 24KB
icons.gif 20KB
file-icons.gif 20KB
file-icons.gif 20KB
tface.gif 19KB
fface.gif 18KB
baoman_02.gif 16KB
34.gif 13KB
38.gif 10KB
cface.gif 8KB
17.gif 8KB
18.gif 8KB
11.gif 8KB
31.gif 7KB
46.gif 6KB
30.gif 6KB
43.gif 5KB
8.gif 5KB
28.gif 5KB
42.gif 5KB
5.gif 5KB
32.gif 4KB
40.gif 4KB
14.gif 4KB
25.gif 4KB
7.gif 4KB
10.gif 4KB
44.gif 4KB
icons-all.gif 4KB
48.gif 4KB
68.gif 3KB
9.gif 3KB
27.gif 3KB
39.gif 3KB
6.gif 3KB
16.gif 3KB
47.gif 3KB
21.gif 3KB
60.gif 3KB
26.gif 3KB
74.gif 2KB
24.gif 2KB
loading.gif 2KB
57.gif 2KB
51.gif 2KB
23.gif 2KB
12.gif 2KB
33.gif 2KB
70.gif 2KB
50.gif 2KB
22.gif 2KB
20.gif 2KB
4.gif 2KB
1.gif 2KB
19.gif 2KB
3.gif 2KB
37.gif 2KB
29.gif 2KB
45.gif 2KB
13.gif 2KB
36.gif 2KB
videologo.gif 2KB
67.gif 2KB
65.gif 2KB
2.gif 2KB
41.gif 2KB
共 619 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
我慢慢地也过来了
- 粉丝: 6410
- 资源: 3991
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 以简单、易用、高性能为目标、开源的时序数据库,支持Linux及Windows, Time Series Database.zip
- python-leetcode面试题解之第198题打家劫舍-题解.zip
- python-leetcode面试题解之第191题位1的个数-题解.zip
- python-leetcode面试题解之第186题反转字符串中的单词II-题解.zip
- 一个基于python的web后端高性能开发框架,下载可用
- python-leetcode面试题解之第179题最大数-题解.zip
- python-leetcode面试题解之第170题两数之和III数据结构设计-题解.zip
- python-leetcode面试题解之第168题Excel表列名称-题解.zip
- python-leetcode面试题解之第167题两数之和II输入有序数组-题解.zip
- python-leetcode面试题解之第166题分数到小数-题解.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论11