# -*- encoding=utf8 -*-
from air_case.mdm_login.登录外网系统.登录资源管控平台 import login_system
from common.timeUtils import timeUtils

__author__ = "xiaohesheng"

"""
case_tag:api,mdm-web,注册医院审核驳回,id2249,id2249-5,sit,on,202309072
主数据平台:注册医院审核驳回
"""
from common.common_func import commonFuc

module = "a3_mdm3_hs"

# 注册医院
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "insertHosRegistInfo_url")
# #获取请求头信息
headers = commonFuc().get_business_data(module, "json_headers",
                                        commonFuc().get_business_data(module, "json_contentType"))
print(headers)
h_name = commonFuc().get_business_data(module, "name1")  # 获取前缀name
h_name = h_name + commonFuc().randomString(5)  # 随机数生成拼接医院名称
request_body = commonFuc().get_business_data(module, "payload", h_name, h_name, h_name, h_name, h_name, h_name, h_name,
                                             h_name)
print(request_body)
# 发送请求
result = commonFuc().http_post(url, request_body, headers)
print(result)

# 医院审核接口_查询数据_开始
# 登录
username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password")
print(username, password)
# 获取token和projectCode
token, projectCode, uxid,corpId,info = login_system(username, password).get_token()
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "queryListPage_url")
# 获取请求头信息
headers = commonFuc().get_business_data(module, "json_headers2",
                                        commonFuc().get_business_data(module, "json_contentType"), token,
                                        projectCode)
request_body = commonFuc().get_business_data(module, "payload2", h_name)
# print('aaaaaaaaaaaa',request_body)
# 发送请求
result1 = commonFuc().http_post(url, request_body, headers)
# print('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',result1)
# 获取接口返回数据
id1 = commonFuc().analysis_json('id', result1)
# print('id1',id1)
code = commonFuc().analysis_json('code', result1)
# print('code',code)
# 断言实际结果中是否包含预期结果的内容
# commonFuc().check_result(code, result)
# 断言实际结果中是否包含预期的文本
commonFuc().check_text_exist(code, result1)
# ===============医院注册提交接口_查询数据_结束


# 锁定医院
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "updateById_url")
# #获取请求头信息
headers = commonFuc().get_business_data(module, "json_headers",
                                        commonFuc().get_business_data(module, "json_contentType"))
# 调用函数获取时间
now = timeUtils().get_time_hms()
request_body = commonFuc().get_business_data(module, "payload3", id1, uxid, now)

# 发送请求
result = commonFuc().http_post(url, request_body, headers)
# print('abc',result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict")
# print(check_dict)
# #断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# #=============== 锁定结束
#

# #医院注册_审核驳回_开始
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "updateById_url")
# 获取请求头信息
headers = commonFuc().get_business_data(module, "json_headers2",
                                        commonFuc().get_business_data(module, "json_contentType"), token,
                                        projectCode)
request_body = commonFuc().get_business_data(module, "payload5", id1, uxid, now)
# 发送请求
result = commonFuc().http_post(url, request_body, headers)
# print('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',result)
# #获取接口返回数据
# code = commonFuc().analysis_json('code', result)
checkDict = commonFuc().get_business_data(module, "checkDict")
#
# #断言实际结果中是否包含预期结果的内容
commonFuc().check_result(checkDict, result)
# #===============医院注册提交接口_审核通过_结束
