perf: 优化类型问题
This commit is contained in:
@@ -138,9 +138,7 @@ export class AuthService {
|
||||
);
|
||||
|
||||
if (existing) {
|
||||
this.logger.warn(
|
||||
`用户 ${userId} 已完成关卡 ${dto.levelId},不重复奖励`,
|
||||
);
|
||||
this.logger.warn(`用户 ${userId} 已完成关卡 ${dto.levelId},不重复奖励`);
|
||||
return { points: user.points };
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { IsIn, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class UserAssetsResponseDto {
|
||||
@ApiProperty({ description: '积分' })
|
||||
points: number;
|
||||
points!: number;
|
||||
}
|
||||
|
||||
export class ConsumePointRequestDto {
|
||||
@@ -11,7 +11,7 @@ export class ConsumePointRequestDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsIn(['hint_unlock'])
|
||||
reason: 'hint_unlock';
|
||||
reason!: 'hint_unlock';
|
||||
|
||||
@ApiProperty({ description: '关卡 ID', required: false })
|
||||
@IsString()
|
||||
@@ -28,21 +28,21 @@ export class EarnPointRequestDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsIn(['level_complete'])
|
||||
reason: 'level_complete';
|
||||
reason!: 'level_complete';
|
||||
|
||||
@ApiProperty({ description: '关卡 ID' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
levelId: string;
|
||||
levelId!: string;
|
||||
}
|
||||
|
||||
export class GameDataResponseDto {
|
||||
@ApiProperty({ description: '用户信息' })
|
||||
user: {
|
||||
user!: {
|
||||
id: string;
|
||||
points: number;
|
||||
};
|
||||
|
||||
@ApiProperty({ description: '已完成的关卡 ID 列表' })
|
||||
completedLevelIds: string[];
|
||||
completedLevelIds!: string[];
|
||||
}
|
||||
|
||||
@@ -5,24 +5,24 @@ export class WxLoginRequestDto {
|
||||
@ApiProperty({ description: '微信 wx.login 返回的 code' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
code: string;
|
||||
code!: string;
|
||||
}
|
||||
|
||||
export class UserInfoDto {
|
||||
@ApiProperty({ description: '用户 ID' })
|
||||
id: string;
|
||||
id!: string;
|
||||
|
||||
@ApiProperty({ description: '用户昵称', nullable: true })
|
||||
nickname: string | null;
|
||||
nickname!: string | null;
|
||||
|
||||
@ApiProperty({ description: '积分' })
|
||||
points: number;
|
||||
points!: number;
|
||||
}
|
||||
|
||||
export class WxLoginResponseDto {
|
||||
@ApiProperty({ description: 'JWT 访问令牌' })
|
||||
token: string;
|
||||
token!: string;
|
||||
|
||||
@ApiProperty({ description: '用户信息' })
|
||||
user: UserInfoDto;
|
||||
user!: UserInfoDto;
|
||||
}
|
||||
|
||||
@@ -13,18 +13,18 @@ import { User } from './user.entity';
|
||||
@Index('idx_user_level', ['userId', 'levelId'], { unique: true })
|
||||
export class UserLevelProgress {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
id!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 191, name: 'user_id' })
|
||||
userId: string;
|
||||
userId!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 191, name: 'level_id' })
|
||||
levelId: string;
|
||||
levelId!: string;
|
||||
|
||||
@ManyToOne(() => User)
|
||||
@JoinColumn({ name: 'user_id' })
|
||||
user: User;
|
||||
user!: User;
|
||||
|
||||
@CreateDateColumn({ name: 'completed_at' })
|
||||
completedAt: Date;
|
||||
completedAt!: Date;
|
||||
}
|
||||
|
||||
@@ -10,28 +10,28 @@ import {
|
||||
@Entity('wx_users')
|
||||
export class User {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
id!: string;
|
||||
|
||||
@Index('idx_user_openid', { unique: true })
|
||||
@Column({ type: 'varchar', length: 128 })
|
||||
openid: string;
|
||||
openid!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 255, name: 'session_key', nullable: true })
|
||||
sessionKey: string | null;
|
||||
sessionKey!: string | null;
|
||||
|
||||
@Column({ type: 'varchar', length: 100, nullable: true })
|
||||
nickname: string | null;
|
||||
nickname!: string | null;
|
||||
|
||||
@Column({ type: 'text', name: 'avatar_url', nullable: true })
|
||||
avatarUrl: string | null;
|
||||
avatarUrl!: string | null;
|
||||
|
||||
/** 积分(默认 10) */
|
||||
@Column({ type: 'int', default: 10 })
|
||||
points: number;
|
||||
points!: number;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
createdAt!: Date;
|
||||
|
||||
@UpdateDateColumn({ name: 'updated_at' })
|
||||
updatedAt: Date;
|
||||
updatedAt!: Date;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import { UserLevelProgress } from '../entities/user-level-progress.entity';
|
||||
import { IUserLevelProgressRepository } from './user-level-progress.repository.interface';
|
||||
|
||||
@Injectable()
|
||||
export class UserLevelProgressRepository
|
||||
implements IUserLevelProgressRepository
|
||||
{
|
||||
export class UserLevelProgressRepository implements IUserLevelProgressRepository {
|
||||
constructor(
|
||||
@InjectRepository(UserLevelProgress)
|
||||
private readonly repository: Repository<UserLevelProgress>,
|
||||
|
||||
Reference in New Issue
Block a user