This commit is contained in:
2024-08-08 00:24:09 +08:00
parent 992ff09f49
commit 9ab5393c45
3 changed files with 544 additions and 482 deletions

View File

@@ -1,211 +1,246 @@
<?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 think\Controller;
class Hdrfollowup extends BaseHttpApi
{
protected $controller_comments = '统一随访记录';
/**
* 新增统一随访记录
*
<?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 think\Controller;
class Hdrfollowup extends BaseHttpApi
{
protected $controller_comments = '统一随访记录';
/**
* 新增统一随访记录
*
* 参数:
* report_dataid 报告ID 报告ID 必须
* userbaseid 基本信息ID 基本信息ID 必须
* name 姓名 姓名 必须
* phone 电话 电话 必须
* content 随访内容 随访内容 必须
* send_time 发送时间
* api/Hdrfollowup/addHdrfollowup
*/
function addHdrfollowup(){
Tools::log_to_write_txt(['新增统一随访记录'=>input()]);
$api_desc = '新增统一随访记录';
Db::startTrans();
try {
$report_dataid = input('report_dataid');
if(empty($report_dataid)){
return json(Tools::set_fail('参数错误.0'));
}
$userbaseid = input('userbaseid');
if(empty($userbaseid)){
return json(Tools::set_fail('参数错误.1'));
}
$name = input('name');
if(empty($name)){
return json(Tools::set_fail('参数错误.2'));
}
$phone = input('phone');
if(empty($phone)){
return json(Tools::set_fail('参数错误.3'));
}
$content = input('content');
if(empty($content)){
return json(Tools::set_fail('参数错误.4'));
}
$send_time = input('send_time');
$data = [
'report_dataid'=>$report_dataid?:'',
'userbaseid'=>$userbaseid?:'',
'name'=>$name?:'',
'phone'=>$phone?:'',
'content'=>$content?:'',
'send_time'=>$send_time?:'',
];
$dataid = Db::table(TabConf::$fa_hdrfollowup)->insertGetId($data);
$this->operateLog('新增统一随访记录',api_user_info('id'));
Db::commit();
return json(Tools::set_ok('ok',$dataid));
}catch (\Exception $e){
Db::rollback();
Tools::log_to_write_txt([
'error'=>'新增统一随访记录.异常.'.$e->getMessage(),
'input'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
/**
* desc获取统一随访记录
*
* api/Hdrfollowup/getHdrfollowupList
* send_time 发送时间
* api/Hdrfollowup/addHdrfollowup
*/
function addHdrfollowup(){
Tools::log_to_write_txt(['新增统一随访记录'=>input()]);
$api_desc = '新增统一随访记录';
Db::startTrans();
try {
$report_dataid = input('report_dataid');
if(empty($report_dataid)){
return json(Tools::set_fail('参数错误.0'));
}
$userbaseid = input('userbaseid');
if(empty($userbaseid)){
return json(Tools::set_fail('参数错误.1'));
}
$name = input('name');
if(empty($name)){
return json(Tools::set_fail('参数错误.2'));
}
$phone = input('phone');
if(empty($phone)){
return json(Tools::set_fail('参数错误.3'));
}
$content = input('content');
if(empty($content)){
return json(Tools::set_fail('参数错误.4'));
}
$send_time = input('send_time');
$data = [
'report_dataid'=>$report_dataid?:'',
'userbaseid'=>$userbaseid?:'',
'name'=>$name?:'',
'phone'=>$phone?:'',
'content'=>$content?:'',
'send_time'=>$send_time?:'',
];
$dataid = Db::table(TabConf::$fa_hdrfollowup)->insertGetId($data);
$this->operateLog('新增统一随访记录',api_user_info('id'));
Db::commit();
return json(Tools::set_ok('ok',$dataid));
}catch (\Exception $e){
Db::rollback();
Tools::log_to_write_txt([
'error'=>'新增统一随访记录.异常.'.$e->getMessage(),
'input'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
/**
* desc获取统一随访记录
*
* api/Hdrfollowup/getHdrfollowupList
*
* 参数:
* 参数:
* 带分页
* 带分页
* current_page 当前页码
* list_rows 每页显示条数 默认15
* report_dataid 报告ID
* report_dataid 报告ID
* userbaseid 基本信息ID
* userbaseid 基本信息ID
*
* 所有字段说明<span style="color: gray">(可能有部分额外字段未在此体现)</span>
* 所有字段说明<span style="color: gray">(可能有部分额外字段未在此体现)</span>
* id ID
* report_dataid 报告ID
* userbaseid 基本信息ID
* name 姓名
* phone 电话
* content 随访内容
* status 状态:0=待发送,1=已发送
* flow 诊断流程:0=初诊,1=复诊
* send_time 发送时间
* create_time 创建时间
* authorwh
*/
function getHdrfollowupList(){
Tools::log_to_write_txt(['获取统一随访记录 入参:'=>input()]);
$api_desc = '获取统一随访记录';
try {
$report_dataid = input('report_dataid');
$userbaseid = input('userbaseid');
$model_obj = Db::table(TabConf::$fa_hdrfollowup);
if(input('report_dataid')){
$model_obj->where('report_dataid',input('report_dataid'));
}
if(input('userbaseid')){
$model_obj->where('userbaseid',input('userbaseid'));
}
$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,'操作异常',[]));
}
}
* id ID
* report_dataid 报告ID
* userbaseid 基本信息ID
* name 姓名
* phone 电话
* content 随访内容
* status 状态:0=待发送,1=已发送
* flow 诊断流程:0=初诊,1=复诊
* send_time 发送时间
* create_time 创建时间
* authorwh
*/
function getHdrfollowupList(){
Tools::log_to_write_txt(['获取统一随访记录 入参:'=>input()]);
$api_desc = '获取统一随访记录';
try {
$report_dataid = input('report_dataid');
$userbaseid = input('userbaseid');
$model_obj = Db::table(TabConf::$fa_hdrfollowup);
if(input('report_dataid')){
$model_obj->where('report_dataid',input('report_dataid'));
}
if(input('userbaseid')){
$model_obj->where('userbaseid',input('userbaseid'));
}
$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,'操作异常',[]));
}
}
/**
* 修改统一随访记录
* 参数:
* id ID
* content 随访内容
* status 状态:0=待发送,1=已发送
* flow 诊断流程:0=初诊,1=复诊
* status 状态:0=待发送,1=已发送
* flow 诊断流程:0=初诊,1=复诊
* send_time 发送时间
* api/Hdrfollowup/updateHdrfollowup
*/
function updateHdrfollowup(){
Tools::log_to_write_txt(['修改统一随访记录'=>input()]);
$api_desc = '修改统一随访记录';
Db::startTrans();
try {
$content = input('content');
$status = input('status');
$flow = input('flow');
$send_time = input('send_time');
if(empty(input('id'))){
return json(Tools::set_fail('参数错误。0'));
}
$data = [
'content'=>$content?:'',
'status'=>$status?:'',
'flow'=>$flow?:'',
'send_time'=>$send_time?:'',
];
$dataid = Db::table(TabConf::$fa_hdrfollowup)
->data($data)
->where('id',input('id'))
->update();
$this->operateLog('修改统一随访记录',api_user_info('id'));
Db::commit();
return json(Tools::set_ok('ok',$dataid));
}catch (\Exception $e){
Db::rollback();
Tools::log_to_write_txt([
'error'=>'修改统一随访记录.异常.'.$e->getMessage(),
'input'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_fail());
}
* send_time 发送时间
* api/Hdrfollowup/updateHdrfollowup
*/
function updateHdrfollowup(){
Tools::log_to_write_txt(['修改统一随访记录'=>input()]);
$api_desc = '修改统一随访记录';
Db::startTrans();
try {
$content = input('content');
$status = input('status');
$flow = input('flow');
$send_time = input('send_time');
if(empty(input('id'))){
return json(Tools::set_fail('参数错误。0'));
}
$data = [
'content'=>$content?:'',
'status'=>$status?:'',
'flow'=>$flow?:'',
'send_time'=>$send_time?:'',
];
$dataid = Db::table(TabConf::$fa_hdrfollowup)
->data($data)
->where('id',input('id'))
->update();
$this->operateLog('修改统一随访记录',api_user_info('id'));
Db::commit();
return json(Tools::set_ok('ok',$dataid));
}catch (\Exception $e){
Db::rollback();
Tools::log_to_write_txt([
'error'=>'修改统一随访记录.异常.'.$e->getMessage(),
'input'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
/**
* 删除随访
* 参数:
* id ID
* api/Hdrfollowup/del
*/
function del(){
Tools::log_to_write_txt(['删除统一随访记录'=>input()]);
$api_desc = '删除统一随访记录';
try {
$id = input('id');
if(empty($id)){
return json(Tools::set_fail('参数错误。0'));
}
Db::table(TabConf::$fa_hdrfollowup)
->where('id',$id)
->delete();
return json(Tools::set_ok('ok'));
} catch (\Exception $e) {
Tools::log_to_write_txt([
'error'=>'删除统一随访记录.异常.'.$e->getMessage(),
'input'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
}

View File

@@ -1,291 +1,302 @@
<?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 Hdrquestionnairequestion extends BaseHttpApi
{
protected $controller_comments = '科室问卷问题(一个问题对应多个答案)';
/**
* desc获取科室问卷问题(一个问题对应多个答案)
*
* api/Hdrquestionnairequestion/getHdrquestionnairequestionList
*
<?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 Hdrquestionnairequestion extends BaseHttpApi
{
protected $controller_comments = '科室问卷问题(一个问题对应多个答案)';
/**
* 新增科室问卷问题(一个问题对应多个答案)
*
* 参数:
* hdrdepartment_id 所属科室 所属科室 必须
* question 问卷问题 问卷问题 必须
* is_common 是否通用:yes=是,no=否 是否通用:yes=是,no=否 必须
* is_only_boy 只适合男:yes=是,no=否 只适合男:yes=是,no=否 必须
* is_only_girl 只适合女:yes=是,no=否 只适合女:yes=是,no=否 必须
* type 选项类型:one=单选,more=多选 选项类型:one=单选,more=多选 必须
* api/Hdrquestionnairequestion/addHdrquestionnairequestion
*/
function addHdrquestionnairequestion()
{
Tools::log_to_write_txt(['新增科室问卷问题(一个问题对应多个答案)' => input()]);
$api_desc = '新增科室问卷问题(一个问题对应多个答案)';
Db::startTrans();
try {
$hdrdepartment_id = input('hdrdepartment_id');
if (empty($hdrdepartment_id)) {
return json(Tools::set_fail('参数错误.0'));
}
$question = input('question');
if (empty($question)) {
return json(Tools::set_fail('参数错误.1'));
}
$is_common = input('is_common');
if (empty($is_common)) {
return json(Tools::set_fail('参数错误.2'));
}
$is_only_boy = input('is_only_boy');
if (empty($is_only_boy)) {
return json(Tools::set_fail('参数错误.3'));
}
$is_only_girl = input('is_only_girl');
if (empty($is_only_girl)) {
return json(Tools::set_fail('参数错误.4'));
}
$type = input('type');
if (empty($type)) {
return json(Tools::set_fail('参数错误.5'));
}
$data = [
'hdrdepartment_id' => $hdrdepartment_id ?: '',
'question' => $question ?: '',
'is_common' => $is_common ?: '',
'is_only_boy' => $is_only_boy ?: '',
'is_only_girl' => $is_only_girl ?: '',
'type' => $type ?: '',
];
$dataid = Db::table(TabConf::$fa_hdrquestionnairequestion)->insertGetId($data);
$this->operateLog('新增科室问卷问题(一个问题对应多个答案)', api_user_info('id'));
Db::commit();
return json(Tools::set_ok('ok', $dataid));
} catch (\Exception $e) {
Db::rollback();
Tools::log_to_write_txt([
'error' => '新增科室问卷问题(一个问题对应多个答案).异常.' . $e->getMessage(),
'input' => input(),
'error_info' => $e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
/**
* 修改科室问卷问题(一个问题对应多个答案)
* 参数:
* id ID ID 必须
* hdrdepartment_id 所属科室
* question 问卷问题
* is_common 是否通用:yes=是,no=否
* is_only_boy 只适合男:yes=是,no=否
* is_only_girl 只适合女:yes=是,no=否
* type 选项类型:one=单选,more=多选
* api/Hdrquestionnairequestion/updateHdrquestionnairequestion
*/
function updateHdrquestionnairequestion()
{
Tools::log_to_write_txt(['修改科室问卷问题(一个问题对应多个答案)' => input()]);
$api_desc = '修改科室问卷问题(一个问题对应多个答案)';
Db::startTrans();
try {
$hdrdepartment_id = input('hdrdepartment_id');
$question = input('question');
$is_common = input('is_common');
$is_only_boy = input('is_only_boy');
$is_only_girl = input('is_only_girl');
$type = input('type');
if (empty(input('id'))) {
return json(Tools::set_fail('参数错误。0'));
}
$data = [
'hdrdepartment_id' => $hdrdepartment_id ?: '',
'question' => $question ?: '',
'is_common' => $is_common ?: '',
'is_only_boy' => $is_only_boy ?: '',
'is_only_girl' => $is_only_girl ?: '',
'type' => $type ?: '',
];
$dataid = Db::table(TabConf::$fa_hdrquestionnairequestion)
->data($data)
->where('id', input('id'))
->update();
$this->operateLog('修改科室问卷问题(一个问题对应多个答案)', api_user_info('id'));
Db::commit();
return json(Tools::set_ok('ok', $dataid));
} catch (\Exception $e) {
Db::rollback();
Tools::log_to_write_txt([
'error' => '修改科室问卷问题(一个问题对应多个答案).异常.' . $e->getMessage(),
'input' => input(),
'error_info' => $e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
/**
* desc 删除科室问卷问题(一个问题对应多个答案)
* authorwh
*
* 参数:
* id 数据id 必须
*
* api/Hdrquestionnairequestion/del
*/
function del()
{
Tools::log_to_write_txt(['删除科室问卷问题(一个问题对应多个答案)' => input()]);
$api_desc = '删除科室问卷问题(一个问题对应多个答案)';
try {
$id = input('id');
if (empty($id)) {
return json(Tools::set_fail('参数错误。0'));
}
Db::table(TabConf::$fa_hdrquestionnairequestion)
->where('id', $id)
->delete();
return json(Tools::set_ok('ok'));
} catch (\Exception $e) {
Tools::log_to_write_txt([
'error' => '删除科室问卷问题(一个问题对应多个答案).异常.' . $e->getMessage(),
'input' => input(),
'error_info' => $e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
/**
* desc获取科室问卷问题(一个问题对应多个答案)
*
* api/Hdrquestionnairequestion/getHdrquestionnairequestionList
*
* 带分页
* current_page 当前页码
* 参数:
* 带分页
* current_page 当前页码
* question 问卷问题
* id ID
* hdrdepartment_id 所属科室
* question 问卷问题
* is_common 是否通用:yes=是,no=否
* is_only_boy 只适合男:yes=是,no=否
* is_only_girl 只适合女:yes=是,no=否
* type 选项类型:one=单选,more=多选
*
* list_rows 每页显示条数 默认15
*
* id ID
* hdrdepartment_id 所属科室
* question 问卷问题
* is_common 是否通用:yes=是,no=否
* is_only_boy 只适合男:yes=是,no=否
* is_only_girl 只适合:yes=是,no=否
* type 选项类型:one=单选,more=多选
* create_time 创建时间
* update_time 更新时间
* authorwh
*/
function getHdrquestionnairequestionList(){
Tools::log_to_write_txt(['获取科室问卷问题(一个问题对应多个答案) 入参:'=>input()]);
$api_desc = '获取科室问卷问题(一个问题对应多个答案)';
try {
$id = input('id');
$hdrdepartment_id = input('hdrdepartment_id');
if(empty($hdrdepartment_id)){
return json(Tools::set_fail('hdrdepartment_id参数错误'));
}
$question = input('question');
$is_common = input('is_common');
$is_only_boy = input('is_only_boy');
$is_only_girl = input('is_only_girl');
$type = input('type');
$model_obj = Db::table(TabConf::$fa_hdrquestionnairequestion);
if(input('question')){
$model_obj->whereLike('question','%'.input('question').'%');
}
if(input('id')){
$model_obj->where('id',input('id'));
}
if(input('hdrdepartment_id')){
$model_obj->where('hdrdepartment_id',input('hdrdepartment_id'));
}
if(input('is_common')){
$model_obj->where('is_common',input('is_common'));
}
if(input('is_only_boy')){
$model_obj->where('is_only_boy',input('is_only_boy'));
}
if(input('is_only_girl')){
$model_obj->where('is_only_girl',input('is_only_girl'));
}
if(input('type')){
$model_obj->where('type',input('type'));
}
$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,'操作异常',[]));
}
}
/**
* 新增科室问卷问题(一个问题对应多个答案)
*
* 参数:
* hdrdepartment_id 所属科室 所属科室 必须
* question 问卷问题 问卷问题 必须
* is_common 是否通用:yes=是,no=否 是否通用:yes=是,no=否 必须
* is_only_boy 只适合男:yes=是,no=否 只适合男:yes=是,no=否 必须
* is_only_girl 只适合女:yes=是,no=否 只适合女:yes=是,no=否 必须
* type 选项类型:one=单选,more=多选 选项类型:one=单选,more=多选 必须
* api/Hdrquestionnairequestion/addHdrquestionnairequestion
*/
function addHdrquestionnairequestion(){
Tools::log_to_write_txt(['新增科室问卷问题(一个问题对应多个答案)'=>input()]);
$api_desc = '新增科室问卷问题(一个问题对应多个答案)';
Db::startTrans();
try {
$hdrdepartment_id = input('hdrdepartment_id');
if(empty($hdrdepartment_id)){
return json(Tools::set_fail('参数错误.0'));
}
$question = input('question');
if(empty($question)){
return json(Tools::set_fail('参数错误.1'));
}
$is_common = input('is_common');
if(empty($is_common)){
return json(Tools::set_fail('参数错误.2'));
}
$is_only_boy = input('is_only_boy');
if(empty($is_only_boy)){
return json(Tools::set_fail('参数错误.3'));
}
$is_only_girl = input('is_only_girl');
if(empty($is_only_girl)){
return json(Tools::set_fail('参数错误.4'));
}
$type = input('type');
if(empty($type)){
return json(Tools::set_fail('参数错误.5'));
}
$data = [
'hdrdepartment_id'=>$hdrdepartment_id?:'',
'question'=>$question?:'',
'is_common'=>$is_common?:'',
'is_only_boy'=>$is_only_boy?:'',
'is_only_girl'=>$is_only_girl?:'',
'type'=>$type?:'',
];
$dataid = Db::table(TabConf::$fa_hdrquestionnairequestion)->insertGetId($data);
$this->operateLog('新增科室问卷问题(一个问题对应多个答案)',api_user_info('id'));
Db::commit();
return json(Tools::set_ok('ok',$dataid));
}catch (\Exception $e){
Db::rollback();
Tools::log_to_write_txt([
'error'=>'新增科室问卷问题(一个问题对应多个答案).异常.'.$e->getMessage(),
'input'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
/**
* 修改科室问卷问题(一个问题对应多个答案)
* 参数:
* id ID ID 必须
* hdrdepartment_id 所属科室
* question 问卷问题
* is_common 是否通用:yes=是,no=否
* is_only_boy 只适合男:yes=是,no=否
* is_only_girl 只适合女:yes=是,no=否
* type 选项类型:one=单选,more=多选
* api/Hdrquestionnairequestion/updateHdrquestionnairequestion
*/
function updateHdrquestionnairequestion(){
Tools::log_to_write_txt(['修改科室问卷问题(一个问题对应多个答案)'=>input()]);
$api_desc = '修改科室问卷问题(一个问题对应多个答案)';
Db::startTrans();
try {
$hdrdepartment_id = input('hdrdepartment_id');
$question = input('question');
$is_common = input('is_common');
$is_only_boy = input('is_only_boy');
$is_only_girl = input('is_only_girl');
$type = input('type');
if(empty(input('id'))){
return json(Tools::set_fail('参数错误。0'));
}
$data = [
'hdrdepartment_id'=>$hdrdepartment_id?:'',
'question'=>$question?:'',
'is_common'=>$is_common?:'',
'is_only_boy'=>$is_only_boy?:'',
'is_only_girl'=>$is_only_girl?:'',
'type'=>$type?:'',
];
$dataid = Db::table(TabConf::$fa_hdrquestionnairequestion)
->data($data)
->where('id',input('id'))
->update();
$this->operateLog('修改科室问卷问题(一个问题对应多个答案)',api_user_info('id'));
Db::commit();
return json(Tools::set_ok('ok',$dataid));
}catch (\Exception $e){
Db::rollback();
Tools::log_to_write_txt([
'error'=>'修改科室问卷问题(一个问题对应多个答案).异常.'.$e->getMessage(),
'input'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
/**
* desc 删除科室问卷问题(一个问题对应多个答案)
* authorwh
*
* 参数:
* id 数据id 必须
*
* api/Hdrquestionnairequestion/del
*/
function del(){
Tools::log_to_write_txt(['删除科室问卷问题(一个问题对应多个答案)'=>input()]);
$api_desc = '删除科室问卷问题(一个问题对应多个答案)';
try {
$id = input('id');
if(empty($id)){
return json(Tools::set_fail('参数错误。0'));
}
Db::table(TabConf::$fa_hdrquestionnairequestion)
->where('id',$id)
->delete();
return json(Tools::set_ok('ok'));
} catch (\Exception $e) {
Tools::log_to_write_txt([
'error'=>'删除科室问卷问题(一个问题对应多个答案).异常.'.$e->getMessage(),
'input'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
* 所有字段说明<span style="color: gray">(可能有部分额外字段未在此体现)</span>
* id ID
* hdrdepartment_id 所属科室
* question 问卷问题
* is_common 是否通用:yes=是,no=否
* is_only_boy 只适合:yes=是,no=否
* is_only_girl 只适合女:yes=是,no=否
* type 选项类型:one=单选,more=多选
* create_time 创建时间
* update_time 更新时间
* authorwh
*/
function getHdrquestionnairequestionList(){
Tools::log_to_write_txt(['获取科室问卷问题(一个问题对应多个答案) 入参:'=>input()]);
$api_desc = '获取科室问卷问题(一个问题对应多个答案)';
try {
$model_obj = Db::table(TabConf::$fa_hdrquestionnairequestion);
$data = $model_obj->paginate(['page'=>input('current_page',1),'list_rows'=>input('list_rows',15)])
->each(function($item, $key){
$ret_field_name_arr = Tools::delete_str_empty_ele('id--testname,,,,,,,,');
//处理为外键字段+外键对应数据的字段名 egusers_id=>nickname
$ret_field_name2 = [];
foreach ($ret_field_name_arr as $ret_typ_field) {
$exp_arr = explode('--',$ret_typ_field);
//$exp_arr[0] 主表字段,$exp_arr[1] 副表字段
$ret_field_name2[$exp_arr[0]] = [$exp_arr[0],$exp_arr[1]];
}
//返回数据类型处理
$return_type_exp_arr = Tools::delete_str_empty_ele('id==two_arr,,,,,,,,');
//处理为类型+字段
$return_type_exp_arr2 = [];
foreach ($return_type_exp_arr as $ret_type_field) {
$exp_arr = explode('==',$ret_type_field);
$return_type_exp_arr2[$exp_arr[0]] = $exp_arr[1];
}
//返回数组 eg: [id-fa_goods_deal==goods_id,id-fa_goods_deal==goods_id]
$rel_table_arr = Tools::delete_str_empty_ele('id-fa_hdrquestionnaireanswer==id,,,,,,,,');
//关联的字段和表
$rel_field_table_arr2 = [];
//关系
foreach ($rel_table_arr as $rel_str) {
$exp_arr = explode('-',$rel_str);
$rel_field_table_arr2[$exp_arr[0]] = [explode('==',$exp_arr[1])[0],explode('==',$exp_arr[1])[1]];
}
foreach($item as $it_key=>$it_val){
if(empty($rel_field_table_arr2[$it_key])){
continue;
}
foreach($return_type_exp_arr as $key=>$val){
$val_arr = explode('==',$val);
if($it_key == $val_arr[0]){
switch($val_arr[1]){
case 'two_arr':
$item[$it_key.'_data'] = Db::table($rel_field_table_arr2[$it_key][0])->where("{$rel_field_table_arr2[$it_key][1]}",$it_val)->select();
break;
case 'one_arr':
$item[$it_key.'_data'] = Db::table($rel_field_table_arr2[$it_key][0])->where("{$rel_field_table_arr2[$it_key][1]}",$it_val)->find();
break;
case 'field_val':
$item[$it_key.'_data'] = Db::table($rel_field_table_arr2[$it_key][0])->where("{$rel_field_table_arr2[$it_key][1]}",$it_val)->value("{$ret_field_name2[$it_key][1]}");
break;
}
}
}
}
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,'操作异常',[]));
}
}

View File

@@ -88,8 +88,24 @@ dump($requestUrl);
// 运行事件循环
$loop->run();
}
function stringToColor($string) {
// 使用crc32函数计算字符串的哈希值
$hash = crc32($string);
// 将整数哈希值转换为16进制并填充0以确保6位长度
$color = sprintf("%06X", $hash & 0xFFFFFF);
// 返回颜色码
return '#' . $color;
}
function test()
{
// 使用示例
$color = $this->stringToColor("example string");
echo $color; // 输出颜色码
die;
// 配置您的讯飞应用信息
$appId = 'd482af59';
$apiKey = '0d20dab630904ad8676d9075375a1914';