Skip to content

Commit

Permalink
Merge pull request #4 from macowners/schema
Browse files Browse the repository at this point in the history
Schema
  • Loading branch information
wlstmd authored Sep 6, 2023
2 parents 1490dc1 + 50a8bcb commit e9feea8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
8 changes: 5 additions & 3 deletions src/sign/sign.controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Body, Controller, Delete, Post, UseGuards } from '@nestjs/common'
import { Body, Controller, Delete, Post, UploadedFile, UseGuards, UseInterceptors } from '@nestjs/common'
import { UserDto } from '../dto/user.dto'
import { SignService } from './sign.service'
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiSecurity, ApiTags } from '@nestjs/swagger'
import { JwtAuthGuard } from '../guard/AuthGuard'
import { FileInterceptor } from '@nestjs/platform-express'

@ApiBearerAuth()
@ApiSecurity('basic')
Expand All @@ -20,10 +21,11 @@ export class SignController {
status: 401,
description: '서버 에러',
})
@UseInterceptors(FileInterceptor('file'))
@ApiOperation({ summary: '회원가입' })
@Post('up')
signUp(@Body() body: UserDto) {
return this.signService.sign_up({ ...body, img: 'default.jpg', score: 100 })
signUp(@UploadedFile() file: Array<Express.Multer.File>, @Body() body: UserDto) {
return this.signService.sign_up({ ...body, img: 'default.jpg', score: 100, group: [] })
}

@ApiResponse({
Expand Down
13 changes: 9 additions & 4 deletions src/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ export class UserController {
return this.userService.profile(_id, JSON.parse(JSON.stringify(file)).filename)
}

@ApiOperation({ summary: '분배기능' })
@Post('calculate-study-schedule')
calculateStudySchedule(@Body('courseCount') courseCount: number, @Body('pageCount') pageCount: number, @Body('remainingDays') remainingDays: number) {
return this.userService.calculateStudySchedule(courseCount, pageCount, remainingDays)
@ApiOperation({ summary: '분배기능-문제집' })
@Post('calculate-study-schedule-P')
calculateStudySchedule_P(@Body('pageCount') pageCount: number, @Body('remainingDays') remainingDays: number) {
return this.userService.calculateStudySchedule_P(pageCount, remainingDays)
}
@ApiOperation({ summary: '분배기능-강의' })
@Post('calculate-study-schedule-S')
calculateStudySchedule_S(@Body('courseCount') courseCount: number, @Body('remainingDays') remainingDays: number) {
return this.userService.calculateStudySchedule_S(courseCount, remainingDays)
}
}
12 changes: 9 additions & 3 deletions src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ export class UserService {
return this.userModel.findByIdAndUpdate(_id, { img }).exec()
}

calculateStudySchedule(courseCount: number, pageCount: number, remainingDays: number) {
const daysPerCourse = Math.ceil(courseCount / remainingDays) // 남은 일 수로 강의를 분배
calculateStudySchedule_P(pageCount: number, remainingDays: number) {
const daysPerPage = Math.ceil(pageCount / remainingDays) // 남은 일 수로 페이지를 분배

return {
daysPerCourse,
daysPerPage,
}
}

calculateStudySchedule_S(courseCount: number, remainingDays: number) {
const daysPerCourse = Math.ceil(courseCount / remainingDays) // 남은 일 수로 강의를 분배

return {
daysPerCourse,
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e9feea8

Please sign in to comment.