Skip to content

Commit

Permalink
Merge pull request #135 from Daseul1/feat/#134
Browse files Browse the repository at this point in the history
[#134]feat: 버그수정
  • Loading branch information
Daseul1 committed Apr 4, 2022
2 parents ae69976 + 35ef92b commit 54443ac
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 21 deletions.
1 change: 1 addition & 0 deletions ars/elk/logstash/logstash.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ output {
elasticsearch {
hosts => "elasticsearch:9200"
index => "artipul00"
document_id => "%{id}"
}
}
8 changes: 4 additions & 4 deletions ars/src/apis/art/art.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class ArtResolver {
}

const result = await this.elasticsearchService.search({
index: 'artipul09',
index: 'artipul00',
query: {
bool: {
must: [{ match: { tag1: tags[0] } }],
Expand Down Expand Up @@ -78,7 +78,7 @@ export class ArtResolver {
}

const result = await this.elasticsearchService.search({
index: 'artipul09',
index: 'artipul00',
query: {
bool: {
must: [{ match: { tag1: tags[0] } }, { match: { tag2: tags[1] } }],
Expand Down Expand Up @@ -117,7 +117,7 @@ export class ArtResolver {
}

const result = await this.elasticsearchService.search({
index: 'artipul09',
index: 'artipul00',
query: {
bool: {
must: [
Expand Down Expand Up @@ -161,7 +161,7 @@ export class ArtResolver {
}

const result = await this.elasticsearchService.search({
index: 'artipul09',
index: 'artipul00',
query: {
bool: {
must: [
Expand Down
14 changes: 8 additions & 6 deletions ars/src/apis/art/art.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ export class ArtService {
.where('user.id =:id', { id: currentUser.id })
.withDeleted()
.getMany();
console.log('***********', art);
return art;
}

Expand Down Expand Up @@ -211,11 +210,14 @@ export class ArtService {
}

async countComletedAuctionArts(userId) {
const result = await this.artRepository.count({
withDeleted: true,
where: { user: userId, is_soldout: true },
});
return result;
const art = await getRepository(Art)
.createQueryBuilder('art')
.leftJoinAndSelect('art.payment', 'payment')
.leftJoinAndSelect('payment.user', 'user')
.where('user.id =:id', { id: userId })
.withDeleted()
.getCount();
return art;
}

async countTimedoutArts(userId) {
Expand Down
2 changes: 2 additions & 0 deletions ars/src/apis/board/board.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { BoardImage } from '../boardImage/entities/boardImage.entity';
import { Comment } from '../comment/entities/comment.entity';
import { FileService } from '../file/file.service';
import { LikeBoardService } from '../likeBoard/likeBoard.service';
import { User } from '../user/entities/user.entity';
import { BoardResolver } from './board.resolver';
import { BoardService } from './board.service';
import { Board } from './entities/board.entity';
Expand All @@ -18,6 +19,7 @@ import { LikeBoard } from './entities/likeBoard.entity';
BoardImage,
Comment,
LikeBoard,
User,
]),
],
providers: [
Expand Down
6 changes: 3 additions & 3 deletions ars/src/apis/board/board.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export class BoardResolver {

// 게시물 모두 조회
@Query(() => [Board])
async fetchBoards() {
return await this.boardService.findAll();
async fetchBoards(@Args('page', { nullable: true }) page: number) {
return await this.boardService.findAll(page);
}

// 내가 쓴 게시물 조회
@UseGuards(GqlAuthAccessGuard)
@Query(() => [Board])
async fetchBoardsOfMine(
@Args('page') page: number,
@Args('page', { nullable: true }) page: number,
@CurrentUser() currentUser: ICurrentUser,
) {
return await this.boardService.findMine({ currentUser }, page);
Expand Down
9 changes: 6 additions & 3 deletions ars/src/apis/board/board.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ export class BoardService {
}

// 게시물 모두 조회
async findAll() {
return await this.boardRepository.find();
async findAll(page) {
return await this.boardRepository.find({
take: 10,
skip: 10 * (page - 1),
});
}

// 내가 쓴 게시물 조회
async findMine({ currentUser }, page) {
return await this.boardRepository.find({
skip: 10,
take: 10,
skip: 10 * (page - 1),
where: { user: currentUser },
});
}
Expand Down
4 changes: 4 additions & 0 deletions ars/src/apis/payment/payment.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Module } from '@nestjs/common';
import { ElasticsearchModule } from '@nestjs/elasticsearch';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ArtService } from '../art/art.service';
import { Art } from '../art/entities/art.entity';
Expand All @@ -21,6 +22,9 @@ import { PaymentService } from './payment.service';
Engage,
]),
EventModule,
ElasticsearchModule.register({
node: 'http://elasticsearch:9200',
}),
],
providers: [
PaymentResolver, //
Expand Down
14 changes: 12 additions & 2 deletions ars/src/apis/payment/payment.resolver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CACHE_MANAGER, Inject, UseGuards } from '@nestjs/common';
import { ElasticsearchService } from '@nestjs/elasticsearch';
import { Args, Mutation, Resolver } from '@nestjs/graphql';
import { Cache } from 'cache-manager';
import { GqlAuthAccessGuard } from 'src/common/auth/gql-auth.guard';
Expand All @@ -11,6 +12,7 @@ export class PaymentResolver {
constructor(
private readonly paymentService: PaymentService,
private readonly userService: UserService,
private readonly elasticsearchService: ElasticsearchService,

@Inject(CACHE_MANAGER)
private readonly cacheManager: Cache,
Expand Down Expand Up @@ -53,9 +55,17 @@ export class PaymentResolver {
const bidder = await this.userService.findOne(currentUser.email);
await this.paymentService.successfulBid(artId, price, bidder, artist);

return artId;
}
const result = await this.elasticsearchService.deleteByQuery({
index: 'artipul00',
query: {
bool: {
must: [{ match: { id: artId } }],
},
},
});

return 'ok';
}
// 레디스에 입찰 정보(작품, 현재 입찰가, 현재 상위 입찰자)
@UseGuards(GqlAuthAccessGuard)
@Mutation(() => [String])
Expand Down
4 changes: 4 additions & 0 deletions ars/src/apis/payment/payment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export class PaymentService {
private readonly connection: Connection,
) {}

async find() {
await this.artRepository.find();
}

// 마감된 작품 체크
async checkTimeout() {
const utc = new Date();
Expand Down
4 changes: 2 additions & 2 deletions ars/src/common/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ type Query {
fetchLikeArt(page: Float): [Art!]!
fetchBoard(boardId: String!): Board!
fetchBoardImgaes(boardId: String!): [BoardImage!]!
fetchBoards: [Board!]!
fetchBoardsOfMine(page: Float!): [Board!]!
fetchBoards(page: Float): [Board!]!
fetchBoardsOfMine(page: Float): [Board!]!
fetchBoardsOfMineCount: Float!
countLikeBoard(boardId: String!): Int!
fetchLikeBoard: [Board!]!
Expand Down
2 changes: 1 addition & 1 deletion frontend/payment.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
{
headers: {
Authorization:
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImJiYkBhLmEiLCJzdWIiOiI4MzdjZTkyOS1lYjE5LTRiYTgtOTgzNi02ZTk3NTQ2NzkzNGEiLCJpYXQiOjE2NDg2MzU0OTcsImV4cCI6MTY0ODYzOTA5N30.0biQLLvJrSYyntwAsBzQX6abz-x7yXsFDSr44uA7h2M",
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImVrdG1mQGEuYSIsInN1YiI6ImM0ZTViYWY5LTI0NzctNDIxZC1iMDRhLWZmNzAwNjQwYjc2MCIsImlhdCI6MTY0OTA0NjMwMCwiZXhwIjoxNjQ5MDQ5OTAwfQ.i__qC-xy43JECudJ0YGuCoHWYyTb7nmRYJHU__4G9Ns",
},
}
);
Expand Down

0 comments on commit 54443ac

Please sign in to comment.