Exemplo n.º 1
0
    def post(self, request, *args, **kwargs):
        """
        新增调用权限记录
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        json_str = request.body.decode('utf-8')
        if not json_str:
            return api_response(-1, 'post参数为空', {})
        request_data_dict = json.loads(json_str)
        app_name = request_data_dict.get('app_name', '')
        ticket_sn_prefix = request_data_dict.get('ticket_sn_prefix', '')
        workflow_ids = request_data_dict.get('workflow_ids', '')
        # username = request.user.username
        username = request.META.get('HTTP_USERNAME')
        flag, msg = AccountBaseService().add_token_record(
            app_name, ticket_sn_prefix, workflow_ids, username)
        if flag is False:
            code, data = -1, {}
        else:
            code, data = 0, {'id': msg}

        return api_response(code, msg, data)
Exemplo n.º 2
0
    def get(self, request, *args, **kwargs):
        """
        获取工单详情,根据用户返回不同的内容(是否有工单表单的编辑权限)
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        request_data = request.GET
        ticket_id = kwargs.get('ticket_id')
        app_name = request.META.get('HTTP_APPNAME')
        app_permission_check, msg = account_base_service_ins.app_ticket_permission_check(app_name, ticket_id)
        if not app_permission_check:
            return api_response(-1, msg, '')

        # username = request_data.get('username', '')
        username = request.META.get('HTTP_USERNAME')
        if not username:
            return api_response(-1, '参数不全,请提供username', '')
        flag, result = ticket_base_service_ins.get_ticket_detail(ticket_id, username)
        if flag:
            code, data = 0, dict(value=result)
        else:
            code, data, msg = -1, {}, result
        return api_response(code, msg, data)
Exemplo n.º 3
0
    def delete(self, request, *args, **kwargs):
        """
        删除工单,仅用于管理员干预处理工单,loonflow管理后台的功能
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        # 校验工单权限
        ticket_id = kwargs.get('ticket_id')
        username = request.META.get('HTTP_USERNAME')
        json_str = request.body.decode('utf-8')
        suggestion = ''
        if json_str:
            request_data_dict = json.loads(json_str)
            suggestion = request_data_dict.get('suggestion')

        flag, result = ticket_base_service_ins.ticket_admin_permission_check(ticket_id, username)
        if flag is False:
            return api_response(-1, result, {})
        flag, result = ticket_base_service_ins.delete_ticket(ticket_id, username, suggestion)
        if flag is False:
            return api_response(-1, result, {})
        else:
            return api_response(0, '', {})
Exemplo n.º 4
0
 def post(self, request, *args, **kwargs):
     """
     add user
     :param request:
     :param args:
     :param kwargs:
     :return:
     """
     json_str = request.body.decode('utf-8')
     if not json_str:
         return api_response(-1, 'post参数为空', {})
     request_data_dict = json.loads(json_str)
     username = request_data_dict.get('username')
     alias = request_data_dict.get('alias')
     email = request_data_dict.get('email')
     password = request_data_dict.get('password')
     phone = request_data_dict.get('phone')
     dept_ids = request_data_dict.get('dept_ids')
     is_active = request_data_dict.get('is_active')
     type_id = request_data_dict.get('type_id')
     creator = request.user.username
     flag, result = account_base_service_ins.add_user(
         username, alias, email, phone, dept_ids, is_active, type_id,
         creator, password)
     if flag is False:
         code, msg, data = -1, result, {}
     else:
         code, msg, data = 0, '', result
     return api_response(code, msg, data)
Exemplo n.º 5
0
 def post(self, request, format=None):
     serializer = BusSerializer(data=request.data)
     if serializer.is_valid():
         data = serializer.save()
         if data.pk:
             return api_response(status.HTTP_201_CREATED, "公交车列表创建成功", serializer.root.data)
     return api_response(status.HTTP_400_BAD_REQUEST, "公交车列表创建失败", serializer.errors)
Exemplo n.º 6
0
 def post(self, request, *args, **kwargs):
     """
     新增工作流
     :param request:
     :param args:
     :param kwargs:
     :return:
     """
     json_str = request.body.decode('utf-8')
     if not json_str:
         return api_response(-1, 'post参数为空', {})
     request_data_dict = json.loads(json_str)
     name = request_data_dict.get('name', '')
     description = request_data_dict.get('description', '')
     notices = request_data_dict.get('notices', '')
     view_permission_check = request_data_dict.get('view_permission_check',
                                                   1)
     limit_expression = request_data_dict.get('limit_expression', '')
     display_form_str = request_data_dict.get('display_form_str', '')
     workflow_admin = request_data_dict.get('workflow_admin', '')
     title_template = request_data_dict.get('title_template', '')
     content_template = request_data_dict.get('content_template', '')
     creator = request.META.get('HTTP_USERNAME', '')
     flag, result = workflow_base_service_ins.add_workflow(
         name, description, notices, view_permission_check,
         limit_expression, display_form_str, creator, workflow_admin,
         title_template, content_template)
     if flag is False:
         code, msg, data = -1, result, {}
     else:
         code, msg, data = 0, '', {'workflow_id': result.get('workflow_id')}
     return api_response(code, msg, data)
Exemplo n.º 7
0
    def get(self, request, *args, **kwargs):
        """
        get worklfow custom notice list
        获取工作流通知列表
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        request_data = request.GET
        # username = request_data.get('username', '')  # 后续会根据username做必要的权限控制
        username = request.META.get('HTTP_USERNAME')
        if not username:
            username = request.user.username
        search_value = request_data.get('search_value', '')
        per_page = int(request_data.get('per_page', 10)) if request_data.get(
            'per_page', 10) else 10
        page = int(request_data.get('page', 1)) if request_data.get('page',
                                                                    1) else 1
        if not username:
            return api_response(-1, '请提供username', '')
        result, msg = workflow_custom_notice_service_ins.get_notice_list(
            search_value, page, per_page)

        if result is not False:
            data = dict(value=result,
                        per_page=msg['per_page'],
                        page=msg['page'],
                        total=msg['total'])
            code, msg, = 0, ''
        else:
            code, data = -1, ''
        return api_response(code, msg, data)
Exemplo n.º 8
0
    def get(self, request, *args, **kwargs):
        request_data = request.GET
        ticket_id = kwargs.get('ticket_id')
        # username = request_data.get('username', '')  # 可用于权限控制
        username = request.META.get('HTTP_USERNAME')
        per_page = int(request_data.get('per_page', 10))
        page = int(request_data.get('page', 1))
        from service.account.account_base_service import AccountBaseService
        app_name = request.META.get('HTTP_APPNAME')
        app_permission_check, msg = AccountBaseService.app_ticket_permission_check(
            app_name, ticket_id)
        if not app_permission_check:
            return api_response(-1, msg, '')

        if not username:
            return api_response(-1, '参数不全,请提供username', '')

        result, msg = TicketBaseService.get_ticket_flow_log(
            ticket_id, username, per_page, page)

        if result is not False:
            data = dict(value=result,
                        per_page=msg['per_page'],
                        page=msg['page'],
                        total=msg['total'])
            code, msg, = 0, ''
        else:
            code, data = -1, ''
        return api_response(code, msg, data)
Exemplo n.º 9
0
    def post(self, request, *args, **kwargs):
        """
        接单,当工单当前处理人实际为多个人时(角色、部门、多人都有可能, 注意角色和部门有可能实际只有一人)
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        json_str = request.body.decode('utf-8')
        if not json_str:
            return api_response(-1, 'post参数为空', {})
        request_data_dict = json.loads(json_str)
        ticket_id = kwargs.get('ticket_id')
        # username = request_data_dict.get('username', '')
        username = request.META.get('HTTP_USERNAME')

        from service.account.account_base_service import AccountBaseService
        app_name = request.META.get('HTTP_APPNAME')
        app_permission_check, msg = AccountBaseService.app_ticket_permission_check(
            app_name, ticket_id)
        if not app_permission_check:
            return api_response(-1, msg, '')

        result, msg = TicketBaseService.accept_ticket(ticket_id, username)
        if result:
            code, msg, data = 0, msg, result
        else:
            code, msg, data = -1, msg, ''
        return api_response(code, msg, data)
Exemplo n.º 10
0
    def get(self, request, *args, **kwargs):
        """
        获取工作流初始状态信息,包括状态详情以及允许的transition
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        workflow_id = kwargs.get('workflow_id')
        request_data = request.GET
        username = request_data.get('username', '')  # 后续会根据username做必要的权限控制

        app_name = request.META.get('HTTP_APPNAME')
        from service.account.account_base_service import AccountBaseService
        # 判断是否有工作流的权限
        app_permission, msg = AccountBaseService.app_workflow_permission_check(
            app_name, workflow_id)
        if not app_permission:
            return api_response(
                -1,
                'APP:{} have no permission to get this workflow info'.format(
                    app_name), '')

        if not (workflow_id and username):
            return api_response(-1, '请提供username', '')
        state_result, msg = WorkflowStateService.get_workflow_init_state(
            workflow_id)
        if state_result is not False:
            code, msg, data = 0, '', state_result
        else:
            code, msg, data = -1, msg, ''
        return api_response(code, msg, data)
Exemplo n.º 11
0
    def put(self, request, *args, **kwargs):
        """
        修改工单状态
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        json_str = request.body.decode('utf-8')
        if not json_str:
            return api_response(-1, 'patch参数为空', {})
        request_data_dict = json.loads(json_str)
        ticket_id = kwargs.get('ticket_id')
        # username = request_data_dict.get('username', '')  # 可用于权限控制
        username = request.META.get('HTTP_USERNAME')
        state_id = request_data_dict.get('state_id')

        from service.account.account_base_service import AccountBaseService
        app_name = request.META.get('HTTP_APPNAME')
        app_permission_check, msg = AccountBaseService.app_ticket_permission_check(app_name, ticket_id)
        if not app_permission_check:
            return api_response(-1, msg, '')

        if not state_id:
            code = -1
            msg = '请提供新的状态id'
            data = ''
        else:
            result, msg = TicketBaseService.update_ticket_state(ticket_id, state_id, username)
            if result:
                code, msg, data = 0, msg, ''
            else:
                code, msg, data = -1, msg, ''
        return api_response(code, msg, data)
Exemplo n.º 12
0
    def get(self, request, *args, **kwargs):
        """
        获取工作流详情
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        workflow_id = kwargs.get('workflow_id')

        app_name = request.META.get('HTTP_APPNAME')
        # 判断是否有工作流的权限
        app_permission, msg = account_base_service_ins.app_workflow_permission_check(
            app_name, workflow_id)
        if not app_permission:
            return api_response(
                -1,
                'APP:{} have no permission to get this workflow info'.format(
                    app_name), '')
        flag, workflow_result = workflow_base_service_ins.get_full_info_by_id(
            workflow_id)
        if flag is False:
            code, msg, data = -1, workflow_result, {}
        else:
            workflow_result['gmt_created'] = str(
                workflow_result['gmt_created'])[:19]
            code = 0
        return api_response(code, msg, workflow_result)
Exemplo n.º 13
0
    def post(self, request, *args, **kwargs):
        """
        强制关闭工单
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        json_str = request.body.decode('utf-8')
        ticket_id = kwargs.get('ticket_id')
        request_data_dict = json.loads(json_str)
        username = request.META.get('HTTP_USERNAME')
        suggestion = request_data_dict.get('suggestion', '')

        flag, result = ticket_base_service_ins.close_ticket_permission_check(
            ticket_id, username)
        if flag is False:
            return api_response(-1, result, {})

        flag, msg = ticket_base_service_ins.close_ticket(
            ticket_id, username, suggestion)
        if flag:
            code, msg, data = 0, '', msg
        else:
            code, msg, data = -1, msg, {}
        return api_response(code, msg, data)
Exemplo n.º 14
0
    def post(self, request, *args, **kwargs):
        """
        加签,加签操作会修改工单处理人,工单状态不表
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        json_str = request.body.decode('utf-8')
        request_data_dict = json.loads(json_str)
        ticket_id = kwargs.get('ticket_id')
        username = request.META.get('HTTP_USERNAME')
        target_username = request_data_dict.get('target_username', '')
        suggestion = request_data_dict.get('suggestion', '')

        app_name = request.META.get('HTTP_APPNAME')
        app_permission_check, msg = account_base_service_ins.app_ticket_permission_check(
            app_name, ticket_id)
        if not app_permission_check:
            return api_response(-1, msg, '')

        result, msg = ticket_base_service_ins.add_node_ticket(
            ticket_id, username, target_username, suggestion)
        if result:
            code, msg, data = 0, msg, {}
        else:
            code, msg, data = -1, msg, ''
        return api_response(code, msg, data)
Exemplo n.º 15
0
    def get(self, request, *args, **kwargs):
        """
        获取工作流初始状态信息,包括状态详情以及允许的transition
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        workflow_id = kwargs.get('workflow_id')
        username = request.META.get('HTTP_USERNAME')

        app_name = request.META.get('HTTP_APPNAME')
        # 判断是否有工作流的权限
        app_permission, msg = account_base_service_ins.app_workflow_permission_check(
            app_name, workflow_id)
        if not app_permission:
            return api_response(
                -1,
                'APP:{} have no permission to get this workflow info'.format(
                    app_name), '')

        if not (workflow_id and username):
            return api_response(-1, '请提供username', '')
        flag, state_result = workflow_state_service_ins.get_workflow_init_state(
            workflow_id)
        if flag is not False:
            code, msg, data = 0, '', state_result
        else:
            code, msg, data = -1, state_result, ''
        return api_response(code, msg, data)
Exemplo n.º 16
0
    def post(self, request, *args, **kwargs):
        """
        转交操作会直接修改工单处理人,且工单状态不变,所以在使用的时候可以在前端做些提醒 避免用户把工单直接转交给下个人,从而干扰了工单的正常流转(
        如用户提交了一个请假单,部门TL审批状态下,tl本来应该点击"同意",工单会自动流转到财务人员审批状态。 应该避免tl直接将工单转交给了某个财务)。这个地方后续会考虑怎么优化下,目前先在前端做提醒
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        json_str = request.body.decode('utf-8')
        if not json_str:
            return api_response(-1, 'post参数为空', {})
        request_data_dict = json.loads(json_str)
        ticket_id = kwargs.get('ticket_id')
        # username = request_data_dict.get('username', '')
        username = request.META.get('HTTP_USERNAME')
        target_username = request_data_dict.get('target_username', '')
        suggestion = request_data_dict.get('suggestion', '')

        from service.account.account_base_service import AccountBaseService
        app_name = request.META.get('HTTP_APPNAME')
        app_permission_check, msg = AccountBaseService.app_ticket_permission_check(
            app_name, ticket_id)
        if not app_permission_check:
            return api_response(-1, msg, '')

        result, msg = TicketBaseService.deliver_ticket(ticket_id, username,
                                                       target_username,
                                                       suggestion)
        if result:
            code, msg, data = 0, msg, result
        else:
            code, msg, data = -1, msg, ''
        return api_response(code, msg, data)
Exemplo n.º 17
0
 def get(self, request, *args, **kwargs):
     """
     获取工作流详情
     :param request:
     :param args:
     :param kwargs:
     :return:
     """
     workflow_id = kwargs.get('workflow_id')
     app_name = request.META.get('HTTP_APPNAME')
     # 判断是否有工作流的权限
     app_permission, msg = account_base_service_ins.app_workflow_permission_check(
         app_name, workflow_id)
     if not app_permission:
         return api_response(
             -1,
             'APP:{} have no permission to get this workflow info'.format(
                 app_name), '')
     flag, workflow_result = workflow_base_service_ins.get_by_id(
         workflow_id)
     if flag is False:
         code, msg, data = -1, workflow_result, {}
     else:
         data = dict(
             name=workflow_result.name,
             description=workflow_result.description,
             notices=workflow_result.notices,
             view_permission_check=workflow_result.view_permission_check,
             limit_expression=workflow_result.limit_expression,
             display_form_str=workflow_result.display_form_str,
             creator=workflow_result.creator,
             gmt_created=str(workflow_result.gmt_created)[:19])
         code = 0
     return api_response(code, msg, data)
Exemplo n.º 18
0
    def post(self, request, *args, **kwargs):
        """
        加签处理完成,加签完成操作后工单处理人回回到之前加签发起人
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        json_str = request.body.decode('utf-8')
        if not json_str:
            return api_response(-1, 'post参数为空', {})
        request_data_dict = json.loads(json_str)
        ticket_id = kwargs.get('ticket_id')
        # username = request_data_dict.get('username', '')
        username = request.META.get('HTTP_USERNAME')
        suggestion = request_data_dict.get('suggestion', '')

        from service.account.account_base_service import AccountBaseService
        app_name = request.META.get('HTTP_APPNAME')
        app_permission_check, msg = AccountBaseService.app_ticket_permission_check(
            app_name, ticket_id)
        if not app_permission_check:
            return api_response(-1, msg, '')

        result, msg = TicketBaseService.add_node_ticket_end(
            ticket_id, username, suggestion)
        if result:
            code, msg, data = 0, msg, result
        else:
            code, msg, data = -1, msg, ''
        return api_response(code, msg, data)
Exemplo n.º 19
0
    def get(self, request, *args, **kwargs):
        """
        获取工作流执行脚本列表
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        request_data = request.GET
        username = request.META.get('HTTP_USERNAME')
        if not username:
            username = request.user.username
        search_value = request_data.get('search_value', '')
        per_page = int(request_data.get('per_page', 10)) if request_data.get(
            'per_page', 10) else 10
        page = int(request_data.get('page', 1)) if request_data.get('page',
                                                                    1) else 1
        if not username:
            return api_response(-1, '请提供username', '')
        flag, result = workflow_run_script_service_ins.get_run_script_list(
            search_value, page, per_page)

        if flag is not False:
            paginator_info = result.get('paginator_info')
            data = dict(value=result.get('run_script_result_restful_list'),
                        per_page=paginator_info.get('per_page'),
                        page=paginator_info.get('page'),
                        total=paginator_info.get('total'))
            code, msg, = 0, ''
        else:
            code, data = -1, ''
        return api_response(code, msg, data)
Exemplo n.º 20
0
    def patch(self, request, *args, **kwargs):
        """
        修改工单字段
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        json_str = request.body.decode('utf-8')
        if not json_str:
            return api_response(-1, 'post参数为空', {})
        request_data_dict = json.loads(json_str)
        ticket_id = kwargs.get('ticket_id')
        # username = request_data_dict.get('username', '')
        username = request.META.get('HTTP_USERNAME')

        from service.account.account_base_service import AccountBaseService
        app_name = request.META.get('HTTP_APPNAME')
        app_permission_check, msg = AccountBaseService.app_ticket_permission_check(
            app_name, ticket_id)
        if not app_permission_check:
            return api_response(-1, msg, '')

        result, msg = TicketBaseService.update_ticket_field_value(
            ticket_id, request_data_dict)
        if result:
            code, msg, data = 0, msg, result
        else:
            code, msg, data = -1, msg, ''
        return api_response(code, msg, data)
Exemplo n.º 21
0
    def patch(self, request, *args, **kwargs):
        """
        修改通知
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        notice_id = kwargs.get('notice_id')

        json_str = request.body.decode('utf-8')
        if not json_str:
            return api_response(-1, 'post参数为空', {})
        request_data_dict = json.loads(json_str)

        name = request_data_dict.get('name', '')
        description = request_data_dict.get('description', '')
        hook_url = request_data_dict.get('hook_url', '')
        hook_token = request_data_dict.get('hook_token', '')
        creator = request.user.username

        flag, result = account_base_service_ins.admin_permission_check(creator)
        if flag is False:
            return api_response(-1, result, {})

        result, msg = workflow_custom_notice_service_ins.update_custom_notice(
            notice_id, name, description, hook_url, hook_token)
        if result is not False:
            data = {}
            code, msg, = 0, ''
        else:
            code, data = -1, {}
        return api_response(code, msg, data)
Exemplo n.º 22
0
    def post(self, request, *args, **kwargs):
        """
        重新执行工单脚本(用于脚本执行出错的情况)
        :return:
        """
        json_str = request.body.decode('utf-8')
        if not json_str:
            return api_response(-1, 'post参数为空', {})
        request_data_dict = json.loads(json_str)
        ticket_id = kwargs.get('ticket_id')
        # username = request_data_dict.get('username', '')
        username = request.META.get('HTTP_USERNAME')

        from service.account.account_base_service import AccountBaseService
        app_name = request.META.get('HTTP_APPNAME')
        app_permission_check, msg = AccountBaseService.app_ticket_permission_check(
            app_name, ticket_id)
        if not app_permission_check:
            return api_response(-1, msg, '')

        if not username:
            api_response(-1, 'need arg username', '')
        result, msg = TicketBaseService.retry_ticket_script(
            ticket_id, username)
        if result:
            code, msg, data = 0, 'Ticket script retry start successful', ''
        else:
            code, msg, data = -1, msg, ''
        return api_response(code, msg, data)
Exemplo n.º 23
0
    def get(self, request, *args, **kwargs):
        """
        获取工作流拥有的state列表信息
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        workflow_id = kwargs.get('workflow_id')
        request_data = request.GET
        username = request_data.get('username', '')  # 后续会根据username做必要的权限控制
        per_page = int(request_data.get('per_page', 10)) if request_data.get(
            'per_page', 10) else 10
        page = int(request_data.get('page', 1)) if request_data.get('page',
                                                                    1) else 1
        if not username:
            return api_response(-1, '请提供username', '')
        result, msg = WorkflowStateService.get_workflow_states_serialize(
            workflow_id, per_page, page)

        if result is not False:
            data = dict(value=result,
                        per_page=msg['per_page'],
                        page=msg['page'],
                        total=msg['total'])
            code, msg, = 0, ''
        else:
            code, data = -1, ''
        return api_response(code, msg, data)
Exemplo n.º 24
0
    def post(self, request, *args, **kwargs):
        """
        新建工单,需要根据不同类型工单传的参数不一样
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        json_str = request.body.decode('utf-8')
        if not json_str:
            return api_response(-1, 'post参数为空', {})
        request_data_dict = json.loads(json_str)
        app_name = request.META.get('HTTP_APPNAME')
        request_data_dict.update(
            dict(username=request.META.get('HTTP_USERNAME')))

        from service.account.account_base_service import AccountBaseService
        # 判断是否有创建某工单的权限
        app_permission, msg = AccountBaseService.app_workflow_permission_check(
            app_name, request_data_dict.get('workflow_id'))
        if not app_permission:
            return api_response(
                -1, 'APP:{} have no permission to create this workflow ticket'.
                format(app_name), '')

        new_ticket_result, msg = TicketBaseService.new_ticket(
            request_data_dict, app_name)
        if new_ticket_result:
            code, data = 0, {'ticket_id': new_ticket_result}
        else:
            code, data = -1, {}
        return api_response(code, msg, data)
Exemplo n.º 25
0
 def put(self, request, *args, **kwargs):
     """
     修改工单状态
     :param request:
     :param args:
     :param kwargs:
     :return:
     """
     json_str = request.body.decode('utf-8')
     if not json_str:
         return api_response(-1, 'patch参数为空', {})
     request_data_dict = json.loads(json_str)
     ticket_id = kwargs.get('ticket_id')
     username = request_data_dict.get('username', '')  # 可用于权限控制
     state_id = request_data_dict.get('state_id')
     if not state_id:
         code = -1
         msg = '请提供新的状态id'
         data = ''
     else:
         result, msg = TicketBaseService.update_ticket_state(
             ticket_id, state_id, username)
         if result:
             code, msg, data = 0, msg, ''
         else:
             code, msg, data = -1, msg, ''
     return api_response(code, msg, data)
Exemplo n.º 26
0
    def get(self, request, *args, **kwargs):
        """
        获取工作流自定义字段列表
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        request_data = request.GET
        # username = request_data.get('username', '')  # 后续会根据username做必要的权限控制
        username = request.META.get('HTTP_USERNAME')
        if not username:
            username = request.user.username
        search_value = request_data.get('search_value', '')
        per_page = int(request_data.get('per_page', 10)) if request_data.get(
            'per_page', 10) else 10
        page = int(request_data.get('page', 1)) if request_data.get('page',
                                                                    1) else 1
        if not username:
            return api_response(-1, '请提供username', '')
        flag, result = workflow_custom_field_service_ins.get_workflow_custom_field_list(
            kwargs.get('workflow_id'), search_value, page, per_page)

        if flag is not False:
            paginator_info = result.get('paginator_info')
            data = dict(
                value=result.get('workflow_custom_field_result_restful_list'),
                per_page=paginator_info.get('per_page'),
                page=paginator_info.get('page'),
                total=paginator_info.get('total'))
            code, msg = 0, ''
        else:
            code, data, msg = -1, {}, ''
        return api_response(code, msg, data)
Exemplo n.º 27
0
    def patch(self, request, *args, **kwargs):
        """
        处理工单
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        json_str = request.body.decode('utf-8')
        if not json_str:
            return api_response(-1, 'patch参数为空', {})
        request_data_dict = json.loads(json_str)
        ticket_id = kwargs.get('ticket_id')

        app_name = request.META.get('HTTP_APPNAME')
        request_data_dict.update(dict(username=request.META.get('HTTP_USERNAME')))
        app_permission_check, msg = account_base_service_ins.app_ticket_permission_check(app_name, ticket_id)
        if not app_permission_check:
            return api_response(-1, msg, {})

        result, msg = ticket_base_service_ins.handle_ticket(ticket_id, request_data_dict)
        if result or result is not False:
            code, data = 0, dict(value=result)
        else:
            code, data = -1, {}
        return api_response(code, msg, data)
Exemplo n.º 28
0
    def get(self, request, *args, **kwargs):
        """
        获取工作流详情
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        workflow_id = kwargs.get('workflow_id')

        app_name = request.META.get('HTTP_APPNAME')
        username = request.user.username

        flag, msg = workflow_permission_service_ins.manage_workflow_permission_check(
            workflow_id, username, app_name)
        if flag is False:
            return api_response(-1, msg, {})

        flag, workflow_result = workflow_base_service_ins.get_full_info_by_id(
            workflow_id)
        if flag is False:
            code, msg, data = -1, workflow_result, {}
        else:
            workflow_result['gmt_created'] = str(
                workflow_result['gmt_created'])[:19]
            code = 0
        return api_response(code, msg, workflow_result)
Exemplo n.º 29
0
    def get(self, request, *args, **kwargs):
        request_data = request.GET
        ticket_id = kwargs.get('ticket_id')
        username = request.META.get('HTTP_USERNAME')
        per_page = int(request_data.get('per_page', 10))
        page = int(request_data.get('page', 1))
        ticket_data = int(request_data.get('ticket_data', 0))
        app_name = request.META.get('HTTP_APPNAME')
        app_permission_check, msg = account_base_service_ins.app_ticket_permission_check(app_name, ticket_id)
        if not app_permission_check:
            return api_response(-1, msg, '')

        if not username:
            return api_response(-1, '参数不全,请提供username', '')

        flag, result = ticket_base_service_ins.get_ticket_flow_log(ticket_id, username, per_page, page, ticket_data)

        if flag is not False:
            paginator_info = result.get('paginator_info')
            data = dict(value=result.get('ticket_flow_log_restful_list'), per_page=paginator_info.get('per_page'),
                        page=paginator_info.get('page'), total=paginator_info.get('total'))
            code, msg,  = 0, ''
        else:
            code, data = -1, ''
        return api_response(code, msg, data)
Exemplo n.º 30
0
 def post(self, request, *args, **kwargs):
     """
     新增流转
     :param request:
     :param args:
     :param kwargs:
     :return:
     """
     json_str = request.body.decode('utf-8')
     if not json_str:
         return api_response(-1, 'post参数为空', {})
     request_data_dict = json.loads(json_str)
     workflow_id = kwargs.get('workflow_id')
     username = request.user.username
     name = request_data_dict.get('name', '')
     transition_type_id = int(request_data_dict.get('transition_type_id', 0))
     timer = int(request_data_dict.get('timer', 0))
     source_state_id = int(request_data_dict.get('source_state_id', 0))
     destination_state_id = int(request_data_dict.get('destination_state_id', 0))
     condition_expression = request_data_dict.get('condition_expression', '')
     attribute_type_id = int(request_data_dict.get('attribute_type_id', 0))
     field_require_check = int(request_data_dict.get('field_require_check', 0))
     alert_enable = int(request_data_dict.get('alert_enable', 0))
     alert_text = request_data_dict.get('alert_text', '')
     flag, result = workflow_transition_service_ins.add_workflow_transition(workflow_id, name, transition_type_id, timer, source_state_id,
                                            destination_state_id, condition_expression, attribute_type_id,
                                            field_require_check, alert_enable, alert_text, username)
     if flag is not False:
         data = dict(value=dict(transition_id=result.get('transition_id')))
         code, msg, = 0, ''
     else:
         code, data, msg = -1, {}, result
     return api_response(code, msg, data)