diff --git a/ars/src/apis/art/art.resolver.ts b/ars/src/apis/art/art.resolver.ts index 820455c..5ec89b4 100644 --- a/ars/src/apis/art/art.resolver.ts +++ b/ars/src/apis/art/art.resolver.ts @@ -97,6 +97,7 @@ export class ArtResolver { start_price: el._source.start_price, instant_bid: el._source.instant_bid, deadline: el._source.deadline, + is_soldout: el._source.is_soldout, thumbnail: el._source.thumbnail, tag1: el._source.tag1, tag2: el._source.tag2, diff --git a/ars/src/apis/art/art.service.ts b/ars/src/apis/art/art.service.ts index 9c781b6..9117eab 100644 --- a/ars/src/apis/art/art.service.ts +++ b/ars/src/apis/art/art.service.ts @@ -132,6 +132,7 @@ export class ArtService { .where('user.id =:id', { id: currentUser.id }) .withDeleted() .getMany(); + return art; } @@ -175,6 +176,7 @@ export class ArtService { } } /////////////////////////////////////////////////////////////////////////// + async countEngage(userId) { const queryRunner = this.connection.createQueryRunner(); await queryRunner.connect(); @@ -187,7 +189,6 @@ export class ArtService { return result; } catch (error) { await queryRunner.rollbackTransaction(); - throw error + 'Art create !'; } finally { await queryRunner.manager.release(); } @@ -205,7 +206,6 @@ export class ArtService { return result; } catch (error) { await queryRunner.rollbackTransaction(); - throw error + 'Art create !'; } finally { await queryRunner.manager.release(); } @@ -219,7 +219,7 @@ export class ArtService { .where('user.id =:id', { id: userId }) .withDeleted() .getCount(); - + return art; } @@ -237,5 +237,6 @@ export class ArtService { }); return result; } + /////////////////////////////////////////////////////////////////////////// } diff --git a/ars/src/apis/auth/auth.service.ts b/ars/src/apis/auth/auth.service.ts index e5dc61e..44e3d73 100644 --- a/ars/src/apis/auth/auth.service.ts +++ b/ars/src/apis/auth/auth.service.ts @@ -22,7 +22,7 @@ export class AuthService { { email: user.email, sub: user.id }, { secret: process.env.REFRESH_TOKEN_KEY, expiresIn: '8h' }, ); - res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000'); + res.setHeader('Access-Control-Allow-Origin', 'https://artipul.shop'); res.setHeader( 'Set-Cookie', `refreshToken=${refreshToken}; path=/; domain=.daseul.shop; SameSite=None; Secure;httpOnly;`, diff --git a/ars/src/apis/board/board.resolver.ts b/ars/src/apis/board/board.resolver.ts index 49b859e..8589cb7 100644 --- a/ars/src/apis/board/board.resolver.ts +++ b/ars/src/apis/board/board.resolver.ts @@ -33,8 +33,8 @@ export class BoardResolver { // 게시물 모두 조회 @Query(() => [Board]) - async fetchBoards(@Args('page', { nullable: true }) page: number) { - return await this.boardService.findAll(page); + async fetchBoards() { + return await this.boardService.findAll(); } // 내가 쓴 게시물 조회 diff --git a/ars/src/apis/board/board.service.ts b/ars/src/apis/board/board.service.ts index 12d7240..98df595 100644 --- a/ars/src/apis/board/board.service.ts +++ b/ars/src/apis/board/board.service.ts @@ -24,20 +24,25 @@ export class BoardService { // 게시물 1개 조회 async findOne(boardId: string) { - return await this.boardRepository.findOne(boardId); + return await this.boardRepository.findOne({ + where: { id: boardId }, + relations: ['art'], + withDeleted: true, + }); } // 게시물 이미지 조회 async findImage({ boardId }) { - return await this.boardImageRepository.find({ board: boardId }); + return await this.boardImageRepository.find({ + where: { board: boardId }, + relations: ['board'], + }); } // 게시물 모두 조회 - async findAll(page) { + async findAll() { return await this.boardRepository.find({ relations: ['art'], - take: 10, - skip: 10 * (page - 1), }); } @@ -65,9 +70,11 @@ export class BoardService { const user = await queryRunner.manager.findOne(User, { id: currentUser.id, }); - const art = await queryRunner.manager.findOne(Art, { - id: artId, - }); + const art = await getRepository(Art) + .createQueryBuilder('art') + .where('art.id = :id', { id: artId }) + .withDeleted() + .getOne(); const result = await queryRunner.manager.save(Board, { ...rest, @@ -106,10 +113,15 @@ export class BoardService { await queryRunner.connect(); await queryRunner.startTransaction(); try { - const board = await queryRunner.manager.findOne(Board, { id: boardId }); + const board = await this.boardRepository.findOne({ + where: { id: boardId }, + relations: ['art'], + withDeleted: true, + }); const user = await queryRunner.manager.findOne(User, { id: currentUser.id, }); + const result = await queryRunner.manager.save(Board, { ...board, ...rest, @@ -117,7 +129,10 @@ export class BoardService { thumbnail: image_urls[0], }); - for (let i = 0; i < image_urls.lenght; i++) { + await queryRunner.manager.delete(BoardImage, { + board: result, + }); + for (let i = 0; i < image_urls.length; i++) { if (i === 0) { await queryRunner.manager.save(BoardImage, { url: image_urls[i], diff --git a/ars/src/apis/event/event.gateway.ts b/ars/src/apis/event/event.gateway.ts index d967dd2..d7c331a 100644 --- a/ars/src/apis/event/event.gateway.ts +++ b/ars/src/apis/event/event.gateway.ts @@ -8,7 +8,7 @@ import { Server, Socket } from 'socket.io'; @WebSocketGateway({ cors: { - origin: ['http://localhost:3000', 'https://daseul.shop'], + origin: ['https://daseul.shop', 'https://artipul.shop'], }, namespace: /./, }) diff --git a/ars/src/apis/payment/payment.resolver.ts b/ars/src/apis/payment/payment.resolver.ts index 9b809fb..a1a3d99 100644 --- a/ars/src/apis/payment/payment.resolver.ts +++ b/ars/src/apis/payment/payment.resolver.ts @@ -56,7 +56,7 @@ export class PaymentResolver { const bidder = await this.userService.findOne(currentUser.email); await this.paymentService.successfulBid(artId, price, bidder, artist); - const result = await this.elasticsearchService.deleteByQuery({ + await this.elasticsearchService.deleteByQuery({ index: 'artipul00', query: { bool: { diff --git a/ars/src/app.module.ts b/ars/src/app.module.ts index eb7159f..bfde053 100644 --- a/ars/src/app.module.ts +++ b/ars/src/app.module.ts @@ -37,7 +37,7 @@ import { EventModule } from './apis/event/event.module'; driver: ApolloDriver, autoSchemaFile: 'src/common/graphql/schema.gql', context: ({ req, res }) => ({ req, res }), - cors: { origin: 'http://localhost:3000', credential: true }, + cors: { origin: 'https://artipul.shop', credential: true }, }), TypeOrmModule.forRoot({ type: 'mysql', diff --git a/ars/src/main.ts b/ars/src/main.ts index fa71fc8..08ee187 100644 --- a/ars/src/main.ts +++ b/ars/src/main.ts @@ -7,7 +7,7 @@ import { NestExpressApplication } from '@nestjs/platform-express'; async function bootstrap() { const app = await NestFactory.create(AppModule); app.enableCors({ - origin: 'http://localhost:3000', + origin: 'https://artipul.shop', credentials: true, }); app.use(graphqlUploadExpress());