Commit 9b01a150 by Aeolus

Merge branch 'master' into aeolus

parents 92264414 deb0e035
...@@ -78,6 +78,10 @@ target/ ...@@ -78,6 +78,10 @@ target/
# Media # Media
*.jpg *.jpg
*.png
*.pdf
*.jpeg
*gif
#Document #Document
*.xls *.xls
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
socket = 127.0.0.1:8893 socket = 127.0.0.1:8893
# 指向网站目录 # 指向网站目录
chdir = /data/www/sukang24h chdir = /data/www/automat
# python 启动程序文件 # python 启动程序文件
wsgi-file = sukang_app.py wsgi-file = automat_app.py
# python 程序内用以启动的 application 变量名 # python 程序内用以启动的 application 变量名
callable = app callable = app
......
...@@ -23,6 +23,7 @@ class Config: ...@@ -23,6 +23,7 @@ class Config:
SQLALCHEMY_POOL_RECYCLE = 1800 SQLALCHEMY_POOL_RECYCLE = 1800
JWT_SECRET = SECRET_KEY JWT_SECRET = SECRET_KEY
TENCENT_REDIS_URL = os.getenv("TENCENT_REDIS_URL") TENCENT_REDIS_URL = os.getenv("TENCENT_REDIS_URL")
MAX_CONTENT_LENGTH = 16 * 1024 * 1024
@staticmethod @staticmethod
def init_app(app): def init_app(app):
......
...@@ -37,6 +37,18 @@ class AdminAccount(Base): ...@@ -37,6 +37,18 @@ class AdminAccount(Base):
return check_password_hash(self._password_hash_, pasword) return check_password_hash(self._password_hash_, pasword)
class AdminBrand(Base):
__tablename__ = 'admin_brand'
id = Column(INTEGER(11), primary_key=True)
user_id = Column(INTEGER(11), nullable=False)
user_no = Column(String(25, 'utf8mb4_unicode_ci'), nullable=False)
brand_id = Column(INTEGER(11), nullable=False)
status = Column(INTEGER(1), nullable=False, server_default=text("'1'"))
created_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
class AdminLoginRecord(Base): class AdminLoginRecord(Base):
__tablename__ = 'admin_login_record' __tablename__ = 'admin_login_record'
...@@ -74,21 +86,37 @@ class AdminPlace(Base): ...@@ -74,21 +86,37 @@ class AdminPlace(Base):
updated_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")) updated_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
class Brand(Base): class AdminProduction(Base):
__tablename__ = 'brand' __tablename__ = 'admin_production'
id = Column(INTEGER(10), primary_key=True) id = Column(INTEGER(11), primary_key=True)
brand_name = Column(VARCHAR(191), nullable=False, index=True, comment='品牌名') user_id = Column(INTEGER(11), nullable=False)
logo = Column(VARCHAR(191), nullable=False, comment='logo') user_no = Column(String(25, 'utf8mb4_unicode_ci'), nullable=False)
created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP")) production_id = Column(INTEGER(11), nullable=False)
updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")) status = Column(INTEGER(1), nullable=False, server_default=text("'1'"))
created_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
class AdminProductionType(Base):
__tablename__ = 'admin_production_type'
id = Column(INTEGER(11), primary_key=True)
user_id = Column(INTEGER(11), nullable=False)
user_no = Column(String(25, 'utf8mb4_unicode_ci'), nullable=False)
production_type_id = Column(INTEGER(11), nullable=False)
status = Column(INTEGER(1), nullable=False, server_default=text("'1'"))
created_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
class Cate(Base): class Brand(Base):
__tablename__ = 'cate' __tablename__ = 'brand'
id = Column(INTEGER(10), primary_key=True) id = Column(INTEGER(10), primary_key=True)
cate_name = Column(VARCHAR(191), nullable=False, index=True, comment='分类名') brand_name = Column(VARCHAR(191), nullable=False, index=True, comment='品牌名')
img = Column(VARCHAR(191), nullable=False, comment='logo')
status = Column(TINYINT(1), default=text("'1'"), comment='状态: 1正常-1删除')
created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP")) created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")) updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
...@@ -228,17 +256,34 @@ class Production(Base): ...@@ -228,17 +256,34 @@ class Production(Base):
__tablename__ = 'production' __tablename__ = 'production'
id = Column(INTEGER(10), primary_key=True) id = Column(INTEGER(10), primary_key=True)
name = Column(String(100, 'utf8mb4_unicode_ci'), nullable=False, index=True, comment='商品名称') production_no = Column(String(45, 'utf8mb4_unicode_ci'), nullable=False)
production_name = Column(String(100, 'utf8mb4_unicode_ci'), nullable=False, index=True, comment='商品名称')
title = Column(String(200, 'utf8mb4_unicode_ci'), nullable=False, comment='商品标题') title = Column(String(200, 'utf8mb4_unicode_ci'), nullable=False, comment='商品标题')
brand_id = Column(INTEGER(10), nullable=False, comment='品牌ID') brand_id = Column(INTEGER(10), nullable=False, comment='品牌ID')
cate_id = Column(INTEGER(10), nullable=False, comment='分类ID') production_type_id = Column(INTEGER(10), nullable=False, comment='分类ID')
weight = Column(INTEGER(10), server_default=text("'0'"))
weight_unit = Column(String(10, 'utf8mb4_unicode_ci'), server_default=text("'g'"))
expiration_date = Column(INTEGER(10), server_default=text("'0'"))
expiration_date_unit = Column(String(10, 'utf8mb4_unicode_ci'), server_default=text("'月'"))
is_expiration_date = Column(TINYINT(1), server_default=text("'0'"))
weight_error = Column(INTEGER(10), server_default=text("'0'"))
price = Column(INTEGER(10), nullable=False, comment='价格') price = Column(INTEGER(10), nullable=False, comment='价格')
original_price = Column(INTEGER(10), nullable=False, comment='商品原价') original_price = Column(INTEGER(10), nullable=False, comment='商品原价')
img = Column(String(200, 'utf8mb4_unicode_ci')) img = Column(String(200, 'utf8mb4_unicode_ci'))
tags = Column(String(255, 'utf8mb4_unicode_ci'), comment='商品标签') tags = Column(String(255, 'utf8mb4_unicode_ci'), comment='商品标签')
content = Column(Text(collation='utf8mb4_unicode_ci'), comment='商品内容') content = Column(Text(collation='utf8mb4_unicode_ci'), comment='商品内容')
summary = Column(Text(collation='utf8mb4_unicode_ci'), comment='商品描述') summary = Column(Text(collation='utf8mb4_unicode_ci'), comment='商品描述')
status = Column(TINYINT(1), comment='状态: 1正常-1删除') status = Column(TINYINT(1), default=text("'1'"), comment='状态: 1正常-1删除')
created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
class ProductionType(Base):
__tablename__ = 'production_type'
id = Column(INTEGER(10), primary_key=True)
production_type_name = Column(VARCHAR(191), nullable=False, index=True)
status = Column(TINYINT(1), default=text("'1'"), comment='状态: 1正常-1删除')
created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP")) created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")) updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
......
...@@ -14,14 +14,13 @@ class AdminAccount(Base): ...@@ -14,14 +14,13 @@ class AdminAccount(Base):
user_no = Column(String(25, 'utf8mb4_unicode_ci'), nullable=False, unique=True) user_no = Column(String(25, 'utf8mb4_unicode_ci'), nullable=False, unique=True)
user_name = Column(String(255, 'utf8mb4_unicode_ci'), nullable=False) user_name = Column(String(255, 'utf8mb4_unicode_ci'), nullable=False)
phone = Column(String(191, 'utf8mb4_unicode_ci'), nullable=False, unique=True) phone = Column(String(191, 'utf8mb4_unicode_ci'), nullable=False, unique=True)
level = Column(INTEGER(1), nullable=False) level = Column(TINYINT(2), nullable=False)
parent_id = Column(INTEGER(10), nullable=False) parent_id = Column(INTEGER(10), nullable=False)
draw = Column(TINYINT(1), nullable=False, server_default=text("'0'"))
rate = Column(INTEGER(10), nullable=False) rate = Column(INTEGER(10), nullable=False)
status = Column(INTEGER(1), nullable=False) status = Column(INTEGER(1), nullable=False)
_password_hash_ = Column(String(255, 'utf8mb4_unicode_ci')) _password_hash_ = Column(String(255, 'utf8mb4_unicode_ci'))
comment = Column(String(255, 'utf8mb4_unicode_ci')) comment = Column(String(255, 'utf8mb4_unicode_ci'))
last_login = Column(DateTime)
expire_time = Column(DateTime)
created_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP")) created_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")) updated_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
...@@ -46,7 +45,7 @@ class AdminMachine(Base): ...@@ -46,7 +45,7 @@ class AdminMachine(Base):
user_id = Column(INTEGER(11), nullable=False) user_id = Column(INTEGER(11), nullable=False)
user_no = Column(String(25, 'utf8mb4_unicode_ci'), nullable=False) user_no = Column(String(25, 'utf8mb4_unicode_ci'), nullable=False)
machine_no = Column(INTEGER(11), nullable=False) machine_no = Column(INTEGER(11), nullable=False)
status = Column(INTEGER(1), nullable=False) status = Column(INTEGER(1), nullable=False, server_default=text("'1'"))
created_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP")) created_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")) updated_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
...@@ -58,30 +57,31 @@ class AdminPlace(Base): ...@@ -58,30 +57,31 @@ class AdminPlace(Base):
user_id = Column(INTEGER(11), nullable=False) user_id = Column(INTEGER(11), nullable=False)
user_no = Column(String(25, 'utf8mb4_unicode_ci'), nullable=False) user_no = Column(String(25, 'utf8mb4_unicode_ci'), nullable=False)
place_id = Column(INTEGER(11), nullable=False) place_id = Column(INTEGER(11), nullable=False)
status = Column(INTEGER(1), nullable=False) status = Column(INTEGER(1), nullable=False, server_default=text("'1'"))
created_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP")) created_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")) updated_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
class Brand(Base): class AdminProduction(Base):
__tablename__ = 'brand' __tablename__ = 'admin_production'
id = Column(INTEGER(10), primary_key=True) id = Column(INTEGER(11), primary_key=True)
brand_name = Column(VARCHAR(191), nullable=False, index=True) user_id = Column(INTEGER(11), nullable=False)
logo = Column(VARCHAR(191), nullable=False) user_no = Column(String(25, 'utf8mb4_unicode_ci'), nullable=False)
created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP")) production_id = Column(INTEGER(11), nullable=False)
updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")) status = Column(INTEGER(1), nullable=False, server_default=text("'1'"))
created_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
class Cate(Base): class Brand(Base):
__tablename__ = 'cate' __tablename__ = 'brand'
id = Column(INTEGER(10), primary_key=True) id = Column(INTEGER(10), primary_key=True)
brand_id = Column(INTEGER(10), nullable=False) name = Column(VARCHAR(191), nullable=False, index=True)
cate_name = Column(VARCHAR(191), nullable=False, index=True) img = Column(VARCHAR(191), nullable=False)
created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP")) created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")) updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
catecol = Column(String(45, 'utf8mb4_unicode_ci'))
class Hatch(Base): class Hatch(Base):
...@@ -117,14 +117,14 @@ class Machine(Base): ...@@ -117,14 +117,14 @@ class Machine(Base):
__tablename__ = 'machine' __tablename__ = 'machine'
id = Column(INTEGER(10), primary_key=True) id = Column(INTEGER(10), primary_key=True)
machine_no = Column(String(20, 'utf8mb4_unicode_ci'), unique=True) machine_no = Column(String(20, 'utf8mb4_unicode_ci'), nullable=False, unique=True)
device_id = Column(String(45, 'utf8mb4_unicode_ci'), unique=True) device_id = Column(String(45, 'utf8mb4_unicode_ci'), unique=True)
qrcode_no = Column(String(20, 'utf8mb4_unicode_ci'), nullable=False, unique=True) qrcode_no = Column(String(20, 'utf8mb4_unicode_ci'), unique=True)
mac = Column(String(30, 'utf8mb4_unicode_ci')) mac = Column(String(30, 'utf8mb4_unicode_ci'), unique=True)
power = Column(TINYINT(3), nullable=False, server_default=text("'0'")) power = Column(TINYINT(3), nullable=False, server_default=text("'0'"))
short_address = Column(VARCHAR(45)) short_address = Column(VARCHAR(45))
address = Column(String(191, 'utf8mb4_unicode_ci')) address = Column(String(191, 'utf8mb4_unicode_ci'))
place_id = Column(INTEGER(10), nullable=False) place_id = Column(INTEGER(10))
mch_platform = Column(INTEGER(11), nullable=False, server_default=text("'1'")) mch_platform = Column(INTEGER(11), nullable=False, server_default=text("'1'"))
position = Column(String(20, 'utf8mb4_unicode_ci')) position = Column(String(20, 'utf8mb4_unicode_ci'))
hatch_number = Column(TINYINT(3), nullable=False, server_default=text("'0'")) hatch_number = Column(TINYINT(3), nullable=False, server_default=text("'0'"))
...@@ -133,6 +133,7 @@ class Machine(Base): ...@@ -133,6 +133,7 @@ class Machine(Base):
created_at = Column(TIMESTAMP, nullable=False, server_default=text("CURRENT_TIMESTAMP")) created_at = Column(TIMESTAMP, nullable=False, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(TIMESTAMP, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")) updated_at = Column(TIMESTAMP, nullable=False, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
command_time = Column(INTEGER(4), nullable=False, server_default=text("'1'")) command_time = Column(INTEGER(4), nullable=False, server_default=text("'1'"))
discounts_id = Column(INTEGER(10), server_default=text("'0'"))
class MachineProduction(Base): class MachineProduction(Base):
...@@ -236,14 +237,16 @@ class Place(Base): ...@@ -236,14 +237,16 @@ class Place(Base):
__tablename__ = 'place' __tablename__ = 'place'
id = Column(INTEGER(10), primary_key=True) id = Column(INTEGER(10), primary_key=True)
parent_id = Column(INTEGER(10))
place_name = Column(VARCHAR(191), nullable=False, index=True) place_name = Column(VARCHAR(191), nullable=False, index=True)
img = Column(VARCHAR(191)) img = Column(VARCHAR(191))
logo = Column(VARCHAR(191), nullable=False) logo = Column(VARCHAR(191))
address = Column(VARCHAR(255), nullable=False, server_default=text("''")) address = Column(VARCHAR(255), server_default=text("''"))
position = Column(String(20, 'utf8mb4_unicode_ci')) position = Column(String(20, 'utf8mb4_unicode_ci'))
open_time = Column(VARCHAR(191), nullable=False) open_time = Column(VARCHAR(191))
close_time = Column(VARCHAR(191), nullable=False) close_time = Column(VARCHAR(191))
open_week = Column(VARCHAR(255), nullable=False, server_default=text("''")) open_week = Column(VARCHAR(255), server_default=text("''"))
status = Column(INTEGER(1), nullable=False, server_default=text("'1'"))
created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP")) created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")) updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
...@@ -263,12 +266,19 @@ class Production(Base): ...@@ -263,12 +266,19 @@ class Production(Base):
__tablename__ = 'production' __tablename__ = 'production'
id = Column(INTEGER(10), primary_key=True) id = Column(INTEGER(10), primary_key=True)
name = Column(String(100, 'utf8mb4_unicode_ci'), nullable=False, index=True) production_no = Column(String(45, 'utf8mb4_unicode_ci'), nullable=False)
production_name = Column(String(100, 'utf8mb4_unicode_ci'), nullable=False, index=True)
title = Column(String(200, 'utf8mb4_unicode_ci'), nullable=False) title = Column(String(200, 'utf8mb4_unicode_ci'), nullable=False)
brand_id = Column(INTEGER(10), nullable=False) brand_id = Column(INTEGER(10), nullable=False)
cate_id = Column(INTEGER(10), nullable=False) production_type_id = Column(INTEGER(10), nullable=False)
price = Column(INTEGER(10), nullable=False) price = Column(INTEGER(10), nullable=False)
original_price = Column(INTEGER(10), nullable=False) original_price = Column(INTEGER(10), nullable=False)
weight = Column(INTEGER(10), server_default=text("'0'"))
weight_unit = Column(String(10, 'utf8mb4_unicode_ci'), server_default=text("'g'"))
expiration_date = Column(INTEGER(10), server_default=text("'0'"))
expiration_date_unit = Column(String(10, 'utf8mb4_unicode_ci'), server_default=text("''"))
is_expiration_date = Column(TINYINT(1), server_default=text("'0'"))
weight_error = Column(INTEGER(10), server_default=text("'0'"))
img = Column(String(200, 'utf8mb4_unicode_ci')) img = Column(String(200, 'utf8mb4_unicode_ci'))
tags = Column(String(255, 'utf8mb4_unicode_ci')) tags = Column(String(255, 'utf8mb4_unicode_ci'))
content = Column(Text(collation='utf8mb4_unicode_ci')) content = Column(Text(collation='utf8mb4_unicode_ci'))
...@@ -278,6 +288,16 @@ class Production(Base): ...@@ -278,6 +288,16 @@ class Production(Base):
updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")) updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
class ProductionType(Base):
__tablename__ = 'production_type'
id = Column(INTEGER(10), primary_key=True)
name = Column(VARCHAR(191), nullable=False, index=True)
created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
catecol = Column(String(45, 'utf8mb4_unicode_ci'))
class Rent(Base): class Rent(Base):
__tablename__ = 'rent' __tablename__ = 'rent'
......
...@@ -124,7 +124,8 @@ def create_rent(): ...@@ -124,7 +124,8 @@ def create_rent():
db.session.add(rent) db.session.add(rent)
db.session.add(rent_detail) db.session.add(rent_detail)
db.session.commit() db.session.commit()
return BaseResponse(data={"out_trade_no": rent_no, "free_order": True}) return BaseResponse(
data={"out_trade_no": rent_no, "free_order": True, "open_hatchs": {str(open_hatch.hatch_no): 1}})
total_fee = 0 total_fee = 0
open_hatchs = {} open_hatchs = {}
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
""" """
@version: @version:
author:Aeolus author:Aeolus
@file: upload_portal.py @file: file_protal.py
""" """
import logging import logging
import uuid import uuid
......
...@@ -14,6 +14,8 @@ from flask import Flask ...@@ -14,6 +14,8 @@ from flask import Flask
from myapps.pc_management.api.admin_portal import admin_route from myapps.pc_management.api.admin_portal import admin_route
from myapps.pc_management.api.place_portal import place_route from myapps.pc_management.api.place_portal import place_route
from myapps.pc_management.api.machine_portal import machine_route from myapps.pc_management.api.machine_portal import machine_route
from myapps.pc_management.api.file_protal import file_route
from myapps.pc_management.api.production_portal import production_route
def register_sukang_blueprint(app: Flask): def register_sukang_blueprint(app: Flask):
...@@ -21,3 +23,5 @@ def register_sukang_blueprint(app: Flask): ...@@ -21,3 +23,5 @@ def register_sukang_blueprint(app: Flask):
app.register_blueprint(admin_route, url_prefix=prefix + "/admin") app.register_blueprint(admin_route, url_prefix=prefix + "/admin")
app.register_blueprint(place_route, url_prefix=prefix + "/place") app.register_blueprint(place_route, url_prefix=prefix + "/place")
app.register_blueprint(machine_route, url_prefix=prefix + "/machine") app.register_blueprint(machine_route, url_prefix=prefix + "/machine")
app.register_blueprint(file_route, url_prefix=prefix + "/file")
app.register_blueprint(production_route, url_prefix=prefix + "/production")
...@@ -137,7 +137,7 @@ def add_user(): ...@@ -137,7 +137,7 @@ def add_user():
account.password = password account.password = password
db.session.add(account) db.session.add(account)
db.session.commit() db.session.commit()
account.user_no = "SK" + str(account.id).zfill(6) account.user_no = "XX" + str(account.id).zfill(6)
db.session.add(account) db.session.add(account)
db.session.commit() db.session.commit()
......
#!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@version:
author:Aeolus
@file: file_protal.py
"""
import logging
import os
import uuid
from flask import Blueprint, request, jsonify, send_from_directory
from config.env_path_config import img_file_path
from utils.my_response import BaseResponse
logger = logging.getLogger(__name__)
file_route = Blueprint('file', __name__)
ALLOWED_EXTENSIONS = ('pdf', 'png', 'jpg', 'jpeg', 'gif')
@file_route.route("/upload_img", methods=['POST'])
def run_upload_img():
file = request.files["file"]
filename = str(file.filename)
if len(filename) >= 20: # 限制文件名的长度必须在20个字符以内
return jsonify({"error_code": "500", "error_message": "文件名长度超出了限制!"})
else:
if filename.find(".") >= 0: # 查找文件中是否包含点这个字符
filetype = file.filename.split(".")[1] # 取出文件类型,后期做判断
if filetype and filetype in ALLOWED_EXTENSIONS: # 后缀格式必须是bmp结尾
uid = uuid.uuid4() # 生成随机名称
save_file_name = str(uid) + "." + filetype # 拼接名称
print(os.path.join(img_file_path, filename))
file.save(os.path.join(img_file_path, save_file_name)) # 保存文件
return BaseResponse(data={"filename": save_file_name})
return jsonify({"error_code": "500", "error_message": "没有选择文件,或不是图片格式,上传失败!"})
@file_route.route('/img/<filename>', )
def run_download_img(filename):
return send_from_directory(img_file_path, filename)
#!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@version:
author:Aeolus
@time: 2022/01/12
@file: machine_portal.py
@function:
@modify:
"""
import logging
from flask import Blueprint, g, request, jsonify
from config.commen_config import DISCOUNTS_TYPES
from models.base_model import db
from models.models import AdminMachine, Machine
from utils.error_code import MACHINE_NOT_EXIST_ERROR
from utils.my_response import BaseResponse
logger = logging.getLogger(__name__)
hatch_route = Blueprint('hatch', __name__)
@hatch_route.route("hatch_list", methods=["POST"])
def run_hatch_list():
"""
:return:
"""
json_data = request.get_json()
page = json_data.get("page", None)
page_size = json_data.get("pageSize", None)
keyword = json_data.get("keyword", None)
admin = g.user
select_sql = """select machine.id, machine.machine_no, machine.device_id, machine.qrcode_no,machine.status,
machine.mac, machine.power, machine.hatch_number, machine.type,machine.place_id,
place.place_name, machine.discounts_id
"""
count_sql = "select count(machine.id) as total_count"
from_sql = """ from machine left join place on machine.place_id = place.id
where machine.machine_no in ( select machine_no from admin_machine where
admin_machine.user_id = {user_id} and admin_machine.status = 1)
""".format(user_id=admin.id)
where_sql = " "
if keyword:
where_sql += """
and CONCAT(machine.machine_no,ifnull(machine.qrcode_no,'')) LIKE '%{keyword}%'
""".format(keyword=keyword)
order_sql = " ORDER BY machine.id ASC, machine.status ASC"
limit_sql = " LIMIT {offset} , {page_size} ".format(offset=(page - 1) * page_size, page_size=page_size)
count_result = db.session.execute(count_sql + from_sql + where_sql).fetchone()
if not count_result:
return BaseResponse(data={"list": [], "page": page, "pageSize": page_size, "total_count": 0})
else:
total_count = count_result.total_count
print(select_sql + from_sql + where_sql + order_sql + limit_sql)
result = db.session.execute(select_sql + from_sql + where_sql + order_sql + limit_sql).fetchall()
return_data = []
for info in result:
return_data.append(
{"machine_no": info.machine_no, "device_id": info.device_id, "place_name": info.place_name,
"mac": info.mac, "power": info.power, "hatch_number": info.hatch_number, "type": info.type,
"status": info.status, "place_id": info.place_id,
"discounts_id": info.discounts_id,
"discounts_name": DISCOUNTS_TYPES.get(int(info.discounts_id), "无此优惠"),
})
return BaseResponse({"list": return_data, "page": page, "pageSize": page_size, "total_count": total_count})
@hatch_route.route("add_machine", methods=["POST"])
def run_add_machine():
"""
:return:
"""
json_data = request.get_json()
machine_no = json_data["machine_no"]
address = json_data.get("address", None)
device_id = json_data.get("device_id", None)
qrcode_no = json_data.get("qrcode_no", None)
mac = json_data.get("mac", None)
power = json_data.get("power", None)
hatch_number = json_data.get("hatch_number", None)
place_id = json_data.get("place_id", None)
type = json_data.get("type", 1)
discounts_id = json_data.get("type", 0)
machine_model = Machine()
machine_model.machine_no = machine_no
machine_model.device_id = device_id
machine_model.qrcode_no = qrcode_no
machine_model.mac = mac
machine_model.power = power
machine_model.place_id = place_id
machine_model.address = address
machine_model.mch_platform = 1
machine_model.hatch_number = hatch_number
machine_model.type = type
machine_model.discounts_id = discounts_id
db.session.add(machine_model)
admin_machine = AdminMachine()
admin_machine.user_id = g.user.id
admin_machine.user_no = g.user.user_no
admin_machine.machine_no = machine_model.machine_no
db.session.add(admin_machine)
db.session.commit()
return BaseResponse()
@hatch_route.route("edit_machine", methods=["POST"])
def run_edit_machine():
"""
:return:
"""
json_data = request.get_json()
machine_no = json_data["machine_no"]
address = json_data.get("address", None)
device_id = json_data.get("device_id", None)
qrcode_no = json_data.get("qrcode_no", None)
mac = json_data.get("mac", None)
power = json_data.get("power", None)
hatch_number = json_data.get("hatch_number", None)
place_id = json_data.get("place_id", None)
type = json_data.get("type", None)
status = json_data.get("status", None)
discounts_id = json_data.get("discounts_id", None)
machine_model = Machine.query.filter_by(machine_no=machine_no).first()
if not machine_model:
return jsonify(MACHINE_NOT_EXIST_ERROR)
if device_id:
machine_model.device_id = device_id
if qrcode_no:
machine_model.qrcode_no = qrcode_no
if mac:
machine_model.mac = mac
if power:
machine_model.power = power
if place_id:
machine_model.place_id = place_id
if address:
machine_model.address = address
if hatch_number:
machine_model.hatch_number = hatch_number
if type:
machine_model.type = type
if status:
machine_model.status = status
if discounts_id:
machine_model.discounts_id = discounts_id
db.session.add(machine_model)
db.session.commit()
return BaseResponse()
@hatch_route.route("machine_detail", methods=["POST"])
def get_machine_detail():
"""
:return:
"""
json_data = request.get_json()
machine_no = json_data["machine_no"]
admin = g.user
select_sql = """select machine.id, machine.machine_no, machine.device_id, machine.qrcode_no,machine.status,
machine.mac, machine.power, machine.hatch_number, machine.type,machine.place_id,
place.place_name, machine.discounts_id
"""
from_sql = """ from machine left join place on machine.place_id = place.id
where machine.machine_no in ( select machine_no from admin_machine where
admin_machine.user_id = {user_id} and admin_machine.status = 1)
""".format(user_id=admin.id)
where_sql = " and machine.machine_no = {}".format(machine_no)
result = db.session.execute(select_sql + from_sql + where_sql).fetchall()
if not result or len(result) != 1:
return jsonify(MACHINE_NOT_EXIST_ERROR)
info = result[0]
return BaseResponse(data={"machine_no": info.machine_no, "device_id": info.device_id, "place_name": info.place_name,
"mac": info.mac, "power": info.power, "hatch_number": info.hatch_number,
"type": info.type, "status": info.status, "place_id": info.place_id,
"discounts_id": info.discounts_id,
"discounts_name": DISCOUNTS_TYPES.get(int(info.discounts_id), "无此优惠"),
})
[uwsgi]
# uwsgi 启动时所使用的地址与端口
socket = 127.0.0.1:8894
# 指向网站目录
chdir = /data/www/automat
# python 启动程序文件
wsgi-file = pc_management_app.py
# python 程序内用以启动的 application 变量名
callable = app
# 处理器数
processes = 2
# 线程数
threads = 4
...@@ -17,9 +17,14 @@ wechatpy = "^1.8.15" ...@@ -17,9 +17,14 @@ wechatpy = "^1.8.15"
flask-redis = "^0.4.0" flask-redis = "^0.4.0"
PyJWT = "^2.2.0" PyJWT = "^2.2.0"
pycryptodome = "^3.11.0" pycryptodome = "^3.11.0"
cryptography = "^36.0.1"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
[[tool.poetry.source]]
name = "aliyun"
url = "http://mirrors.cloud.aliyuncs.com/pypi/simple/"
[build-system] [build-system]
requires = ["poetry-core>=1.0.0"] requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api" build-backend = "poetry.core.masonry.api"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment