automated terminal push
This commit is contained in:
98
.legacy/gemini
Normal file
98
.legacy/gemini
Normal file
@@ -0,0 +1,98 @@
|
||||
package com.example.filedownload.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "file_downloads")
|
||||
public class FileDownload {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String url;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String hostIp;
|
||||
|
||||
@Column(nullable = false)
|
||||
private LocalDateTime dateTime;
|
||||
|
||||
// Constructors, getters and setters
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
package com.example.filedownload.service;
|
||||
|
||||
import com.example.filedownload.model.FileDownload;
|
||||
import com.example.filedownload.repository.FileDownloadRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Service
|
||||
public class FileDownloadService {
|
||||
|
||||
@Autowired
|
||||
private FileDownloadRepository fileDownloadRepository;
|
||||
|
||||
public FileDownload save(String url, String hostIp) {
|
||||
FileDownload fileDownload = new FileDownload();
|
||||
fileDownload.setUrl(url);
|
||||
fileDownload.setHostIp(hostIp);
|
||||
fileDownload.setDateTime(LocalDateTime.now());
|
||||
return fileDownloadRepository.save(fileDownload);
|
||||
}
|
||||
}
|
||||
|
||||
package com.example.filedownload.service;
|
||||
|
||||
import com.example.filedownload.model.FileDownload;
|
||||
import com.example.filedownload.repository.FileDownloadRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Service
|
||||
public class FileDownloadService {
|
||||
|
||||
@Autowired
|
||||
private FileDownloadRepository fileDownloadRepository;
|
||||
|
||||
public FileDownload save(String url, String hostIp) {
|
||||
FileDownload fileDownload = new FileDownload();
|
||||
fileDownload.setUrl(url);
|
||||
fileDownload.setHostIp(hostIp);
|
||||
fileDownload.setDateTime(LocalDateTime.now());
|
||||
return fileDownloadRepository.save(fileDownload);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
package com.example.filedownload.controller;
|
||||
|
||||
import com.example.filedownload.model.FileDownload;
|
||||
import com.example.filedownload.service.FileDownloadService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class FileDownloadController {
|
||||
|
||||
@Autowired
|
||||
private FileDownloadService fileDownloadService;
|
||||
|
||||
@GetMapping("/doesexist/{url}")
|
||||
public boolean doesExist(@PathVariable String url) {
|
||||
String fullUrl = "google.com/" + url; // Assuming "google.com" is the base URL
|
||||
return fileDownloadService.existsByUrl(fullUrl);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user