# -*- encoding: utf-8 -*-
# -----------------------------------------------------------------------------
# @File Name  : customer.py
# @Time       : 2021/1/11 下午5:50
# @Author     : X. Peng
# @Email      : acepengxiong@163.com
# @Software   : PyCharm
# -----------------------------------------------------------------------------
from flask import request, g
from flask_restful import Resource, reqparse

from app.api.engine import redis
from app.service.customer import get_customer_list
from app.utils.auth import login_require


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

    @login_require
    def get(self):
        """获取客户列表分页数据."""
        self.parser.add_argument('name', type=str, required=False, help='客户名')
        self.parser.add_argument('pageNumber', type=int, required=True)
        self.parser.add_argument('pageSize', type=int, required=True)
        args = self.parser.parse_args()
        args['ifa_id'] = g.ifa_id
        data = get_customer_list(args)
        resp = {
            "statusCode": "0000",
            "message": "成功",
            "attributes": data
        }
        return resp