-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: 식물 카드 상세 조회 API #33
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
778517e
Docs: update PR template (add swagger)
jokj624 6ca3e37
Refactor: file name kebab-case 적용
jokj624 b93b261
Feat: plant util 함수
jokj624 c6c3918
Feat: plant 상세 조회 API
jokj624 e034566
Docs: update PR template (add checklist)
jokj624 ecb8328
Feat: plant 상세 조회 service 로직 unit test
jokj624 3859104
Feat: plant 상세 조회 controller unit test
jokj624 301a075
Fix: plants service 로직 time mocking
jokj624 9716720
Feat: env test 환경 설정
jokj624 8c08c6a
Feat: e2e test 격리된 docker 환경 구축
jokj624 3818ed6
Feat: plants e2e test
jokj624 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,13 +1,21 @@ | ||
## 📚 PR 요약 / Linked Issue | ||
해당 PR에서 작업한 내용을 한 줄로 요약해주세요. | ||
|
||
해당 PR에서 작업한 내용을 한 줄로 요약해주세요. | ||
close #{no} | ||
|
||
## 💡 변경 사항 | ||
|
||
디테일한 작업 내역을 적어주세요. | ||
주의할 사항이 있다면 적어주세요. | ||
변경사항 (모듈 설치 등)이 있다면 적어주세요. | ||
|
||
## ✅ PR check list | ||
- [ ] 커밋 컨벤션, 제목 등을 확인했나요? | ||
- [ ] 알맞은 라벨을 달았나요? | ||
- [ ] 셀프 코드리뷰를 작성했나요? | ||
## 📖 Swagger | ||
|
||
API Swagger 를 추가했다면 캡쳐해주세요. | ||
|
||
## ✅ PR check list | ||
|
||
- [ ] 테스트 코드를 작성했나요? (unit/e2e) | ||
- [ ] 커밋 컨벤션, 제목 등을 확인했나요? | ||
- [ ] 알맞은 라벨을 달았나요? | ||
- [ ] 셀프 코드리뷰를 작성했나요? |
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 |
---|---|---|
@@ -1,8 +1,17 @@ | ||
import { SIGNIN_DESCRIPTION } from './auth'; | ||
import { PLANT_INFORMATION, PLANT_WATER_LOG } from './plants'; | ||
import { | ||
READ_PLANT_DETAIL, | ||
READ_PLANT_INFORMATION, | ||
READ_PLANT_WATER_LOG, | ||
} from './plants'; | ||
|
||
export const ERROR_DESCRIPTION = { | ||
INTERNAL_SERVER_ERROR: 'Internal Server Error', | ||
}; | ||
|
||
export { SIGNIN_DESCRIPTION, PLANT_INFORMATION, PLANT_WATER_LOG }; | ||
export { | ||
SIGNIN_DESCRIPTION, | ||
READ_PLANT_DETAIL, | ||
READ_PLANT_INFORMATION, | ||
READ_PLANT_WATER_LOG, | ||
}; |
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,34 @@ | ||
export const PLANT_STATUS: Record< | ||
string, | ||
{ statusMessage: string; statusGague: number } | ||
> = { | ||
healthy: { | ||
statusMessage: '힘이 솟아요', | ||
statusGague: 1, | ||
}, | ||
waterDay: { | ||
statusMessage: '물 주는 날이에요!', | ||
statusGague: 1, | ||
}, | ||
happy: { | ||
statusMessage: '기분이 좋아요', | ||
statusGague: 0.75, | ||
}, | ||
thirsty: { | ||
statusMessage: '갈증나요', | ||
statusGague: 0.5, | ||
}, | ||
veryThirsty: { | ||
statusMessage: '물 주세요', | ||
statusGague: 0.25, | ||
}, | ||
}; | ||
|
||
export const PLANT_D_DAY: Record<number, number[]> = { | ||
1: [0, 3, 7], | ||
2: [0, 4, 13], | ||
3: [0, 6, 13], | ||
4: [0, 3, 7], | ||
5: [0, 3, 7], | ||
6: [0, 3, 7], | ||
}; | ||
Comment on lines
+27
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. plant health status 가 바뀌는 기준 데이입니다. |
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,48 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { ResponseSuccessDto } from 'src/common/dto/response-success.dto'; | ||
import { READ_PLANT_DETAIL } from 'src/constants/swagger'; | ||
|
||
const DTO_RESPONSE_DESCRIPTION = READ_PLANT_DETAIL.DTO_DESCRIPTION.RESPONSE; | ||
|
||
export class ResponsePlantDetailData { | ||
@ApiProperty({ description: DTO_RESPONSE_DESCRIPTION.ID }) | ||
id: number; | ||
|
||
@ApiProperty({ description: DTO_RESPONSE_DESCRIPTION.NICKNAME }) | ||
nickname: string; | ||
|
||
@ApiProperty({ description: DTO_RESPONSE_DESCRIPTION.DURATION }) | ||
duration: number; | ||
|
||
@ApiProperty({ | ||
required: false, | ||
description: DTO_RESPONSE_DESCRIPTION.INSTAGRAM, | ||
}) | ||
instagram?: string; | ||
|
||
@ApiProperty({ description: DTO_RESPONSE_DESCRIPTION.D_DAY }) | ||
dDay: number; | ||
|
||
@ApiProperty({ description: DTO_RESPONSE_DESCRIPTION.PLANT_ID }) | ||
plantId: number; | ||
|
||
@ApiProperty({ description: DTO_RESPONSE_DESCRIPTION.PLANT_IMAGE }) | ||
plantImage: string; | ||
|
||
@ApiProperty({ description: DTO_RESPONSE_DESCRIPTION.PLANT_NAME }) | ||
plantName: string; | ||
|
||
@ApiProperty({ description: DTO_RESPONSE_DESCRIPTION.LEVEL_NAME }) | ||
levelName: string; | ||
|
||
@ApiProperty({ description: DTO_RESPONSE_DESCRIPTION.STATUS_MESSAGE }) | ||
statusMessage: string; | ||
|
||
@ApiProperty({ description: DTO_RESPONSE_DESCRIPTION.STATUS_GAGUE }) | ||
statusGague: number; | ||
} | ||
|
||
export class ResponsePlantDetailDto extends ResponseSuccessDto { | ||
@ApiProperty() | ||
data: ResponsePlantDetailData; | ||
} |
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
4 changes: 2 additions & 2 deletions
4
src/plants/dto/response-plantwaterlog.dto.ts → ...lants/dto/response-plant-water-log.dto.ts
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 |
---|---|---|
|
@@ -10,17 +10,18 @@ import { | |
} from '@nestjs/swagger'; | ||
|
||
import { PlantsService } from './plants.service'; | ||
import { ResponsePlantInformationDto } from './dto/response-plantInformation.dto'; | ||
import { ResponsePlantInformationDto } from './dto/response-plant-information.dto'; | ||
import { CommonParamsDto } from 'src/common/dto/common-params.dto'; | ||
import { | ||
ERROR_DESCRIPTION, | ||
PLANT_INFORMATION, | ||
PLANT_WATER_LOG, | ||
READ_PLANT_DETAIL, | ||
READ_PLANT_INFORMATION, | ||
READ_PLANT_WATER_LOG, | ||
} from 'src/constants/swagger'; | ||
import { wrapSuccess } from 'src/utils/success'; | ||
import { RESPONSE_MESSAGE } from 'src/common/objects'; | ||
import { ResponsePlantWaterLogDto } from './dto/response-plantwaterlog.dto'; | ||
|
||
import { ResponsePlantWaterLogDto } from './dto/response-plant-water-log.dto'; | ||
import { ResponsePlantDetailDto } from './dto/response-plant-detail.dto'; | ||
@Controller('plants') | ||
@ApiTags('Plants') | ||
@ApiInternalServerErrorResponse({ | ||
|
@@ -29,23 +30,37 @@ import { ResponsePlantWaterLogDto } from './dto/response-plantwaterlog.dto'; | |
export class PlantsController { | ||
constructor(private readonly plantsService: PlantsService) {} | ||
|
||
@Get(':id/information') | ||
@ApiOperation({ | ||
summary: PLANT_INFORMATION.API_OPERATION.SUMMARY, | ||
description: PLANT_INFORMATION.API_OPERATION.DESCRIPTION, | ||
@Get(':id') | ||
@ApiOperation(READ_PLANT_DETAIL.API_OPERATION) | ||
@ApiParam(READ_PLANT_DETAIL.API_PARAM) | ||
Comment on lines
+34
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
@ApiOkResponse({ type: ResponsePlantDetailDto }) | ||
@ApiBadRequestResponse({ | ||
description: READ_PLANT_DETAIL.ERROR_DESCRIPTION.BAD_REQUEST, | ||
}) | ||
@ApiParam({ | ||
type: Number, | ||
name: PLANT_INFORMATION.API_PARAM.NAME, | ||
required: true, | ||
description: PLANT_INFORMATION.API_PARAM.DESCRIPTION, | ||
@ApiNotFoundResponse({ | ||
description: READ_PLANT_DETAIL.ERROR_DESCRIPTION.NOT_FOUND, | ||
}) | ||
async getPlantDetail( | ||
@Param() { id }: CommonParamsDto, | ||
): Promise<ResponsePlantDetailDto> { | ||
const data = await this.plantsService.getUserPlantDetail(id); | ||
|
||
return wrapSuccess( | ||
HttpStatus.OK, | ||
RESPONSE_MESSAGE.READ_PLANT_DETAIL_SUCCESS, | ||
data, | ||
); | ||
} | ||
|
||
@Get(':id/information') | ||
@ApiOperation(READ_PLANT_INFORMATION.API_OPERATION) | ||
@ApiParam(READ_PLANT_INFORMATION.API_PARAM) | ||
@ApiOkResponse({ type: ResponsePlantInformationDto }) | ||
@ApiBadRequestResponse({ | ||
description: PLANT_INFORMATION.ERROR_DESCRIPTION.BAD_REQUEST, | ||
description: READ_PLANT_INFORMATION.ERROR_DESCRIPTION.BAD_REQUEST, | ||
}) | ||
@ApiNotFoundResponse({ | ||
description: PLANT_INFORMATION.ERROR_DESCRIPTION.NOT_FOUND, | ||
description: READ_PLANT_INFORMATION.ERROR_DESCRIPTION.NOT_FOUND, | ||
}) | ||
async getPlantInformation( | ||
@Param() { id }: CommonParamsDto, | ||
|
@@ -60,19 +75,11 @@ export class PlantsController { | |
} | ||
|
||
@Get(':id/water') | ||
@ApiOperation({ | ||
summary: PLANT_WATER_LOG.API_OPERATION.SUMMARY, | ||
description: PLANT_WATER_LOG.API_OPERATION.DESCRIPTION, | ||
}) | ||
@ApiParam({ | ||
type: Number, | ||
name: PLANT_WATER_LOG.API_PARAM.NAME, | ||
required: true, | ||
description: PLANT_WATER_LOG.API_PARAM.DESCRIPTION, | ||
}) | ||
@ApiOperation(READ_PLANT_WATER_LOG.API_OPERATION) | ||
@ApiParam(READ_PLANT_WATER_LOG.API_PARAM) | ||
@ApiOkResponse({ type: ResponsePlantWaterLogDto }) | ||
@ApiBadRequestResponse({ | ||
description: PLANT_WATER_LOG.ERROR_DESCRIPTION.BAD_REQUEST, | ||
description: READ_PLANT_WATER_LOG.ERROR_DESCRIPTION.BAD_REQUEST, | ||
}) | ||
async getPlantWaterLog( | ||
@Param() { id }: CommonParamsDto, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[] <- 요거 머죠!?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 왜 모바일에선 너가 말한것처럼 이상한 기호 보이고 pc 에선 안보임 ㄷ ㄷ
![image](https://private-user-images.githubusercontent.com/20807197/261783908-f372213f-f0eb-4888-a040-aef5ed735446.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIxMTUyMjEsIm5iZiI6MTcyMjExNDkyMSwicGF0aCI6Ii8yMDgwNzE5Ny8yNjE3ODM5MDgtZjM3MjIxM2YtZjBlYi00ODg4LWEwNDAtYWVmNWVkNzM1NDQ2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI3VDIxMTUyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQyODlhMTllOGE4ODUwYjFiYWU5MTNhMTJkOThiMjY5YjNmZGM3NWIzNTljOGM0NDFlN2VjZjk2ZWZmMjYyOGYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.khGw4ttJoTfA54_PNLR8NvhopWrBpoQBAR2WjSs1-Fk)