def defect_info(): request_data = request.get_json() try: defectInfo = PimDefect.query.filter_by(user_id=request_data['user_id']). \ filter(PimDefect.code_number == request_data['code_number']).order_by(PimDefect.created_at.desc()).all() if defectInfo: resp = serializer(defectInfo, exclude=[ "user_id", "spec", "extend", "code_number", "updated_at", "location_id", "size_id", "defect_type_id" ], exclude_dict={ "defect_type": [ "user_id", "spec", "extend", "code_number", "created_at", "updated_at", "size" ], "location": [ "user_id", "spec", "extend", "code_number", "created_at", "updated_at" ], "size": [ "user_id", "spec", "extend", "code_number", "created_at", "updated_at" ] }) return api_result(status_code=1, data={'result': resp}) return api_result(status_code=0, message=messages.user_not_found) except Exception as e: logger.error(e)
def size(): try: pim_size = PimSize.query.filter_by().all() return api_result(status_code=1, data={ 'result': serializer(pim_size, exclude=[ "user_id", "spec", "extend", "created_at", "updated_at" ]) }) except Exception as e: logger.error(e)
def input_info(): request_data = request.get_json() try: saveinputinfo = PimSaveInputInfo.query.filter_by(user_id=request_data["user_id"]). \ filter(PimSaveInputInfo.input_info_id == request_data["input_info_id"]).all() if saveinputinfo: return api_result(status_code=1, data={ 'result': serializer(saveinputinfo, exclude=['spec', 'extend']) }) return api_result(status_code=0, message=messages.user_not_found) except Exception as e: logger.error(e)
def leave_type(): session = get_session() try: pim_leave_type = session.query(PimLeaveType).all() return api_result(status_code=1, data={ "result": serializer(pim_leave_type, exclude=[ "user_id", "spec", "extend", "created_at", "updated_at" ]) }) except Exception as e: logger.error(e)
def loose_info(): data = request.get_json() if 'user_id' in data and 'code_number' in data: try: info = LooseInfo.query.filter_by( code_number=data.get('code_number', 0)).first() if info: return api_result(status_code=1, data={ 'result': serializer(info, exclude=[ 'extend', 'user_id', 'code_number' ]) }) except Exception as e: logger.error(e) return api_result(status_code=0, message=messages.loose_info_none)
def qrcode_info(): request_data = request.get_json() try: clothInfo = PimClothInfo.query.filter_by(user_id=request_data['user_id']). \ filter(PimClothInfo.code_number == request_data['code_number']).all() if clothInfo: return api_result(status_code=1, data={ "result": serializer(clothInfo, exclude=[ "spec", "extend", "code_number", "created_at", "updated_at" ]) }) return api_result(status_code=0, message=messages.user_not_found) except Exception as e: logger.error(e.args)