first commit
This commit is contained in:
@@ -0,0 +1,220 @@
|
||||
<?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 Hdrquestionnaireanswer extends BaseHttpApi
|
||||
{
|
||||
protected $controller_comments = '科室问卷答案';
|
||||
|
||||
/**
|
||||
* desc:获取科室问卷答案
|
||||
*
|
||||
* api/Hdrquestionnaireanswer/getHdrquestionnaireanswerList
|
||||
*
|
||||
* 参数:
|
||||
* 带分页
|
||||
* current_page 当前页码
|
||||
* list_rows 每页显示条数 默认15
|
||||
* id ID
|
||||
* hdrquestionnairequestion_id 问卷问题ID
|
||||
* answer 问卷答案
|
||||
*
|
||||
* 所有字段说明<span style="color: gray">(可能有部分额外字段未在此体现)</span>:
|
||||
* id ID
|
||||
* hdrquestionnairequestion_id 问卷问题ID
|
||||
* answer 问卷答案
|
||||
* create_time 创建时间
|
||||
* update_time 更新时间
|
||||
|
||||
* author:wh
|
||||
*/
|
||||
function getHdrquestionnaireanswerList(){
|
||||
Tools::log_to_write_txt(['获取科室问卷答案 入参:'=>input()]);
|
||||
$api_desc = '获取科室问卷答案';
|
||||
try {
|
||||
|
||||
$id = input('id');
|
||||
$hdrquestionnairequestion_id = input('hdrquestionnairequestion_id');
|
||||
$answer = input('answer');
|
||||
|
||||
|
||||
$model_obj = Db::table(TabConf::$fa_hdrquestionnaireanswer);
|
||||
|
||||
if(input('id')){
|
||||
$model_obj->where('id',input('id'));
|
||||
}
|
||||
if(input('hdrquestionnairequestion_id')){
|
||||
$model_obj->where('hdrquestionnairequestion_id',input('hdrquestionnairequestion_id'));
|
||||
}
|
||||
if(input('answer')){
|
||||
$model_obj->where('answer',input('answer'));
|
||||
}
|
||||
|
||||
$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,'操作异常',[]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增一个问卷答案
|
||||
*
|
||||
* 参数:
|
||||
* hdrquestionnairequestion_id 问卷问题ID 问卷问题ID 必须
|
||||
* answer 问卷答案 问卷答案 必须
|
||||
* api/Hdrquestionnaireanswer/addHdrquestionnaireanswer
|
||||
*/
|
||||
function addHdrquestionnaireanswer(){
|
||||
Tools::log_to_write_txt(['新增一个问卷答案'=>input()]);
|
||||
$api_desc = '新增一个问卷答案';
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
$hdrquestionnairequestion_id = input('hdrquestionnairequestion_id');
|
||||
if(empty($hdrquestionnairequestion_id)){
|
||||
return json(Tools::set_fail('参数错误.0'));
|
||||
}
|
||||
|
||||
$answer = input('answer');
|
||||
if(empty($answer)){
|
||||
return json(Tools::set_fail('参数错误.1'));
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'hdrquestionnairequestion_id'=>$hdrquestionnairequestion_id?:'',
|
||||
'answer'=>$answer?:'',
|
||||
];
|
||||
|
||||
|
||||
$dataid = Db::table(TabConf::$fa_hdrquestionnaireanswer)->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 必须
|
||||
* hdrquestionnairequestion_id 问卷问题ID
|
||||
* answer 问卷答案
|
||||
* api/Hdrquestionnaireanswer/updateHdrquestionnaireanswer
|
||||
*/
|
||||
function updateHdrquestionnaireanswer(){
|
||||
Tools::log_to_write_txt(['修改科室问卷答案'=>input()]);
|
||||
|
||||
$api_desc = '修改科室问卷答案';
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
$hdrquestionnairequestion_id = input('hdrquestionnairequestion_id');
|
||||
$answer = input('answer');
|
||||
if(empty(input('id'))){
|
||||
return json(Tools::set_fail('参数错误。0'));
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'hdrquestionnairequestion_id'=>$hdrquestionnairequestion_id?:'',
|
||||
'answer'=>$answer?:'',
|
||||
];
|
||||
|
||||
|
||||
$dataid = Db::table(TabConf::$fa_hdrquestionnaireanswer)
|
||||
->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: 删除科室问卷答案
|
||||
* author:wh
|
||||
*
|
||||
* 参数:
|
||||
* id 数据id 必须
|
||||
* api/Hdrquestionnaireanswer/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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user