diff --git a/.DS_Store b/.DS_Store index 45d21ae..970b22e 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/ars/docker-compose.dev.yaml b/ars/docker-compose.dev.yaml index d71fefb..5d69b1b 100644 --- a/ars/docker-compose.dev.yaml +++ b/ars/docker-compose.dev.yaml @@ -3,7 +3,7 @@ version: '3.3' services: my_backend: platform: linux/x86_64 - image: asia.gcr.io/artiful-a1/my_backend:2.0 + image: asia.gcr.io/artiful-a1/my_backend:1.9 build: context: . dockerfile: Dockerfile diff --git a/ars/elk/logstash/logstash.conf b/ars/elk/logstash/logstash.conf index 7013835..a51b377 100644 --- a/ars/elk/logstash/logstash.conf +++ b/ars/elk/logstash/logstash.conf @@ -13,13 +13,13 @@ input { last_run_metadata_path => "./aaa.txt" tracking_column_type => "numeric" - statement => "select art.id, title, start_price, instant_bid, price, thumbnail, createdAt, deadline, tag1, tag2, tag3, tag4, updatedat, u.nickname, unix_timestamp(art.updatedat) as updatedat from art left join user as u ON art.userId = u.id where unix_timestamp(art.updatedat) > :sql_last_value order by updatedat asc" + statement => "select art.id, title, start_price, instant_bid, thumbnail, createdAt, deadline, is_soldout, tag1, tag2, tag3, tag4, updatedat, u.nickname, unix_timestamp(art.updatedat) as updatedat from art left join user as u ON art.userId = u.id where unix_timestamp(art.updatedat) > :sql_last_value order by updatedat asc" } } output { elasticsearch { hosts => "elasticsearch:9200" - index => "artipul09" + index => "artipul00" } } \ No newline at end of file diff --git a/ars/src/apis/art/art.resolver.ts b/ars/src/apis/art/art.resolver.ts index 1d0ab90..e3b9287 100644 --- a/ars/src/apis/art/art.resolver.ts +++ b/ars/src/apis/art/art.resolver.ts @@ -40,7 +40,9 @@ export class ArtResolver { } const result = await this.elasticsearchService.search({ - index: 'artipul09', + index: 'artipul00', + from: 0, + size: 500, query: { bool: { must: [{ match: { tag1: tags[0] } }], @@ -48,7 +50,7 @@ export class ArtResolver { }, }); - if (!result.hits.hits.length) return null; + if (!result.hits.hits.length) return []; const artTags = result.hits.hits.map((el: any) => { return { @@ -56,8 +58,8 @@ 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, + is_soldout: el._source.is_soldout, thumbnail: el._source.thumbnail, tag1: el._source.tag1, nickname: el._source.nickname, @@ -78,7 +80,9 @@ export class ArtResolver { } const result = await this.elasticsearchService.search({ - index: 'artipul09', + index: 'artipul00', + from: 0, + size: 500, query: { bool: { must: [{ match: { tag1: tags[0] } }, { match: { tag2: tags[1] } }], @@ -86,7 +90,7 @@ export class ArtResolver { }, }); - if (!result.hits.hits.length) return null; + if (!result.hits.hits.length) return []; const artTags = result.hits.hits.map((el: any) => { return { @@ -94,8 +98,8 @@ 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, + is_soldout: el._source.is_soldout, thumbnail: el._source.thumbnail, tag1: el._source.tag1, tag2: el._source.tag2, @@ -117,7 +121,9 @@ export class ArtResolver { } const result = await this.elasticsearchService.search({ - index: 'artipul09', + index: 'artipul00', + from: 0, + size: 500, query: { bool: { must: [ @@ -129,7 +135,7 @@ export class ArtResolver { }, }); - if (!result.hits.hits.length) return null; + if (!result.hits.hits.length) return []; const artTags = result.hits.hits.map((el: any) => { return { @@ -137,8 +143,8 @@ 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, + is_soldout: el._source.is_soldout, thumbnail: el._source.thumbnail, tag1: el._source.tag1, tag2: el._source.tag2, @@ -161,7 +167,9 @@ export class ArtResolver { } const result = await this.elasticsearchService.search({ - index: 'artipul09', + index: 'artipul00', + from: 0, + size: 500, query: { bool: { must: [ @@ -174,7 +182,7 @@ export class ArtResolver { }, }); - if (!result.hits.hits.length) return null; + if (!result.hits.hits.length) return []; const artTags = result.hits.hits.map((el: any) => { return { @@ -182,8 +190,8 @@ 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, + 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 994db75..00aacb8 100644 --- a/ars/src/apis/art/art.service.ts +++ b/ars/src/apis/art/art.service.ts @@ -34,9 +34,7 @@ export class ArtService { tag2: tags[1], tag3: tags[2], tag4: tags[3], - createdAt: MoreThan(createdAt), }, - order: { createdAt: 'ASC' }, }); break; case 3: @@ -45,9 +43,7 @@ export class ArtService { tag1: tags[0], tag2: tags[1], tag3: tags[2], - createdAt: MoreThan(createdAt), }, - order: { createdAt: 'ASC' }, }); break; case 2: @@ -55,18 +51,14 @@ export class ArtService { where: { tag1: tags[0], tag2: tags[1], - createdAt: MoreThan(createdAt), }, - order: { createdAt: 'ASC' }, }); break; case 1: result = await this.artRepository.find({ where: { tag1: tags[0], - createdAt: MoreThan(createdAt), }, - order: { createdAt: 'ASC' }, }); } await queryRunner.commitTransaction(); @@ -105,7 +97,6 @@ export class ArtService { skip: 10 * (page - 1), where: { user: currentUser.id, deletedAt: Not(IsNull()) }, }); - console.log(art); return art; } @@ -134,7 +125,7 @@ export class ArtService { } // 작품 등록 - async create({ image_urls, tags, ...rest }, currentUser) { + async create({ thumbnail, tags, ...rest }, currentUser) { const queryRunner = this.connection.createQueryRunner(); await queryRunner.connect(); await queryRunner.startTransaction(); @@ -142,27 +133,27 @@ export class ArtService { const result = await queryRunner.manager.save(Art, { ...rest, user: currentUser, - thumbnail: image_urls[0], + thumbnail: thumbnail, tag1: tags[0], tag2: tags[1], tag3: tags[2], tag4: tags[3], }); - for (let i = 0; i < image_urls.length; i++) { - if (i === 0) { - await queryRunner.manager.save(ArtImage, { - url: image_urls[i], - isMain: true, - art: result, - }); - } else { - await queryRunner.manager.save(ArtImage, { - url: image_urls[i], - art: result, - }); - } - } + // for (let i = 0; i < image_urls.length; i++) { + // if (i === 0) { + // await queryRunner.manager.save(ArtImage, { + // url: image_urls[i], + // isMain: true, + // art: result, + // }); + // } else { + // await queryRunner.manager.save(ArtImage, { + // url: image_urls[i], + // art: result, + // }); + // } + // } await queryRunner.commitTransaction(); return result; } catch (error) { diff --git a/ars/src/apis/art/dto/createArtInput.ts b/ars/src/apis/art/dto/createArtInput.ts index 55ed12b..9db1173 100644 --- a/ars/src/apis/art/dto/createArtInput.ts +++ b/ars/src/apis/art/dto/createArtInput.ts @@ -17,27 +17,18 @@ export class CreateArtInput { @Field(() => Int) price: number; - @Field(() => Date) + @Field(() => Date, { nullable: true }) deadline: Date; - @Field(() => [String]) - image_urls: string[]; + // @Field(() => [String]) + // image_urls: string[]; + + @Field(() => String) + thumbnail: string; @Field(() => Boolean) is_soldout: boolean; @Field(() => [String]) tags: string[]; - - // @Field(() => String) - // tag1: string; - - // @Field(() => String, { nullable: true }) - // tag2?: string; - - // @Field(() => String, { nullable: true }) - // tag3?: 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 7ff338f..87b0acd 100644 --- a/ars/src/apis/art/entities/art.entity.ts +++ b/ars/src/apis/art/entities/art.entity.ts @@ -52,8 +52,8 @@ export class Art { deletedAt: Date; @Column() - @Field(() => Date) - deadline: Date; + @Field(() => String) + deadline: string; @Column({ default: false }) @Field(() => Boolean) diff --git a/ars/src/apis/art/entities/artsSearch.entity.ts b/ars/src/apis/art/entities/artsSearch.entity.ts index bff902b..a0d06fd 100644 --- a/ars/src/apis/art/entities/artsSearch.entity.ts +++ b/ars/src/apis/art/entities/artsSearch.entity.ts @@ -20,17 +20,17 @@ export class ArtsSearch { @Field(() => Int) instant_bid: number; - @Column({ default: null }) - @Field(() => Int) - price: number; - @Column() @Field(() => String) thumbnail: string; @Column() - @Field(() => Date) - deadline: Date; + @Field(() => String, { nullable: true }) + deadline: string; + + @Column({ default: false }) + @Field(() => Boolean) + is_soldout: boolean; @Column() @Field(() => String) diff --git a/ars/src/apis/art/entities/likeArt.entity.ts b/ars/src/apis/art/entities/likeArt.entity.ts index 33ffe8d..ee967ac 100644 --- a/ars/src/apis/art/entities/likeArt.entity.ts +++ b/ars/src/apis/art/entities/likeArt.entity.ts @@ -1,3 +1,4 @@ + import { Field, ObjectType } from '@nestjs/graphql'; import { User } from 'src/apis/user/entities/user.entity'; import { diff --git a/ars/src/apis/board/board.service.ts b/ars/src/apis/board/board.service.ts index 68b281c..81640fb 100644 --- a/ars/src/apis/board/board.service.ts +++ b/ars/src/apis/board/board.service.ts @@ -60,6 +60,7 @@ export class BoardService { const user = await queryRunner.manager.findOne(User, { id: currentUser.id, }); + const result = await queryRunner.manager.save(Board, { ...rest, user: user, diff --git a/ars/src/apis/board/entities/board.entity.ts b/ars/src/apis/board/entities/board.entity.ts index b8a74a5..5dd3333 100644 --- a/ars/src/apis/board/entities/board.entity.ts +++ b/ars/src/apis/board/entities/board.entity.ts @@ -31,7 +31,7 @@ export class Board { @Field(() => String) thumbnail: string; - @ManyToOne(() => User) + @ManyToOne(() => User, { eager: true }) @Field(() => User) user: User; } diff --git a/ars/src/apis/tag/entities/tag.entity.ts b/ars/src/apis/tag/entities/tag.entity.ts deleted file mode 100644 index 9ee49f1..0000000 --- a/ars/src/apis/tag/entities/tag.entity.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Field, Int, ObjectType } from '@nestjs/graphql'; -import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; - -@Entity() -@ObjectType() -export class Tag { - @PrimaryGeneratedColumn() - @Field(() => Int) - id: number; - - @Column() - @Field(() => String) - name: string; -} diff --git a/ars/src/common/graphql/schema.gql b/ars/src/common/graphql/schema.gql index 291b22d..4cc2639 100644 --- a/ars/src/common/graphql/schema.gql +++ b/ars/src/common/graphql/schema.gql @@ -50,7 +50,7 @@ type Art { thumbnail: String! createdAt: DateTime! deletedAt: DateTime! - deadline: DateTime! + deadline: String! is_soldout: Boolean! updatedAt: DateTime! user: User! @@ -101,9 +101,9 @@ type ArtsSearch { title: String! start_price: Int! instant_bid: Int! - price: Int! thumbnail: String! - deadline: DateTime! + deadline: String + is_soldout: Boolean! tag1: String! tag2: String tag3: String @@ -203,8 +203,8 @@ input CreateArtInput { start_price: Int! instant_bid: Int! price: Int! - deadline: DateTime! - image_urls: [String!]! + deadline: DateTime + thumbnail: String! is_soldout: Boolean! tags: [String!]! }