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')
Esempio n. 2
0
    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 tearDown(self):
     self.connection = get_connection(self.app.config['DB'])
     with self.connection.cursor() as cursor:
         cursor.execute('set foreign_key_checks=0')
         cursor.execute('truncate accounts')
         cursor.execute('truncate sellers')
         cursor.execute('truncate users')
         cursor.execute('truncate permission_types')
         cursor.execute('truncate events')
         cursor.execute('truncate event_kinds')
         cursor.execute('truncate event_types')
         cursor.execute('truncate event_types_kinds')
         cursor.execute('truncate menus')
         cursor.execute('truncate main_categories')
         cursor.execute('truncate sub_categories')
         cursor.execute('truncate product_origin_types')
         cursor.execute('truncate seller_status_types')
         cursor.execute('truncate seller_attribute_types')
         cursor.execute('truncate products')
         cursor.execute('truncate enquiry_types')
         cursor.execute('truncate enquiries')
         cursor.execute('truncate enquiry_replies')
         cursor.execute('truncate product_sales_volumes')
         cursor.execute('truncate product_images')
         cursor.execute('truncate events_products')
         cursor.execute('set foreign_key_checks=1')
     self.connection.close()
Esempio n. 4
0
    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')
Esempio n. 5
0
    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, *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('서버에서 알 수 없는 에러가 발생했습니다.')
Esempio n. 7
0
    def setUp(self):
        self.app = create_app(config.test_config)
        self.connection = get_connection(self.app.config['DB'])
        self.client = self.app.test_client()

        with self.connection.cursor() as cursor:
            cursor.execute("INSERT INTO permission_types (`id`, `name`) VALUES (3, '일반유저')")
        self.connection.commit()
        self.connection.close()
 def tearDown(self):
     self.connection = get_connection(self.app.config['DB'])
     with self.connection.cursor() as cursor:
         cursor.execute('set foreign_key_checks=0')
         cursor.execute('truncate menus')
         cursor.execute('truncate main_categories')
         cursor.execute('truncate sub_categories')
         cursor.execute('set foreign_key_checks=1')
     self.connection.close()
Esempio n. 9
0
 def tearDown(self):
     self.connection = get_connection(self.app.config['DB'])
     with self.connection.cursor() as cursor:
         cursor.execute('set foreign_key_checks=0')
         cursor.execute('truncate accounts')
         cursor.execute('truncate users')
         cursor.execute('truncate permission_types')
         cursor.execute('set foreign_key_checks=1')
     self.connection.close()
Esempio n. 10
0
    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('서버에 알 수 없는 에러가 발생했습니다.')
Esempio n. 11
0
    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')
Esempio n. 12
0
    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')
Esempio n. 13
0
    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 setUp(self):
        self.app = create_app(config.test_config)
        self.connection = get_connection(self.app.config['DB'])
        self.client = self.app.test_client()

        with self.connection.cursor() as cursor:
            cursor.execute("INSERT INTO menus (`id`, `name`) VALUES (5, '브랜드')")
            cursor.execute("INSERT INTO main_categories (`id`, `name`, `menu_id`) VALUES (12, '아우터', 5)")
            cursor.execute("INSERT INTO sub_categories (`id`, `name`, `main_category_id`) VALUES (62, '코트', 12)")
        self.connection.commit()
        self.connection.close()
Esempio n. 16
0
    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('서버에 알 수 없는 에러가 발생했습니다.')
Esempio n. 17
0
    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')
Esempio n. 18
0
    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')
Esempio n. 19
0
    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')
Esempio n. 20
0
 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')
Esempio n. 21
0
    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('서버에 알 수 없는 에러가 발생했습니다.')
Esempio n. 22
0
    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')
Esempio n. 23
0
    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('서버에서 알 수 없는 에러가 발생했습니다.')
Esempio n. 24
0
    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('서버에 알 수 없는 에러가 발생했습니다.')
Esempio n. 26
0
    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('서버에 알 수 없는 에러가 발생했습니다.')
Esempio n. 27
0
    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')
Esempio n. 28
0
    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 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 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('서버에서 알 수 없는 에러가 발생했습니다.')