Пример #1
0
        else:
            return json({
                "error_code": response.status_code,
                "error_message": "Sync Error!"
            }, status=520)

    return json(None)



sqlapimanager.create_api(Warehouse,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[auth_func],
    GET_MANY=[auth_func],
    POST=[auth_func],
    PUT_SINGLE=[auth_func],
    DELETE_SINGLE=[auth_func]),
    collection_name='warehouse')


sqlapimanager.create_api(ItemBalances,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[auth_func], GET_MANY=[auth_func], POST=[auth_func], PUT_SINGLE=[auth_func], DELETE_SINGLE=[auth_func]),
    collection_name='itembalances')


@app.route("/api/v1/create_itembalances", methods=["POST"])
async def create_itembalances(request):
Пример #2
0
        ItemCategory.tenant_id == tenant_id).all()
    if category is not None:
        result = []
        for _ in category:
            list_ = to_dict(_)
            result.append(list_)
        return json(result)


sqlapimanager.create_api(ItemCategory,
                         max_results_per_page=1000000,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(GET_SINGLE=[],
                                         GET_MANY=[],
                                         POST=[],
                                         PUT_SINGLE=[]),
                         postprocess=dict(POST=[],
                                          PUT_SINGLE=[],
                                          DELETE_SINGLE=[],
                                          GET_MANY=[]),
                         collection_name='itemcategory')

sqlapimanager.create_api(PriceList,
                         max_results_per_page=1000000,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(GET_SINGLE=[],
                                         GET_MANY=[],
                                         POST=[],
                                         PUT_SINGLE=[]),
        i =1
        page = request.args.get("page",None)
        results_per_page = request.args.get("results_per_page",None)
        if page is not None and results_per_page is not None and int(page) != 1:
            i = i + int(results_per_page)*int(page)
        for obj in objects:
            if obj is not None:
                obj_tmp = to_dict(obj)
                obj_tmp["stt"] = i
                i = i +1
                datas.append(obj_tmp)
        result = datas
     
sqlapimanager.create_api(Nation, max_results_per_page=1000000,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[auth_func], GET_MANY=[], POST=[auth_func, prepost_danhmuc], PUT_SINGLE=[auth_func, preput_danhmuc]),
    postprocess=dict(POST=[], PUT_SINGLE=[], DELETE_SINGLE=[], GET_MANY =[]),
    collection_name='nation')
 
 
 
sqlapimanager.create_api(Province, max_results_per_page=1000000,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[auth_func], GET_MANY=[], POST=[auth_func, prepost_danhmuc, prepost_put_danhmuc], PUT_SINGLE=[auth_func, prepost_danhmuc, prepost_put_danhmuc]),
    postprocess=dict(POST=[], PUT_SINGLE=[], DELETE_SINGLE=[], GET_MANY =[]),
    collection_name='province')
 
 
 
sqlapimanager.create_api(District, max_results_per_page=1000000,
Пример #4
0
import time
from application.models.inventory.workstation import *

from gatco_restapi.helpers import to_dict
from application.common.helper import pre_post_set_user_tenant_id, pre_get_many_user_tenant_id, get_tennat_id, current_user, auth_func


@app.route("/api/v1/get_workstation_tenant", methods=["POST"])
def get_workstation_tenant(request):
    data = request.json
    if data is not None:
        workstation = db.session.query(Workstation).filter(
            Workstation.tenant_id == data).all()
        if workstation is not None:
            arr = []
            for _ in workstation:
                arr.append(to_dict(_))
        return json(arr)
    return json({"message": "no record"})


sqlapimanager.create_api(Workstation,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(GET_SINGLE=[auth_func],
                                         GET_MANY=[auth_func],
                                         POST=[auth_func],
                                         PUT_SINGLE=[auth_func],
                                         DELETE_SINGLE=[auth_func]),
                         collection_name='workstation')
Пример #5
0
                    "error_message": "Không tìm thấy sản phẩm trong kho"
                },
                status=520)


# sqlapimanager.create_api(MoveWarehouse,
#     methods=['GET', 'POST', 'DELETE', 'PUT'],
#     url_prefix='/api/v1',
#     preprocess=dict(GET_SINGLE=[auth_func],
#                     GET_MANY=[pre_get_many_user_tenant_id],
#                     POST=[pre_post_set_user_tenant_id],
#                     PUT_SINGLE=[pre_post_set_user_tenant_id]),
#     collection_name='movewarehouse')

sqlapimanager.create_api(MoveWarehouse,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(GET_SINGLE=[],
                                         GET_MANY=[],
                                         POST=[],
                                         PUT_SINGLE=[]),
                         collection_name='movewarehouse')

# sqlapimanager.create_api(MoveWarehouseDetails,
#     methods=['GET', 'POST', 'DELETE', 'PUT'],
#     url_prefix='/api/v1',
#     preprocess=dict(GET_SINGLE=[],
#                     GET_MANY=[],
#                     POST=[],
#                     PUT_SINGLE=[]),
#     collection_name='movewarehousedetails')
    # print("resssss",to_dict(response))

    if response == 200:
        await response.json()

    else:
        return json({
            "ok": False,
            "message": "error"
        })

    # async with aiohttp.ClientSession(headers=fb_headers, json_serialize=ujson.dumps) as session:
    #     async with session.post(url, json=params) as response:
    #         # if response.status == 200:
    #         await response.json()


sqlapimanager.create_api(Notify, max_results_per_page=1000000,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(GET_SINGLE=[], GET_MANY=[], POST=[], PUT_SINGLE=[]),
                        #  postprocess=dict(POST=[postprocess_send_notify_cosoKCB]),
                         collection_name='notify')

sqlapimanager.create_api(Permission, max_results_per_page=1000000,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(GET_SINGLE=[], GET_MANY=[apply_user_filter], POST=[], PUT_SINGLE=[]),
                         postprocess=dict(POST=[]),
                         collection_name='permission')
Пример #7
0
                page) != 1:
            i = i + int(results_per_page) * int(page)
        for obj in objects:
            if obj is not None:
                obj_tmp = to_dict(obj)
                obj_tmp["stt"] = i
                i = i + 1
                datas.append(obj_tmp)
        result = datas


sqlapimanager.create_api(
    User,
    max_results_per_page=1000000,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    # exclude_columns= ["password","salt","active"],
    preprocess=dict(GET_SINGLE=[], GET_MANY=[], POST=[], PUT_SINGLE=[]),
    postprocess=dict(POST=[], PUT_SINGLE=[], DELETE_SINGLE=[], GET_MANY=[]),
    collection_name='user')

sqlapimanager.create_api(Role,
                         max_results_per_page=1000000,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(GET_SINGLE=[],
                                         GET_MANY=[],
                                         POST=[],
                                         PUT_SINGLE=[]),
                         postprocess=dict(POST=[],
                                          PUT_SINGLE=[],
Пример #8
0
        for obj in objects:
            if obj is not None:
                obj_tmp = to_dict(obj)
                obj_tmp["stt"] = i
                i = i + 1
                datas.append(obj_tmp)
        result = datas


sqlapimanager.create_api(QuocGia,
                         max_results_per_page=1000000,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(
                             GET_SINGLE=[auth_func],
                             GET_MANY=[],
                             POST=[auth_func, prepost_danhmuc],
                             PUT_SINGLE=[auth_func, preput_danhmuc]),
                         postprocess=dict(POST=[],
                                          PUT_SINGLE=[],
                                          DELETE_SINGLE=[],
                                          GET_MANY=[postprocess_add_stt]),
                         collection_name='quocgia')

sqlapimanager.create_api(
    TinhThanh,
    max_results_per_page=1000000,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(
        GET_SINGLE=[auth_func],
        GET_MANY=[],
Пример #9
0
                return json(
                    {
                        "error_code":
                        "PARAMS_ERROR",
                        "error_message":
                        "Mã danh mục đã bị trùng, vui lòng chọn mã khác"
                    },
                    status=520)


sqlapimanager.create_api(
    User,
    max_results_per_page=1000000,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    # preprocess=dict(GET_SINGLE=[], GET_MANY=[], POST=[ prepost_user], PUT_SINGLE=[ preput_user], DELETE=[predelete_user]),
    # postprocess=dict(POST=[], PUT_SINGLE=[], DELETE_SINGLE=[], GET_MANY =[]),
    # exclude_columns= ["password","salt","active"],
    preprocess=dict(GET_SINGLE=[], GET_MANY=[], POST=[], PUT_SINGLE=[]),
    postprocess=dict(POST=[], PUT_SINGLE=[], DELETE_SINGLE=[], GET_MANY=[]),
    collection_name='user')

sqlapimanager.create_api(
    Role,
    max_results_per_page=1000000,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    # preprocess=dict(GET_SINGLE=[], GET_MANY=[], POST=[], PUT_SINGLE=[]),
    preprocess=dict(GET_SINGLE=[], GET_MANY=[], POST=[], PUT_SINGLE=[]),
    postprocess=dict(POST=[], PUT_SINGLE=[], DELETE_SINGLE=[], GET_MANY=[]),
    collection_name='role')
Пример #10
0
            {
                "error_code":
                "PARAMS_ERROR",
                "error_message":
                "Notification code already in use, please select again"
            },
            status=520)


sqlapimanager.create_api(DanhMucDoanhNghiep,
                         max_results_per_page=1000000,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(GET_SINGLE=[auth_func],
                                         GET_MANY=[auth_func],
                                         POST=[auth_func],
                                         PUT_SINGLE=[auth_func]),
                         postprocess=dict(POST=[],
                                          PUT_SINGLE=[],
                                          DELETE_SINGLE=[],
                                          GET_MANY=[]),
                         collection_name='danhmucdoanhnghiep')

sqlapimanager.create_api(DanhSachChiNhanhDonVi,
                         max_results_per_page=1000000,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(GET_SINGLE=[auth_func],
                                         GET_MANY=[auth_func],
                                         POST=[auth_func],
                                         PUT_SINGLE=[auth_func]),
Пример #11
0
        goodsreciept = db.session.query(GoodsReciept).filter(
            and_(GoodsReciept.id == data["id"],
                 GoodsReciept.tenant_id == tenant_id)).first()
        result = []
        if goodsreciept is not None:
            list_goods = to_dict(goodsreciept)
            result.append(list_goods)
            return json(result)


sqlapimanager.create_api(GoodsReciept,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(GET_SINGLE=[auth_func],
                                         GET_MANY=[auth_func],
                                         POST=[auth_func],
                                         PUT_SINGLE=[auth_func]),
                         postprocess=dict(POST=[],
                                          GET_MANY=[],
                                          PUT_SINGLE=[],
                                          DELETE_SINGLE=[]),
                         collection_name='goodsreciept')

# sqlapimanager.create_api(GoodsRecieptDetails,
#     methods=['GET', 'POST', 'DELETE', 'PUT'],
#     url_prefix='/api/v1',
#     preprocess=dict(GET_SINGLE=[auth_func],
#                     GET_MANY=[auth_func],
#                     POST=[auth_func],
#                     PUT_SINGLE=[auth_func]),
#     collection_name='goodsrecieptdetails')
Пример #12
0
                    'organization_require']
                medicalEquipment_new.status = _['status']
                db.session.add(medicalEquipment_new)
                db.session.commit()
    return json({
        "error_code": "Upload success",
    })


sqlapimanager.create_api(MedicalEquipment,
                         max_results_per_page=1000000,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(
                             GET_SINGLE=[auth_func],
                             GET_MANY=[auth_func],
                             POST=[auth_func, prepost_put_stt],
                             PUT_SINGLE=[auth_func, prepost_put_stt]),
                         postprocess=dict(POST=[],
                                          PUT_SINGLE=[],
                                          DELETE_SINGLE=[],
                                          GET_MANY=[postprocess_add_stt]),
                         collection_name='medicalequipment')

# @app.route('/api/v1/get_data_medical',methods=['POST'])
# async def get_data_medical(request):
#     req = request.json
#     if req  != None and req != "":
#         find_text = req['text']
#         search = "%{}%".format(find_text)
#         list = db.session.query(MedicalEquipment).filter(MedicalEquipment.name.like(search)).all()
#         if len(list) == 0 :
Пример #13
0
    # data = []
    # i = 1
    # currentUser = await current_user(request)
    # if currentUser is None:
    #     return json({"error_code":"PERMISSION_DENY","error_message":"Hết phiên làm việc!"}, status=520)
    # print ('_____________________',objects)
    # result = data


sqlapimanager.create_api(
    Unit,
    max_results_per_page=1000000,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    # preprocess=dict(GET_SINGLE=[], GET_MANY=[], POST=[], PUT_SINGLE=[]),
    preprocess=dict(GET_SINGLE=[], GET_MANY=[], POST=[], PUT_SINGLE=[]),
    postprocess=dict(POST=[],
                     PUT_SINGLE=[],
                     DELETE_SINGLE=[],
                     GET_MANY=[get_unit_name],
                     GET_SINGLE=[get_singer_unit_name]),
    collection_name='unit')

sqlapimanager.create_api(
    Contact,
    max_results_per_page=1000000,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    # preprocess=dict(GET_SINGLE=[], GET_MANY=[], POST=[], PUT_SINGLE=[]),
    preprocess=dict(GET_SINGLE=[], GET_MANY=[], POST=[], PUT_SINGLE=[]),
    postprocess=dict(POST=[], PUT_SINGLE=[], DELETE_SINGLE=[], GET_MANY=[]),
Пример #14
0
                obj_tmp["stt"] = i
                obj_tmp["amount"] = result
                i = i + 1
                datas.append(obj_tmp)
        result = datas


sqlapimanager.create_api(Organization,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(GET_SINGLE=[auth_func],
                                         GET_MANY=[auth_func],
                                         POST=[auth_func],
                                         PUT_SINGLE=[auth_func],
                                         DELETE_SINGLE=[auth_func]),
                         postprocess=dict(
                             GET_SINGLE=[auth_func, response_debt_calculation],
                             GET_MANY=[auth_func, response_debt_calculation],
                             POST=[auth_func],
                             PUT_SINGLE=[auth_func],
                             DELETE_SINGLE=[auth_func]),
                         collection_name='organization')

sqlapimanager.create_api(OrganizationStaff,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         preprocess=dict(GET_SINGLE=[auth_func],
                                         GET_MANY=[auth_func],
                                         POST=[auth_func],
                                         PUT_SINGLE=[auth_func],
Пример #15
0
    if purchaseorder is not None:
        result = []
        for _ in purchaseorder:
            list_purchaseorder = to_dict(_)
            result.append(list_purchaseorder)

        return json(result)



sqlapimanager.create_api(PurchaseOrder,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[],
                    GET_MANY=[],
                    POST=[],
                    PUT_SINGLE=[]),
    postprocess=dict(
        POST=[],
        PUT_SINGLE=[],
        DELETE_SINGLE=[]),
    collection_name='purchaseorder')

# sqlapimanager.create_api(PurchaseOrderDetails,
#     methods=['GET', 'POST', 'DELETE', 'PUT'],
#     url_prefix='/api/v1',
#     preprocess=dict(GET_SINGLE=[],
#                     GET_MANY=[],
#                     POST=[auth_func],
#                     PUT_SINGLE=[auth_func]),
#     collection_name='purchaseorderdetails')
Пример #16
0
                #     to_dict(obj)["status"]  = "finish"
                # elif obj['amount'] < thanhtoan:
                #     to_dict(obj)["status"]  = "wrong"
                obj_tmp = to_dict(obj)
                obj_tmp["stt"] = i
                i = i - 1
                datas.append(obj_tmp)
        result = datas


sqlapimanager.create_api(Payment,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         postprocess=dict(GET_SINGLE=[auth_func],
                                          GET_MANY=[response_getmany_stt],
                                          POST=[],
                                          PUT_SINGLE=[]),
                         preprocess=dict(GET_SINGLE=[],
                                         GET_MANY=[],
                                         POST=[],
                                         PUT_SINGLE=[]),
                         collection_name='payment')

sqlapimanager.create_api(PaymentDetails,
                         methods=['GET', 'POST', 'DELETE', 'PUT'],
                         url_prefix='/api/v1',
                         postprocess=dict(GET_SINGLE=[auth_func],
                                          GET_MANY=[],
                                          POST=[],
                                          PUT_SINGLE=[]),
                         preprocess=dict(GET_SINGLE=[],
                                         GET_MANY=[],
Пример #17
0
    if request.method == "POST" or request.method == "PUT":
        if "secret" not in data or data["secret"] is None or data[
                "secret"] == "":
            return json(
                {
                    "error_code": "PARAMS_ERROR",
                    "error_message": "Vui lòng nhập mật khẩu của ứng dụng!"
                },
                status=520)


sqlapimanager.create_api(
    AppInfo,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[auth_func],
                    GET_MANY=[auth_func],
                    POST=[auth_func, pre_process_post_put_appinfo],
                    PUT_SINGLE=[auth_func, pre_process_post_put_appinfo]),
    exclude_columns=["secret"],
    collection_name='appinfo')


@app.route('/app_api/v1/token', methods=['POST'])
async def get_token(request):
    if not check_content_json(request):
        return json(
            {
                'error_code': "ERROR_PARAMS",
                'error_message': 'Header request không hợp lệ'
            },
            status=200)