From 175f6139c6e554e0b697268dca37c66b72fa7e94 Mon Sep 17 00:00:00 2001 From: Arios67 Date: Thu, 31 Mar 2022 16:44:12 +0900 Subject: [PATCH] =?UTF-8?q?[#99]feat:=20save=20Bid,=20=EB=82=B4=EA=B0=80?= =?UTF-8?q?=20=EC=93=B4=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ars/src/apis/art/art.service.ts | 12 ++---------- ars/src/apis/art/dto/createArtInput.ts | 12 ++++++------ ars/src/apis/art/entities/art.entity.ts | 10 +++------- ars/src/apis/payment/payment.resolver.ts | 3 ++- ars/src/apis/payment/payment.service.ts | 8 +++++++- ars/src/common/graphql/schema.gql | 12 +++++------- 6 files changed, 25 insertions(+), 32 deletions(-) diff --git a/ars/src/apis/art/art.service.ts b/ars/src/apis/art/art.service.ts index e03625a..cc6a06b 100644 --- a/ars/src/apis/art/art.service.ts +++ b/ars/src/apis/art/art.service.ts @@ -37,7 +37,6 @@ export class ArtService { createdAt: MoreThan(createdAt), }, order: { createdAt: 'ASC' }, - take: 9, }); break; case 3: @@ -49,7 +48,6 @@ export class ArtService { createdAt: MoreThan(createdAt), }, order: { createdAt: 'ASC' }, - take: 9, }); break; case 2: @@ -60,7 +58,6 @@ export class ArtService { createdAt: MoreThan(createdAt), }, order: { createdAt: 'ASC' }, - take: 9, }); break; case 1: @@ -70,7 +67,6 @@ export class ArtService { createdAt: MoreThan(createdAt), }, order: { createdAt: 'ASC' }, - take: 9, }); } await queryRunner.commitTransaction(); @@ -138,7 +134,7 @@ export class ArtService { } // 작품 등록 - async create({ image_urls, tag1, tag2, tag3, tag4, ...rest }, currentUser) { + async create({ image_urls, ...rest }, currentUser) { const queryRunner = this.connection.createQueryRunner(); await queryRunner.connect(); await queryRunner.startTransaction(); @@ -147,10 +143,6 @@ export class ArtService { ...rest, user: currentUser, thumbnail: image_urls[0], - tag1, - tag2, - tag3, - tag4, }); for (let i = 0; i < image_urls.length; i++) { @@ -230,7 +222,7 @@ export class ArtService { } async countAuctionArts(userId) { - const result = await this.artRepository.find({ + const result = await this.artRepository.count({ where: { user: userId, is_soldout: false }, }); return result; diff --git a/ars/src/apis/art/dto/createArtInput.ts b/ars/src/apis/art/dto/createArtInput.ts index 555c8b9..9e1e6a9 100644 --- a/ars/src/apis/art/dto/createArtInput.ts +++ b/ars/src/apis/art/dto/createArtInput.ts @@ -29,12 +29,12 @@ export class CreateArtInput { @Field(() => String) tag1: string; - @Field(() => String) - tag2: string; + @Field(() => String, { nullable: true }) + tag2?: string; - @Field(() => String) - tag3: string; + @Field(() => String, { nullable: true }) + tag3?: string; - @Field(() => String) - tag4: string; + @Field(() => String, { nullable: true }) + tag4?: string; } diff --git a/ars/src/apis/art/entities/art.entity.ts b/ars/src/apis/art/entities/art.entity.ts index 7c64995..7ff338f 100644 --- a/ars/src/apis/art/entities/art.entity.ts +++ b/ars/src/apis/art/entities/art.entity.ts @@ -63,10 +63,6 @@ export class Art { @Field(() => Date) updatedAt: Date; - @DeleteDateColumn() - @Field(() => Date) - deletedAt: Date; - @ManyToOne(() => User, { eager: true }) @Field(() => User) user: User; @@ -81,13 +77,13 @@ export class Art { @Column({ nullable: true, default: null }) @Field(() => String, { nullable: true }) - tag2: string; + tag2?: string; @Column({ nullable: true, default: null }) @Field(() => String, { nullable: true }) - tag3: string; + tag3?: string; @Column({ nullable: true, default: null }) @Field(() => String, { nullable: true }) - tag4: string; + tag4?: string; } diff --git a/ars/src/apis/payment/payment.resolver.ts b/ars/src/apis/payment/payment.resolver.ts index 53fd69d..64fd1e4 100644 --- a/ars/src/apis/payment/payment.resolver.ts +++ b/ars/src/apis/payment/payment.resolver.ts @@ -70,9 +70,10 @@ export class PaymentResolver { @Mutation(() => String) async saveBid( @Args('artId') artId: string, + @Args('bid_price') bid_price: number, @CurrentUser() currentUser: ICurrentUser, ) { - await this.paymentService.save(artId, currentUser.id); + await this.paymentService.save(artId, currentUser.id, bid_price); return 'ok'; } } diff --git a/ars/src/apis/payment/payment.service.ts b/ars/src/apis/payment/payment.service.ts index 020fa3d..da9b0f7 100644 --- a/ars/src/apis/payment/payment.service.ts +++ b/ars/src/apis/payment/payment.service.ts @@ -113,7 +113,7 @@ export class PaymentService { return [bid_price, email]; } - async save(artId, userId) { + async save(artId, userId, bid_price) { const queryRunner = this.connection.createQueryRunner(); await queryRunner.connect(); await queryRunner.startTransaction(); @@ -125,11 +125,17 @@ export class PaymentService { }, }); + await queryRunner.manager.update( + Art, + { id: artId }, + { price: bid_price }, + ); if (!prevEngage) await queryRunner.manager.save(Engage, { userId: userId, art: artId, }); + await queryRunner.commitTransaction(); } catch (error) { await queryRunner.rollbackTransaction(); diff --git a/ars/src/common/graphql/schema.gql b/ars/src/common/graphql/schema.gql index 4abc48d..f9896b6 100644 --- a/ars/src/common/graphql/schema.gql +++ b/ars/src/common/graphql/schema.gql @@ -49,12 +49,10 @@ type Art { price: Int! thumbnail: String! createdAt: DateTime! - deadline: String! - is_soldout: Boolean! - updatedAt: DateTime! deletedAt: DateTime! deadline: DateTime! is_soldout: Boolean! + updatedAt: DateTime! user: User! payment: Payment! tag1: String! @@ -177,7 +175,7 @@ type Mutation { checkTimedoutAndProcess: String! instantBid(artId: String!, price: Float!, artistEmail: String!): String! Bid(artId: String!, bid_price: Float!): [String!]! - saveBid(artId: String!): String! + saveBid(artId: String!, bid_price: Float!): String! createPointTransaction(impUid: String!, charge_amount: Float!): PointTransaction! cancelPointTransaction(impUid: String!): PointTransaction! } @@ -192,9 +190,9 @@ input CreateArtInput { image_urls: [String!]! is_soldout: Boolean! tag1: String! - tag2: String! - tag3: String! - tag4: String! + tag2: String + tag3: String + tag4: String } """The `Upload` scalar type represents a file upload."""