Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#110
Browse files Browse the repository at this point in the history
  • Loading branch information
Daseul1 authored Apr 1, 2022
2 parents 080784c + 6eae714 commit dc7bdd6
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 25 deletions.
5 changes: 1 addition & 4 deletions ars/docker-compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ version: '3.3'

services:
my_backend:
platform: linux/x86_64
image: asia.gcr.io/artiful-a1/my_backend:1.9
build:
context: .
dockerfile: Dockerfile
env_file:
- ./.env.dev
ports:
- 3000:3000
volumes:
- ./src:/myfolder/src
- ./.env:/myfolder/.env

my_database:
platform: linux/x86_64
Expand Down
5 changes: 3 additions & 2 deletions ars/src/apis/art/art.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class ArtResolver {
});
return artTags;
}
}


@Query(() => Art)
async fetchArt(@Args('artId') artId: string) {
Expand All @@ -210,6 +210,7 @@ export class ArtResolver {
async fetchArtImages(@Args('artId') artId: string) {
return await this.artService.findImages({ artId });
}

///////////////////////////////////////////////////////////////////////////
@UseGuards(GqlAuthAccessGuard)
@Query(() => Number)
Expand Down Expand Up @@ -316,7 +317,7 @@ export class ArtResolver {
@UseGuards(GqlAuthAccessGuard)
@Query(() => [Art])
async fetchLikeArt(
@Args('page') page: number,
@Args('page', { nullable: true }) page: number,
@CurrentUser() currentUser: ICurrentUser,
) {
return await this.likeArtService.find(currentUser.id, page);
Expand Down
7 changes: 4 additions & 3 deletions ars/src/apis/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class AuthService {
{ email: user.email, sub: user.id },
{ secret: process.env.REFRESH_TOKEN_KEY, expiresIn: '8h' },
);
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000');
res.setHeader('Access-Control-Allow-Origin', 'https://artipul.shop');
res.setHeader(
'Set-Cookie',
`refreshToken=${refreshToken}; path=/; domain=.daseul.shop; SameSite=None; Secure;httpOnly;`,
Expand All @@ -38,10 +38,11 @@ export class AuthService {
const createUser = { ...rest, password: hashedPassword };
user = await this.userService.create({ ...createUser });
this.setRefreshToken({ user, res });
res.redirect('http://localhost:3000/socialLogin');
res.redirect('https://artipul.shop/socialLogin');
} else {
this.setRefreshToken({ user, res });
res.redirect('http://localhost:3000');
res.redirect('https://artipul.shop/');
res.send(user);
}
}
}
16 changes: 11 additions & 5 deletions ars/src/apis/likeArt/likeArt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ export class LikeArtService {
) {}

async find(userId, page) {
const arts = await this.likeArtRepository.find({
take: 10,
skip: 10 * (page - 1),
where: { userId: userId },
});
let arts = [];
if (page) {
arts = await this.likeArtRepository.find({
take: 10,
skip: 10 * (page - 1),
where: { userId: userId },
});
} else {
arts = await this.likeArtRepository.find({ userId });
}

return arts.map((ele) => ele.art);
}

Expand Down
6 changes: 3 additions & 3 deletions ars/src/apis/payment/payment.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export class PaymentResolver {
const arts = await this.paymentService.checkTimeout();
arts.map(async (e) => {
const bidInfo = await this.cacheManager.get(e.id);
const price = bidInfo[0];
const bidder = await this.userService.findOne(bidInfo[1]);
if (price) {
if (bidInfo) {
const price = bidInfo[0];
const bidder = await this.userService.findOne(bidInfo[1]);
await this.paymentService.successfulBid(e.id, price, bidder, e.user);
} else {
await this.paymentService.failedBid(e.id);
Expand Down
15 changes: 8 additions & 7 deletions ars/src/apis/payment/payment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ export class PaymentService {

// 마감된 작품 체크
async checkTimeout() {
const time = new Date();
const yyyy = time.getFullYear();
const mm = time.getMonth() + 1;
const dd = time.getDate();
const currentTime = `${yyyy}-${mm}-${dd}`;

const utc = new Date();
const KR_TIME_DIFF = 9 * 60 * 60 * 1000;
const currentTime = new Date(Number(utc) + Number(KR_TIME_DIFF));
console.log(currentTime, ' 현 재 시 간 ');
return await this.artRepository.find({
where: {
Expand Down Expand Up @@ -104,7 +101,11 @@ export class PaymentService {
// 입찰
async call(artId, bid_price, email) {
const art = await this.artRepository.findOne(artId);
const time = Number(art.deadline) - Number(new Date());

const utc = new Date();
const KR_TIME_DIFF = 9 * 60 * 60 * 1000;
const currentTime = new Date(Number(utc) + Number(KR_TIME_DIFF));
const time = Number(art.deadline) - Number(currentTime);
if (time > 0) {
await this.cacheManager.set(artId, [bid_price, email], {
ttl: time + 60000,
Expand Down
5 changes: 5 additions & 0 deletions ars/src/apis/user/user.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export class UserResolver {
return await this.userService.findUserEmail({ phoneNum });
}

@Query(() => String)
async findSocialUser(@Args('email') email: string) {
const user = await this.userService.findOne(email);
}

@Mutation(() => User)
async createUser(@Args('createUserInput') createUserInput: CreateUserInput) {
const { password, ...rest } = createUserInput;
Expand Down
3 changes: 2 additions & 1 deletion ars/src/common/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ type Query {
fetchTransactionCompletedArts(page: Float!): [Art!]!
fetchEngaging(page: Float!): [Engage!]!
fetchArtistWorks(artId: String!): [Art!]!
fetchLikeArt(page: Float!): [Art!]!
fetchLikeArt(page: Float): [Art!]!
fetchBoard(boardId: String!): Board!
fetchBoardImgaes(boardId: String!): [BoardImage!]!
fetchBoards: [Board!]!
Expand All @@ -163,6 +163,7 @@ type Query {
fetchArtistProfile(artId: String!): Profile!
fetchUser: User!
findUserEmail(phoneNum: String!): String!
findSocialUser(email: String!): String!
fetchPointTransactions: [PointTransaction!]!
}

Expand Down

0 comments on commit dc7bdd6

Please sign in to comment.