31 lines
951 B
TypeScript
31 lines
951 B
TypeScript
import { Controller, Post, Body, Param } from '@nestjs/common';
|
|
import { AuthService } from './auth.service';
|
|
import { AuthDto } from './dto/auth.dto';
|
|
import { SkipAuth } from '@/common/decorators/skip-auth.decorator';
|
|
import { UserRoleDto } from './dto/user-role.dto';
|
|
import { RolePermissionDto } from './dto/role-permission.dto';
|
|
|
|
@Controller()
|
|
export class AuthController {
|
|
constructor(private readonly authService: AuthService) {}
|
|
|
|
// 用户登录
|
|
@Post('login')
|
|
@SkipAuth()
|
|
signIn(@Body() authDto: AuthDto) {
|
|
return this.authService.signIn(authDto);
|
|
}
|
|
|
|
// 授权用户角色
|
|
@Post('userRole/:id')
|
|
grantUserRole(@Param('id') id: string, @Body() dto: UserRoleDto) {
|
|
return this.authService.grantUserRole(+id, dto);
|
|
}
|
|
|
|
// 授权角色权限
|
|
@Post('rolePermission/:id')
|
|
grantRolePermission(@Param('id') id: string, @Body() dto: RolePermissionDto) {
|
|
return this.authService.grantRolePermission(+id, dto);
|
|
}
|
|
}
|