Compare commits

..

No commits in common. "9d23757f45ac6cf5fbc387ca2f2499eadef9f479" and "e67711c2fe35bb5c57fd04c0615882c22965d116" have entirely different histories.

6 changed files with 8 additions and 11 deletions

View File

@ -90,7 +90,6 @@ export class PostEntity extends BaseEntity {
@OneToMany(() => CommentEntity, (comment) => comment.post, { cascade: true })
comments: Relation<CommentEntity>[];
@Expose()
@ManyToOne(() => UserEntity, (user) => user.posts, {
nullable: false,
onDelete: 'CASCADE',

View File

@ -1,6 +1,6 @@
import { join } from 'path';
import { Injectable, OnModuleInit } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { ModuleRef } from '@nestjs/core';
import { DataSource, DataSourceOptions } from 'typeorm';
@ -11,7 +11,7 @@ import { TypeormMigrationRun } from '@/modules/database/commands/typeorm.migrati
import { DBOptions } from '@/modules/database/types';
@Injectable()
export class AutoMigrateResolver implements OnModuleInit {
export class AutoMigrateResolver {
constructor(private ref: ModuleRef) {}
async onModuleInit() {

View File

@ -1,5 +1,4 @@
import type { Relation } from 'typeorm';
import { Entity, ManyToOne, OneToOne } from 'typeorm';
import { Entity, ManyToOne, OneToOne, Relation } from 'typeorm';
import { BaseToken } from '@/modules/user/entities/base.token';
import { RefreshTokenEntity } from '@/modules/user/entities/refresh.token.entity';

View File

@ -1,5 +1,4 @@
import type { Relation } from 'typeorm';
import { Entity, JoinColumn, OneToOne } from 'typeorm';
import { Entity, JoinColumn, OneToOne, Relation } from 'typeorm';
import { AccessTokenEntity } from '@/modules/user/entities/access.token.entity';
import { BaseToken } from '@/modules/user/entities/base.token';

View File

@ -1,5 +1,4 @@
import { Exclude, Expose, Type } from 'class-transformer';
import type { Relation } from 'typeorm';
import {
Column,
CreateDateColumn,
@ -7,6 +6,7 @@ import {
Entity,
OneToMany,
PrimaryColumn,
Relation,
UpdateDateColumn,
} from 'typeorm';
@ -50,7 +50,7 @@ export class UserEntity {
*
*/
@Expose()
@Column({ comment: '用户手机号', length: 64, nullable: true, unique: true })
@Column({ comment: '用户手机号', length: 64, nullable: false, unique: true })
phone?: string;
/**

View File

@ -1,6 +1,6 @@
import { BadGatewayException, ExecutionContext, Injectable } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { plainToInstance } from 'class-transformer';
import { plainToClass } from 'class-transformer';
import { validateOrReject } from 'class-validator';
@ -14,7 +14,7 @@ export class LocalAuthGuard extends AuthGuard('local') {
async canActivate(context: ExecutionContext): Promise<boolean> {
const request = context.switchToHttp().getRequest();
try {
await validateOrReject(plainToInstance(CredentialDto, request.body), {
await validateOrReject(plainToClass(CredentialDto, request.body), {
validationError: { target: false },
});
} catch (error) {