Skip to content

Commit

Permalink
Merge pull request #119 from Daseul1/feat/#118
Browse files Browse the repository at this point in the history
[#118]feat: 엔티티수정, art 수정, createBoard 수정
  • Loading branch information
Daseul1 committed Apr 2, 2022
2 parents 1aea584 + 759fa45 commit 535380f
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 69 deletions.
4 changes: 2 additions & 2 deletions ars/elk/logstash/logstash.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ input {
last_run_metadata_path => "./aaa.txt"

tracking_column_type => "numeric"
statement => "select art.id, title, start_price, instant_bid, 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"
}
}
21 changes: 12 additions & 9 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',
from: 0,
size: 500,
query: {
Expand All @@ -50,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 {
Expand All @@ -59,6 +59,7 @@ export class ArtResolver {
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
deadline: el._source.deadline,
is_soldout: el._source.is_soldout,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
nickname: el._source.nickname,
Expand All @@ -79,7 +80,7 @@ export class ArtResolver {
}

const result = await this.elasticsearchService.search({
index: 'artipul09',
index: 'artipul00',
from: 0,
size: 500,
query: {
Expand All @@ -89,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 {
Expand All @@ -98,6 +99,7 @@ export class ArtResolver {
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
deadline: el._source.deadline,
is_soldout: el._source.is_soldout,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
tag2: el._source.tag2,
Expand All @@ -119,7 +121,7 @@ export class ArtResolver {
}

const result = await this.elasticsearchService.search({
index: 'artipul09',
index: 'artipul00',
from: 0,
size: 500,
query: {
Expand All @@ -133,16 +135,16 @@ export class ArtResolver {
},
});

if (!result.hits.hits.length) return null;
if (!result.hits.hits.length) return [];

const artTags = result.hits.hits.map((el: any) => {
console.log('=======', el);
return {
id: el._source.id,
title: el._source.title,
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
deadline: el._source.deadline,
is_soldout: el._source.is_soldout,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
tag2: el._source.tag2,
Expand All @@ -165,7 +167,7 @@ export class ArtResolver {
}

const result = await this.elasticsearchService.search({
index: 'artipul09',
index: 'artipul00',
from: 0,
size: 500,
query: {
Expand All @@ -180,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 {
Expand All @@ -189,6 +191,7 @@ export class ArtResolver {
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
deadline: el._source.deadline,
is_soldout: el._source.is_soldout,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
tag2: el._source.tag2,
Expand Down
33 changes: 16 additions & 17 deletions ars/src/apis/art/art.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export class ArtService {
skip: 10 * (page - 1),
where: { user: currentUser.id, deletedAt: Not(IsNull()) },
});
console.log(art);
return art;
}

Expand Down Expand Up @@ -126,35 +125,35 @@ 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();
try {
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) {
Expand Down
7 changes: 5 additions & 2 deletions ars/src/apis/art/dto/createArtInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ export class CreateArtInput {
@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;
Expand Down
4 changes: 2 additions & 2 deletions ars/src/apis/art/entities/art.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class Art {
deletedAt: Date;

@Column()
@Field(() => Date)
deadline: Date;
@Field(() => String)
deadline: string;

@Column({ default: false })
@Field(() => Boolean)
Expand Down
8 changes: 4 additions & 4 deletions ars/src/apis/art/entities/artsSearch.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ export class ArtsSearch {
@Field(() => Int)
instant_bid: number;

@Column({ default: null })
@Field(() => Int)
price: number;

@Column()
@Field(() => String)
thumbnail: string;
Expand All @@ -32,6 +28,10 @@ export class ArtsSearch {
@Field(() => String, { nullable: true })
deadline: string;

@Column({ default: false })
@Field(() => Boolean)
is_soldout: boolean;

@Column()
@Field(() => String)
tag1: string;
Expand Down
9 changes: 1 addition & 8 deletions ars/src/apis/art/entities/likeArt.entity.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { ObjectType } from '@nestjs/graphql';
import { User } from 'src/apis/user/entities/user.entity';
import {
Column,
Entity,
ManyToOne,
PrimaryColumn,
PrimaryGeneratedColumn,
} from 'typeorm';
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { Art } from './art.entity';

@Entity()
Expand Down
6 changes: 0 additions & 6 deletions ars/src/apis/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,17 @@ export class AuthService {

async loginOAuth(req, res) {
let email = req.user.email;
console.log(email + '****************!!');
let user = await this.userService.findOne(email);
console.log('LLLLLLOOOOOO !' + user);
if (!user) {
const { password, ...rest } = req.user;
const hashedPassword = await bcrypt.hash(String(password), 1);
const createUser = { ...rest, password: hashedPassword };
user = await this.userService.create({ ...createUser });
this.setRefreshToken({ user, res });
console.log('user created !!!');
res.redirect('https://artipul.shop/socialLogin');
return user;
} else {
this.setRefreshToken({ user, res });
res.redirect('https://artipul.shop/');
res.send(user);
return user;
}
}
}
7 changes: 6 additions & 1 deletion ars/src/apis/board/board.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { InjectRepository } from '@nestjs/typeorm';
import { Connection, Repository } from 'typeorm';
import { BoardImage } from '../boardImage/entities/boardImage.entity';
import { Comment } from '../comment/entities/comment.entity';
import { User } from '../user/entities/user.entity';
import { Board } from './entities/board.entity';

@Injectable()
Expand Down Expand Up @@ -56,9 +57,13 @@ export class BoardService {
await queryRunner.connect();
await queryRunner.startTransaction();
try {
const user = await queryRunner.manager.findOne(User, {
id: currentUser.id,
});

const result = await queryRunner.manager.save(Board, {
...rest,
user: currentUser,
user: user,
thumbnail: image_urls[0],
});

Expand Down
2 changes: 1 addition & 1 deletion ars/src/apis/board/entities/board.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Board {
@Field(() => String)
thumbnail: string;

@ManyToOne(() => User)
@ManyToOne(() => User, { eager: true })
@Field(() => User)
user: User;
}
14 changes: 0 additions & 14 deletions ars/src/apis/tag/entities/tag.entity.ts

This file was deleted.

6 changes: 3 additions & 3 deletions ars/src/common/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type Art {
thumbnail: String!
createdAt: DateTime!
deletedAt: DateTime!
deadline: DateTime!
deadline: String!
is_soldout: Boolean!
updatedAt: DateTime!
user: User!
Expand Down Expand Up @@ -101,9 +101,9 @@ type ArtsSearch {
title: String!
start_price: Int!
instant_bid: Int!
price: Int!
thumbnail: String!
deadline: String
is_soldout: Boolean!
tag1: String!
tag2: String
tag3: String
Expand Down Expand Up @@ -204,7 +204,7 @@ input CreateArtInput {
instant_bid: Int!
price: Int!
deadline: DateTime
image_urls: [String!]!
thumbnail: String!
is_soldout: Boolean!
tags: [String!]!
}
Expand Down

0 comments on commit 535380f

Please sign in to comment.