init: 项目初始代码

This commit is contained in:
2026-10-14 14:00:29 +08:00
commit cc434cf89f
464 changed files with 66984 additions and 0 deletions

97
app/api/model/User.php Normal file
View File

@@ -0,0 +1,97 @@
<?php
declare (strict_types = 1);
namespace app\api\model;
/**
* 用户中心缓存表
* @mixin \think\Model
*/
class User extends BaseModel
{
protected $schema = [
'id' => 'int',
'uc_id' => 'int',
'admin_id' => 'int',
'role_id' => 'int',
'org_id' => 'int',
'dept_id' => 'int',
'staff_code' => 'string',
'nickname' => 'string',
'mobile' => 'string',
'email' => 'string',
'avatar' => 'string',
'gender' => 'int',
'create_time' => 'int',
'update_time' => 'int',
'signin_time' => 'int',
'signin_ip' => 'string',
'status' => 'int',
];
/**
* 获取详情
* @param array $data
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getInfo($data) : array
{
if (isset($data['admin_id'])) {
$result = $this->where('uc_id',$data['admin_id'])->find();
return $result ? $result->toArray() : [];
}
if (isset($data['uc_id'])) {
$result = $this->where('uc_id',$data['uc_id'])->find();
return $result ? $result->toArray() : [];
}
return [];
}
/**
* 通过角色ID,摘取对应菜单ID
* @param array $data
* @return array
*/
public function getMenuList(array $data):array
{
return $this->getMenuListUserCode($data['staff_code']);
}
/**
* 获取角色名称
* @param $roleId
* @return array|\think\Model|null
*/
public function getRolesName($roleId):string
{
$result = $this->getRoleDetailId($roleId);
return $result['role_name'] ?? '';
}
/**
* 查找菜单列表
* @param $arr
* @return array
*/
public function getMenuSiderList($arr):array
{
$result = $this->getMenuListApp();
if(!empty($result)) {
$newData = [];
foreach ($result as $datum) {
if (in_array($datum['id'],$arr)) {
array_push($newData,$datum);
}
}
return $newData;
} else {
return [];
}
}
}