582f454a5a
- 将后端目录名从大写改为小写 (Controller->controller 等) - 将命名空间从 App\ 改为 app\ (符合 webman 官方规范) - 移除不必要的 bootstrap 目录 - 完善出差审批业务功能: - 添加删除草稿功能 - 添加审批操作功能(同意/拒绝) - 完善审批详情页,显示审批人和审批记录 - 前端优化: - 调整列表页行高 - 隐藏底部导航栏 - 仪表盘只显示3个快捷入口 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
93 lines
2.1 KiB
PHP
93 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace app\controller;
|
|
|
|
use app\model\User;
|
|
use Webman\Http\Request;
|
|
use Webman\Http\Response;
|
|
|
|
class UserController extends BaseController
|
|
{
|
|
/**
|
|
* 获取用户信息
|
|
*/
|
|
public function info(Request $request): Response
|
|
{
|
|
$userId = $this->getUserId($request);
|
|
$user = User::find($userId);
|
|
|
|
if (!$user) {
|
|
return $this->error('用户不存在');
|
|
}
|
|
|
|
return $this->success($user);
|
|
}
|
|
|
|
/**
|
|
* 获取用户菜单权限
|
|
*/
|
|
public function menu(Request $request): Response
|
|
{
|
|
// TODO: 根据用户权限返回菜单
|
|
return $this->success([
|
|
['id' => 1, 'name' => '首页', 'path' => '/dashboard'],
|
|
['id' => 2, 'name' => '出差审批', 'path' => '/business-trip'],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 获取用户可切换的公司列表
|
|
*/
|
|
public function companies(Request $request): Response
|
|
{
|
|
$userId = $this->getUserId($request);
|
|
|
|
// TODO: 从数据库获取用户关联的公司列表
|
|
return $this->success([
|
|
['id' => 1, 'name' => '公司A'],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 切换当前公司
|
|
*/
|
|
public function switchCompany(Request $request): Response
|
|
{
|
|
$companyId = $request->post('company_id');
|
|
|
|
// TODO: 更新用户当前公司
|
|
|
|
return $this->success();
|
|
}
|
|
|
|
/**
|
|
* 获取用户列表(用于选择审批人等)
|
|
*/
|
|
public function list(Request $request): Response
|
|
{
|
|
$userId = $this->getUserId($request);
|
|
$keyword = $request->get('keyword', '');
|
|
$page = (int) $request->get('page', 1);
|
|
$pageSize = (int) $request->get('page_size', 50);
|
|
|
|
$query = User::active();
|
|
|
|
if ($keyword) {
|
|
$query->search($keyword);
|
|
}
|
|
|
|
$total = $query->count();
|
|
$list = $query->orderBy('id')
|
|
->offset(($page - 1) * $pageSize)
|
|
->limit($pageSize)
|
|
->get();
|
|
|
|
return $this->success([
|
|
'list' => $list,
|
|
'total' => $total,
|
|
'page' => $page,
|
|
'page_size' => $pageSize,
|
|
]);
|
|
}
|
|
}
|