@Service
public class ServerPackService
extends java.lang.Object
| Constructor and Description |
|---|
ServerPackService(ServerPackRepository injectedServerPackRepository)
Constructor responsible for our DI.
|
| Modifier and Type | Method and Description |
|---|---|
void |
deleteByProjectIDAndFileID(int projectID,
int fileID)
Delete a server pack with a given CurseForge project and file ID.
|
void |
deleteServerPack(int id)
Deletes a server pack with the given id.
|
void |
deleteServerPack(int projectID,
int fileID)
Delete a server pack with a given CurseForge project and file ID.
|
org.springframework.http.ResponseEntity<org.springframework.core.io.Resource> |
downloadServerPackById(int id)
Download a server pack with the given database id.
|
java.util.Optional<ServerPackModel> |
findByFileID(int fileID)
Find a server pack by its database id.
|
java.util.Optional<ServerPackModel> |
findByProjectIDAndFileID(int projectID,
int fileID)
Find a specific server pack by searching with a CurseForge project and file ID.
|
java.util.List<ServerPackModel> |
getServerPacks()
Get a list of all available server packs.
|
java.util.List<ServerPackModel> |
getServerPacksByProjectID(int projectID)
Get a list of all server packs using a CurseForge project ID.
|
void |
insert(ServerPackModel serverPackModel)
Store a server pack in the database.
|
void |
updateConfirmedCounter(int id,
int vote)
Either increment or decrement the confirmed working value of a given server pack entry in the database, identified by the
database id.
|
void |
updateDownloadCounter(int id)
Increment the download counter for a given server pack entry in the database identified by the database id.
|
void |
updateServerPackByID(int id,
ServerPackModel serverPackModel)
Update a server pack database entry with the given database id.
|
void |
updateServerPackByProjectIDAndFileID(int projectID,
int fileID,
ServerPackModel serverPackModel)
Update a server pack entry in the database identified by a CurseForge project and file ID combination, using a passed
server pack.
|
org.springframework.http.ResponseEntity<java.lang.Object> |
voteForServerPack(java.lang.String voting)
Either upvote or downvote a given server pack.
|
@Autowired public ServerPackService(ServerPackRepository injectedServerPackRepository)
injectedServerPackRepository - Instance of ServerPackRepository.public java.util.Optional<ServerPackModel> findByProjectIDAndFileID(int projectID, int fileID)
projectID - Integer. The CurseForge project ID.fileID - Integer. The CurseForge project file ID.Optional. I recommend to make use of Optional.isPresent() and Optional.get().public void deleteByProjectIDAndFileID(int projectID,
int fileID)
projectID - Integer. The CurseForge project ID.fileID - Integer. The CurseForge file ID.public java.util.Optional<ServerPackModel> findByFileID(int fileID)
fileID - Integer. The database id with which to search for a server pack.Optional. I recommend to make use of Optional.isPresent() and Optional.get().public org.springframework.http.ResponseEntity<org.springframework.core.io.Resource> downloadServerPackById(int id)
id - Integer. The database id of the server pack to download.public org.springframework.http.ResponseEntity<java.lang.Object> voteForServerPack(java.lang.String voting)
voting - String. The database id of the server pack and whether it should be up- or downvoted.public java.util.List<ServerPackModel> getServerPacks()
public java.util.List<ServerPackModel> getServerPacksByProjectID(int projectID)
projectID - Integer. The CurseForge project ID with which to search for server pack.Optional. I recommend to make use of Optional.isPresent() and Optional.get().public void insert(ServerPackModel serverPackModel)
serverPackModel - Instance of ServerPackModel to store in the database.public void updateServerPackByID(int id,
ServerPackModel serverPackModel)
id - Integer. The database id of the server pack to initialize.serverPackModel - Instance of ServerPackModel with which to initialize the entry in the database.public void updateDownloadCounter(int id)
id - Integer. The database id of the server pack.public void updateConfirmedCounter(int id,
int vote)
id - Integer. The database id of the server pack.vote - Integer. Positive for upvote, negative for downvotepublic void updateServerPackByProjectIDAndFileID(int projectID,
int fileID,
ServerPackModel serverPackModel)
projectID - The CurseForge project ID.fileID - The CurseForge file ID.serverPackModel - The server pack with which to initialize the entry in the database.public void deleteServerPack(int id)
id - Integer. The database id of the server pack to delete.public void deleteServerPack(int projectID,
int fileID)
projectID - Integer. The CurseForge project ID.fileID - Integer. The CurseForge file ID.