Skip to content

Commit

Permalink
fix: be conflict fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SeungGwan123 committed Nov 21, 2024
1 parent 5f2df42 commit 33cd907
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/corinee-server -f ./dockerfile-server .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/corinee-server
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/corinee-client -f ./dockerfile-client .
docker build --build-arg VITE_API_BASE_URL=${{ secrets.VITE_API_BASE_URL }} -t ${{ secrets.DOCKERHUB_USERNAME }}/corinee-client -f ./dockerfile-client .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/corinee-client
- name: make deploy environment
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/api/instance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';

export const instance = axios.create({
baseURL: !import.meta.env.VITE_API_BASE_URL ? '' : import.meta.env.VITE_API_BASE_URL,
baseURL: import.meta.env.VITE_API_BASE_URL,
withCredentials: true,
timeout: 2000,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/hooks/SSE/useSSEOrderbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SSEOrderBook } from '@/types/orderbook';
import { useRef, useState, useEffect } from 'react';

export function useSSEOrderbook(targetMarketCodes: { market: string }[]) {
const BASE_URL = `${!import.meta.env.VITE_API_BASE_URL ? '' : import.meta.env.VITE_API_BASE_URL}/api/upbit/orderbook`;
const BASE_URL = `${import.meta.env.VITE_API_BASE_URL}/upbit/orderbook`;
const eventSource = useRef<EventSource | null>(null);
const [isConnected, setIsConnected] = useState<boolean>(false);
const [sseData, setSSEData] = useState<SSEOrderBook | null>();
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/hooks/SSE/useSSETicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SSEDataType } from '@/types/ticker';
import { useEffect, useRef, useState } from 'react';

export function useSSETicker(targetMarketCodes: { market: string }[]) {
const BASE_URL = `${!import.meta.env.VITE_API_BASE_URL ? '' : import.meta.env.VITE_API_BASE_URL}/api/upbit/price-updates`;
const BASE_URL = `${import.meta.env.VITE_API_BASE_URL}/upbit/price-updates`;
const eventSource = useRef<EventSource | null>(null);
const [isConnected, setIsConnected] = useState<boolean>(false);
const [sseData, setSSEData] = useState<SSEDataType | null>();
Expand Down
8 changes: 0 additions & 8 deletions packages/server/src/asset/asset.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ export class AssetRepository extends Repository<Asset> {
console.log(e);
}
}
<<<<<<< HEAD
async updateAssetQuantityPrice(asset, queryRunner) {
=======
async updateAsset(asset, queryRunner) {
>>>>>>> 55132d7 (feat: 매도 로직 작성)
try {
await queryRunner.manager
.createQueryBuilder()
Expand Down Expand Up @@ -56,14 +52,10 @@ export class AssetRepository extends Repository<Asset> {
await queryRunner.manager
.createQueryBuilder()
.update(Asset)
<<<<<<< HEAD
.set({
price: asset.price,
quantity: asset.quantity
})
=======
.set({ price: asset.price })
>>>>>>> 55132d7 (feat: 매도 로직 작성)
.where('assetId = :assetId', { assetId: asset.assetId })
.execute();
} catch (e) {
Expand Down
80 changes: 0 additions & 80 deletions packages/server/src/trade/trade-ask.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export class AskService implements OnModuleInit {
}

async calculatePercentBuy(user, moneyType: string, percent: number) {
<<<<<<< HEAD
const account = await this.accountRepository.findOne({
where : {user: {id: user.userId}}
})
Expand All @@ -51,24 +50,6 @@ export class AskService implements OnModuleInit {
if(askDto.receivedAmount * askDto.receivedPrice < 5000) throw new BadRequestException();
if (this.transactionCreateAsk) await this.waitForTransactionCreate();
this.transactionCreateAsk = true;
=======
const asset = await this.assetRepository.findOne({
where:{
account: {id: user.userId},
assetName: moneyType
}
})

return Number(asset.quantity) * (percent / 100);
}
async createAskTrade(user, askDto) {
if (this.transactionCreateAsk) await this.waitForTransactionCreate();
this.transactionCreateAsk = true;
// const temp = await this.assetRepository.findOne({
// where: {assetId: 1}
// })
// console.log(temp.quantity)
>>>>>>> 55132d7 (feat: 매도 로직 작성)
const queryRunner = this.dataSource.createQueryRunner();
await queryRunner.connect();
await queryRunner.startTransaction('READ COMMITTED');
Expand All @@ -85,7 +66,6 @@ export class AskService implements OnModuleInit {
statusCode: 422,
});
}
<<<<<<< HEAD
const userAsset = await this.checkCurrency(askDto, userAccount, queryRunner)
const assetBalance = userAsset.quantity - askDto.receivedAmount;
if(assetBalance <= 0){
Expand All @@ -100,26 +80,6 @@ export class AskService implements OnModuleInit {
await this.tradeRepository.createTrade(askDto, user.userId,'sell', queryRunner);
await queryRunner.commitTransaction();

=======
const userAsset = await this.checkCurrency(user, askDto, queryRunner);
userAsset.quantity -= askDto.receivedAmount
if(userAsset.quantity !==0){
await this.assetRepository.updateAssetQuantity(
userAsset,
queryRunner,
)
}else {
await this.assetRepository.delete({
assetId: userAsset.assetId
})
}
await this.tradeRepository.createTrade(askDto, user.userId,'sell', queryRunner);
await queryRunner.commitTransaction();
const temp = await this.assetRepository.findOne({
where: {assetId: userAsset.assetId}
})
console.log(temp.quantity)
>>>>>>> 55132d7 (feat: 매도 로직 작성)
return {
statusCode: 200,
message: '거래가 정상적으로 등록되었습니다.',
Expand All @@ -137,15 +97,9 @@ export class AskService implements OnModuleInit {
this.transactionCreateAsk = false;
}
}
<<<<<<< HEAD
async checkCurrency(askDto,account,queryRunner) {
const { typeGiven, receivedAmount } = askDto;
const userAsset = await this.assetRepository.getAsset(account.id,typeGiven,queryRunner)
=======
async checkCurrency(user, askDto,queryRunner) {
const { typeGiven, receivedAmount } = askDto;
const userAsset = await this.assetRepository.getAsset(user.userId, typeGiven,queryRunner)
>>>>>>> 55132d7 (feat: 매도 로직 작성)
if(!userAsset){
throw new UnprocessableEntityException({
message: '자산이 부족합니다.',
Expand All @@ -171,7 +125,6 @@ export class AskService implements OnModuleInit {
userId,
} = askDto;
try {
<<<<<<< HEAD
const account = await this.accountRepository.findOne({
where: { user : { id : userId } }
})
Expand All @@ -185,16 +138,6 @@ export class AskService implements OnModuleInit {
askDto.assetBalance = userAsset.quantity;
askDto.asset = userAsset;
}
=======
const userAsset = await this.assetRepository.findOne({
where: {
account: { id: userId },
assetName: typeGiven
},
});
askDto.assetBalance = userAsset.quantity;
askDto.asset = userAsset;
>>>>>>> 55132d7 (feat: 매도 로직 작성)
const currentCoinOrderbook =
this.coinDataUpdaterService.getCoinOrderbookByAsk(askDto);
for (const order of currentCoinOrderbook) {
Expand Down Expand Up @@ -228,19 +171,12 @@ export class AskService implements OnModuleInit {
asset,
typeGiven,
typeReceived,
<<<<<<< HEAD
krw
=======
tradeId,
asset,
assetBalance
>>>>>>> 55132d7 (feat: 매도 로직 작성)
} = askDto;
let result = false;
try {
const buyData = { ...tradeData };
buyData.quantity =
<<<<<<< HEAD
tradeData.quantity >= bid_size ? bid_size.toFixed(8) : tradeData.quantity.toFixed(8)
buyData.price = (bid_price * krw).toFixed(8);
if(buyData.quantity<0.00000001){
Expand All @@ -249,28 +185,16 @@ export class AskService implements OnModuleInit {
}
const user = await this.userRepository.getUser(userId);

=======
tradeData.quantity >= bid_size ? bid_size : tradeData.quantity;
buyData.price = bid_price;
>>>>>>> 55132d7 (feat: 매도 로직 작성)
await this.tradeHistoryRepository.createTradeHistory(
user,
buyData,
queryRunner,
);

<<<<<<< HEAD
if (!asset && tradeData.price > buyData.price) {
asset.price = Math.floor(asset.price + (tradeData.price - buyData.price) * buyData.quantity);

await this.assetRepository.updateAssetPrice(asset, queryRunner);
=======
if (assetBalance !== 0) {
asset.price =
asset.price * asset.quantity - buyData.price * buyData.quantity;
await this.assetRepository.updateAssetPrice(asset, queryRunner);

>>>>>>> 55132d7 (feat: 매도 로직 작성)
}

const account = await this.accountRepository.findOne({
Expand All @@ -294,11 +218,7 @@ export class AskService implements OnModuleInit {
tradeData,
queryRunner,
);
<<<<<<< HEAD
}
=======

>>>>>>> 55132d7 (feat: 매도 로직 작성)
await queryRunner.commitTransaction();
result = true;
} catch (error) {
Expand Down
6 changes: 0 additions & 6 deletions packages/server/src/trade/trade.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ import { AuthGuard } from 'src/auth/auth.guard';
import { ApiBearerAuth, ApiSecurity, ApiBody } from '@nestjs/swagger';
import { AskService } from './trade-ask.service';
import { TradeDto } from './dtos/trade.dto';
<<<<<<< HEAD
import { TradeService } from './trade.service';
import {Response} from "express";
=======
>>>>>>> 55132d7 (feat: 매도 로직 작성)

@Controller('trade')
export class TradeController {
Expand Down Expand Up @@ -96,7 +93,6 @@ export class TradeController {
) {
return this.askService.calculatePercentBuy(req.user, moneyType, percent);
}
<<<<<<< HEAD

@ApiBearerAuth('access-token')
@ApiSecurity('access-token')
Expand All @@ -123,6 +119,4 @@ export class TradeController {
const response = await this.tradeService.getMyTradeData(req.user, coin)
return res.status(response.statusCode).json(response)
}
=======
>>>>>>> 55132d7 (feat: 매도 로직 작성)
}

0 comments on commit 33cd907

Please sign in to comment.