백테스팅 목록 아이템 삭제 기능추가
This commit is contained in:
@@ -75,6 +75,15 @@ public class PaperTradingController {
|
||||
uid, symbol, side, source, from, to, page, pageSize));
|
||||
}
|
||||
|
||||
@DeleteMapping("/trades/batch")
|
||||
public ResponseEntity<Map<String, Integer>> deleteTradesBatch(
|
||||
@RequestHeader Map<String, String> h,
|
||||
@RequestBody PaperTradeDeleteRequest body) {
|
||||
long uid = TradingControllerSupport.requireRegisteredUser(h);
|
||||
int deleted = paperTradingService.deleteTradesBatch(uid, body != null ? body.getIds() : null);
|
||||
return ResponseEntity.ok(Map.of("deleted", deleted));
|
||||
}
|
||||
|
||||
@GetMapping("/ledger")
|
||||
public ResponseEntity<PaperPageDto<PaperLedgerEntryDto>> ledger(
|
||||
@RequestHeader Map<String, String> h,
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.goldenchart.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PaperTradeDeleteRequest {
|
||||
private List<Long> ids;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface GcPaperTradeRepository extends JpaRepository<GcPaperTrade, Long> {
|
||||
@@ -30,4 +31,6 @@ public interface GcPaperTradeRepository extends JpaRepository<GcPaperTrade, Long
|
||||
@Param("from") LocalDateTime from,
|
||||
@Param("to") LocalDateTime to,
|
||||
Pageable pageable);
|
||||
|
||||
List<GcPaperTrade> findByAccountIdAndIdIn(Long accountId, Collection<Long> ids);
|
||||
}
|
||||
|
||||
@@ -173,6 +173,21 @@ public class PaperTradingService {
|
||||
return listTrades(userId, null, null, null, null, null, 0, 100).getContent();
|
||||
}
|
||||
|
||||
/** 체결 이력 일괄 삭제 (분석 목록에서 그룹 제거용) */
|
||||
@Transactional
|
||||
public int deleteTradesBatch(Long userId, List<Long> ids) {
|
||||
if (ids == null || ids.isEmpty()) return 0;
|
||||
long uid = TradingAccess.requireUserId(userId);
|
||||
GcAppSettings app = appSettingsService.getEntity(uid, null);
|
||||
GcPaperAccount account = getOrCreateAccount(uid, app);
|
||||
List<Long> distinct = ids.stream().filter(id -> id != null && id > 0).distinct().toList();
|
||||
if (distinct.isEmpty()) return 0;
|
||||
List<GcPaperTrade> owned = tradeRepo.findByAccountIdAndIdIn(account.getId(), distinct);
|
||||
if (owned.isEmpty()) return 0;
|
||||
tradeRepo.deleteAll(owned);
|
||||
return owned.size();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public PaperPageDto<PaperLedgerEntryDto> listLedger(Long userId,
|
||||
LocalDateTime from, LocalDateTime to,
|
||||
|
||||
Reference in New Issue
Block a user