Exemplo n.º 1
0
    def patch(self, ticket_id):
        logger.info(f'start patch /service/tickets/{ticket_id} request')

        username = get_request_username()
        if not ticket_id:
            return api_response("请输入工单id", 400)

        ins = WorkFlowAPiRequest(username)
        request_data = json.loads(request.data)
        request_data['username'] = username
        status, resp = ins.getdata(
            parameters={},
            method='patch',
            url='/api/v1.0/tickets/{}'.format(ticket_id),
            data=request_data)
        if resp['code'] == 0:
            return api_response(
                {
                    'code': resp['code'],
                    'data': resp['data'],
                    'msg': resp['msg']
                }, 200)
        else:
            return api_response(
                {
                    'code': resp['code'],
                    'data': None,
                    'msg': resp['msg']
                }, 400)
Exemplo n.º 2
0
    def get(self, ticket_id):
        logger.info(f'start get /service/tickets/{ticket_id} request')

        username = get_request_username()
        if not ticket_id:
            return api_response("请输入工单id", 400)

        ins = WorkFlowAPiRequest(username)
        status, resp = ins.getdata(
            dict(per_page=10, name=''),
            method='get',
            url='/api/v1.0/tickets/{}?username={}'.format(ticket_id, username))
        if resp['code'] == 0:
            return api_response(
                {
                    'code': resp['code'],
                    'data': resp['data'],
                    'msg': resp['msg']
                }, 200)
        else:
            return api_response(
                {
                    'code': resp['code'],
                    'data': None,
                    'msg': resp['msg']
                }, 400)
Exemplo n.º 3
0
    def get(self, params):
        logger.info('start /service/tickets/ request')

        username = get_request_username()
        category = params['category']
        page = params['page'] or 1
        url = '/api/v1.0/tickets?username={}'.format(username)
        if category:
            url += '&category={}'.format(category)

        ins = WorkFlowAPiRequest(username)
        status, resp = ins.getdata(dict(per_page=10, name='', page=page),
                                   method='get',
                                   url=url)
        if resp['code'] == 0:
            return api_response(
                {
                    'code': resp['code'],
                    'data': resp['data'],
                    'msg': resp['msg']
                }, 200)
        else:
            return api_response(
                {
                    'code': resp['code'],
                    'data': None,
                    'msg': resp['msg']
                }, 400)
Exemplo n.º 4
0
 def get(self):
     logger.info('start /service/workflows/ request')
     ins = WorkFlowAPiRequest(get_request_username())
     status, resp = ins.getdata(dict(per_page=10, name=''),
                                method='get',
                                url='/api/v1.0/workflows')
     if resp['code'] == 0:
         return api_response(
             {
                 'code': resp['code'],
                 'data': resp['data'],
                 'msg': resp['msg']
             }, 200)
     else:
         return api_response(
             {
                 'code': resp['code'],
                 'data': None,
                 'msg': resp['msg']
             }, 400)
Exemplo n.º 5
0
 def get(self, workflow_id):
     logger.info('start /service/init_state/ request')
     username = get_request_username()
     ins = WorkFlowAPiRequest(username)
     status, resp = ins.getdata(
         dict(per_page=10, name=''),
         method='get',
         url='/api/v1.0/workflows/{}/init_state?username={}'.format(
             workflow_id, username))
     if resp['code'] == 0:
         return api_response(
             {
                 'code': resp['code'],
                 'data': resp['data'],
                 'msg': resp['msg']
             }, 200)
     else:
         return api_response(
             {
                 'code': resp['code'],
                 'data': None,
                 'msg': resp['msg']
             }, 400)
Exemplo n.º 6
0
 def post(self):
     logger.info('start /service/create_ticket/ request')
     username = get_request_username()
     ins = WorkFlowAPiRequest(username)
     request_data = json.loads(request.data)
     request_data['username'] = username
     status, resp = ins.getdata(dict(per_page=10, name=''),
                                method='post',
                                url='/api/v1.0/tickets',
                                data=request_data)
     if resp['code'] == 0:
         return api_response(
             {
                 'code': resp['code'],
                 'data': resp['data'],
                 'msg': resp['msg']
             }, 200)
     else:
         return api_response(
             {
                 'code': resp['code'],
                 'data': None,
                 'msg': resp['msg']
             }, 400)