Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
COMPANY_INSIGHT_MAX_LENGTH,
PortfolioCorrection,
} from '../../domain/portfolio-correction.entity';
import { CorrectionStatus } from '../../domain/enums/correction-status.enum';

export class UpdateCompanyInsightReqDTO {
@Transform(({ value }: { value: string }) => value?.trim())
Expand All @@ -26,6 +27,9 @@ export class UpdateCompanyInsightResDTO {
@ApiProperty({ nullable: true })
id: number;

@ApiProperty({ enum: CorrectionStatus })
status: CorrectionStatus;
Comment on lines +30 to +31
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

❌ 문제: UpdateCompanyInsightResDTO 클래스명이 '수정' 응답임을 나타내고 있으나, 현재 '조회' API(getCompanyInsight)에서도 공통으로 사용되고 있습니다. status 필드가 추가되면서 단순 수정 결과 이상의 정보를 포함하게 되었으므로 네이밍이 부적절합니다.
✅ 제안: CompanyInsightResDTO와 같이 조회와 수정 시 공통으로 사용할 수 있는 범용적인 이름으로 변경하는 것을 권장합니다.

References
  1. 네이밍 컨벤션 준수 여부 확인 (우선순위 중간) (link)


@ApiProperty({ nullable: true, maxLength: COMPANY_INSIGHT_MAX_LENGTH })
companyInsight: string | null;

Expand All @@ -35,6 +39,7 @@ export class UpdateCompanyInsightResDTO {
static from(correction: PortfolioCorrection): UpdateCompanyInsightResDTO {
const dto = new UpdateCompanyInsightResDTO();
dto.id = correction.id;
dto.status = correction.status;
dto.companyInsight = correction.companyInsight;
dto.highlightPoint = correction.highlightPoint;
return dto;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BusinessException } from 'src/common/exceptions/business.exception';
import { ErrorCode } from 'src/common/exceptions/error-code.enum';
import { AiRelayPort, AiRelayJsonResponse } from 'src/common/ports/ai-relay.port';
import { PortfolioCorrectionFacade } from '../facades/portfolio-correction.facade';
import { PortfolioCorrectionService } from './portfolio-correction.service';
Expand Down Expand Up @@ -112,18 +111,15 @@ describe('PortfolioCorrectionService', () => {
);
});

it('throws COMPANY_INSIGHT_NOT_READY when company insight is still null', async () => {
it('returns company insight response with status when company insight is still null', async () => {
repository.findByIdAndUserId.mockResolvedValue(createCorrection({ companyInsight: null }));

try {
await service.getCompanyInsight(1, 7);
fail('Expected getCompanyInsight to throw');
} catch (error: unknown) {
expect(error).toBeInstanceOf(BusinessException);
expect(error).toMatchObject({
response: { errorCode: ErrorCode.COMPANY_INSIGHT_NOT_READY },
});
}
await expect(service.getCompanyInsight(1, 7)).resolves.toMatchObject({
id: 1,
status: CorrectionStatus.NOT_STARTED,
companyInsight: null,
highlightPoint: null,
});
});

it('moves status to DOING_RAG before company insight generation starts', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ export class PortfolioCorrectionService {
userId: number
): Promise<UpdateCompanyInsightResDTO> {
const correction = await this.findByIdAndUserIdOrThrow(correctionId, userId);

if (correction.companyInsight === null) {
throw new BusinessException(ErrorCode.COMPANY_INSIGHT_NOT_READY);
}

return UpdateCompanyInsightResDTO.from(correction);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ export class PortfolioCorrectionController {
description: '특정 AI 첨삭의 기업 분석 정보를 조회합니다.',
})
@ApiCommonResponse(UpdateCompanyInsightResDTO)
@ApiCommonErrorResponse(
ErrorCode.UNAUTHORIZED,
ErrorCode.CORRECTION_NOT_FOUND,
ErrorCode.COMPANY_INSIGHT_NOT_READY
)
@ApiCommonErrorResponse(ErrorCode.UNAUTHORIZED, ErrorCode.CORRECTION_NOT_FOUND)
async getCompanyInsight(
@User('sub') userId: number,
@Param('correctionId', ParseIntPipe) correctionId: number
Expand Down
Loading