Commit 2891ca8b by Aeolus

update

parent 64097be9
# coding: utf-8
from sqlalchemy import Column, DateTime, Index, String, TIMESTAMP, Text, text
from sqlalchemy.dialects.mysql import CHAR, INTEGER, TINYINT, VARCHAR
from sqlalchemy.dialects.mysql import INTEGER, TINYINT, VARCHAR
from models.base_model import Base
class Brand(Base):
__tablename__ = 'brand'
id = Column(INTEGER(10), primary_key=True)
brand_name = Column(VARCHAR(191), nullable=False, index=True, comment='品牌名')
logo = Column(VARCHAR(191), nullable=False, comment='logo')
created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
class Cate(Base):
__tablename__ = 'cate'
id = Column(INTEGER(10), primary_key=True)
cate_name = Column(VARCHAR(191), nullable=False, index=True, comment='分类名')
created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP"))
updated_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
class Hatch(Base):
__tablename__ = 'hatch'
__table_args__ = (
Index('hatch_machine_UNIQUE', 'machine_id', 'hatch_no', unique=True),
Index('hatch_machine_UNIQUE', 'machine_no', 'hatch_no', unique=True),
)
id = Column(INTEGER(10), primary_key=True, unique=True)
machine_id = Column(INTEGER(10), comment='机柜id')
hatch_no = Column(TINYINT(3), comment='机柜仓口号')
production_id = Column(INTEGER(10), comment='商品id')
machine_no = Column(String(20, 'utf8mb4_unicode_ci'), nullable=False, comment='机柜id')
hatch_no = Column(TINYINT(3), nullable=False, comment='机柜仓口号')
production_id = Column(INTEGER(10), nullable=False, comment='商品id')
name = Column(String(100, 'utf8mb4_unicode_ci'), nullable=False, comment='商品名称')
titile = Column(String(200, 'utf8mb4_unicode_ci'), nullable=False, comment='商品标题')
brand_id = Column(INTEGER(10), nullable=False, comment='品牌ID')
brand_name = Column(String(100, 'utf8mb4_unicode_ci'), nullable=False, comment='商品名称')
cate_id = Column(INTEGER(10), nullable=False, comment='分类ID')
cate_name = Column(String(200, 'utf8mb4_unicode_ci'), nullable=False, comment='商品标题')
price = Column(INTEGER(10), nullable=False, comment='价格')
original_price = Column(INTEGER(10), nullable=False, comment='商品原价')
img = Column(String(200, 'utf8mb4_unicode_ci'))
tags = Column(String(255, 'utf8mb4_unicode_ci'), comment='商品标签')
content = Column(Text(collation='utf8mb4_unicode_ci'), comment='商品内容')
summary = Column(Text(collation='utf8mb4_unicode_ci'), comment='商品描述')
status = Column(TINYINT(3), nullable=False, server_default=text("'1'"),
comment='充电宝状态1在仓库2在机柜可用3在机柜占用4出货成功5永久锁 7未清洁 8手动弹出')
created_at = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP"))
......@@ -25,14 +56,15 @@ class Machine(Base):
__tablename__ = 'machine'
id = Column(INTEGER(10), primary_key=True)
mac_no = Column(CHAR(17), nullable=False, unique=True, comment='机柜编号')
position = Column(String(20, 'utf8mb4_unicode_ci'), comment='机柜位置坐标')
machine_no = Column(String(17, 'utf8mb4_unicode_ci'), nullable=False, unique=True, comment='机柜编号')
short_address = Column(VARCHAR(45))
address = Column(VARCHAR(191), comment='机柜位置')
address = Column(String(191, 'utf8mb4_unicode_ci'), comment='机柜位置')
place_id = Column(INTEGER(10), nullable=False)
mch_platform = Column(INTEGER(11), nullable=False, server_default=text("'1'"), comment='1随身玩 2晓见文旅')
type = Column(TINYINT(3), nullable=False, server_default=text("'1'"), comment='机柜类型1正常')
position = Column(String(20, 'utf8mb4_unicode_ci'), comment='机柜位置坐标')
hatch_number = Column(TINYINT(3), nullable=False, server_default=text("'60'"), comment='机柜的仓口数量')
type = Column(TINYINT(3), nullable=False, server_default=text("'1'"), comment='机柜类型1正常')
status = Column(TINYINT(1), server_default=text("'1'"), comment='状态: 1正常-1删除')
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"))
......@@ -54,8 +86,6 @@ class Place(Base):
id = Column(INTEGER(10), primary_key=True)
place_name = Column(VARCHAR(191), nullable=False, index=True, comment='场所名')
main_title = Column(VARCHAR(191), nullable=False, comment='主标题')
vic_title = Column(VARCHAR(191), nullable=False, comment='副标题')
img = Column(VARCHAR(191), comment='展示界面的图片')
logo = Column(VARCHAR(191), nullable=False, comment='微型头像')
address = Column(VARCHAR(255), nullable=False, server_default=text("''"))
......@@ -77,10 +107,11 @@ class Production(Base):
cate_id = Column(INTEGER(10), nullable=False, comment='分类ID')
price = Column(INTEGER(10), nullable=False, comment='价格')
original_price = Column(INTEGER(10), nullable=False, comment='商品原价')
tags = Column(String(255, 'utf8mb4_unicode_ci'), nullable=False, comment='商品标签')
content = Column(Text(collation='utf8mb4_unicode_ci'), nullable=False, comment='商品内容')
summary = Column(Text(collation='utf8mb4_unicode_ci'), nullable=False, comment='商品描述')
status = Column(TINYINT(1), nullable=False, comment='状态: 1整除-1删除')
img = Column(String(200, 'utf8mb4_unicode_ci'))
tags = Column(String(255, 'utf8mb4_unicode_ci'), comment='商品标签')
content = Column(Text(collation='utf8mb4_unicode_ci'), comment='商品内容')
summary = Column(Text(collation='utf8mb4_unicode_ci'), comment='商品描述')
status = Column(TINYINT(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"))
......
......@@ -7,9 +7,11 @@ author:Aeolus
"""
from flask import Flask
from myapps.sukang24h.api.wx_auth import wx_auth_route
from myapps.sukang24h.api.wx_auth_portal import wx_auth_route
from myapps.sukang24h.api.hatch_portal import hatch_route
def register_sukang_blueprint(app: Flask):
prefix = "/sukang"
app.register_blueprint(wx_auth_route, url_prefix=prefix + "/wx_auth")
app.register_blueprint(hatch_route, url_prefix=prefix + "/hatch")
#!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@version:
author:Aeolus
@file: hatch_portal.py
"""
import logging
from flask import Blueprint, request, jsonify
from models.models import Machine, Production, Hatch
from utils.error_code import MACHINE_NOT_EXIST_ERROR, HATCH_NOT_EXIST_ERROR
from utils.my_response import BaseResponse
logger = logging.getLogger(__name__)
hatch_route = Blueprint('hatch', __name__)
@hatch_route.route('list', methods=["post"])
def get_production_list():
json_data = request.get_json()
machine_no = json_data["machine_no"]
machine_info = Machine.query.filter_by(machine_no=machine_no, status=1).first()
if not machine_info:
return jsonify(MACHINE_NOT_EXIST_ERROR)
hatch_list = Hatch.query.filter_by(machine_no=machine_no).order_by(Hatch.hatch_no.asc()).all()
if not hatch_list:
return jsonify(HATCH_NOT_EXIST_ERROR)
hatch_data = [{
"machine_no": i.machine_no,
"hatch_no": i.hatch_no,
"production_id": i.production_id,
"name": i.name,
"titile": i.titile,
"brand_id": i.brand_id,
"brand_name": i.brand_name,
"cate_id": i.cate_id,
"cate_name": i.cate_name,
"price": i.price,
"original_price": i.original_price,
"img": i.img,
"tags": i.tags,
"content": i.content,
"summary": i.summary,
"status": i.status,
} for i in hatch_list]
return BaseResponse(data=hatch_data)
@hatch_route.route('info', methods=["post"])
def get_production_info():
json_data = request.get_json()
machine_no = json_data["machine_no"]
hatch_no = json_data["hatch_no"]
machine_info = Machine.query.filter_by(machine_no=machine_no, status=1).first()
if not machine_info:
return jsonify(MACHINE_NOT_EXIST_ERROR)
hatch_info = Hatch.query.filter_by(machine_no=machine_no, hatch_no=hatch_no).first()
if not hatch_info:
return jsonify(HATCH_NOT_EXIST_ERROR)
hatch_data = {
"machine_no": hatch_info.machine_no,
"hatch_no": hatch_info.hatch_no,
"production_id": hatch_info.production_id,
"name": hatch_info.name,
"titile": hatch_info.titile,
"brand_id": hatch_info.brand_id,
"brand_name": hatch_info.brand_name,
"cate_id": hatch_info.cate_id,
"cate_name": hatch_info.cate_name,
"price": hatch_info.price,
"original_price": hatch_info.original_price,
"img": hatch_info.img,
"tags": hatch_info.tags,
"content": hatch_info.content,
"summary": hatch_info.summary,
"status": hatch_info.status,
}
return BaseResponse(data=hatch_data)
#!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@version:
author:Aeolus
@file: upload_portal.py
"""
import logging
import uuid
from flask import Blueprint, request, jsonify
logger = logging.getLogger(__name__)
upload_route = Blueprint('upload', __name__)
@upload_route.route("/upload", methods=['POST'])
def upload_file():
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 != None and filetype == "bmp": # 后缀格式必须是bmp结尾
uid = uuid.uuid4() # 生成随机名称
save_file_name = str(uid) + "." + filetype # 拼接名称
file.save(save_file_name) # 保存文件
return jsonify({"error_code": "0", "error_message": "文件上传成功 {}".format(save_file_name)})
else:
return jsonify({"error_code": "500", "error_message": "没有选择文件,或不是图片格式,上传失败!"})
......@@ -3,7 +3,7 @@
"""
@version:
author:Aeolus
@file: wx_auth.py
@file: wx_auth_portal.py
"""
import logging
import time
......
......@@ -150,3 +150,37 @@ WXBizMsgCrypt_GenReturnXml_Error = {
"error_code": 4011,
"error_message": "gen return xml error"
}
MACHINE_NOT_EXIST_ERROR = {
"error_code": '5001',
"error_message": "机柜不存在"
}
MACHINE_IS_USE_ERROR = {
"error_code": '5002',
"error_message": "已有他人正在租借中,请稍后"
}
MACHINE_IS_NOT_ONLINE_ERROR = {
"error_code": '5003',
"error_message": "机柜不在线"
}
MACHINE_ADD_ERROR = {
"error_code": '5004',
"error_message": "机柜添加失败"
}
MACHINE_NO_DUPLICATE_ERROR = {
"error_code": '5005',
"error_message": "machine_no duplicate,机柜编号重复"
}
MACHINE_EDIT_ERROR = {
"error_code": '5006',
"error_message": "machine edit error, 机柜修改错误"
}
HATCH_NOT_EXIST_ERROR = {
"error_code": "5007",
"error_message": "no hatch, 没有商品信息"
}
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