# -*- encoding: utf-8 -*-
# -----------------------------------------------------------------------------
# @File Name  : order.py
# @Time       : 2020/11/18 下午3:19
# @Author     : X. Peng
# @Email      : acepengxiong@163.com
# @Software   : PyCharm
# -----------------------------------------------------------------------------
import uuid

from flask_restful import Resource, reqparse
from flask import request, render_template
from flask import make_response

from app.utils.html_to_pdf import html_to_pdf
from app.api.engine import pdf_folder


class OrderHandlers(Resource):
    """."""

    def __init__(self):
        """."""
        self.parser = reqparse.RequestParser()

    def get(self):
        """."""
        # self.parser.add_argument('product_id',type=str,required=True,help='商品ID不能为空')
        # args = self.parser.parse_args()
        STUDENT_LIST = [
            {'name': 'pj', 'age': 38, 'gender': '中'},
            {'name': 'lc', 'age': 73, 'gender': '男'},
            {'name': 'fy', 'age': 84, 'gender': '女'}
        ]
        params = {'a': 'hello', 'b': 'world'}
        template = render_template('student.html', student=STUDENT_LIST, params=params)
        html_to_pdf(template, pdf_folder + str(uuid.uuid4()) + '.pdf')
        resp = make_response(template)
        resp.headers['Content-Type'] = 'text/html'
        return resp

    def post(self):
        """."""
        pass

    def put(self, id):
        """."""
        pass

    def delete(self, id):
        """."""
        pass
