Skip to content

Commit

Permalink
Merge pull request #136 from Arios67/feat/#131
Browse files Browse the repository at this point in the history
엘라스틱 서치 수정 (즉시 구매 시 엘라스틱서치 삭제)
  • Loading branch information
Arios67 committed Apr 4, 2022
2 parents 54443ac + 884c115 commit 7f54222
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 12 deletions.
1 change: 0 additions & 1 deletion ars/elk/logstash/logstash.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ input {
jdbc {
jdbc_driver_library => "/usr/share/logstash/mysql-connector-java-8.0.28.jar"
jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
#jdbc_connection_string => "jdbc:mysql://10.90.0.4:3306/ars"
jdbc_connection_string => "jdbc:mysql://my_database:3306/ars"
jdbc_user => "root"
jdbc_password => "3160"
Expand Down
5 changes: 1 addition & 4 deletions ars/src/apis/art/art.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Module } from '@nestjs/common';
import {
ElasticsearchModule,
ElasticsearchService,
} from '@nestjs/elasticsearch';
import { ElasticsearchModule } from '@nestjs/elasticsearch';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ArtImage } from '../artImage/entities/artImage.entity';
import { Engage } from '../engage/entities/engage.entity';
Expand Down
13 changes: 8 additions & 5 deletions ars/src/apis/art/art.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ export class ArtResolver {
if (redisValue) {
return redisValue;
}

const result = await this.elasticsearchService.search({
index: 'artipul00',
from: 0,
size: 500,
query: {
bool: {
must: [{ match: { tag1: tags[0] } }],
Expand All @@ -56,7 +57,6 @@ export class ArtResolver {
title: el._source.title,
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
price: el._source.price,
deadline: el._source.deadline,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
Expand All @@ -79,6 +79,8 @@ export class ArtResolver {

const result = await this.elasticsearchService.search({
index: 'artipul00',
from: 0,
size: 500,
query: {
bool: {
must: [{ match: { tag1: tags[0] } }, { match: { tag2: tags[1] } }],
Expand All @@ -94,7 +96,6 @@ export class ArtResolver {
title: el._source.title,
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
price: el._source.price,
deadline: el._source.deadline,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
Expand All @@ -118,6 +119,8 @@ export class ArtResolver {

const result = await this.elasticsearchService.search({
index: 'artipul00',
from: 0,
size: 500,
query: {
bool: {
must: [
Expand All @@ -137,7 +140,6 @@ export class ArtResolver {
title: el._source.title,
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
price: el._source.price,
deadline: el._source.deadline,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
Expand All @@ -162,6 +164,8 @@ export class ArtResolver {

const result = await this.elasticsearchService.search({
index: 'artipul00',
from: 0,
size: 500,
query: {
bool: {
must: [
Expand All @@ -182,7 +186,6 @@ export class ArtResolver {
title: el._source.title,
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
price: el._source.price,
deadline: el._source.deadline,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
Expand Down
3 changes: 3 additions & 0 deletions ars/src/apis/art/art.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ export class ArtService {
.createQueryBuilder('art')
.leftJoinAndSelect('art.payment', 'payment')
.leftJoinAndSelect('payment.user', 'user')
.take(10)
.skip(10 * (page - 1))
.where('user.id =:id', { id: currentUser.id })
.withDeleted()
.getMany();
Expand Down Expand Up @@ -217,6 +219,7 @@ export class ArtService {
.where('user.id =:id', { id: userId })
.withDeleted()
.getCount();

return art;
}

Expand Down
3 changes: 2 additions & 1 deletion ars/src/apis/board/board.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Connection, Repository } from 'typeorm';
import { Connection, getRepository, Repository } from 'typeorm';
import { Art } from '../art/entities/art.entity';
import { BoardImage } from '../boardImage/entities/boardImage.entity';
import { Comment } from '../comment/entities/comment.entity';
Expand Down Expand Up @@ -35,6 +35,7 @@ export class BoardService {
// 게시물 모두 조회
async findAll(page) {
return await this.boardRepository.find({
relations: ['art'],
take: 10,
skip: 10 * (page - 1),
});
Expand Down
10 changes: 10 additions & 0 deletions ars/src/apis/payment/payment.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export class PaymentResolver {
private readonly userService: UserService,
private readonly elasticsearchService: ElasticsearchService,

private readonly elasticsearchService: ElasticsearchService,

@Inject(CACHE_MANAGER)
private readonly cacheManager: Cache,
) {}
Expand Down Expand Up @@ -64,6 +66,9 @@ export class PaymentResolver {
},
});

return artId;
}

return 'ok';
}
// 레디스에 입찰 정보(작품, 현재 입찰가, 현재 상위 입찰자)
Expand All @@ -88,4 +93,9 @@ export class PaymentResolver {
await this.paymentService.save(artId, currentUser.id, bid_price);
return 'ok';
}

@Mutation(() => String)
async enterBidRomm(@Args('artId') artId: string) {
return await this.paymentService.room(artId);
}
}
7 changes: 6 additions & 1 deletion ars/src/apis/payment/payment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ export class PaymentService {

// DB 저장
async save(artId, userId, bid_price) {
this.eventGateway.server.emit('message', bid_price);
this.eventGateway.server.emit('message', {
price: bid_price,
artId: artId,
});
const queryRunner = this.connection.createQueryRunner();
await queryRunner.connect();
await queryRunner.startTransaction();
Expand Down Expand Up @@ -161,4 +164,6 @@ export class PaymentService {
where: { userId: userId },
});
}

async room(artId) {}
}
1 change: 1 addition & 0 deletions ars/src/common/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ type Mutation {
instantBid(artId: String!, price: Float!, artistEmail: String!): String!
Bid(artId: String!, bid_price: Float!): [String!]!
saveBid(artId: String!, bid_price: Float!): String!
enterBidRomm(artId: String!): String!
createPointTransaction(impUid: String!, charge_amount: Float!): PointTransaction!
cancelPointTransaction(impUid: String!): PointTransaction!
}
Expand Down

0 comments on commit 7f54222

Please sign in to comment.