def post(self, *args): """POST 메소드: 배송지 추가 사용자가 입력한 배송지 정보를 받아 데이터베이스에 추가한다. 최대 배송지 생성 개수는 5개이다. Args: args: 'recipient' : 수신자 'phone' : 폰번호 'address1' : 메인주소 'address2' : 상세주소 'post_number': 우편번호 g.account_id : 데코레이터에서 넘겨받은 어카운트 아이디 g.permission_type_id: 데코레이터에서 넘겨받은 권한 아이디 Author: 김기용 Returns: 201, {'message': 'success'}: 배송지 생성 성공 Raises: 400, {'message': 'invalid_parameter', 'error_message': '[데이터]가(이) 유효하지 않습니다.'} 500, {'message': 'unable_to_close_database', 'errorMessage': '커넥션 종료 실패'} 500, {'message': 'internal_server_error', 'errorMessage': format(e)}) History: 2020-12-28(김기용): 초기 생성 2020-12-29(김기용): 데코레이터 추가 2020-12-30(김기용): 수정된 데코레이터반영: 데코레이터에서 permission_type 을 받음 2021-01-02(김기용): 수정된 데코레이터 반영: signin_decorator(True) """ connection = None try: data = { 'user_id': g.account_id, 'permission_type_id': g.permission_type_id, 'recipient': args[0], 'phone': args[1], 'address1': args[2], 'address2': args[3], 'post_number': args[4], } connection = get_connection(self.database) self.service.create_destination_service(connection, data) connection.commit() return {'message': 'success'} except Exception as e: connection.rollback() raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('서버에서 알 수 없는 에러가 발생했습니다.')
def get(self, *args): data = { 'product_name': args[0], 'id': args[1], 'seller_name': args[2], 'membership_number': args[3], 'is_answered': args[4], 'type': args[5], 'start_date': args[6], 'end_date': args[7], 'page': args[8], 'length': args[9], 'response_date': args[10] } try: connection = get_connection(self.database) enquiries = self.service.get_enquiry_service(connection, data) return jsonify({'message': 'success', 'result': enquiries}) except Exception as e: raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def get(self, *args): try: data = { 'account_id': args[2], 'username': args[3], 'seller_english_name': args[4], 'seller_name': args[5], 'contact_name': args[6], 'contact_phone': args[7], 'contact_email': args[8], 'seller_attribute_type_name': args[9], 'seller_status_type_name': args[10], 'updated_at': args[11], 'start_date': args[12], 'end_date': args[13] } page = request.args.get('page') page_view = request.args.get('page_view') connection = get_connection(self.database) result = self.service.seller_search_service( connection, data, page, page_view) return jsonify({'message': 'success', 'seller_list': result}), 200 except Exception as e: raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail( 'database close fail in seller_list_view')
def get(self, *args): try: data = { 'seller_name': request.args.get('seller_name'), 'permission_type_id': g.permission_type_id } connection = get_connection(self.database) sellers = dict() if data['seller_name'] and g.permission_type_id == 1: sellers = self.service.search_seller_list_service( connection, data) return jsonify({'message': 'success', 'result': sellers}) except Exception as e: traceback.print_exc() raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def post(self, *args): data = { 'username': args[0], 'password': args[1], 'seller_attribute_type_id': args[2], 'name': args[3], 'english_name': args[4], 'contact_phone': args[5], 'service_center_number': args[6], } try: connection = get_connection(self.database) self.service.seller_signup_service(connection, data) connection.commit() return jsonify({'message': 'success'}), 200 except Exception as e: connection.rollback() raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def post(self): """ POST 메소드: 유저 구글 소셜 로그인 Args: None Headers: Authorization : 구글 토큰 Author: 김민구 Returns: 200, {'message': 'success', 'token': token} : 유저 로그인 성공 Raises: 400, {'message': 'key_error', 'error_message': format(e)} : 잘못 입력된 키값 403, {'message': 'invalid_token', 'error_message': '구글 소셜 로그인에 실패하였습니다.'} : 유효하지 않은 토큰 403, {'message': 'invalid_user', 'error_message': '구글 소셜 로그인에 실패했습니다.'} : 유효하지 않은 유저 500, { 'message': 'database_connection_fail', 'error_message': '서버에 알 수 없는 에러가 발생했습니다.' } : 커넥션 종료 실패 500, {'message': 'database_error', 'error_message': '서버에 알 수 없는 에러가 발생했습니다.'} : 데이터베이스 에러 500, {'message': 'data_manipulation_fail', 'error_message': '소셜 로그인을 실패하였습니다.'} : 데이터 조작 에러 500, {'message': 'internal_server_error', 'error_message': format(e)}) : 서버 에러 History: 2020-12-29(김민구): 초기 생성 2020-12-31(김민구): 에러 문구 변경 2021-01-02(김민구): 데이터 조작 에러 추가 2021-01-05(김민구): 기존 회원이 존재할 때 username이 달라서 생기는 이슈를 제거함 """ connection = None try: google_token = request.headers.get('Authorization') connection = get_connection(self.database) user_info = id_token.verify_oauth2_token(google_token, requests.Request()) token = self.user_service.social_sign_in_logic(connection, user_info) connection.commit() return jsonify({'message': 'success', 'token': token}), 200 except Exception as e: traceback.print_exc() connection.rollback() raise e except ValueError: connection.rollback() raise InvalidToken('구글 소셜 로그인에 실패하였습니다.') finally: try: if connection is not None: connection.close() except Exception: raise DatabaseCloseFail('서버에 알 수 없는 에러가 발생했습니다.')
def patch(self, *args): data = { 'permission': g.permission_type_id, 'account': g.account_id, "status": args[0], "ids": args[1] } """PATCH 메소드: 주문 상태 변경 Args: args = ('status', 'ids') Author: 김민서 Returns: { "message": "주문 상태가 업데이트 되었습니다." } Raises: 400, {'message': 'key error', 'errorMessage': 'key_error'} : 잘못 입력된 키값 400, {'message': 'unable to close database', 'errorMessage': 'unable_to_close_database'}: 커넥션 종료 실패 400, {'message': 'now order status is not allowed to update status', 'errorMessage': '현재 상태는 업데이트가 불가합니다.'}: 주문 상태 변경 불가능 상태 400, {'message': 'unable_to_update_status', 'errorMessage': '업데이트가 불가합니다.'}: 수정 불가 403, {'message': 'no_permission', 'errorMessage': '권한이 없습니다.'} : 권한 없음 500, {'message': 'internal_server_error', 'errorMessage': 'internal server error'} : 알 수 없는 에러 History: 2021-01-01(김민서): 초기 생성 2021-01-12(김민서): 1차 수정 """ try: connection = get_connection(self.database) self.service.update_order_status_service(connection, data) connection.commit() return jsonify({'message': '주문 상태가 업데이트 되었습니다.'}), 200 except Exception as e: connection.rollback() raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def get(self, *args): """ GET 메소드: 해당 유저가 직전에 마친 결제 정보를 조회 결제가 완료된 페이지에서 확인하는 정보다. order_id에 해당되는 결제 상품 정보를 테이블에서 조회 후 가져옴 Args: args = ('account_id', 'cart_id') Author: 고수희 Returns: #통화에 대한 정의와 정수로 변환 { "message": "success", "result": { "order_number": "20210101000001000", "total_price": 8000.0 } } Raises: 400, {'message': 'key error', 'errorMessage': 'key_error'} : 잘못 입력된 키값 400, {'message': 'cart item does not exist error', 'errorMessage': 'cart_item_does_not_exist'} : 장바구니 상품 정보 조회 실패 400, {'message': 'unable to close database', 'errorMessage': 'unable_to_close_database'}: 커넥션 종료 실패 500, {'message': 'internal server error', 'errorMessage': format(e)}) : 서버 에러 History: 2020-12-28(고수희): 초기 생성 2020-12-30(고수희): 1차 수정 - 데코레이터 추가, 사용자 권한 체크 2021-01-02(고수희): decorator 수정 """ data = { "order_id": args[0], "user_id": g.account_id, "user_permission": g.permission_type_id } try: connection = get_connection(self.database) store_order_info = self.service.get_store_order_service( connection, data) return jsonify({'message': 'success', 'result': store_order_info}) except Exception as e: raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def post(self, *args): """POST 메소드: 유저생성 Args: args = ('username', 'password', 'phone', 'email') Author: 김민구 Returns: 200, {'message': 'success'} : 유저 생성 성공 Raises: 400, {'message': 'invalid_parameter', 'errorMessage': '[데이터]가(이) 유효하지 않습니다.'} : 잘못된 요청값 400, {'message': 'key_error', 'error_message': format(e)} : 잘못 입력된 키값 403, {'message': 'user_already_exist', 'error_message': '이미 사용중인 [데이터] 입니다.'} : 중복 유저 존재 500, { 'message': 'database_connection_fail', 'error_message': '서버에 알 수 없는 에러가 발생했습니다.' } : 커넥션 종료 실패 500, {'message': 'database_error', 'error_message': '서버에 알 수 없는 에러가 발생했습니다.'} : 데이터베이스 에러 500, {'message': 'data_manipulation_fail', 'error_message': '유저 등록을 실패하였습니다.'} : 데이터 조작 에러 500, {'message': 'internal_server_error', 'error_message': format(e)}) : 서버 에러 History: 2020-12-28(김민구): 초기 생성 2020-12-31(김민구): 에러 문구 변경 2021-01-02(김민구): 데이터 조작 에러 추가 """ connection = None try: data = { 'username': args[0], 'password': args[1], 'phone': args[2], 'email': args[3] } connection = get_connection(self.database) self.user_service.sign_up_logic(data, connection) connection.commit() return jsonify({'message': 'success'}), 200 except Exception as e: traceback.print_exc() connection.rollback() raise e finally: try: if connection is not None: connection.close() except Exception: raise DatabaseCloseFail('서버에 알 수 없는 에러가 발생했습니다.')
def patch(self, *args): """ PATCH 메소드: 배송지 정보 수정 사용자가 입력한 배송지 정보를 받아 수정한다. Args: 'destination_id' : 배송지 아이디 'recipient' : 수신자 'phone' : 폰번호 'address1' : 메인주소 'address2' : 상세주소 'post_number' : 우편번호 'default_location': 기본 배송지 g.account_id : 데코레이터에서 넘겨받은 어카운트 아이디 g.permission_type_id: 데코레이터에서 넘겨받은 권한 아이디 Author: 김기용 Returns: {'message':'success'} Raises: 500, {'message': 'unable to close database', 'errorMessage': '커넥션 종료 실패'} 500, {'message': 'internal server error', 'errorMessage': format(e)}) """ connection = None try: data = dict() data['destination_id'] = args[0] data['recipient'] = args[1] data['phone'] = args[2] data['address1'] = args[3] data['address2'] = args[4] data['post_number'] = args[5] data['default_location'] = args[6] data['account_id'] = g.account_id data['permission_type_id'] = g.permission_type_id connection = get_connection(self.database) self.service.update_destination_info_service(connection, data) connection.commit() return {'message': 'success'} except Exception as e: connection.rollback() raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('서버에서 알 수 없는 에러가 발생했습니다')
def get(self, *args): """ GET 메소드: 기획전 정보 조회 Args: event_id = 기획전 아이디 Author: 김민구 Returns: 기획전 정보 조회 성공 200, { 'message': 'success', 'result': { "detail_image": "url" "event_id": 1, "event_kind_id": 1, "event_kind_name": "상품", "event_type_id": 1, "event_type_name": "상품(이미지)", "is_button": 0 } } Raises: 400, {'message': 'invalid_parameter', 'error_message': '[데이터]가(이) 유효하지 않습니다.'} : 잘못된 요청값 400, {'message': 'key_error', 'error_message': format(e)} : 잘못 입력된 키값 500, { 'message': 'database_connection_fail', 'error_message': '서버에 알 수 없는 에러가 발생했습니다.' } : 커넥션 종료 실패 500, {'message': 'database_error', 'error_message': '서버에 알 수 없는 에러가 발생했습니다.'} : 데이터베이스 에러 500, {'message': 'internal_server_error', 'error_message': format(e)}) : 서버 에러 History: 2020-01-01(김민구): 초기 생성 """ connection = None try: event_id = args[0] connection = get_connection(self.database) result = self.event_list_service.event_detail_information_logic( connection, event_id) return jsonify({'message': 'success', 'result': result}) except Exception as e: traceback.print_exc() raise e finally: try: if connection is not None: connection.close() except Exception: raise DatabaseCloseFail('서버에 알 수 없는 에러가 발생했습니다.')
def post(self, *args): """POST 메소드: 장바구니 상품 생성 Args: args = ('account_id', 'product_id', 'stock_id', 'quantity', 'origin_price', 'sale', 'discounted_price') Author: 고수희 Returns: 200, {'message': 'success'} : 장바구니 상품 추가 성공 Raises: 400, {'message': 'key error', 'errorMessage': 'key_error'} : 잘못 입력된 키값 400, {'message': 'cart item create error', 'errorMessage': 'cart_item_create_error'} : 장바구니 상품 추가 실패 400, {'message': 'unable to close database', 'errorMessage': 'unable_to_close_database'} : 커넥션 종료 실패 403, {'message': 'customer permission denied', 'errorMessage': 'customer_permission_denied'} : 사용자 권한이 아님 500, {'message': 'internal server error', 'errorMessage': format(e)}) : 서버 에러 History: 2020-12-28(고수희): 초기 생성 2020-12-30(고수희): 1차 수정 - 데코레이터 추가, 사용자 권한 체크 추가 """ data = { 'user_id': g.account_id, 'user_permission': g.permission_type_id, 'product_id': args[0], 'stock_id': args[1], 'quantity': args[2], 'original_price': args[3], 'sale': args[4], 'discounted_price': args[5] } try: connection = get_connection(self.database) cart_id = self.service.post_cart_item_service(connection, data) connection.commit() return {'message': 'success', 'result': {"cart_id": cart_id}}, 201 except Exception as e: connection.rollback() raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def get(self, *args): """ GET 메소드: 해당 셀러의 정보 출력 account_id에 해당되는 셀러 정보를 테이블에서 조회 후 가져옴 Args: args = ('seller_id') Author: 고수희 Returns: { "message": "success", "result": { "background_image": "https://img.freepik.com/free-psd/top-view-t-shirt-concept-mock-up_23-2148809114.jpg?size=626&ext=jpg&ga=GA1.2.1060993109.1605750477", "english_name": "i am seller_2", "id": 2, "name": "나는셀러2", "profile_image": "https://img.freepik.com/free-psd/logo-mockup-white-paper_1816-82.jpg?size=626&ext=jpg&ga=GA1.2.1060993109.1605750477" } } Raises: 400, {'message': 'key error', 'errorMessage': 'key_error'} : 잘못 입력된 키값 400, {'message': 'seller does not exist error', 'errorMessage': 'seller_does_not_exist'} : 셀러 정보 조회 실패 400, {'message': 'unable to close database', 'errorMessage': 'unable_to_close_database'}: 커넥션 종료 실패 500, {'message': 'internal server error', 'errorMessage': format(e)}) : 서버 에러 History: 2021-01-01(고수희): 초기 생성 """ account_id = args[0] try: connection = get_connection(self.database) seller_info = self.service.get_seller_info_service( connection, account_id) return jsonify({'message': 'success', 'result': seller_info}) except Exception as e: raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def get(self, *args): """ GET 메소드: 해당 셀러의 카테고리 출력 seller_id에 해당되는 셀러 정보를 테이블에서 조회 후 가져옴 Author: 고수희 Returns: { "message": "success", "result": [ { "main_category_id": 1, "name": "아우터" }, { "main_category_id": 2, "name": "상의" } ] } Raises: 400, {'message': 'key error', 'errorMessage': 'key_error'} : 잘못 입력된 키값 400, {'message': 'seller category does not exist', 'errormessage': 'seller_category_not_exist'} : 셀러 카테고리 조회 실패 500, {'message': 'server error', 'errorMessage': 'server_error'}': 서버 에러 History: 2021-01-02(고수희): 초기 생성 """ data = {"seller_id": args[0]} try: connection = get_connection(self.database) category_list = self.service.get_seller_category_service( connection, data) return jsonify({'message': 'success', 'result': category_list}) except Exception as e: raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def post(self, *args): data = {'enquiry_id': args[0], 'answer': args[1]} try: connection = get_connection(self.database) self.service.post_answer_service(connection, data) connection.commit() return {'message': 'success'} except Exception as e: raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def get(self): """ GET 메소드: 해당 유저가 사용한 가장 최신의 주문자 정보 조회 user_id에 해당되는 주문 내역들을 조회해서, 가장 최근에 사용한 주문자 정보 사용 Author: 고수희 Returns: { "name": "고수희", "phone": "01021341234, "email": "*****@*****.**" } Raises: 400, {'message': 'key error', 'errorMessage': 'key_error'} : 잘못 입력된 키값 400, {'message': 'unable to close database', 'errorMessage': 'unable_to_close_database'} : 커넥션 종료 실패 403, {'message': 'customer permission denied', 'errorMessage': 'customer_permission_denied'} : 사용자 권한이 아님 500, {'message': 'internal server error', 'errorMessage': format(e)}) : 서버 에러 History: 2020-12-30(고수희): 초기 생성 2021-01-02(고수희): decorator 수정 """ data = { "user_id": g.account_id, "user_permission": g.permission_type_id } try: connection = get_connection(self.database) sender_info = self.service.get_sender_info_service( connection, data) return jsonify({'message': 'success', 'result': sender_info}) except Exception as e: raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def get(self, destination_id): """GET 메소드: 배송지 상세정보 조회 pass converter 로 받은 destination_id 에 해당하는 배송지 상세정보를 조회, 반환해준다. Args: destination_id : url pass_parameter 로 입력받은 값 Author: 김기용 Returns: 201, {"message": "success", "result": {"address1": "주소1", "address2": "주소2", "default_location": 0, "id": 3, "phone": "01012345678", "post_number": "12345678", "recipient": "수취인", "user_id": 152 }} Raises: 500, {'message': 'internal server error', 'errorMessage': format(e)}) History: 2020-12-29(김기용): 초기 생성 """ connection = None try: data = dict() data['destination_id'] = destination_id connection = get_connection(self.database) destination_detail = self.service.get_destination_detail_service( connection, data) return {'message': 'success', 'result': destination_detail[0]} except Exception as e: raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('서버에서 알 수 없는 에러가 발생했습니다.')
def post(self, *args): """ POST 메소드: 유저 로그인 Args: args = ('username', 'password') Author: 김민구 Returns: 200, {'message': 'success', 'token': token} : 유저 로그인 성공 Raises: 400, {'message': 'invalid_parameter', 'errorMessage': '[데이터]가(이) 유효하지 않습니다.'} : 잘못된 요청값 400, {'message': 'key_error', 'error_message': format(e)} : 잘못 입력된 키값 403, {'message': 'invalid_user', 'error_message': '로그인에 실패했습니다.'} : 로그인 실패 500, {'message': 'create_token_denied', 'error_message': '로그인에 실패했습니다.'} : 토큰 생성 실패 500, { 'message': 'database_connection_fail', 'error_message': '서버에 알 수 없는 에러가 발생했습니다.' } : 커넥션 종료 실패 500, {'message': 'database_error', 'error_message': '서버에 알 수 없는 에러가 발생했습니다.'} : 데이터베이스 에러 500, {'message': 'internal_server_error', 'error_message': format(e)}) : 서버 에러 History: 2020-12-29(김민구): 초기 생성 2020-12-31(김민구): 에러 문구 변경 2021-01-02(김민구): 데이터 조작 에러 추가 """ connection = None try: data = { 'username': args[0], 'password': args[1] } connection = get_connection(self.database) token = self.user_service.sign_in_logic(data, connection) return jsonify({'message': 'success', 'token': token}), 200 except Exception as e: traceback.print_exc() raise e finally: try: if connection is not None: connection.close() except Exception: raise DatabaseCloseFail('서버에 알 수 없는 에러가 발생했습니다.')
def get(self, *args): data = {'enquiry_id': args[0]} try: connection = get_connection(self.database) result = self.service.get_answer_service(connection, data) return jsonify({'message': 'success', 'result': result}) except Exception as e: raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def get(self, *args): """ GET 메소드: 상품 검색 사용자가 입력한 검색 키워드로 해당하는 상품이름, 셀러이름을 조회해서반환해준다. Args: search : 검색키워드 limit : 표시할 상품 개수 sort_type: 정렬 종류(최신순, 판매순, 추천순) Author: 김기용 Returns: 200, {'message': 'success', 'result': 상품정보들} Raises: 400, {'message': 'key error', 'errorMessage': '키 값이 일치하지 않습니다.'} 400, {'message': 'invalid_parameter', 'error_message': '[데이터]가(이) 유효하지 않습니다.'} 500, {'message': 'unable to close database', 'errorMessage': '커넥션 종료 실패'}: 커넥션 종료 실패 500, {'message': 'internal server error', 'errorMessage': format(e)}): 서버 에러 History: 2020-12-31(김기용): 초기 생성 2021-01-01(김기용): 북마크에 대한 정보 추가 2021-01-02(김기용): Param 값에대한 Rule 을 정의해주었다. """ connection = None try: data = { 'search': args[0], 'limit': int(args[1]), 'sort_type': args[2] } connection = get_connection(self.database) result = self.service.product_search_service(connection, data) return jsonify({'message': 'success', 'result': result}) finally: try: if connection is not None: connection.close() except Exception: raise DatabaseCloseFail('서버에 알 수 없는 에러가 발생했습니다.')
def delete(self, *args): """ DELETE 메소드: 북마크 삭제 Args: product_id = 상품 아이디 Author: 김민구 Returns: 200, {'message': 'success'} Raises: 400, {'message': 'key_error', 'error_message': format(e)} : 잘못 입력된 키값 400, {'message': 'not_exist_bookmark', 'error_message': '해당 북마크가 존재하지 않습니다.'} : 존재하지 않는 북마크 500, { 'message': 'database_connection_fail', 'error_message': '서버에 알 수 없는 에러가 발생했습니다.' } : 커넥션 종료 실패 500, {'message': 'database_error', 'error_message': '서버에 알 수 없는 에러가 발생했습니다.'} : 데이터베이스 에러 500, {'message': 'data_manipulation_fail', 'error_message': '북마크 삭제를 실패하였습니다.'} : 데이터 조작 에러 500, {'message': 'internal_server_error', 'error_message': format(e)}) : 서버 에러 History: 2020-01-02(김민구) 초기 생성 2020-01-07(김민구): 상품 존재 유무 체크 추가 """ connection = None try: data = {'product_id': args[0], 'account_id': g.account_id} connection = get_connection(self.database) self.bookmark_service.delete_bookmark_logic(connection, data) connection.commit() return jsonify({'message': 'success'}), 200 except Exception as e: traceback.print_exc() connection.rollback() raise e finally: try: if connection is not None: connection.close() except Exception: raise DatabaseCloseFail('서버에 알 수 없는 에러가 발생했습니다.')
def get(self, *args): """GET 메소드: 해당 셀러의 히스토리 정보를 조회. account_id 에 해당되는 셀러 히스토리를 테이블에서 조회 후 가져온다. Args: args = (account_id) Author: 이영주 Returns: seller_history Raises: 400, {'message': 'key error', 'errorMessage': 'key_error'} : 잘못 입력된 키값 400, {'message': 'seller does not exist error', 'errorMessage': 'seller_does_not_exist'}: 셀러 정보 조회 실패 400, {'message': 'unable to close database', 'errorMessage': 'unable_to_close_database'}: 커넥션 종료 실패 500, {'message': 'internal server error', 'errorMessage': format(e)}) : 서버 에러 History: 2020-12-28(이영주): 초기 생성 """ data = {'account_id': args[0]} try: connection = get_connection(self.database) seller_history = self.service.get_seller_history(connection, data) return jsonify({ 'message': 'success', 'result': seller_history }), 200 except Exception as e: raise e except Exception as e: raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def get(self, *args): connection = None try: offset = args[0] connection = get_connection(self.database) result = self.service.seller_list_service(connection, offset) return jsonify({'message': 'success', 'result': result}) except Exception as e: raise e finally: try: if connection is not None: connection.close() except Exception: raise DatabaseCloseFail('서버에 알 수 없는 에러가 발생했습니다.')
def get(self): """GET 메소드: 해당 유저에 대한 배송지 정보 받아오기 유저에 관련된 모든 배송지 정보를 조회 및 반환한다. Args: g.account_id : 데코레이터에서 넘겨받은 유저 정보 g.permission_type_id: 권한정보 Author: 김기용 Returns: 200, {'message': 'success', 'result': 유저 배송지 정보들}: 배송지 조회 성공 Raises: 400, {'message': 'key error', 'errorMessage': '키 값이 일치하지 않습니다.'} 500, {'message': 'unable to close database', 'errorMessage': '커넥션 종료 실패'}: 500, {'message': 'internal server error', 'errorMessage': format(e)}) History: 2020-12-29(김기용): 초기 생성 2021-01-02(김기용): 데코레이터 수정 """ connection = None try: data = dict() if 'account_id' in g: data['account_id'] = g.account_id if 'permission_type_id' in g: data['permission_type_id'] = g.permission_type_id connection = get_connection(self.database) destination_detail = self.service.get_destination_detail_by_user_service(connection, data) return {'message': 'success', 'result': destination_detail} except Exception as e: raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('서버에서 알 수 없는 에러가 발생했습니다.')
def get(self, product_id): """ GET 메소드: 상품 상세정보 조회 pass converter 로 받은 product_id 해당하는 상품상세 정보를 조회 반환해준다. Args: Author: 김기용 Returns: 200, {'message': 'success', 'result': 상품정보} Raises: 400, {'message': 'key error', 'errorMessage': '키 값이 일치하지 않습니다.'} 500, {'message': 'unable to close database', 'errorMessage': '커넥션 종료 실패'} 500, {'message': 'internal server error', 'errorMessage': format(e)}): 서버 에러 History: 2020-12-31(김기용): 초기 생성 2021-01-01(김기용): 1차 구현 2021-01-02(김기용): 북마크에대한 정보를 추가해주었다. """ connection = None try: data = dict() data['product_id'] = product_id if 'account_id' in g: data['account_id'] = g.account_id connection = get_connection(self.database) result = self.service.product_detail_service(connection, data) return jsonify({'message': 'success', 'result': result}) except Exception as e: traceback.print_exc() raise e finally: try: if connection is not None: connection.close() except Exception: raise DatabaseCloseFail('서버에 알 수 없는 에러가 발생했습니다.')
def post(self, *args): data = { 'name': args[0], 'gender': args[1], 'age': args[2] } """POST 메소드: 유저생성 Args: args = ('name', 'gender', 'age') Author: 홍길동 Returns: 200, {'message': 'success'} : 유저 생성 성공 Raises: 400, {'message': 'key error', 'errorMessage': 'key_error'} : 잘못 입력된 키값 400, {'message': 'user create error', 'errorMessage': 'user_create_error'} : 유저 생성 실패 403, {'message': 'user already exist', errorMessage': 'already_exist'} : 중복 유저 생성 실패 400, {'message': 'unable to close database', 'errorMessage': 'unable_to_close_database'}: 커넥션 종료 실패 500, {'message': 'internal server error', 'errorMessage': format(e)}) : 서버 에러 History: 2020-20-20(홍길동): 초기 생성 2020-20-21(홍길동): 1차 수정 2020-20-22(홍길동): 2차 수정 """ try: connection = get_connection(self.database) self.service.post_sample_user_service(connection, data) connection.commit() return {'message': 'success'} except Exception as e: connection.rollback() raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def delete(self, *args): """DELETE 메소드: 배송지 삭제 Args: 'destination_id': 배송지 아이디 g.account_id : 데코레이터에서 넘겨받은 account_id g.permission_type_id : 데코레이터에서 넘겨받은 권한 아이디 Author: 김기용 Returns: 200, {'message': 'success'}: 배송지 삭제 성공 Raises: 500, {'message': 'unable_to_close_database', 'errorMessage': '커넥션 종료 실패'} 500, {'message': 'internal_server_error', 'errorMessage': format(e)}): 서버 에러 History: 2020-12-29(김기용): 초기 생성 2020-12-30(김기용): 데코레이터 추가 """ connection = None try: data = dict() data['destination_id'] = args[0] data['account_id'] = g.account_id data['permission_type_id'] = g.permission_type_id connection = get_connection(self.database) self.service.delete_destination_service(connection, data) connection.commit() return {'message': 'success'} except Exception as e: connection.rollback() raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('서버에서 알 수 없는 에러가 발생했습니다')
def patch(self, *args): """PATCH 메소드: 셀러 상태 정보 수정 Args: Author: 이영주 Returns: 200, {'message': 'success'} : 셀러 정보변경 Raises: 400, {'message': 'key error', 'errorMessage': 'key_error'} : 잘못 입력된 키값 400, {'message': 'unable to update', 'errorMessage': 'unable_to_update'} : 셀러 정보 수정 실패 400, {'message': 'unable to close database', 'errorMessage': 'unable_to_close_database'}: 커넥션 종료 실패 500, {'message': 'internal server error', 'errorMessage': format(e)}) : 서버 에러 History: 2021-01-03(이영주): 초기 생성 """ try: data = { 'account_id': args[0], 'seller_status_type_id': args[1], 'seller_id': args[2], 'updater_id': args[3] } connection = get_connection(self.database) self.service.patch_seller_status(connection, data) self.service.patch_seller_history(connection, data) connection.commit() return {'message': 'success'} except Exception as e: connection.rollback() raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def delete(self, *args): if g.permission_type_id != 1: raise NoPermission('마스터 이용자만 사용 가능합니다') """ 기획전 논리삭제 Args: args[0](event_id) : 이벤트 아이디 Returns: { 'message': 'success', 'deleted_event_id': 삭제된 이벤트 아이디 } Raises: 400, {'message': 'event is not deleted', 'errorMessage': 'failed to delete event'} : 이벤트 삭제 실패했을 때 History: 2021-01-04(강두연): 작성 """ data = {'event_id': args[0]} try: connection = get_connection(self.database) self.service.event_delete_service(connection, data) connection.commit() return jsonify({ 'message': 'success', 'deleted_event_id': data['event_id'] }) except Exception as e: connection.rollback() traceback.print_exc() raise e finally: try: if connection: connection.close() except Exception: raise DatabaseCloseFail('database close fail')
def post(self, *args): print(args) data = {'username': args[0], 'password': args[1]} connection = None try: connection = get_connection(self.database) token = self.service.seller_signin_service(connection, data) return jsonify({'message': 'login success', 'token': token}), 200 except Exception as e: raise e finally: try: if connection is not None: connection.close() except Exception: raise DatabaseCloseFail('서버에 알 수 없는 에러가 발생했습니다.')