first commit
This commit is contained in:
8
app/api/v1/barcode/__init__.py
Normal file
8
app/api/v1/barcode/__init__.py
Normal file
@ -0,0 +1,8 @@
|
||||
from fastapi import APIRouter
|
||||
from app.api.v1.barcode import barcode, template
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
router.include_router(barcode.router)
|
||||
router.include_router(template.router, prefix='/template')
|
||||
BIN
app/api/v1/barcode/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
app/api/v1/barcode/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/api/v1/barcode/__pycache__/attribute.cpython-311.pyc
Normal file
BIN
app/api/v1/barcode/__pycache__/attribute.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/api/v1/barcode/__pycache__/barcode.cpython-311.pyc
Normal file
BIN
app/api/v1/barcode/__pycache__/barcode.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/api/v1/barcode/__pycache__/size.cpython-311.pyc
Normal file
BIN
app/api/v1/barcode/__pycache__/size.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/api/v1/barcode/__pycache__/template.cpython-311.pyc
Normal file
BIN
app/api/v1/barcode/__pycache__/template.cpython-311.pyc
Normal file
Binary file not shown.
9
app/api/v1/barcode/barcode.py
Normal file
9
app/api/v1/barcode/barcode.py
Normal file
@ -0,0 +1,9 @@
|
||||
import json
|
||||
from time import time
|
||||
from fastapi import APIRouter
|
||||
from app.config import config
|
||||
from app.utils.logger_util import logger
|
||||
from app.utils.response_util import response
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
9
app/api/v1/barcode/template/__init__.py
Normal file
9
app/api/v1/barcode/template/__init__.py
Normal file
@ -0,0 +1,9 @@
|
||||
from fastapi import APIRouter
|
||||
from app.api.v1.barcode.template import template, size, attribute
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
router.include_router(template.router)
|
||||
router.include_router(size.router, prefix='/size')
|
||||
router.include_router(attribute.router, prefix='/attribute')
|
||||
BIN
app/api/v1/barcode/template/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
app/api/v1/barcode/template/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
app/api/v1/barcode/template/__pycache__/size.cpython-311.pyc
Normal file
BIN
app/api/v1/barcode/template/__pycache__/size.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/api/v1/barcode/template/__pycache__/template.cpython-311.pyc
Normal file
BIN
app/api/v1/barcode/template/__pycache__/template.cpython-311.pyc
Normal file
Binary file not shown.
93
app/api/v1/barcode/template/attribute.py
Normal file
93
app/api/v1/barcode/template/attribute.py
Normal file
@ -0,0 +1,93 @@
|
||||
import json
|
||||
from time import time
|
||||
from fastapi import APIRouter
|
||||
from app.config import config
|
||||
from app.utils.logger_util import logger
|
||||
from app.utils.response_util import response
|
||||
from app import mongo
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/get-all", tags=[""])
|
||||
async def template_get_all():
|
||||
start_time = time()
|
||||
|
||||
attributes = await mongo.template_attributes_collection.find({}, {
|
||||
"_id": False
|
||||
}).sort("id", mongo.asc).to_list()
|
||||
|
||||
return response({
|
||||
"attributes": attributes
|
||||
}, start_time=start_time)
|
||||
|
||||
|
||||
@router.post("/create", tags=[""])
|
||||
async def create(params: dict):
|
||||
start_time = time()
|
||||
data = params["attribute"]
|
||||
|
||||
data["id"] = await mongo.get_next_id(mongo.template_attributes_collection)
|
||||
|
||||
logger.json(data)
|
||||
|
||||
try:
|
||||
await mongo.template_attributes_collection.insert_one(data)
|
||||
|
||||
return response({
|
||||
"message": "Атрибут создан",
|
||||
"ok": True
|
||||
}, start_time=start_time)
|
||||
except Exception as e:
|
||||
return response({
|
||||
"message": str(e),
|
||||
"ok": False
|
||||
}, start_time=start_time, code=400)
|
||||
|
||||
|
||||
@router.post("/update", tags=[""])
|
||||
async def update(params: dict):
|
||||
start_time = time()
|
||||
data = params["data"]
|
||||
|
||||
logger.json(data)
|
||||
|
||||
try:
|
||||
await mongo.template_attributes_collection.update_one({
|
||||
"id": data["id"]
|
||||
}, {
|
||||
"$set": data
|
||||
})
|
||||
|
||||
return response({
|
||||
"message": "Данные атрибута обновлены",
|
||||
"ok": True
|
||||
}, start_time=start_time)
|
||||
except Exception as e:
|
||||
return response({
|
||||
"message": str(e),
|
||||
"ok": False
|
||||
}, start_time=start_time, code=400)
|
||||
|
||||
|
||||
@router.post("/delete", tags=[""])
|
||||
async def delete(params: dict):
|
||||
start_time = time()
|
||||
attribute_id = params["attributeId"]
|
||||
|
||||
logger.json(attribute_id)
|
||||
|
||||
try:
|
||||
await mongo.template_attributes_collection.delete_one({
|
||||
"id": attribute_id
|
||||
})
|
||||
|
||||
return response({
|
||||
"message": "Атрибут удален",
|
||||
"ok": True
|
||||
}, start_time=start_time)
|
||||
except Exception as e:
|
||||
return response({
|
||||
"message": str(e),
|
||||
"ok": False
|
||||
}, start_time=start_time, code=400)
|
||||
93
app/api/v1/barcode/template/size.py
Normal file
93
app/api/v1/barcode/template/size.py
Normal file
@ -0,0 +1,93 @@
|
||||
import json
|
||||
from time import time
|
||||
from fastapi import APIRouter
|
||||
from app.config import config
|
||||
from app.utils.logger_util import logger
|
||||
from app.utils.response_util import response
|
||||
from app import mongo
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/get-all", tags=[""])
|
||||
async def get_all():
|
||||
start_time = time()
|
||||
|
||||
sizes = await mongo.template_sizes_collection.find({}, {
|
||||
"_id": False
|
||||
}).sort("id", mongo.asc).to_list()
|
||||
|
||||
return response({
|
||||
"sizes": sizes
|
||||
}, start_time=start_time)
|
||||
|
||||
|
||||
@router.post("/create", tags=[""])
|
||||
async def create(params: dict):
|
||||
start_time = time()
|
||||
data = params["size"]
|
||||
|
||||
data["id"] = await mongo.get_next_id(mongo.template_sizes_collection)
|
||||
|
||||
logger.json(data)
|
||||
|
||||
try:
|
||||
await mongo.template_sizes_collection.insert_one(data)
|
||||
|
||||
return response({
|
||||
"message": "Размер создан",
|
||||
"ok": True
|
||||
}, start_time=start_time)
|
||||
except Exception as e:
|
||||
return response({
|
||||
"message": str(e),
|
||||
"ok": False
|
||||
}, start_time=start_time, code=400)
|
||||
|
||||
|
||||
@router.post("/update", tags=[""])
|
||||
async def update(params: dict):
|
||||
start_time = time()
|
||||
data = params["data"]
|
||||
|
||||
logger.json(data)
|
||||
|
||||
try:
|
||||
await mongo.template_sizes_collection.update_one({
|
||||
"id": data["id"]
|
||||
}, {
|
||||
"$set": data
|
||||
})
|
||||
|
||||
return response({
|
||||
"message": "Данные размера обновлены",
|
||||
"ok": True
|
||||
}, start_time=start_time)
|
||||
except Exception as e:
|
||||
return response({
|
||||
"message": str(e),
|
||||
"ok": False
|
||||
}, start_time=start_time, code=400)
|
||||
|
||||
|
||||
@router.post("/delete", tags=[""])
|
||||
async def delete(params: dict):
|
||||
start_time = time()
|
||||
size_id = params["templateId"]
|
||||
|
||||
logger.json(size_id)
|
||||
|
||||
try:
|
||||
await mongo.template_sizes_collection.delete_one({
|
||||
"id": size_id
|
||||
})
|
||||
|
||||
return response({
|
||||
"message": "Размер удален",
|
||||
"ok": True
|
||||
}, start_time=start_time)
|
||||
except Exception as e:
|
||||
return response({
|
||||
"message": str(e),
|
||||
"ok": False
|
||||
}, start_time=start_time, code=400)
|
||||
91
app/api/v1/barcode/template/template.py
Normal file
91
app/api/v1/barcode/template/template.py
Normal file
@ -0,0 +1,91 @@
|
||||
import json
|
||||
from time import time
|
||||
from fastapi import APIRouter
|
||||
from app.config import config
|
||||
from app.utils.logger_util import logger
|
||||
from app.utils.response_util import response
|
||||
from app import mongo
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/get-all", tags=[""])
|
||||
async def get_all():
|
||||
start_time = time()
|
||||
|
||||
templates = await mongo.templates_collection.find({}, {
|
||||
"_id": False
|
||||
}).sort("id", mongo.desc).to_list()
|
||||
|
||||
return response({
|
||||
"templates": templates
|
||||
}, start_time=start_time)
|
||||
|
||||
|
||||
@router.post("/create", tags=[""])
|
||||
async def create(data: dict):
|
||||
start_time = time()
|
||||
|
||||
data["id"] = await mongo.get_next_id(mongo.templates_collection)
|
||||
|
||||
logger.json(data)
|
||||
|
||||
try:
|
||||
await mongo.templates_collection.insert_one(data)
|
||||
|
||||
return response({
|
||||
"message": "Шаблон создан",
|
||||
"ok": True
|
||||
}, start_time=start_time)
|
||||
except Exception as e:
|
||||
return response({
|
||||
"message": str(e),
|
||||
"ok": False
|
||||
}, start_time=start_time, code=400)
|
||||
|
||||
|
||||
@router.post("/update", tags=[""])
|
||||
async def update(data: dict):
|
||||
start_time = time()
|
||||
|
||||
logger.json(data)
|
||||
|
||||
try:
|
||||
await mongo.templates_collection.update_one({
|
||||
"id": data["id"]
|
||||
}, {
|
||||
"$set": data
|
||||
})
|
||||
|
||||
return response({
|
||||
"message": "Данные шаблона обновлены",
|
||||
"ok": True
|
||||
}, start_time=start_time)
|
||||
except Exception as e:
|
||||
return response({
|
||||
"message": str(e),
|
||||
"ok": False
|
||||
}, start_time=start_time, code=400)
|
||||
|
||||
|
||||
@router.post("/delete", tags=[""])
|
||||
async def delete(params: dict):
|
||||
start_time = time()
|
||||
id = params["id"]
|
||||
|
||||
logger.json(id)
|
||||
|
||||
try:
|
||||
await mongo.templates_collection.delete_one({
|
||||
"id": id
|
||||
})
|
||||
|
||||
return response({
|
||||
"message": "Шаблон удален",
|
||||
"ok": True
|
||||
}, start_time=start_time)
|
||||
except Exception as e:
|
||||
return response({
|
||||
"message": str(e),
|
||||
"ok": False
|
||||
}, start_time=start_time, code=400)
|
||||
Reference in New Issue
Block a user