refactor:替换自增id为cuid
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 },
|
||||
});
|
||||
|
||||
@@ -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[];
|
||||
}
|
||||
|
||||
@@ -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[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user