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

128 lines
3.7 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\Mmodel;
use wanghua\general_utility_tools_php\tool\Tools;
use think\Controller;
class Gulianguser extends BaseHttpApi
{
protected $controller_comments = '估量-用户';
/**
* 新增估量-用户
*
* 参数:
* name 姓名 【必须】
* phone 手机号 【必须】
* api/Gulianguser/addGulianguser
*/
function addGulianguser(){
Tools::log_to_write_txt(['新增估量-用户'=>input()]);
$api_desc = '新增估量-用户';
Db::startTrans();
try {
$name = input('name');
if(empty($name)){
return json(Tools::set_fail('参数错误.0',['error_msg'=>'错误信息name错误']));
}
$phone = input('phone');
if(empty($phone)){
return json(Tools::set_fail('参数错误.1',['error_msg'=>'错误信息phone错误']));
}
$data = [
'name'=>$name?:'',
'phone'=>$phone?:'',
];
$dataid = Mmodel::existsUpdateInsert(TabConf::$fa_gulianguser,['phone'=>$phone],$data);
//$dataid = Db::table(TabConf::$fa_gulianguser)->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/Gulianguser/getGulianguserList
*
* 参数:
* name 姓名
* phone 手机号
*
* 所有字段说明<span style="color: gray">(可能有部分额外字段未在此体现)</span>
* id ID
* name 姓名
* phone 手机号
* authorwh
*/
function getGulianguserList(){
Tools::log_to_write_txt(['获取估量-用户 入参:'=>input()]);
$api_desc = '获取估量-用户';
try {
$name = input('name');
$phone = input('phone');
$model_obj = Db::table(TabConf::$fa_gulianguser);
if(input('name')){
$model_obj->where('name',input('name'));
}
if(input('phone')){
$model_obj->where('phone',input('phone'));
}
//$model_obj->field('name,phone');
$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,'操作异常',[]));
}
}
}