refactor: 重构配置模块
This commit is contained in:
@@ -32,7 +32,8 @@ export class ConfigService {
|
||||
await this.prisma.sysConfig.create({ data });
|
||||
}
|
||||
|
||||
async findAll({ page, pageSize }: QueryListDto): Promise<QueryListResult> {
|
||||
async findAll(dto: QueryListDto): Promise<QueryListResult> {
|
||||
const { page, pageSize, key, value } = dto;
|
||||
const query: Prisma.SysConfigFindManyArgs = {
|
||||
select: {
|
||||
key: true,
|
||||
@@ -41,6 +42,10 @@ export class ConfigService {
|
||||
},
|
||||
skip: pageSize * (page - 1),
|
||||
take: pageSize,
|
||||
where: {
|
||||
...(key && { key: { contains: key } }),
|
||||
...(value && { value: { contains: value } }),
|
||||
},
|
||||
};
|
||||
|
||||
const [list, count] = await this.prisma.$transaction([
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
import { PaginationDto } from 'src/common/dto/pagination.dto';
|
||||
import { IsOptional } from 'class-validator';
|
||||
|
||||
export class QueryListDto extends PaginationDto {}
|
||||
export class QueryListDto extends PaginationDto {
|
||||
@IsOptional()
|
||||
key?: string;
|
||||
|
||||
@IsOptional()
|
||||
value?: string;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
import { PaginationDto } from 'src/common/dto/pagination.dto';
|
||||
import { IsInt, IsOptional } from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
|
||||
export class QueryListDto extends PaginationDto {}
|
||||
export class QueryListDto extends PaginationDto {
|
||||
@IsOptional()
|
||||
code?: string;
|
||||
|
||||
@IsOptional()
|
||||
name?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
status?: number;
|
||||
}
|
||||
|
||||
@@ -25,15 +25,15 @@ export class RoleService {
|
||||
await this.prisma.sysRole.create({ data });
|
||||
}
|
||||
|
||||
async findPage({ page, pageSize }: QueryListDto): Promise<QueryListResult> {
|
||||
async findPage(dto: QueryListDto): Promise<QueryListResult> {
|
||||
const { page, pageSize, code, status, name } = dto;
|
||||
const query: Prisma.SysRoleFindManyArgs = {
|
||||
skip: pageSize * (page - 1),
|
||||
take: pageSize,
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
code: true,
|
||||
status: true,
|
||||
where: {
|
||||
...(code && { code: { contains: code } }),
|
||||
...(!isNaN(status) && { status }),
|
||||
...(name && { name: { contains: name } }),
|
||||
},
|
||||
};
|
||||
const [list, count] = await this.prisma.$transaction([
|
||||
|
||||
Reference in New Issue
Block a user