更新
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\logic\tcm;
|
||||
|
||||
use app\common\cache\AdminAuthCache;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\model\tcm\PrescriptionLibrary;
|
||||
@@ -33,12 +34,64 @@ class PrescriptionLibraryLogic extends BaseLogic
|
||||
return count(array_intersect($myRoles, $allowRoles)) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 是否具备消费者/诊间开方相关菜单权限(用于处方库列表鉴权别名)
|
||||
*/
|
||||
public static function hasPrescriptionOperatePermission(int $adminId): bool
|
||||
{
|
||||
$cache = new AdminAuthCache($adminId);
|
||||
$uris = $cache->getAdminUri() ?? [];
|
||||
$normalized = array_map(static fn ($item) => strtolower((string) $item), $uris);
|
||||
$allowed = [
|
||||
'tcm.prescription/lists',
|
||||
'tcm.prescription/add',
|
||||
'tcm.prescription/edit',
|
||||
'tcm.prescription/detail',
|
||||
'cf.prescription/lists',
|
||||
'cf.prescription/add',
|
||||
'cf.prescription/edit',
|
||||
'cf.prescription/read',
|
||||
'cf.prescription/del',
|
||||
'cf.prescription/audit',
|
||||
'wcf.prescription/lists',
|
||||
'wcf.prescription/read',
|
||||
'wcf.prescription/add',
|
||||
'wcf.prescription/edit',
|
||||
'wcf.prescription/delete',
|
||||
'tcm.prescriptionlibrary/lists',
|
||||
];
|
||||
|
||||
return count(array_intersect($allowed, $normalized)) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 开方页按医师 creator_id 拉取处方库:本人 / 超管角色 / 有开方菜单权限(医助代开方)
|
||||
*/
|
||||
public static function canListLibraryForCreator(int $adminId, array $adminInfo, int $targetCreatorId): bool
|
||||
{
|
||||
if ($targetCreatorId <= 0) {
|
||||
return false;
|
||||
}
|
||||
if ($targetCreatorId === $adminId) {
|
||||
return true;
|
||||
}
|
||||
if (self::canManageAllPrescriptions($adminId, $adminInfo)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return self::hasPrescriptionOperatePermission($adminId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加处方库
|
||||
*/
|
||||
public static function add(array $params): ?int
|
||||
{
|
||||
try {
|
||||
$params['formula_type'] = in_array($params['formula_type'] ?? '', ['主方', '辅方'], true)
|
||||
? $params['formula_type']
|
||||
: '主方';
|
||||
|
||||
// 处理药材数据
|
||||
if (isset($params['herbs']) && is_array($params['herbs'])) {
|
||||
$params['herbs'] = json_encode($params['herbs'], JSON_UNESCAPED_UNICODE);
|
||||
@@ -69,6 +122,12 @@ class PrescriptionLibraryLogic extends BaseLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($params['formula_type'])) {
|
||||
$params['formula_type'] = in_array($params['formula_type'], ['主方', '辅方'], true)
|
||||
? $params['formula_type']
|
||||
: '主方';
|
||||
}
|
||||
|
||||
// 处理药材数据
|
||||
if (isset($params['herbs']) && is_array($params['herbs'])) {
|
||||
$params['herbs'] = json_encode($params['herbs'], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
Reference in New Issue
Block a user