2025-04-10 21:52:11 +08:00

84 lines
2.4 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
// +----------------------------------------------------------------------
// | Library for ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
// +----------------------------------------------------------------------
// | 官方网站: https://thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// | 免费声明 ( https://thinkadmin.top/disclaimer )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/zoujingli/ThinkLibrary
// | github 仓库地址 https://github.com/zoujingli/ThinkLibrary
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace think\admin\model;
use think\admin\Model;
/**
* 用户权限模型
*
* @property int $id
* @property int $sort 排序权重
* @property int $status 权限状态(1使用,0禁用)
* @property string $create_at 创建时间
* @property string $desc 备注说明
* @property string $title 权限名称
* @property string $utype 身份权限
* @class SystemAuth
* @package think\admin\model
*/
class SystemAuth extends Model
{
protected $createTime = 'create_at';
protected $updateTime = false;
/**
* 日志名称
* @var string
*/
protected $oplogName = '系统权限';
/**
* 日志类型
* @var string
*/
protected $oplogType = '系统权限管理';
/**
* 获取权限数据
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function items(): array
{
return static::mk()->where(['status' => 1])->order('sort desc,id desc')->select()->toArray();
}
/**
* 删除权限事件
* @param string $ids
*/
public function onAdminDelete(string $ids)
{
if (count($aids = str2arr($ids)) > 0) SystemNode::mk()->whereIn('auth', $aids)->delete();
sysoplog($this->oplogType, lang("删除%s[%s]及授权配置", [lang($this->oplogName), $ids]));
}
/**
* 格式化创建时间
* @param mixed $value
* @return string
*/
public function getCreateAtAttr($value): string
{
return format_datetime($value);
}
}