def signin_seller(): connection = None try: data = request.json if 'username' not in data: raise ApiException(400, INVALID_PASSWORD) if 'password' not in data: raise ApiException(400, INVALID_INPUT_PASSWORD) seller_login_info = { 'username': data['username'], 'password': data['password'] } connection = connect_db() seller_service = SellerService() seller_info = seller_service.signin_seller(seller_login_info, connection) connection.commit() return seller_info except ApiException as e: if connection: connection.rollback() raise e finally: if connection: connection.close()
def signin_user(): """ [서비스] 유저 로그인 Author: Mark Hasung Kim Returns: user_info: 유저 로그인 토큰 dict형식으로 반환해준다 """ connection = None try: data = request.json if 'username' not in data: raise ApiException(400, INVALID_INPUT) if 'password' not in data: raise ApiException(400, INVALID_INPUT) login_info = { 'username': data['username'], 'password': data['password'] } connection = connect_db() user_service = UserService() user_info = user_service.signin_user(login_info, connection) return user_info except ApiException as e: if connection: connection.rollback() raise e finally: if connection: connection.close()
def get_address(): """[서비스] user가 주문시 이전 배송지 존재하면 가져오기 Author: Ji Yoon Lee Args: - token(str) : 로그인 user의 token이 header에 담겨 들어와 로그인 유효성 검사를 거침 Returns: - 200: { 'message' : 'SUCCESS', 'result' : { 'data' : 배송지 목록 } } - 400: 요청 실패시 '요청에 실패하였습니다' """ connection = None try: user_id = g.token_info['user_id'] connection = connect_db() if connection: order_service = OrderService() address_option = order_service.get_address(user_id, connection) return address_option except Exception as e: raise ApiException(400, REQUEST_FAILED) finally: if connection: connection.close()
def get_shipping_memo(): """[서비스] user가 주문시 배송메모 선택하는 드롭박스 Author: Ji Yoon Lee Returns: - 200: { 'message' : 'SUCCESS', 'result' : { 'data' : 배송 메모 리스트 } } - 400: 요청 실패시 '요청에 실패하였습니다' """ connection = None try: connection = connect_db() if connection: order_service = OrderService() memo_option = order_service.get_shipping_memo(connection) return memo_option except Exception as e: raise ApiException(400, REQUEST_FAILED) finally: if connection: connection.close()
def get_seller_product_page_info(): """ [어드민] 셀러 상품 등록하기전에 선택할수있는 정보 (product_categories, product_sizes, product_colors) 뿌려주기 Author: Mark Hasung Kim Returns: product_get_info (모든 product_categories, product_sizes, product_colors) """ connection = None try: user_type_id = g.token_info['user_type_id'] if user_type_id != 2: raise ApiException(403, ACCESS_DENIED) connection = connect_db() seller_service = SellerService() product_get_info = seller_service.get_product_post_info(connection) return product_get_info except ApiException as e: if connection: connection.rollback() raise e finally: if connection: connection.close()
def get_order_detail(order_item_id): # 주문 상세정보 가져오는 엔드포인트 order_service = OrderService() order_filter = {'order_item_id': order_item_id} # # 셀러일 경우 필터에 seller_id 추가 # if g.token_info['account_type_id'] == 2: # order_filter['seller_id'] = g.token_info['seller_id'] connection = None try: connection = connect_db() order_detail = order_service.get_order_detail( connection, order_filter) return jsonify(order_detail), 200 except Exception as e: return jsonify({"message": f"{e}"}), 400 finally: try: if connection: connection.close() except Exception as e: return jsonify({"message": f"{e}"}), 500
def list_sellers(*args): db_connection = None user = g.token_info filter_info = { 'seller_id': args[0], 'account_id': args[1], 'email': args[2], 'seller_en': args[3], 'seller_kr': args[4], 'user_id': args[5], 'manager_name': args[6], 'manager_email': args[7], 'seller_status': args[8], 'manager_phone': args[9], 'seller_category': args[10], 'created_upper': args[11], 'created_lower': args[12], 'excel': args[13], 'page': args[14] if args[14] else 1, 'limit': args[15] if args[15] else 10, 'order_by': args[16] } try: connection = connect_db() account_service = AccountService() seller_list = account_service.filter_seller(filter_info, user, connection) return jsonify({'seller_list': seller_list}), 200 except Exception as e: return jsonify({'MESSAGE': f'{e}'}), 400 finally: connection.close()
def wrapper(*args, **kwargs): access_token = request.headers.get('AUTHORIZATION', None) if access_token: try: payload = jwt.decode(access_token, SECRET_KEY, ALGORITHM) account_id = payload['account_id'] connection = connect_db() account_dao = AccountDao() account = account_dao.account_identifier(account_id, connection) if not account: return jsonify({'MESSAGE': 'account_nonexistant'}), 404 if account['is_active'] == 0: return jsonify({'MESSAGE': 'account_not_active'}), 400 g.token_info = { 'account_id' : account_id, 'account_type_id' : account['account_type_id'], 'seller_id' : account['seller_id']} return func(*args, **kwargs) except Error as e: return Jsonify({'MESSAGE': 'DB_error'}), 400 except jwt.InvalidTokenError: return jsonify({'MESSAGE': 'invalid_token'}), 401 except not connection: return jsonify({'MESSAGE': 'no_db_connection'}), 400 return jsonify({'MESSAGE': 'invalid_token'}), 401
def sign_up_seller(*args): connection = None try: account_info = { 'email': args[0], 'password': args[1], 'account_type_id': args[2], 'name': '미설정', 'service_number': args[4], 'seller_name_kr': args[5], 'seller_name_en': args[6], 'subcategory_id': args[7], 'seller_status_id': 1 } print(account_info) connection = connect_db() account_service = AccountService() account_service.signup_seller(account_info, connection) connection.commit() return jsonify({'MESSAGE': 'SUCCESS'}), 200 except Exception as e: connection.rollback() return jsonify({'MESSAGE': f'{e}'}), 400 finally: if connection: connection.close()
def sign_up_master(*args): connection = None account_info = { 'email': args[0], 'password': args[1], 'account_type_id': args[2], 'name': args[4], 'master_code': args[5] } connection = connect_db() if connection: account_service = AccountService() try: account_service.signup_account(account_info, connection) if account_info['master_code'] != 'brandi_team1': connection.rollback() return jsonify({'MESSAGE': 'WRONG_MASTER_CODE'}) connection.commit() return jsonify({'MESSAGE': 'ACCOUNT_CREATED', }), 200 except Exception as e: connection.rollback() return jsonify({'MESSAGE': f'{e}'}), 400 finally: if connection: connection.close()
def get_sub_category(*args): """ 상품 분류별 sub 카테고리 목록 표출 엔드포인트 Args: *args: main_category_id(int): 1차 카테고리 인덱스 번호 """ connection = None #쿼리 스트링에 값이 없으면 에러 반환 if args[0] is None: return jsonify({'message': 'MAIN_CATEGORY_ID_ERROR'}), 400 try: connection = connect_db() if connection: filter_data = {'main_category_id': args[0]} product_service = ProductService() sub_categories = product_service.product_sub_category( filter_data, connection) return jsonify({'data': sub_categories}), 200 else: return jsonify({'message': 'NO_DATABASE_CONNECTION'}), 400 except Exception as e: return jsonify({'message': f'{e}'}), 500 finally: try: connection.close() except Exception as e: return jsonify({'message': f'{e}'}), 500
def order_detail(cart_number): """ [어드민] 주문 상세 관리(마스터) Author: Sung joun Jang Args: - product_id: 조회하고자 하는 상품의 pk 값 - cart_number: 조회하고자 하는 카트의 외부 고유 값 Returns: - 200: message: 반환되는 메세지 result: { data: 전달하는 데이터 값 } """ # 로그인 했을 때 3(마스터)인지 확인 if g.token_info['user_type_id'] != 3: raise ApiException(400, USER_NOT_MASTER) connection = None try: connection = connect_db() master_service = MasterService() result = master_service.order_detail(connection, cart_number) return {'result': result} except Exception as e: if connection: connection.rollback() raise e finally: if connection is not None: connection.close()
def order_ready_init(): """ [어드민] 주문관리(마스터) - 상품준비(초기값) Author: Sung joun Jang Args: Returns: - 200: message: 반환되는 메세지 result: { data: 전달하는 데이터 값 } """ # 로그인 했을 때 3(마스터)인지 확인 if g.token_info['user_type_id'] != 3: raise ApiException(400, USER_NOT_MASTER) connection = None try: connection = connect_db() master_service = MasterService() result = master_service.order_ready_init(connection) return {'result': result} except Exception as e: if connection: connection.rollback() raise e finally: if connection is not None: connection.close()
def get_product_list(*args): connection = None """상품 리스트 엔드포인트 상품 관리 페이지에서 필터링된 상품 리스트를 표출 쿼리 파라미터로 필터링에 사용할 파라미터 값을 받음 Return: 200: 상품 리스트 403: NO_AUTHORIZATION 500: NO_DATABASE_CONNECTION, DB_CURSOR_ERROR NO_DATABASE_CONNECTION History: 2020-11-28 : 초기 생성 2020-11-19 : pagination 수정 수정할 사항 @login_validator로 g.account_info 받을 예정 g.account_info ={ 'account_id' : , 'account_type_id' : , 'seller_id' : id or None } """ #유효성 검사 완료한 쿼리 값 저장 filter_data = { 'started_date': args[0], 'ended_date': args[1], 'seller_name': args[2], 'product_name': args[3], 'product_number': args[4], 'product_code': args[5], 'seller_subcategory_id': args[6], 'is_selling': args[7], 'is_visible': args[8], 'is_discount': args[9], 'limit': args[10], 'page': args[11], 'account_type_id': g.token_info['account_type_id'] } try: connection = connect_db() if connection: product_service = ProductService() products = product_service.get_product_list( filter_data, connection) return jsonify(products), 200 else: return jsonify({'message': 'NO_DATABASE_CONNECTION'}), 500 except Exception as e: return jsonify({'message': f'{e}'}), 400 finally: try: connection.close() except Exception as e: return jsonify({'message': f'{e}'}), 500
def update_order_status(*args): # 주문 id를 리스트로 받아서 일괄적으로 주문 상태를 업데이트하는 엔드포인트 order_service = OrderService() update_status = { 'editor_id': g.token_info['account_id'], 'order_item_id': args[0], 'order_status_id': args[1], 'order_action_id': args[2] } connection = None try: connection = connect_db() number_of_orders_updated = order_service.update_order_status( connection, update_status) connection.commit() return jsonify({ "message": f"{number_of_orders_updated} order(s) successfully updated" }), 201 except Exception as e: connection.rollback() return jsonify({"message": f"{e}"}), 400 finally: try: if connection: connection.close() except Exception as e: return jsonify({"message": f"{e}"}), 500
def edit_seller(*args): connection = None change_info = { 'subcategory_id': args[0], 'seller_status_id': args[1], 'seller_name_kr': args[2], 'seller_name_en': args[3], 'seller_number': args[4], 'profile_pic_url': args[5], 'short_desc': args[6], 'long_desc': args[7], 'open_time': args[8], 'close_time': args[9], 'delivery_policy': args[10], 'return_policy': args[11], 'zip_code': args[12], 'address_1': args[13], 'address_2': args[14], 'is_open_weekend': args[15], 'seller_id': args[16] } connection = connect_db() user = g.token_info if connection: account_service = AccountService() try: change_account = account_service.change_seller_info(change_info, user, connection) connection.commit() return change_account except Exception as e: connection.rollback() return jsonify({'MESSAGE': f'{e}'}), 400 finally: connection.close()
def get_question_open(): """ [서비스] 제품 상세페이지에서 질문 올릴 때 질문유형 선택 드롭박스 Author: Ji Yoon Lee Args: - token(str): 로그인 user의 token이 header에 담겨 들어와 로그인 유효성 검사를 거침 Returns: - 200 : { 'message': 'SUCCESS', 'result': { 'data': 질문 유형 목록 } } - 400: "요청에 실패하였습니다" Note: 회원만 질문을 남길 수 있음 """ connection = None try: connection = connect_db() if connection: product_service = ProductService() type_list = product_service.get_question_open(connection) return type_list except Exception as e: if connection: connection.rollback() raise ApiException(400, REQUEST_FAILED) finally: if connection: connection.close()
def products_category(): """ 상품 카테고리 list Author: Chae hyun Kim Returns: - 200: { "message" : "SUCCESS" "result" : { "data" : category_list, "totalCount" : 2차 카테고리 총 갯수 } } """ connection = None try: connection = connect_db() produts_category_service = ProductService() category_list = produts_category_service.products_category( connection) return category_list except Exception as e: if connection: connection.rollback raise e finally: if connection: connection.close()
def product_detail(product_id): """ [서비스] 제품 상세페이지 제품정보 가져오기 Author: Ji Yoon Lee Args: - product_id (path parameter) Returns: - 200 : { 'message': 'SUCCESS', 'result': { 'product': 상품정보 } } - 400: "요청에 실패하였습니다" """ connection = None try: connection = connect_db() if connection: product_service = ProductService() product_detail = product_service.get_product_detail( product_id, connection) return product_detail except Exception as e: if connection: connection.rollback() raise ApiException(400, REQUEST_FAILED) finally: if connection: connection.close()
def wrapper(*args, **kwargs): access_token = request.headers.get('AUTHORIZATION') try: if access_token: payload = jwt.decode(access_token, SECRET_KEY, ALGORITHM) user_id = payload['user_id'] connection = connect_db() user_info = {'user_id': user_id} user_dao = UserDao() user = user_dao.user_identifier(user_info, connection) if not user: raise ApiException(400, INVALID_USER) if user['is_delete'] == 1: raise ApiException(400, USER_HAS_BEEN_DELETED) g.token_info = { 'user_id': user_id, 'user_type_id': user['user_type_id'], } return func(*args, **kwargs) else: raise ApiException(401, LOGIN_REQUIRED) except jwt.InvalidTokenError: raise ApiException(400, INVALID_TOKEN) except ApiException as e: raise e
def get_product_qna(product_id): """ [서비스] 제품 상세페이지에서 해당 상품 관련 질문 답변 Author: Ji Yoon Lee Args: - token(str): 로그인 user의 token이 header에 담겨 들어와 로그인 유효성 검사를 거침 - product_id (path parameter) - limit(int): 한 페이지에 보여질 게시물 수 (질문기준 갯수) - offset(int): 페이지 이동 시, 몇번째 게시물부터 보여줄 지 Returns: - 200 : { 'message': 'SUCCESS', 'result': { 'data': { 질문 정보, 답변 정보(답변 있을시) } } } - 400: 존재하지 않는 상품의 경로로 들어온 경우 '잘못된 경로입니다' Note: - token 유무 상관없이 제품 상페페이지 접근 가능. - 단, token이 있고 해당 유저가 상품 질문을 남긴 경우, 자신이 등록한 글과 해당 답변은 열람 가능 - 글 등록시 공개로 등록된 글은 본인의 글 아니여도 누구나 열람 가능 - 자신의 아이디와 판매자의 브랜드 이름은 공개 - 다른 회원이 올린 비공개 게시물은 아이디 부분 비공개처리 """ connection = None try: # 회원인지 비회원인지 확인. 회원이라면 회원 특정. if "token_info" in g: user_id = g.token_info["user_id"] else: user_id = None info = { 'user_id': user_id, 'product_id': product_id, 'limit': int(request.args.get("limit", 5)), 'offset': int(request.args.get("offset", 0)) } connection = connect_db() if connection: product_service = ProductService() product_qna = product_service.get_product_qna(info, connection) return product_qna except Exception as e: if connection: connection.rollback() raise ApiException(400, WRONG_URI_PATH) finally: if connection: connection.close()
def order_ready(): """ [어드민] 주문관리(마스터) - 상품준비(검색값) Author: Sung joun Jang Args: - categories: filter조건으로 들어오는 샐러 속성 값(리스트) - seachText: 검색창에 쓴 텍스트 값 - searcgCategory: 검색 유형 - limit: 한 페이지에 보여줄 데이터의 값 - offset: 페이지에 대한 정보 Returns: - 200: message: 반환되는 메세지 result: { data: 전달하는 데이터 값 } """ # 로그인 했을 때 3(마스터)인지 확인 if g.token_info['user_type_id'] != 3: raise ApiException(400, USER_NOT_MASTER) # 카테고리는 sql 'in'으로 검사하기 위해 튜플로 엮음 filters = { 'categories': tuple(request.args.getlist('categories')), 'search_text': request.args.get('searchText'), 'search_category': request.args.get('searchCategory') } # 페이지에 대한 조건들 limit = request.args.get('limit', None) offset = request.args.get('offset', None) # 한 페이지당 데이터 갯수는 기본 10개로 설정. if limit is None: filters['limit'] = 10 else: filters['limit'] = int(limit) # 페이지 시작은 0부터 시작함. if offset is None: filters['offset'] = 0 else: filters['offset'] = int(offset) connection = None try: connection = connect_db() master_service = MasterService() result = master_service.order_ready(connection, filters) return {'result': result} except Exception as e: if connection: connection.rollback() raise e finally: if connection is not None: connection.close()
def post_product_qna(): """ [서비스] 제품 상세페이지에서 질문 등록 Author: Ji Yoon Lee Args: - token(str): 로그인 user의 token이 header에 담겨 들어와 로그인 유효성 검사를 거침 - body(dict): 'questionType', 'content', 'isPrivate'(비공개글일시), 'productId' Returns: - 200 : { 'message': 'SUCCESS', 'result': { 'data': { 등록된 질문 id, 질문 로그 id } } } - 400: '요청에 실패하였습니다', 필수 parameter 미입력시 '** 정보를 입력해 주세요' - 401: '로그인이 필요합니다' """ connection = None try: user_id = g.token_info['user_id'] data = request.json if user_id is None: raise ApiException(401, LOGIN_REQUIRED) if 'questionType' not in data: raise ApiException(400, SELECT_QUESTION_TYPE) if 'content' not in data: raise ApiException(400, CONTENT_MISSING) if 'productId' not in data: raise ApiException(400, PRODUCT_INFO_MISSING) connection = connect_db() question_info = { 'question_type_id': data['questionType'], 'contents': data['content'], 'is_private': data.get('isPrivate', 1), 'product_id': data['productId'], 'user_id': user_id } product_service = ProductService() product_qna = product_service.post_product_qna( question_info, connection) connection.commit() return product_qna except ApiException as e: if connection: connection.rollback() raise ApiException(400, REQUEST_FAILED) finally: if connection: connection.close()
def post_order_confirmation_direct(): """ [서비스] 제품 상세페이지에서 바로결제로 주문 (배송정보 입력페이지로 넘어가는 부분) Author: Ji Yoon Lee Args: - token(str): 로그인 user의 token이 header에 담겨 들어와 로그인 유효성 검사를 거침 - body(dict): 바로결제 할 상품의 'productId', 상품정보 담긴 'products' Returns: - 200: { 'message': 'SUCCESS', 'result': { 'data': 주문 id (orderId) } } - 400: 필수 parameter 미입력시 '** 정보를 입력해 주세요' """ connection = None try: data = request.json # request로 들어온 데이터 검증 if 'productId' not in data: raise ApiException(400, PRODUCT_MISSING) if 'products' not in data: raise ApiException(400, PRODUCT_INFO_MISSING) products = data['products'] for product in products: if 'color' not in product: raise ApiException(400, COLOR_NOT_IN_INPUT) if 'size' not in product: raise ApiException(400, SIZE_NOT_IN_INPUT) order_info = { 'user_id': g.token_info['user_id'], 'product_id': data['productId'], 'order_status_type_id': 3 # 바로결제 시도시 order_status_type_id = 3 } connection = connect_db() if connection: order_service = OrderService() order_id = order_service.direct_purchase(order_info, products, connection) connection.commit() return order_id except Exception as e: connection.rollback() raise e finally: if connection: connection.close()
def products_list(): """ products list Author: Chae hyun Kim Args: - query parameter : 필요할 경우 category의 id, limit과 offset 조건을 query paramter로 받는다 Returns: - 200: { "message" : "SUCCESS", "result" : { "data" : product list, "totalCount" : 상품 총 갯수 } } Note: - filtering 조건으로 category의 id가 query parameter를 통해 들어올 경우 해당 조건에 해당하는 product list로 결과 반환 """ MINIMUM_CATEGORY_NUMBER = 4 MAXIMUM_CATEGORY_NUMBER = 5 connection = None try: connection = connect_db() products_service = ProductService() page_condition = {} category = request.args.get('category', None) limit = request.args.get('limit', None) offset = request.args.get('offset', None) # filtering 조건으로 들어올 category의 값이 허용 범위를 넘었을 경우 에러 반환 if category is not None: if int(category) < MINIMUM_CATEGORY_NUMBER or int( category) > MAXIMUM_CATEGORY_NUMBER: raise ApiException(404, INVALID_FILTER_CONDITION) page_condition['category'] = category # "더보기"를 누르기 전 limit 조건이 들어오지 않았을 경우 기본으로 30으로 지정 if limit is None: page_condition['limit'] = 30 else: page_condition['limit'] = int(limit) # "더보기"를 누르기 전 offset 조건이 들어오지 않았을 경우 기본으로 0으로 지정 if offset is None: page_condition['offset'] = 0 else: page_condition['offset'] = int(offset) product_list = products_service.products_list( connection, page_condition) return product_list except Exception as e: if connection: connection.rollback raise e finally: if connection: connection.close()
def post_address(): """ [서비스] user가 주문시 새로운 배송지 추가 Author: Ji Yoon Lee Args: - token(str) : 로그인 user의 token이 header에 담겨 들어와 로그인 유효성 검사를 거침 - body(dict) : 'name', 'phone', 'postal', 'address', 'addressDetail', 'isDefault'(optional) Returns: - 200 : { 'message' : 'SUCCESS', 'result' : { 'data' : 새로 등록된 주소 id (address_id) } } - 400 : 필수 parameter 미입력시 '** 정보를 입력해 주세요' Note: - 배송지의 address, address_detail이 동일한 주소는 중복 등록 불가 """ connection = None # try: data = request.json if 'name' not in data: raise ApiException(400, NAME_MISSING) if 'phone' not in data: raise ApiException(400, PHONE_MISSING) if 'postal' not in data: raise ApiException(400, POSTAL_MISSING) if 'address' not in data: raise ApiException(400, ADDRESS_MISSING) if 'addressDetail' not in data: raise ApiException(400, ADDRESS_DETAIL_MISSING) address_info = { 'user_id' : g.token_info['user_id'], 'recipient_name' : data['name'], 'recipient_phone' : data['phone'], 'recipient_postal_code' : data['postal'], 'recipient_address' : data['address'], 'recipient_address_detail' : data['addressDetail'], 'is_default' : data.get('isDefault', 0) } connection = connect_db() if connection: order_service = OrderService() post_address = order_service.post_address(address_info, connection) connection.commit() return post_address
def main(): name = str(sys.argv[1]) db = db_connector.connect_db() cursor = db.cursor() rows_with_name = get_all_rows_with_name(name, cursor) result_dict = {} for row in rows_with_name: list_of_prints = get_list_of_prints_for_composer(row[0], cursor) result_dict[row[3]] = list_of_prints json.dump(result_dict, sys.stdout, indent=4, ensure_ascii=False)
def confirm_order(): connection = None order_dao = OrderDao() try: connection = connect_db() with connection.cursor(pymysql.cursors.DictCursor) as cursor: query = """ SELECT order_items.id, order_items.detailed_order_number FROM order_items INNER JOIN order_logs ON (order_logs.order_item_id = order_items.id AND order_logs.order_status_id = order_items.order_status_id) WHERE order_items.order_status_id = 4 AND order_logs.created_at < (CURRENT_TIMESTAMP() - INTERVAL 2 MINUTE) """ cursor.execute(query) orders = cursor.fetchall() order_item_id = [order['id'] for order in orders] confirm_order = { "order_item_id": order_item_id, "order_status_id": 4, "new_order_status_id": 5 } confirmed_orders = order_dao.update_order_status( connection, confirm_order) order_log = [[order['id'], None, 5] for order in orders] created_logs = order_dao.create_order_log(connection, order_log) if len(orders) == confirmed_orders == created_logs: connection.commit() for order in orders: print( f"Order confirmed: no.{order['detailed_order_number']}" ) else: connection.rollback() print( "Something went wrong with order confirmation. Will try again in 1 minute" ) except ProgrammingError: connection.rollback() print("No order to update. Will try again in 1 minute") finally: try: if connection: connection.close() except Exception as e: print(f"connection error: {e}")
def sign_in(): connection = None try: connection = connect_db() login_data = request.json account_service = AccountService() token = account_service.signin(login_data, connection) return token except Exception as e: return jsonify({'MESSAGE': f'{e}'}), 400 finally: if connection: connection.close()
def account_level(): """ [어드민] 샐러 계정 관리(마스터) - level 값 변경하기 Author: Sung joun Jang Args: Returns: - 200: message: 반환되는 메세지 result: { data: 전달하는 데이터 값 } """ # 로그인 했을 때 3(마스터)인지 확인 if g.token_info['user_type_id'] != 3: raise ApiException(400, USER_NOT_MASTER) body = request.json # 필수 request 값이 없으면 에러 return if not body.get('sellerId'): raise ApiException(400, NOT_SELLER) if not body.get('actionId'): raise ApiException(400, NOT_ACTION) seller_id = body['sellerId'] action_id = body['actionId'] data = { 'user_id': g.token_info['user_id'], 'seller_id': seller_id, 'action_id': action_id } connection = None try: connection = connect_db() master_service = MasterService() result = master_service.account_level(connection, data) if result: connection.commit() return {'result': result} except Exception as e: if connection: connection.rollback() raise e finally: if connection is not None: connection.close()
# -------------------------------------------------------------------------------- # Author: Roberto Ferreira Junior # # Email: [email protected] # # Description: Script to run the vmInventory for all DST Softlayer sub accounts. # # Version: 1.0 # -------------------------------------------------------------------------------- bm_scanned = 0 total_guests = 0 total_accounts = 0 status = connect_db() if status[0] == 0: conn = status[1] cursor = conn.cursor() def get_accounts(): """ RETURNS ALL SL ACCOUNTS (ACCOUNTS, KEYS AND DESCRIPTION) """ # Get accounts to be procesed url = "https://dstnotes.lexington.ibm.com/DST/servers.nsf/CGI_SLAPIConfig?OpenAgent&login" request = urllib2.Request(url) base64string = base64.encodestring("%s:%s" % ("*****@*****.**", "sadb_uat")).replace("\n", "") request.add_header("Authorization", "Basic %s" % base64string) try: