Edwardsamaxl | cba512d | 2025-06-09 21:17:29 +0800 | [diff] [blame^] | 1 | package com.pt.service; |
| 2 | |
| 3 | import com.pt.entity.TorrentMeta; |
| 4 | import com.pt.repository.TorrentMetaRepository; |
| 5 | import org.springframework.beans.factory.annotation.Autowired; |
| 6 | import org.springframework.stereotype.Service; |
| 7 | |
| 8 | import java.time.LocalDateTime; |
| 9 | |
| 10 | @Service |
| 11 | public class TorrentMetaService { |
| 12 | |
| 13 | @Autowired |
| 14 | private TorrentMetaRepository torrentMetaRepository; |
| 15 | |
| 16 | public void save(TorrentMeta torrentMeta) { |
| 17 | // 这里可以添加保存逻辑,比如调用repository的save方法 |
| 18 | // torrentMetaRepository.save(torrentMeta); |
| 19 | System.out.println("Saving TorrentMeta: " + torrentMeta); |
| 20 | } |
| 21 | |
| 22 | public void save(String infoHash, String name, long size) { |
| 23 | TorrentMeta torrentMeta = new TorrentMeta(); |
| 24 | torrentMeta.setInfoHash(infoHash); |
| 25 | torrentMeta.setFilename(name); |
| 26 | torrentMeta.setSize(size); |
| 27 | torrentMeta.setUploadTime(LocalDateTime.now()); |
| 28 | torrentMetaRepository.save(torrentMeta); |
| 29 | } |
| 30 | } |