优化部分代码,增加微信公众号模板

This commit is contained in:
李琦
2026-08-13 19:01:21 +08:00
parent 21f39eed85
commit 2f5e298d6b
10 changed files with 83 additions and 41 deletions

View File

@@ -153,7 +153,10 @@ class RoleService extends BaseService
*/
public function delete($id): mixed
{
if (in_array($id, [1, 2])) {
// BaseController::delete 传入的是 ids 数组,直接 in_array($id,[1,2]) 会因「数组与标量比较恒 false」绕过保护
// 这里统一归一为数组后用 array_intersect 判断是否命中内置角色1超管 / 2默认
$ids = is_array($id) ? $id : [$id];
if (array_intersect(array_map('intval', $ids), [1, 2])) {
$this->utils->errorThrow('管理员角色禁止删除');
}
return $this->del($id);