Skip to content

Commit

Permalink
add api: get ticket's participant info
Browse files Browse the repository at this point in the history
  • Loading branch information
blackholll committed Sep 30, 2019
1 parent 037b082 commit eaf8d79
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/ticket/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.urls import path
from apps.ticket.views import TicketListView, TicketView, TicketTransition, TicketFlowlog, TicketFlowStep, TicketState, \
TicketsStates, TicketAccept, TicketDeliver, TicketAddNode, \
TicketAddNodeEnd, TicketField, TicketScriptRetry, TicketComment, TicketHookCallBack
TicketAddNodeEnd, TicketField, TicketScriptRetry, TicketComment, TicketHookCallBack, TicketParticipantInfo

urlpatterns = [
path('', TicketListView.as_view()),
Expand All @@ -18,5 +18,6 @@
path('/<int:ticket_id>/retry_script', TicketScriptRetry.as_view()),
path('/<int:ticket_id>/comments', TicketComment.as_view()),
path('/<int:ticket_id>/hook_call_back', TicketHookCallBack.as_view()),
path('/<int:ticket_id>/participant_info', TicketParticipantInfo.as_view()),
path('/states', TicketsStates.as_view()), # 批量获取工单状态
]
22 changes: 22 additions & 0 deletions apps/ticket/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,3 +519,25 @@ def post(self, request, *args, **kwargs):
else:
code, msg, data = -1, msg, ''
return api_response(code, msg, data)


class TicketParticipantInfo(View):
def get(self, request, *args, **kwargs):
"""
工单当前处理人详情,调用方后端可用获取处理人信息后提供催办等功能
:param request:
:param args:
:param kwargs:
:return:
"""
ticket_id = kwargs.get('ticket_id')
flag, msg = TicketBaseService.get_ticket_participant_info(ticket_id)
if flag:
code, msg, data = 0, '', msg
else:
code, msg, data = -1, msg, {}
return api_response(code, msg, data)




28 changes: 28 additions & 0 deletions service/ticket/ticket_base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1901,3 +1901,31 @@ def hook_call_back(cls, ticket_id, app_name, request_data_dict):
if not flag:
return False, msg
return True, ''

@classmethod
@auto_log
def get_ticket_participant_info(cls, ticket_id):
"""
获取工单当前详细参与人信息
:param ticket_id:
:return:
"""
ticket_obj = TicketRecord.objects.filter(id=ticket_id, is_deleted=0).first()
from apps.account.models import LoonUser
participant_username_list, participant_info_list = [], []

if ticket_obj.participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_PERSONAL:
participant_username_list = [ticket_obj.participant]
elif ticket_obj.participant_type_id in (
CONSTANT_SERVICE.PARTICIPANT_TYPE_MULTI, CONSTANT_SERVICE.PARTICIPANT_TYPE_MULTI_ALL):
participant_username_list = ticket_obj.participant.split(',')
elif ticket_obj.participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_ROLE:
participant_username_list, msg = AccountBaseService.get_role_username_list(ticket_obj.participant)
elif ticket_obj.participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_DEPT:
participant_username_list, msg = AccountBaseService.get_dept_username_list(ticket_obj.participant)
if participant_username_list:
participant_queryset = LoonUser.objects.filter(username__in=participant_username_list, is_deleted=0)
for participant_0 in participant_queryset:
participant_info_list.append(dict(username=participant_0.username, alias=participant_0.alias,
phone=participant_0.phone, email=participant_0.email))
return True, dict(participant_username_list=participant_username_list, participant_info_list=participant_info_list)

0 comments on commit eaf8d79

Please sign in to comment.