-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from depromeet/feature/reward-issue47
리워드 시스템 추가
- Loading branch information
Showing
10 changed files
with
219 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { Expose } from 'class-transformer'; | ||
|
||
export class SendLightningSuccessDtoResDto { | ||
constructor(sendLightningSuccess: boolean) { | ||
this.sendLightningSuccess = sendLightningSuccess; | ||
} | ||
@ApiProperty({ | ||
type: Boolean, | ||
default: false, | ||
description: '번개보낸 성공여부', | ||
}) | ||
@Expose() | ||
sendLightningSuccess: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Prop, Schema, SchemaFactory, SchemaOptions } from '@nestjs/mongoose'; | ||
|
||
import { Exclude, Expose, Transform, Type } from 'class-transformer'; | ||
import { Types } from 'mongoose'; | ||
|
||
const options: SchemaOptions = { | ||
collection: 'lightning', | ||
timestamps: true, | ||
}; | ||
|
||
@Schema(options) | ||
export class Lightning { | ||
@Prop({ type: Types.ObjectId }) | ||
sendUser: Types.ObjectId; | ||
|
||
@Prop({ type: Types.ObjectId }) | ||
receiveUser: Types.ObjectId; | ||
|
||
@Prop({ | ||
type: Date, | ||
expires: 0, | ||
}) | ||
@Expose() | ||
expireAt: Date; | ||
} | ||
|
||
export const LightningSchema = SchemaFactory.createForClass(Lightning); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { InjectModel } from '@nestjs/mongoose'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { Model } from 'mongoose'; | ||
import { UserIdDto } from 'src/common/dtos/UserId.dto'; | ||
import { Lightning } from 'src/models/lightning.model'; | ||
|
||
@Injectable() | ||
export class LightningRepository { | ||
constructor( | ||
@InjectModel(Lightning.name) | ||
private readonly LightningModel: Model<Lightning>, | ||
) {} | ||
|
||
async saveLighting( | ||
senderIdDto: UserIdDto, | ||
receiveIdDto: UserIdDto, | ||
expireAtDate: Date, | ||
): Promise<Lightning> { | ||
const lightning = new this.LightningModel({ | ||
sendUser: senderIdDto.userId, | ||
receiveUser: receiveIdDto.userId, | ||
expireAt: expireAtDate, | ||
}); | ||
return await lightning.save(); | ||
} | ||
|
||
async findOneLightningByUserId( | ||
senderIdDto: UserIdDto, | ||
receiveIdDto: UserIdDto, | ||
): Promise<Lightning | null> { | ||
return await this.LightningModel.findOne({ | ||
sendUser: senderIdDto.userId, | ||
receiveUser: receiveIdDto.userId, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters