新增修改用户配置,获取用户配置接口
This commit is contained in:
parent
668b95a229
commit
e41253d65d
@ -189,4 +189,31 @@ class UserController extends AbstractController
|
||||
$data = $UserService->getLocation();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户配置
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getUserSystem(): ResponseInterface
|
||||
{
|
||||
$UserService = new UserService();
|
||||
$data = $UserService->getUserSystem();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户配置
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function putUserSystem(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(UserRequest::class);
|
||||
$request->scene('putUserSystem')->validateResolved();
|
||||
|
||||
$UserService = new UserService();
|
||||
$data = $UserService->putUserSystem();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
98
app/Model/UserSystem.php
Normal file
98
app/Model/UserSystem.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $user_system_id 主键id
|
||||
* @property int $user_id 用户id
|
||||
* @property int $is_accept_im_message_push 是否接受im消息推送(0:否 1:是)
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class UserSystem extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'user_system';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['user_system_id', 'user_id', 'is_accept_im_message_push', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "user_system_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据-多
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params = [], array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否存在
|
||||
* @param array $params
|
||||
* @return bool
|
||||
*/
|
||||
public static function getExists(array $params): bool
|
||||
{
|
||||
return self::where($params)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数量
|
||||
* @param array $params
|
||||
* @return int
|
||||
*/
|
||||
public static function getCount(array $params): int
|
||||
{
|
||||
return self::where($params)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return \Hyperf\Database\Model\Model|UserSystem
|
||||
*/
|
||||
public static function addUserSystem(array $data): \Hyperf\Database\Model\Model|UserSystem
|
||||
{
|
||||
return self::create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param array $params
|
||||
* @param array $data
|
||||
* @return int
|
||||
*/
|
||||
public static function edit(array $params = [], array $data = []): int
|
||||
{
|
||||
return self::where($params)->update($data);
|
||||
}
|
||||
|
||||
}
|
||||
@ -41,6 +41,9 @@ class UserRequest extends FormRequest
|
||||
'is_default',
|
||||
'tag',
|
||||
],
|
||||
'putUserSystem' => [ // 修改用户配置
|
||||
'is_accept_im_message_push',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
@ -59,7 +62,6 @@ class UserRequest extends FormRequest
|
||||
return [
|
||||
'avatar' => 'required|url',
|
||||
'user_name' => 'required',
|
||||
|
||||
'province_id' => 'required_with:city_id,county_id',
|
||||
'city_id' => 'required_with:county_id',
|
||||
'county_id' => 'required',
|
||||
@ -68,6 +70,7 @@ class UserRequest extends FormRequest
|
||||
'consignee_tel' => 'required',
|
||||
'is_default' => ['required','numeric','min:0','max:1'],
|
||||
'tag' => ['sometimes','required','numeric','min:1','max:4'],
|
||||
'is_accept_im_message_push' => ['required','numeric','min:0','max:1'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -95,6 +98,10 @@ class UserRequest extends FormRequest
|
||||
'tag.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'tag.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'tag.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_accept_im_message_push.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_accept_im_message_push.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_accept_im_message_push.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_accept_im_message_push.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,86 +124,6 @@ class OrderPrescriptionService extends BaseService
|
||||
return OrderPrescription::getCount($params);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 开具处方
|
||||
// * 医生-正常开具
|
||||
// * 药师-先开具药师处方,再开具医院签章
|
||||
// * @param string $order_prescription_id 处方id
|
||||
// * @param string $user_id 用户id
|
||||
// * @return array
|
||||
// */
|
||||
// public function openPrescription1(string $order_prescription_id, string $user_id): array
|
||||
// {
|
||||
// try {
|
||||
// // 获取用户数据
|
||||
// $params = array();
|
||||
// $params['user_id'] = $user_id;
|
||||
// $user = User::getOne($params);
|
||||
// if (empty($user)) {
|
||||
// throw new BusinessException("用户数据错误");
|
||||
// }
|
||||
//
|
||||
// if ($user['user_type'] != 2 && $user['user_type'] != 3) {
|
||||
// throw new BusinessException("用户类型错误");
|
||||
// }
|
||||
//
|
||||
// // 获取处方数据
|
||||
// $params = array();
|
||||
// $params['order_prescription_id'] = $order_prescription_id;
|
||||
// $order_prescription = OrderPrescription::getOne($params);
|
||||
// if (empty($order_prescription)) {
|
||||
// throw new BusinessException("处方数据错误");
|
||||
// }
|
||||
//
|
||||
// if (empty($order_prescription['doctor_created_time'])) {
|
||||
// throw new BusinessException("医生开方日期错误");
|
||||
// }
|
||||
//
|
||||
// $CaService = new CaService($order_prescription,$user);
|
||||
//
|
||||
// // 获取云证书签名+验证云证书签名
|
||||
// $CaService->getVerifyCertSign($order_prescription,1);
|
||||
//
|
||||
// // 医生
|
||||
// if ($user['user_type'] == 2) {
|
||||
// // 生成处方图片+处方图片生成pdf
|
||||
// $prescription_img_oss_path = $CaService->createPrescriptionImgPdf($order_prescription);
|
||||
// }
|
||||
//
|
||||
// // 药师-医院签章
|
||||
// if ($user['user_type'] == 3) {
|
||||
// // 获取医院云证书签名+验证云证书签名
|
||||
// $CaService->getVerifyCertSign($order_prescription,2);
|
||||
//
|
||||
// // 下载医生开具的处方pdf至本地
|
||||
// $CaService->downOssPdfToLocal();
|
||||
// }
|
||||
//
|
||||
// // 进行处方pdf签章
|
||||
// $file_id = $CaService->addSignPdf($user['user_type']);
|
||||
//
|
||||
// // 药师-医院签章
|
||||
// if ($user['user_type'] == 3) {
|
||||
// // 药师端时,需要进行系统签章
|
||||
// // 把药师签章的pdf存储至本地文件
|
||||
// // 下载药师签章pdf图片
|
||||
// dump($file_id);
|
||||
// $CaService->downCaPdfToLocal($file_id,1);
|
||||
//
|
||||
// // 进行处方pdf签章
|
||||
// $file_id = $CaService->addSignPdf($user['user_type']);
|
||||
// }
|
||||
//
|
||||
// $result = array();
|
||||
// $result['prescription_img_oss_path'] = $prescription_img_oss_path ?? "";
|
||||
// $result['file_id'] = $file_id;
|
||||
// return $result;
|
||||
//
|
||||
// } catch (\Throwable $e) {
|
||||
// throw new BusinessException($e->getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 开具处方
|
||||
* 医生-正常开具
|
||||
|
||||
@ -13,6 +13,7 @@ use App\Model\UserDoctorInfo;
|
||||
use App\Model\UserLocation;
|
||||
use App\Model\UserPatient;
|
||||
use App\Model\UserShipAddress;
|
||||
use App\Model\UserSystem;
|
||||
use App\Utils\Mask;
|
||||
use App\Utils\PcreMatch;
|
||||
use Extend\Tencent\map\Location;
|
||||
@ -686,6 +687,75 @@ class UserService extends BaseService
|
||||
return success($area);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户配置
|
||||
* @return array
|
||||
*/
|
||||
public function getUserSystem(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
// 定义返回数据
|
||||
$result = array(
|
||||
"is_accept_im_message_push" => 0,
|
||||
);
|
||||
|
||||
// 获取用户配置数据
|
||||
$params = array();
|
||||
$params['user_id'] = $user_info['user_id'];
|
||||
$user_system = UserSystem::getOne($params);
|
||||
if (empty($user_system)){
|
||||
return success($result);
|
||||
}
|
||||
|
||||
$result['is_accept_im_message_push'] = 0;
|
||||
return success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户配置
|
||||
* @return array
|
||||
*/
|
||||
public function putUserSystem(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
$request_params = $this->request->all();
|
||||
|
||||
// 获取用户配置数据
|
||||
$params = array();
|
||||
$params['user_id'] = $user_info['user_id'];
|
||||
$user_system = UserSystem::getOne($params);
|
||||
if (empty($user_system)){
|
||||
// 新增
|
||||
$data = array();
|
||||
$data['user_id'] = $user_info['user_id'];
|
||||
$data['is_accept_im_message_push'] = $request_params['is_accept_im_message_push'];
|
||||
$user_system = UserSystem::addUserSystem($data);
|
||||
if (empty($user_system)){
|
||||
return fail();
|
||||
}
|
||||
}else{
|
||||
// 修改
|
||||
$data = array();
|
||||
|
||||
if ($user_system['is_accept_im_message_push'] != $request_params['is_accept_im_message_push']){
|
||||
$data['is_accept_im_message_push'] = $request_params['is_accept_im_message_push'];
|
||||
}
|
||||
|
||||
if (!empty($data)){
|
||||
$params = array();
|
||||
$params['user_system_id'] = $user_system['user_system_id'];
|
||||
|
||||
$res = UserSystem::edit($params,$data);
|
||||
if (!$res){
|
||||
return fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
return success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过user_id获取用户openid
|
||||
* @param string|int $user_id
|
||||
|
||||
@ -696,6 +696,12 @@ Router::addGroup('/user', function () {
|
||||
|
||||
// 获取用户地址
|
||||
Router::get('/location', [UserController::class, 'getLocation']);
|
||||
|
||||
// 获取用户配置
|
||||
Router::get('/system', [UserController::class, 'getUserSystem']);
|
||||
|
||||
// 修改用户配置
|
||||
Router::put('/system', [UserController::class, 'putUserSystem']);
|
||||
});
|
||||
|
||||
// 获取患者问诊病例
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user