Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
26 changes: 0 additions & 26 deletions .eslintrc.js

This file was deleted.

7 changes: 0 additions & 7 deletions .prettierrc

This file was deleted.

4 changes: 0 additions & 4 deletions .vscode/settings.json

This file was deleted.

10 changes: 0 additions & 10 deletions Dockerfile

This file was deleted.

8 changes: 0 additions & 8 deletions nest-cli.json

This file was deleted.

92 changes: 0 additions & 92 deletions package.json

This file was deleted.

Empty file.
Empty file added src/apis/auth/auth.module.ts
Empty file.
Empty file added src/apis/auth/auth.resolver.ts
Empty file.
Empty file added src/apis/auth/auth.service.ts
Empty file.
19 changes: 19 additions & 0 deletions src/apis/shops/dto/create-shop.input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Field, InputType } from "@nestjs/graphql";

@InputType()
export class CreateShopInput {
@Field(() => String)
name: string;

@Field(() => String)
phone: string;

@Field(() => String)
openHour: string;

@Field(() => String)
closeHour: string;

@Field(() => String)
address: string;
}
5 changes: 5 additions & 0 deletions src/apis/shops/dto/update-shop.input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { InputType, PartialType } from "@nestjs/graphql";
import { CreateShopInput } from "./create-shop.input";

@InputType()
export class UpdateShopInput extends PartialType(CreateShopInput) {}
47 changes: 47 additions & 0 deletions src/apis/shops/entities/shop.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Field, ObjectType } from '@nestjs/graphql';
import {
Column,
DeleteDateColumn,
Entity,
OneToMany,
PrimaryGeneratedColumn,
} from 'typeorm';

@Entity()
@ObjectType()
export class Shop {
@PrimaryGeneratedColumn('uuid')
@Field(() => String)
id: string;

@Column({ length: 10 })
@Field(() => String)
name: string;

@Column({ length: 13 })
@Field(() => String)
phone: string;

@Column()
@Field(() => String)
openHour: string;

@Column()
@Field(() => String)
closeHour: string;

@Column({ length: 100 })
@Field(() => String)
address: string;

@DeleteDateColumn({ nullable: true })
@Field(() => Date)
deleteAt?: Date;

// // 가게(own):예약 = 1:N
// @OneToMany(() => Reservation, (reservation) => reservation.id, {
// nullable: true,
// })
// @Field(() => [Reservation])
// reservation?: Reservation[];
}
28 changes: 28 additions & 0 deletions src/apis/shops/interface/shops-service.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { CreateShopInput } from '../dto/create-shop.input';
import { UpdateShopInput } from '../dto/update-shop.input';

export interface IShopsServiceCreate {
phone: string;
createShopInput: CreateShopInput;
}

export interface IShopsServiceFindOne {
shopId: string;
}

export interface IShopsServiceFindOneByPhone {
phone: string;
}

export interface IShopsServiceUpdate {
shopId: string;
updateShopInput: UpdateShopInput;
}

export interface IShopsServiceDelete {
shopId: string;
}

export interface IShopsServiceRestore {
shopId: string;
}
18 changes: 18 additions & 0 deletions src/apis/shops/shops.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Module } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { Shop } from "./entities/shop.entity";
import { ShopsResolver } from "./shops.resolver";
import { ShopsService } from "./shops.service";

@Module({
imports: [
TypeOrmModule.forFeature([
Shop, //
]),
],
providers: [
ShopsResolver, //
ShopsService,
],
})
export class ShopsModule {}
66 changes: 66 additions & 0 deletions src/apis/shops/shops.resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Args, Mutation, Resolver, Query } from '@nestjs/graphql';
import { CreateShopInput } from './dto/create-shop.input';
import { UpdateShopInput } from './dto/update-shop.input';
import { Shop } from './entities/shop.entity';
import { ShopsService } from './shops.service';

@Resolver()
export class ShopsResolver {
constructor(
private readonly shopsService: ShopsService, //
) {}

@Query(() => [Shop])
fetchShops(): Promise<Shop[]> {
return this.shopsService.findAll();
}

@Query(() => Shop)
fetchShop(
@Args('shopId') shopId: string, //
): Promise<Shop> {
return this.shopsService.findOne({ shopId });
}

@Query(() => [Shop])
fetchShopsWithDeleted(): Promise<Shop[]> {
return this.shopsService.findAllDeleted();
}

@Query(() => Shop)
fetchShopWithDeleted(
@Args('shopId') shopId: string, //
): Promise<Shop> {
return this.shopsService.findOneDeleted({ shopId });
}

@Mutation(() => Shop)
createShop(
@Args('createShopInput') createShopInput: CreateShopInput,
): Promise<Shop> {
const phone = createShopInput.phone;
return this.shopsService.create({ phone, createShopInput });
}

@Mutation(() => Shop)
async updateShop(
@Args('shopId') shopId: string,
@Args('updateShopInput') updateShopInput: UpdateShopInput,
): Promise<Shop> {
return this.shopsService.update({ shopId, updateShopInput });
}

@Mutation(() => Boolean)
deleteShop(
@Args('shopId') shopId: string, //
): Promise<boolean> {
return this.shopsService.delete({ shopId });
}

@Mutation(() => Boolean)
restoreShop(
@Args('shopId') shopId: string, //
): Promise<boolean> {
return this.shopsService.restore({ shopId });
}
}
Loading