perf: 授权管理支持模糊查询

alert-autofix-31
xiaojunnuo 2025-07-28 23:36:10 +08:00
parent 86b3df1941
commit 866eb6241b
2 changed files with 7 additions and 2 deletions

View File

@ -57,7 +57,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
show: false, show: false,
}, },
search: { search: {
show: false, show: true,
}, },
form: { form: {
wrapper: { wrapper: {

View File

@ -23,8 +23,13 @@ export class AccessController extends CrudController<AccessService> {
async page(@Body(ALL) body) { async page(@Body(ALL) body) {
body.query = body.query ?? {}; body.query = body.query ?? {};
delete body.query.userId; delete body.query.userId;
body.query.userId = this.getUserId()
let name = body.query?.name;
delete body.query.name;
const buildQuery = qb => { const buildQuery = qb => {
qb.andWhere('user_id = :userId', { userId: this.getUserId() }); if (name) {
qb.andWhere('name like :name', { name: `%${name.trim()}%` });
}
}; };
const res = await this.service.page({ const res = await this.service.page({
query: body.query, query: body.query,