feat:parmas
This commit is contained in:
@@ -41,9 +41,30 @@ def query_room_info(params) -> str:
|
||||
return str(result)
|
||||
|
||||
|
||||
def book_room(data: dict) -> str:
|
||||
resp = requests.post('http://127.0.0.1:8000/myapi/room/', data)
|
||||
return resp.text
|
||||
def book_room(data: dict, params: dict) -> str:
|
||||
# resp = requests.post('http://127.0.0.1:8000/myapi/room/', data)
|
||||
"""
|
||||
:data {
|
||||
startDateTime (not null)
|
||||
endDateTime (not null)
|
||||
qzId (not null)
|
||||
ownnerId (not null)
|
||||
subject (not null)
|
||||
meetingroomId (not null)
|
||||
content (not null)
|
||||
personAmount (not null)
|
||||
}
|
||||
:params: ytenantId (not null)
|
||||
:return:
|
||||
"""
|
||||
tenant_id = params.get('ytenantId', None)
|
||||
if not tenant_id:
|
||||
raise Exception("ytenantId 不能为空")
|
||||
access_token = getinfo.get_access_token(tenant_id)
|
||||
params['access_token'] = access_token
|
||||
content = getinfo.book_meeting_room(params, data)
|
||||
return content
|
||||
|
||||
|
||||
|
||||
def check_and_process_think(content: str) -> str:
|
||||
@@ -170,7 +191,7 @@ def process_chat(user_id: str, user_input: str, params: dict):
|
||||
new_content = new_content.replace("`", '')
|
||||
data = json.loads(new_content)
|
||||
# 触发预订函数------
|
||||
result = book_room(data=data)
|
||||
result = book_room(data=data, params=params)
|
||||
print(result)
|
||||
book_promot = f'''
|
||||
系统调用API预订该会议室的结果如下:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
import time
|
||||
from yonbip_open_api_sdk import sign_opt, request_opt
|
||||
from yj_room_agent import settings
|
||||
@@ -118,6 +119,7 @@ def query_meetingbooking_info(params):
|
||||
request_url = gateway_url + settings.QUERY_MEETINGBOOKING_INFO[1]
|
||||
print("request url ", request_url)
|
||||
print("paramas ", params)
|
||||
params['pageSize'] = 800
|
||||
respones = requests.get(url=request_url, params=params,
|
||||
headers=settings.DEFAULT_HEADER)
|
||||
result = respones.json()
|
||||
@@ -134,10 +136,8 @@ def book_meeting_room(params, data):
|
||||
request_url = gateway_url + settings.BOOK_MEETING_ROOM[1]
|
||||
print("request url ", request_url)
|
||||
print("paramas ", params)
|
||||
print("data: ",data)
|
||||
respones = requests.post(url=request_url, params=params,
|
||||
headers=settings.DEFAULT_HEADER, data=data)
|
||||
result = respones.json()
|
||||
if respones.status_code == 200:
|
||||
return result
|
||||
else:
|
||||
raise Exception(f"预定会议室失败 状态码: {respones.status_code}")
|
||||
headers=settings.DEFAULT_HEADER, data=json.dumps(data))
|
||||
print("respone ", respones)
|
||||
return respones.text
|
||||
|
||||
@@ -21,6 +21,7 @@ from yj_room_agent import views
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('test/', views.hello, name='hello'),
|
||||
path('chat/', views.room_chat),
|
||||
path('getMeetingType/', views.query_meeting_type),
|
||||
path('getMeeting/', views.query_meeting),
|
||||
path('getMeetingBookingDetails/', views.query_meetingooking_info),
|
||||
|
||||
@@ -103,22 +103,20 @@ def book_meeting_room(request):
|
||||
data = request.POST.dict()
|
||||
print("data is {0}".format(data))
|
||||
print("当前params : {0}".format(params))
|
||||
# tenant_id = params.get('ytenantId', None)
|
||||
# if not tenant_id:
|
||||
# raise Exception("ytenantId 不能为空")
|
||||
# try:
|
||||
# access_token = getinfo.get_access_token(tenant_id)
|
||||
# params['access_token'] = access_token
|
||||
#
|
||||
# book_meeting = getinfo.book_meeting_room(params,data)
|
||||
# content = json.loads(json.dumps(book_meeting))
|
||||
# print("room type :", content)
|
||||
# return JsonResponse(content)
|
||||
# except Exception as ex:
|
||||
# return JsonResponse(str(ex))
|
||||
#
|
||||
# else:
|
||||
# return HttpResponseNotAllowed(['POST'])
|
||||
tenant_id = params.get('ytenantId', None)
|
||||
if not tenant_id:
|
||||
raise Exception("ytenantId 不能为空")
|
||||
try:
|
||||
access_token = getinfo.get_access_token(tenant_id)
|
||||
params['access_token'] = access_token
|
||||
|
||||
book_meeting = getinfo.book_meeting_room(params,data)
|
||||
content = json.loads(json.dumps(book_meeting))
|
||||
print("room type :", content)
|
||||
return JsonResponse(content)
|
||||
except Exception as ex:
|
||||
return JsonResponse(str(ex))
|
||||
|
||||
|
||||
|
||||
@require_POST
|
||||
|
||||
Reference in New Issue
Block a user