Esempio n. 1
0
def build_response(name, data):
    return api.response(
        code=to_http_status(APIStatus.Ok),
        model=api.model(
            name, {
                'status': fields.Integer(description='返回状态码'),
                'msg': fields.String(description='返回状态信息'),
                'data': fields.Nested(model=data, description='返回的数据')
            }),
        description='返回内容')
Esempio n. 2
0
    def ResponseBody(self,
                     data,
                     model_name,
                     response_model="model",
                     response_code="200",
                     response_data="成功",
                     response_templates=None,
                     response_fileds=False,
                     function=None):
        """返回整个BODY
        :params data          : response data
        :params response_model: model | response
        :return : response data model
        """

        models = {}
        for _key in data:
            if isinstance(data[_key], dict):
                _fields = fields.Nested(
                    model=api.model(_key, self.NestedList(data[_key])))
            elif isinstance(data[_key], list):
                _fields = fields.List(
                    fields.Nested(
                        model=api.model(_key, self.NestedList(data[_key]))))
            else:
                _fields = self.__swich_fields_keys[
                    data[_key].__class__.__name__](data[_key],
                                                   Description=data[_key])
            models[_key] = _fields
        if response_fileds:
            return models
        if response_model == "response":
            return api.response(response_code,
                                response_data,
                                model=api.model(model_name, models))
        # if function:
        #     api.doc(body=api.model(model_name, models))(function)
        return api.doc(body=api.model(model_name, models))
Esempio n. 3
0
from flask_restplus import fields
from server.status import APIStatus, FeedAPIStatus
from server import api

response_success = api.response(
    200, '成功',
    api.model(
        'response_success', {
            'state':
            fields.Integer(description=str(APIStatus.Ok)),
            'msg':
            fields.String(description=FeedAPIStatus.Decriptions[APIStatus.Ok]),
        }))

request_order_received_statistics_param = api.doc(params={
    'start_time':
    '开始日期(时间戳),默认:8天前',
    'end_time':
    '结束日期(时间戳),默认:昨天',
    'periods':
    '时间周期,2:日,3:周,4:月,默认:2',
    'goods_type':
    '货源类型,1:跨城,2:同城,默认:0全部',
    'goods_price_type':
    '货源类型,1:议价,2:一口价,默认:0全部',
    'dimension':
    '维度,1:按数量,2:按金额,默认:1',
    'region_id':
    '地区id,默认:0全部',
    'comment_type':
    '评价:1:好评,2:中评,3:差评,默认:0全部',
Esempio n. 4
0
    'limit': '条数',
})

request_user_message_read_put = api.doc(body=api.model('request_user_message_read_post', {
    'user_name': fields.String(description='用户名'),

}))

response_system_message_list_get = api.response(200, '成功', api.model('response_system_message_list_get', {
    'state': fields.Integer(description='100000'),
    'msg': fields.String(description='成功'),
    'count': fields.Integer(description='总消息数'),
    'data': fields.Nested(model=api.model('goods_id', {
        'id': fields.Integer(description='消息id'),
        'title': fields.String(description='消息标题'),
        'content': fields.String(description='消息内容'),
        'user_id': fields.Integer(description='发布者id'),
        'create_time': fields.String(description='消息发布时间'),
        'update_time': fields.String(description='消息修改时间'),
        'msg_type': fields.Integer(description='消息类型: 1.手动发布, 2自动发布'),
        'is_deleted': fields.Integer(description='是否删除')
    }), description='货物ID')
}))

response_user_message_list_get = api.response(200, '成功', api.model('response_user_message_list_get', {
    'state': fields.Integer(description='100000'),
    'msg': fields.String(description='成功'),
    'unread': fields.Integer(description='未读消息数'),
    'count': fields.Integer(description='总消息数'),
    'data': fields.Nested(model=api.model('goods_id', {
        'is_read': fields.Integer(description='是否已读,0未读,1已读'),
Esempio n. 5
0
# coding=utf-8
# author=whitefirer

from server import api
from server.status import APIStatus, AdminAPIStatus
from flask_restplus import fields

NodeModel = api.model(
    'node_model', {
        'hb_id': fields.String(description='红包ID', required=True),
        'data_type': fields.String(description='节点数据类型', required=True),
        'node_data': fields.String(description='节点数据', required=True),
        'click_time': fields.Float(description='点击时间', required=True),
    })

response_hb_success = api.response(
    200, '成功',
    api.model(
        'response_hb_success', {
            'state':
            fields.Integer(description=str(APIStatus.Ok)),
            'msg':
            fields.String(
                description=AdminAPIStatus.Decriptions[APIStatus.Ok]),
            'data':
            fields.Nested(model=NodeModel, description='数据')
        }))
Esempio n. 6
0
# coding=utf-8
# author=whitefirer


from flask_restplus import fields
from server.status import APIStatus, AdminAPIStatus
from server import api


request_token = api.header('token', type=str, description='登录令牌', required=True)

response_success = api.response(200, '成功', api.model('response_success', {
    'state': fields.Integer(description=str(APIStatus.Ok)),
    'msg': fields.String(description=AdminAPIStatus.Decriptions[APIStatus.Ok]),
}))

response_bad_request = api.response(400, '请求参数错误', api.model('response_bad_request', {
    'state': fields.Integer(description=str(APIStatus.BadRequest)),
    'msg': fields.String(description=AdminAPIStatus.Decriptions[APIStatus.BadRequest]),
}))

response_unauthorized = api.response(401, '验证失败', api.model('response_unauthorized', {
    'state': fields.Integer(description=str(APIStatus.UnLogin)),
    'msg': fields.String(description=AdminAPIStatus.Decriptions[APIStatus.UnLogin]),
}))


response_forbidden = api.response(403, '服务器拒绝该请求', api.model('response_response_forbidden', {
    'state': fields.Integer(description=str(APIStatus.Forbidden)),
    'msg': fields.String(description=AdminAPIStatus.Decriptions[APIStatus.Forbidden]),
}))
Esempio n. 7
0
    'goods_type': '货源类型,0:全部,1:一口价,2:议价',
    'register_start_time': '注册期开始时间,默认:空',
    'register_end_time': '注册日期结束时间,默认:空',
    'statistic_start_time': '注册期开始时间,默认:空',
    'statistic_end_time': '注册日期结束时间,默认:空',
    'region_id': '用户自选地区id',
    'page': '页数',
    'limit': '条数'
},
                                       description='推广统计列表查询参数')

response_promote_effect_param_success = response_success = api.response(
    200, '成功',
    api.model(
        'response_success', {
            'state':
            fields.Integer(description=str(APIStatus.Ok)),
            'msg':
            fields.String(description=FeedAPIStatus.Decriptions[APIStatus.Ok]),
        }))

request_promote_effect_add_param = api.doc(
    body=api.model('request_promote_effect_add', {
        'mobile': fields.String(description='手机号'),
    },
                   description='推广统计列表新增推广人员参数'))

response_promote_effect_add_param_success = api.response(
    200, '成功',
    api.model(
        'response_success', {