update P15

This commit is contained in:
2026-04-01 12:44:52 +08:00
parent 73309d7890
commit 7c83fa4664
4 changed files with 206 additions and 4 deletions
@@ -287,7 +287,7 @@ class DataScopeController extends AbstractController
? Company::query()->whereIn('id', $company_ids)->pluck('label', 'id')->toArray()
: [];
$platform_names = !empty($platform_ids)
? Platform::query()->whereIn('id', $platform_ids)->pluck('id', 'id')->toArray()
? Platform::query()->whereIn('id', $platform_ids)->pluck('name', 'id')->toArray()
: [];
$store_names = !empty($store_ids)
? Store::query()->whereIn('id', $store_ids)->pluck('label', 'id')->toArray()
@@ -297,7 +297,7 @@ class DataScopeController extends AbstractController
return array_map(function (array $scope) use ($company_names, $platform_names, $store_names): array {
$name = match ($scope['scope_type']) {
'company' => $company_names[$scope['scope_id']] ?? null,
'platform' => isset($platform_names[$scope['scope_id']]) ? "Platform #{$scope['scope_id']}" : null,
'platform' => $platform_names[$scope['scope_id']] ?? null,
'store' => $store_names[$scope['scope_id']] ?? null,
default => null,
};
@@ -22,12 +22,12 @@ class UserController extends AbstractController
/**
* 用户列表
*
* 支持分页、按 username/email 模糊搜索、按 status 精确筛选
* 支持分页、按 username/email 模糊搜索、按 status/role_id 精确筛选
*/
#[OA\Get(
path: '/users',
summary: '用户列表',
description: '获取用户列表,支持分页、按 username/email 模糊搜索、按 status 精确筛选',
description: '获取用户列表,支持分页、按 username/email 模糊搜索、按 status/role_id 精确筛选',
security: [['bearerAuth' => []]],
tags: ['Users'],
parameters: [
@@ -36,6 +36,7 @@ class UserController extends AbstractController
new OA\Parameter(name: 'username', in: 'query', required: false, description: '用户名模糊搜索', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'email', in: 'query', required: false, description: '邮箱模糊搜索', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'status', in: 'query', required: false, description: '状态筛选(0=禁用,1=启用)', schema: new OA\Schema(type: 'integer', enum: [0, 1])),
new OA\Parameter(name: 'role_id', in: 'query', required: false, description: '按角色筛选', schema: new OA\Schema(type: 'integer')),
],
responses: [
new OA\Response(
@@ -83,6 +84,12 @@ class UserController extends AbstractController
$query->where('status', (int) $status);
}
// 按 role_id 精确筛选
$role_id = $this->request->input('role_id');
if ($role_id !== null && $role_id !== '') {
$query->where('role_id', (int) $role_id);
}
// 按 created_at 降序排序
$query->orderBy('created_at', 'desc');