35 lines
897 B
TypeScript
35 lines
897 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import type { ActorContext } from '../common/actor-context.js';
|
|
import { UsersService } from '../users/users.service.js';
|
|
import { RegisterUserDto } from '../users/dto/register-user.dto.js';
|
|
import { LoginDto } from '../users/dto/login.dto.js';
|
|
|
|
/**
|
|
* 认证服务:将控制层输入转发到用户域能力,避免控制器直接操作用户仓储。
|
|
*/
|
|
@Injectable()
|
|
export class AuthService {
|
|
constructor(private readonly usersService: UsersService) {}
|
|
|
|
/**
|
|
* 注册能力委托给用户服务。
|
|
*/
|
|
register(dto: RegisterUserDto) {
|
|
return this.usersService.register(dto);
|
|
}
|
|
|
|
/**
|
|
* 登录能力委托给用户服务。
|
|
*/
|
|
login(dto: LoginDto) {
|
|
return this.usersService.login(dto);
|
|
}
|
|
|
|
/**
|
|
* 读取当前登录用户详情。
|
|
*/
|
|
me(actor: ActorContext) {
|
|
return this.usersService.me(actor);
|
|
}
|
|
}
|