Skip to content

Commit

Permalink
[#87]feat: 작가id로 작품검색
Browse files Browse the repository at this point in the history
  • Loading branch information
Arios67 committed Mar 30, 2022
1 parent e28b6b3 commit b00f646
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 16 deletions.
3 changes: 2 additions & 1 deletion ars/src/apis/art/art.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ export class ArtResolver {

// 미대생 마감된 작품 조회
@UseGuards(GqlAuthAccessGuard)
@Query(() => Art)
async fetchTimedOutArt(@CurrentUser() currentUser: ICurrentUser) {
return await this.artService.fetchTimedOutArt(currentUser);
}

// 일반유저(내가) 구매한 작품 조회
@UseGuards(GqlAuthAccessGuard)
@Query(() => [Art])
async fetchtransactioncompletedArts(
async fetchTransactionCompletedArts(
@CurrentUser() currentUser: ICurrentUser,
) {
return await this.artService.findcompleteAuction({ currentUser });
Expand Down
16 changes: 15 additions & 1 deletion ars/src/apis/art/art.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,25 @@ export class ArtService {
async fetchTimedOutArt(currentUser) {
const art = await this.artRepository.find({
withDeleted: true,
where: { user: currentUser.id, deletedAt: Not(null) },
where: { user: currentUser.id, deletedAt: Not('null') },
});
console.log(art);
return art;
}

// 작품Id로 해당 작가 모든 작품검색
async findArtistWorks(artId) {
const art = await this.artRepository.findOne({
withDeleted: true,
where: { id: artId },
});
const user = art.user;
return await this.artRepository.find({
withDeleted: true,
where: { user: user },
});
}

// 일반유저(내가) 구매한 작품 조회
async findcompleteAuction({ currentUser }) {
const art = await this.artRepository.find({
Expand Down
6 changes: 6 additions & 0 deletions ars/src/apis/user/user.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ArtService } from '../art/art.service';
import { Art } from '../art/entities/art.entity';
import { ArtImage } from '../artImage/entities/artImage.entity';
import { Profile } from '../profile/entities/profile.entity';
import { User } from './entities/user.entity';
import { UserResolver } from './user.resolver';
Expand All @@ -10,11 +13,14 @@ import { UserService } from './user.service';
TypeOrmModule.forFeature([
User, //
Profile,
Art,
ArtImage,
]),
],
providers: [
UserResolver, //
UserService,
ArtService,
],
})
export class UserModule {}
12 changes: 11 additions & 1 deletion ars/src/apis/user/user.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import * as bcrypt from 'bcrypt';
import { UseGuards } from '@nestjs/common';
import { GqlAuthAccessGuard } from 'src/common/auth/gql-auth.guard';
import { CurrentUser, ICurrentUser } from 'src/common/auth/gql-user.param';
import { Art } from '../art/entities/art.entity';
import { ArtService } from '../art/art.service';

@Resolver()
export class UserResolver {
constructor(private readonly userService: UserService) {}
constructor(
private readonly userService: UserService,
private readonly artService: ArtService,
) {}

@UseGuards(GqlAuthAccessGuard)
@Query(() => User)
Expand All @@ -22,6 +27,11 @@ export class UserResolver {
return await this.userService.findUserEmail({ phoneNum });
}

@Query(() => [Art])
async fetchArtistWorks(@Args('artId') artId: string) {
return await this.artService.findArtistWorks(artId);
}

@Mutation(() => User)
async createUser(@Args('createUserInput') createUserInput: CreateUserInput) {
const { password, ...rest } = createUserInput;
Expand Down
28 changes: 15 additions & 13 deletions ars/src/common/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
# THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
# ------------------------------------------------------

type Profile {
id: String!
url: String
introduce: String
address: String
user: User!
}

type User {
id: String!
name: String!
Expand All @@ -15,18 +23,6 @@ type User {
profile: Profile
}

type Profile {
id: String!
url: String
introduce: String
address: String
user: User!
}

type Token {
accessToken: String!
}

type Payment {
id: String!
createdAt: DateTime!
Expand Down Expand Up @@ -67,6 +63,10 @@ type ArtImage {
art: Art!
}

type Token {
accessToken: String!
}

type PointTransaction {
id: String!
impUid: String!
Expand Down Expand Up @@ -123,7 +123,8 @@ type Query {
fetchArt(artId: String!): Art!
fetchArtImages(artId: String!): [ArtImage!]!
fetchAuctionArts: [Art!]!
fetchtransactioncompletedArts: [Art!]!
fetchTimedOutArt: Art!
fetchTransactionCompletedArts: [Art!]!
fetchLikeArt: [Art!]!
fetchBoard(boardId: String!): Board!
fetchBoardImgaes(boardId: String!): [BoardImage!]!
Expand All @@ -137,6 +138,7 @@ type Query {
fetchArtistProfile(artId: String!): Profile!
fetchUser: User!
findUserEmail(phoneNum: String!): String!
fetchArtistWorks(artId: String!): [Art!]!
fetchPurchaseList: Payment!
fetchEngaging: [Engage!]!
fetchPointTransactions: [PointTransaction!]!
Expand Down

0 comments on commit b00f646

Please sign in to comment.