refactor:替换自增id为cuid

This commit is contained in:
2024-11-27 15:25:57 +08:00
parent b02e2d2160
commit 5b382a124a
27 changed files with 161 additions and 114 deletions

View File

@@ -19,12 +19,12 @@ export class AuthController {
// 授权用户角色
@Post('userRole/:id')
grantUserRole(@Param('id') id: string, @Body() dto: UserRoleDto) {
return this.authService.grantUserRole(+id, dto);
return this.authService.grantUserRole(id, dto);
}
// 授权角色权限
@Post('rolePermission/:id')
grantRolePermission(@Param('id') id: string, @Body() dto: RolePermissionDto) {
return this.authService.grantRolePermission(+id, dto);
return this.authService.grantRolePermission(id, dto);
}
}

View File

@@ -62,7 +62,7 @@ export class AuthService {
return { accessToken };
}
async grantUserRole(id: number, { roleIds }: UserRoleDto) {
async grantUserRole(id: string, { roleIds }: UserRoleDto) {
const user = await this.prisma.sysUser.findUnique({
where: { id },
});
@@ -96,7 +96,7 @@ export class AuthService {
});
}
async grantRolePermission(id: number, { permissionIds }: RolePermissionDto) {
async grantRolePermission(id: string, { permissionIds }: RolePermissionDto) {
const role = await this.prisma.sysRole.findUnique({
where: { id },
});

View File

@@ -1,8 +1,8 @@
import { ArrayUnique, IsInt, IsNotEmpty } from 'class-validator';
import { ArrayUnique, IsNotEmpty, IsString } from 'class-validator';
export class RolePermissionDto {
@IsNotEmpty()
@IsInt({ each: true })
@IsString({ each: true })
@ArrayUnique()
permissionIds: number[];
permissionIds: string[];
}

View File

@@ -1,8 +1,8 @@
import { ArrayUnique, IsInt, IsNotEmpty } from 'class-validator';
import { ArrayUnique, IsNotEmpty, IsString } from 'class-validator';
export class UserRoleDto {
@IsNotEmpty()
@IsInt({ each: true })
@IsString({ each: true })
@ArrayUnique()
roleIds: number[];
roleIds: string[];
}