Files
fast_response/digital_doctor/application/api/controller/Ttchathistory.php
2025-03-17 10:56:09 +08:00

101 lines
3.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\api\controller;
use think\Db;
use app\common\model\TabConf;
use wanghua\general_utility_tools_php\file\upload\FileUpload;
use wanghua\general_utility_tools_php\tool\Tools;
use wanghua\general_utility_tools_php\Validate;
use think\Controller;
class Ttchathistory extends BaseHttpApi
{
protected $controller_comments = '疼痛科聊天历史';
/**
* desc获取疼痛科聊天历史
*
* api/Ttchathistory/getTtchathistoryList
*
* 参数:
* 带分页
* current_page 当前页码
* list_rows 每页显示条数 默认15
* hdruserbaseinfo_id 统一基本信息 统一基本信息 必须
*
* 所有字段说明<span style="color: gray">(可能有部分额外字段未在此体现)</span>
* id ID
* username 用户
* type 聊天角色
* chat_msg 问诊内容
* ticket 对话票据(用于隔离用户聊天历史记录)
* userbaseinfo_id 基本信息ID
* create_time 创建时间
* hdruserbaseinfo_id 统一基本信息
* authorwh
*/
function getTtchathistoryList(){
Tools::log_to_write_txt(['获取疼痛科聊天历史 入参:'=>input()]);
$api_desc = '获取疼痛科聊天历史';
try {
//$hdruserbaseinfo_id = input('hdruserbaseinfo_id');
//if(empty($hdruserbaseinfo_id)){
// return json(Tools::set_fail('hdruserbaseinfo_id参数错误'));
//}
$reportid = input('reportid');
if(empty($reportid)){
return json(Tools::set_fail('reportid参数错误'));
}
//查询最新的ticket
//$last_ticket = Db::table(TabConf::$fa_tt_chathistory)
// ->where('hdruserbaseinfo_id',$hdruserbaseinfo_id)
// ->order('id desc')
// ->value('ticket');
$model_obj = Db::table(TabConf::$fa_tt_chathistory);
//if(!empty($last_ticket)){
// $model_obj->where('ticket',$last_ticket);
//}
//【对话记录跟着报告走】
$model_obj->where('reportid',$reportid);
//if(input('hdruserbaseinfo_id')){
// $model_obj->where('hdruserbaseinfo_id',input('hdruserbaseinfo_id'));
//}
$data = $model_obj->paginate(['page'=>input('current_page',1),'list_rows'=>input('list_rows',15)])
->each(function($item, $key){
return $item;
});
// ['total'] => int(30)
// ['per_page'] => int(15)
// ['current_page'] => int(1)
// ['last_page''] => int(2)
$data = $data->toArray();//包含 data列表
return json(Tools::set_ok('ok',$data));
}catch(\Exception $e){
Tools::log_to_write_txt([
'error'=>'获取疼痛科聊天历史.异常.'.$e->getMessage(),
'参数'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_res(500,'操作异常',[]));
}
}
}