Skip to content

Commit

Permalink
Merge branch 'stage' of https://github.com/mash-up-kr/VitaminC_server
Browse files Browse the repository at this point in the history
…into stage
  • Loading branch information
Ho-s committed Sep 21, 2024
2 parents a7b2c27 + ba6c383 commit d3266f1
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 1 deletion.
122 changes: 122 additions & 0 deletions src/gpt/__fixtures__/stream-test-places.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
export const testPlaces = [
{
id: 243854995,
name: '크래프트맥코이',
category: '호프,요리주점',
categoryIconCode: 5,
address: '남대문로9길 51',
x: 126.97958042191954,
y: 37.5668225648663,
menuList: [
{ menu: '맥코이 푸틴', photo: '', price: '14,000' },
{ menu: '고르곤졸라피자', photo: '', price: '16,000' },
{ menu: '페퍼로니피자', photo: '', price: '16,000' },
{ menu: '맥코이포테이토', photo: '', price: '10,000' },
{ menu: '달달포테이토', photo: '', price: '12,000' },
{ menu: '육즙팡팡소시지', photo: '', price: '16,000' },
{ menu: '닭또옹집튀김', photo: '', price: '10,000' },
{ menu: '맥코이떡볶이', photo: '', price: '10,000' },
{ menu: '모듬튀김', photo: '', price: '18,000' },
{ menu: '에그인헬', photo: '', price: '16,000' },
],
mainPhotoUrl:
'http://t1.daumcdn.net/place/119310EF646D4E5FA98241D2F3BD523F',
photoList: [
'http://t1.daumcdn.net/place/119310EF646D4E5FA98241D2F3BD523F',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/995dfced3e6052829e043bf7a8130138e4641221?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/f5a2b1d175b6713f55687e811483d29ba13b5a4f?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/f91e62ff1013e2f2fa3e3630c31da9f3c013ea0d?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/2e1ea65f5b77ea586e86861208f3295083d26d3b?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/995dfced3e6052829e043bf7a8130138e4641221?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/f5a2b1d175b6713f55687e811483d29ba13b5a4f?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/f91e62ff1013e2f2fa3e3630c31da9f3c013ea0d?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/2e1ea65f5b77ea586e86861208f3295083d26d3b?original',
'https://postfiles.pstatic.net/MjAyMzA5MDdfNTIg/MDAxNjk0MDM1Mzc4MDE0.eL6bF4bf-XwhR9wMaphN-CvivNJPPDI4M2nXSHwy_kQg.mKNGfjFVY41XOJXl2ywaw1FYMY4cFO954UQhuwOqroMg.JPEG.jhggo3/IMG_2823.jpg?type=w773',
],
score: 4.2,
commentCnt: 6,
blogReviewCnt: 10,
openTimeList: [],
offDayList: [],
createdAt: '2024-09-19T18:08:33.226Z',
updatedAt: '2024-09-19T18:08:33.226Z',
},
{
id: 10372376,
name: '라칸티나',
category: '이탈리안',
categoryIconCode: 6,
address: '을지로 19',
x: 126.979942795018,
y: 37.56621355373227,
menuList: [
{ menu: '피레또 디 만조 알라 로씨니', photo: '', price: '36,000' },
{ menu: '비스테까 알 페페 네로', photo: '', price: '34,000' },
{ menu: '피레또 디 만조 아이 풍기', photo: '', price: '34,000' },
{ menu: '비스테까 스피에디니 리소토', photo: '', price: '29,000' },
{ menu: '티라미수', photo: '', price: '4,800' },
{ menu: '봉골레파스타', photo: '' },
],
mainPhotoUrl:
'http://t1.daumcdn.net/place/342DD268B8824A56B4A8C8D0CAABD4C4',
photoList: [
'http://t1.daumcdn.net/place/342DD268B8824A56B4A8C8D0CAABD4C4',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/842a1ed3b3a0fd1ed620c8d487e6e9f08da90008?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/885b79575ca8340b5a5456467d8a98f76aa61d37?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/b3797adb6f244c15df1bf7f5b8b59bb02fed6208?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/3b4330590cbfae7407048d7502a479fd3faecb4c?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/842a1ed3b3a0fd1ed620c8d487e6e9f08da90008?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/885b79575ca8340b5a5456467d8a98f76aa61d37?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/b3797adb6f244c15df1bf7f5b8b59bb02fed6208?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/3b4330590cbfae7407048d7502a479fd3faecb4c?original',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/ad322b8a082a43bad6047adff3b7122ff867e23d?original',
],
score: 3.3,
commentCnt: 85,
blogReviewCnt: 195,
openTimeList: [
{ timeSE: '11:30 ~ 22:00', timeName: '영업시간', dayOfWeek: '월~토' },
{ timeSE: '15:00 ~ 17:00', timeName: '휴게시간', dayOfWeek: '월~토' },
],
offDayList: [
{ weekAndDay: '일요일', holidayName: '휴무일', temporaryHolidays: 'N' },
],
createdAt: '2024-09-19T18:08:33.310Z',
updatedAt: '2024-09-19T18:08:33.310Z',
},
{
id: 21547535,
name: '더라운지',
category: '와인바',
categoryIconCode: 100,
address: '소공로 119',
x: 126.97791489210915,
y: 37.56467068647689,
menuList: [
{ menu: '아메리카노', photo: '', price: '15,000' },
{ menu: '카푸치노', photo: '', price: '16,000' },
{ menu: '카페 라떼', photo: '', price: '16,000' },
{ menu: '콜드 브루 라떼 (ICE)', photo: '', price: '16,000' },
{ menu: '바닐라 라떼', photo: '', price: '17,000' },
],
mainPhotoUrl:
'http://t1.daumcdn.net/place/AE0E68765A964D528416F32A087476AF',
photoList: [
'http://t1.daumcdn.net/place/AE0E68765A964D528416F32A087476AF',
'http://t1.daumcdn.net/local/kakaomapPhoto/review/aed9eb40f3915106b8d154f01eddf2aa990b9000?original',
'https://t1.daumcdn.net/local/review_placeapp/btqjeEZ2E0P_qyLsCtUBC6KJsSl6j8ZGY1_img.jpg',
'https://postfiles.pstatic.net/MjAyNDA4MjdfMTE1/MDAxNzI0NzQyMjkwMjcw.JlqvmZZfhqB33rljDOGYkkjbNKGaCfnEA2QjcApY2jwg.EHCIs4u8rUcxd6ldAulKx4-R4TBeP9YqEVmWWMG-u0Eg.JPEG/SE-290a859f-643e-11ef-b52a-7fb63e4cd313.jpg?type=w386',
'https://postfiles.pstatic.net/MjAyNDA4MjdfMjE4/MDAxNzI0NzQyMjg4NjM0.7op5EsfKbuFI7PH7hZ6uET-cSH76yhTxBEH6F4463Mcg.Trr8Yys2utPpxDhuZbXIg0mhanIjd4ZY_bpMvSU73uQg.JPEG/SE-2909e95e-643e-11ef-b52a-9b744e872a94.jpg?type=w386',
'https://postfiles.pstatic.net/MjAyNDA4MjdfMTU3/MDAxNzI0NzQyMjc5MjYy.WkKSwB6MSGorZiJ350baPBF6Sfc0StKToTFQGEllJykg.mRdNbD0VUU2xtfZEOlzmg_yVGHRXtRYwo8j37ccD8QYg.JPEG/SE-c9701e48-643f-11ef-aa1c-113fbce6de51.jpg?type=w773',
],
score: 4.2,
commentCnt: 5,
blogReviewCnt: 7,
openTimeList: [
{ timeSE: '10:00 ~ 22:00', timeName: '영업시간', dayOfWeek: '매일' },
],
offDayList: [],
createdAt: '2024-09-19T18:08:33.207Z',
updatedAt: '2024-09-19T18:08:33.207Z',
},
];
37 changes: 36 additions & 1 deletion src/gpt/gpt.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Controller, Get, Injectable, Param } from '@nestjs/common';
import { Controller, Get, Injectable, Param, Query, Sse } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';

import { Observable } from 'rxjs';

import { UseAuthGuard } from 'src/common/decorators/auth-guard.decorator';
import { CurrentUser } from 'src/common/decorators/user.decorator';
import { User, UserRole } from 'src/entities';
import { testPlaces } from 'src/gpt/__fixtures__/stream-test-places';

import { GptService } from './gpt.service';

Expand All @@ -17,4 +22,34 @@ export class GptController {
checkIfIsBadWordx(@Param('word') word: string) {
return this.gptService.checkIfIsBadwordWithGpt(word);
}

@UseAuthGuard([UserRole.USER])
@Sse('restaurants/recommend/test')
async recommendRestaurantsTest(
@CurrentUser() user: User,
@Query('question') question: string,
// default x,y 강남역으로 해놨음
@Query('x') x: string = '127.027926',
@Query('y') y: string = '37.497175',
): Promise<Observable<MessageEvent>> {
return new Observable((observer) => {
const processStream = async () => {
const textStream =
'테스트테스트테스트줄넘기\n테스트테스트테스트테스트테스트테스트테스트🤩테스트테스트'.split(
'',
);
for (const char of textStream) {
await new Promise((resolve) => setTimeout(resolve, 100));
// @ts-ignore
observer.next({ type: 'text', data: char });
}
testPlaces.forEach((testPlace) => {
// @ts-ignore
observer.next({ data: testPlace, type: 'json' });
});
observer.complete();
};
processStream().catch((error) => observer.error(error));
});
}
}

0 comments on commit d3266f1

Please sign in to comment.