106 lines
2.2 KiB
TypeScript
106 lines
2.2 KiB
TypeScript
import {
|
|
Controller,
|
|
Post,
|
|
Body,
|
|
Query,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { Public } from '../../../auth/decorators/public.decorator';
|
|
import { RegisterApiService } from '../../services/api/RegisterApiService';
|
|
|
|
@Controller('api/login/register')
|
|
export class RegisterApiController {
|
|
constructor(private readonly registerApiService: RegisterApiService) {}
|
|
|
|
/**
|
|
* 用户注册
|
|
*/
|
|
@Post('user')
|
|
@Public()
|
|
async userRegister(@Body() data: {
|
|
username: string;
|
|
password: string;
|
|
confirm_password: string;
|
|
mobile?: string;
|
|
email?: string;
|
|
captcha?: string;
|
|
invite_code?: string;
|
|
}) {
|
|
return this.registerApiService.userRegister(data);
|
|
}
|
|
|
|
/**
|
|
* 手机号注册
|
|
*/
|
|
@Post('mobile')
|
|
@Public()
|
|
async mobileRegister(@Body() data: {
|
|
mobile: string;
|
|
password: string;
|
|
confirm_password: string;
|
|
sms_code: string;
|
|
invite_code?: string;
|
|
}) {
|
|
return this.registerApiService.mobileRegister(data);
|
|
}
|
|
|
|
/**
|
|
* 邮箱注册
|
|
*/
|
|
@Post('email')
|
|
@Public()
|
|
async emailRegister(@Body() data: {
|
|
email: string;
|
|
password: string;
|
|
confirm_password: string;
|
|
email_code: string;
|
|
invite_code?: string;
|
|
}) {
|
|
return this.registerApiService.emailRegister(data);
|
|
}
|
|
|
|
/**
|
|
* 第三方注册
|
|
*/
|
|
@Post('third-party')
|
|
@Public()
|
|
async thirdPartyRegister(@Body() data: {
|
|
third_party_type: string;
|
|
third_party_id: string;
|
|
username?: string;
|
|
mobile?: string;
|
|
email?: string;
|
|
invite_code?: string;
|
|
}) {
|
|
return this.registerApiService.thirdPartyRegister(data);
|
|
}
|
|
|
|
/**
|
|
* 检查用户名是否可用
|
|
*/
|
|
@Post('check-username')
|
|
@Public()
|
|
async checkUsername(@Body() data: { username: string }) {
|
|
return this.registerApiService.checkUsername(data.username);
|
|
}
|
|
|
|
/**
|
|
* 检查手机号是否可用
|
|
*/
|
|
@Post('check-mobile')
|
|
@Public()
|
|
async checkMobile(@Body() data: { mobile: string }) {
|
|
return this.registerApiService.checkMobile(data.mobile);
|
|
}
|
|
|
|
/**
|
|
* 检查邮箱是否可用
|
|
*/
|
|
@Post('check-email')
|
|
@Public()
|
|
async checkEmail(@Body() data: { email: string }) {
|
|
return this.registerApiService.checkEmail(data.email);
|
|
}
|
|
}
|
|
|