init: 项目初始代码
This commit is contained in:
49
app/api/model/Role.php
Normal file
49
app/api/model/Role.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace app\api\model;
|
||||
|
||||
/**
|
||||
* 角色类
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class Role extends BaseModel
|
||||
{
|
||||
|
||||
protected $schema = [
|
||||
'id' => 'int',
|
||||
'name' => 'string',
|
||||
'desc' => 'string',
|
||||
'create_time' => 'int',
|
||||
'update_time' => 'int',
|
||||
];
|
||||
|
||||
|
||||
protected $disuse = [
|
||||
'desc'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 角色菜单关联
|
||||
* @return \think\model\relation\HasMany
|
||||
*/
|
||||
public function RoleToMenu()
|
||||
{
|
||||
return $this->hasMany(RoleToMenu::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详情
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getInfo(array $data):array
|
||||
{
|
||||
$result = $this->find($data['role_id']);
|
||||
return $result ? $result->toArray() : [];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user