|
|
|
|
@ -164,19 +164,19 @@ public class ToBuysService { |
|
|
|
|
return toBuysRepository.deleteByUserIdAndTobuyId(userId, tobuyId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Stocks buyToBuys(String username, ToBuysBuyDTO dto) { |
|
|
|
|
public Stocks buyToBuys(String username, ToBuysDTO dto) { |
|
|
|
|
// ユーザー情報を取得
|
|
|
|
|
User user = getUserByUsername(username); |
|
|
|
|
// 新しい在庫を作成
|
|
|
|
|
Stocks stock = new Stocks(); |
|
|
|
|
stock.setStuffs(dto.getStuff_id()); |
|
|
|
|
stock.setStuff_id(dto.getStuff_id()); |
|
|
|
|
stock.setUser_id(user); |
|
|
|
|
stock.setAmount(dto.getAmount()); |
|
|
|
|
stock.setPrice(dto.getPrice()); |
|
|
|
|
stock.setLast_update(dto.getLast_update()); |
|
|
|
|
stock.setBuy_date(dto.getBuy_date()); |
|
|
|
|
stock.setExp_date(dto.getExp_date()); |
|
|
|
|
deleteToBuys(toBuyDTO); |
|
|
|
|
deleteToBuyByIds(dto.getUser_id(), dto.getTobuy_id()); |
|
|
|
|
// データベースに保存
|
|
|
|
|
return stockRepository.save(stock); |
|
|
|
|
} |
|
|
|
|
|