Skip to content

Commit

Permalink
ticket list api support arg:state_ids
Browse files Browse the repository at this point in the history
  • Loading branch information
blackholll committed Sep 26, 2018
1 parent fadb8d8 commit eb96b8d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/ticket/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ def get(self, request, *args, **kwargs):
create_start = request_data.get('create_start', '')
create_end = request_data.get('create_end', '')
workflow_ids = request_data.get('workflow_ids', '')
state_ids = request_data.get('state_ids', '')
reverse = int(request_data.get('reverse', 1))
per_page = int(request_data.get('per_page', 10))
page = int(request_data.get('page', 1))
# 待办,关联的,创建
category = request_data.get('category')
ticket_result_restful_list, msg = TicketBaseService.get_ticket_list(sn=sn, title=title, username=username,
create_start=create_start, create_end=create_end,
workflow_ids=workflow_ids,category=category, reverse=reverse, per_page=per_page, page=page)
workflow_ids=workflow_ids, state_ids=state_ids, category=category, reverse=reverse, per_page=per_page, page=page)
if ticket_result_restful_list is not False:
data = dict(value=ticket_result_restful_list, per_page=msg['per_page'], page=msg['page'], total=msg['total'])
code, msg, = 0, ''
Expand Down
1 change: 1 addition & 0 deletions docs/apis/ticket.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ title | varchar | 否 | 工单标题,模糊查询
create_start | varchar | 否 | 创建时间起
create_end | varchar | 否 | 创建时间止
workflow_ids | varchar | 否 | 工作流ids,逗号隔开多个工作流id
state_ids | varchar | 否 | 状态ids,逗号隔开多个状态id
reverse | varchar | 否 | 是否按照创建时间倒序,0或者1
page| int | 否 | 页码,默认1
per_page| int | 否 | 每页个数,默认10
Expand Down
7 changes: 6 additions & 1 deletion service/ticket/ticket_base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self):

@classmethod
@auto_log
def get_ticket_list(cls, sn='', title='', username='', create_start='', create_end='',workflow_ids='', category='', reverse=1, per_page=10, page=1):
def get_ticket_list(cls, sn='', title='', username='', create_start='', create_end='',workflow_ids='', state_ids='', category='', reverse=1, per_page=10, page=1):
"""
工单列表
:param sn:
Expand All @@ -33,6 +33,7 @@ def get_ticket_list(cls, sn='', title='', username='', create_start='', create_e
:param create_start: 创建时间起
:param create_end: 创建时间止
:param workflow_ids: 工作流id,str,逗号隔开
:param state_ids: 状态ids,str,逗号隔开
:param category: 查询类别(创建的,待办的,关联的:包括创建的、处理过的、曾经需要处理但是没有处理的)
:param reverse: 按照创建时间倒序
:param per_page:
Expand All @@ -56,6 +57,10 @@ def get_ticket_list(cls, sn='', title='', username='', create_start='', create_e
workflow_id_str_list = workflow_ids.split(',')
workflow_id_list = [int(workflow_id_str) for workflow_id_str in workflow_id_str_list]
query_params &= Q(workflow_id__in=workflow_id_list)
if state_ids:
state_id_str_list = state_ids.split(',')
state_id_list = [int(state_id_str) for state_id_str in state_id_str_list]
query_params &= Q(state_id__in=state_id_list)

if reverse:
order_by_str = '-gmt_created'
Expand Down

0 comments on commit eb96b8d

Please sign in to comment.