Skip to content

Commit

Permalink
[#99]feat: save Bid, 내가 쓴 게시물 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Arios67 committed Mar 31, 2022
1 parent f924eee commit 175f613
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 32 deletions.
12 changes: 2 additions & 10 deletions ars/src/apis/art/art.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export class ArtService {
createdAt: MoreThan(createdAt),
},
order: { createdAt: 'ASC' },
take: 9,
});
break;
case 3:
Expand All @@ -49,7 +48,6 @@ export class ArtService {
createdAt: MoreThan(createdAt),
},
order: { createdAt: 'ASC' },
take: 9,
});
break;
case 2:
Expand All @@ -60,7 +58,6 @@ export class ArtService {
createdAt: MoreThan(createdAt),
},
order: { createdAt: 'ASC' },
take: 9,
});
break;
case 1:
Expand All @@ -70,7 +67,6 @@ export class ArtService {
createdAt: MoreThan(createdAt),
},
order: { createdAt: 'ASC' },
take: 9,
});
}
await queryRunner.commitTransaction();
Expand Down Expand Up @@ -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();
Expand All @@ -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++) {
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions ars/src/apis/art/dto/createArtInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
10 changes: 3 additions & 7 deletions ars/src/apis/art/entities/art.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ export class Art {
@Field(() => Date)
updatedAt: Date;

@DeleteDateColumn()
@Field(() => Date)
deletedAt: Date;

@ManyToOne(() => User, { eager: true })
@Field(() => User)
user: User;
Expand All @@ -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;
}
3 changes: 2 additions & 1 deletion ars/src/apis/payment/payment.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
8 changes: 7 additions & 1 deletion ars/src/apis/payment/payment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
12 changes: 5 additions & 7 deletions ars/src/common/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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!
}
Expand All @@ -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."""
Expand Down

0 comments on commit 175f613

Please sign in to comment.