-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into be/feature/get_my_rank
- Loading branch information
Showing
13 changed files
with
259 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export interface CropPrice { | ||
crop: string; | ||
crop: number; | ||
price: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,52 @@ | ||
import { Body, Controller, Get, Param, Post } from '@nestjs/common'; | ||
import { Body, Controller, Get, Post, Query } from '@nestjs/common'; | ||
import { OrderService } from './order.service'; | ||
import { OrderBookService } from './orderBook.service'; | ||
import { OrderBookDto } from './dto/orderBook.dto'; | ||
import DtoTransformer from './utils/dtoTransformer'; | ||
import { LimitOrderDto } from './dto/limitOrder.dto'; | ||
import { ApiOperation, ApiResponse } from '@nestjs/swagger'; | ||
import { ApiOperation } from '@nestjs/swagger'; | ||
import { MatchingService } from './matching.service'; | ||
import { successhandler, successMessage } from '../global/successhandler'; | ||
|
||
@Controller('api/order') | ||
export class OrderController { | ||
constructor( | ||
private readonly orderService: OrderService, | ||
private readonly orderBookService: OrderBookService | ||
private readonly orderBookService: OrderBookService, | ||
private readonly machineService: MatchingService | ||
) {} | ||
|
||
@Post('buy') | ||
@Post('buy/limit') | ||
@ApiOperation({ summary: '구매 주문 생성' }) | ||
@ApiResponse({ status: 200, description: '구매 주문이 성공적으로 생성되었습니다.' }) | ||
async createBuyOrder(@Body() limitOrderDto: LimitOrderDto): Promise<string> { | ||
async createBuyOrder(@Body() limitOrderDto: LimitOrderDto) { | ||
const orderDto = DtoTransformer.toOrderDto(limitOrderDto); | ||
const orderId = await this.orderService.saveOrder(orderDto); | ||
|
||
await this.orderService.saveOrderToOrderBook(orderDto, orderId); | ||
return '구매 주문이 성공적으로 생성되었습니다.'; | ||
await this.orderService.saveOrder(orderDto); | ||
await this.machineService.matchOrders(limitOrderDto.cropId); | ||
return successhandler(successMessage.CREATE_ORDER_SUCCESS); | ||
} | ||
|
||
@Post('sell') | ||
@Post('sell/limit') | ||
@ApiOperation({ summary: '판매 주문 생성' }) | ||
@ApiResponse({ status: 200, description: '판매 주문이 성공적으로 생성되었습니다.' }) | ||
async createSellOrder(@Body() limitOrderDto: LimitOrderDto): Promise<string> { | ||
async createSellOrder(@Body() limitOrderDto: LimitOrderDto) { | ||
const orderDto = DtoTransformer.toOrderDto(limitOrderDto); | ||
const orderId = await this.orderService.saveOrder(orderDto); | ||
|
||
await this.orderService.saveOrderToOrderBook(orderDto, orderId); | ||
return '판매 주문이 성공적으로 생성되었습니다.'; | ||
} | ||
|
||
@Get('buy/:cropId') | ||
async getBuyOrders(@Param('cropId') cropId: number): Promise<OrderBookDto[]> { | ||
return await this.orderBookService.getBuyOrders(cropId); | ||
await this.orderService.saveOrder(orderDto); | ||
await this.machineService.matchOrders(limitOrderDto.cropId); | ||
return successhandler(successMessage.CREATE_ORDER_SUCCESS); | ||
} | ||
|
||
@Get('sell/:cropId') | ||
async getSellOrders(@Param('cropId') cropId: number): Promise<OrderBookDto[]> { | ||
return await this.orderBookService.getSellOrders(cropId); | ||
@Get('') | ||
@ApiOperation({ summary: '각 회원 체결 내역 조회' }) | ||
async getTransactionsByMemberId(@Query('memberId') memberId: number) { | ||
const transactions = await this.orderBookService.getTransactionsByMemberId(memberId); | ||
return successhandler(successMessage.GET_TRANSACTION_SUCCESS, transactions); | ||
} | ||
|
||
@Post('cancel') | ||
@ApiOperation({ summary: '주문 취소' }) | ||
async cancelOrder( | ||
@Body() | ||
{ cropId, orderId, orderType }: { cropId: number; orderId: number; orderType: 'buy' | 'sell' } | ||
): Promise<string> { | ||
) { | ||
await this.orderBookService.removeOrder(cropId, orderId, orderType); | ||
return '주문이 성공적으로 취소되었습니다.'; | ||
return successhandler(successMessage.DELETE_ORDER_SUCCESS); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.