Game calendar working
This commit is contained in:
18
db/1.0.0/9. createGameCalendarEvent.sql
Normal file
18
db/1.0.0/9. createGameCalendarEvent.sql
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
CREATE TABLE raid_builder.game_calendar_event(
|
||||||
|
game_calendar_event_id uuid PRIMARY KEY,
|
||||||
|
game_id uuid REFERENCES raid_builder.game(game_id),
|
||||||
|
event_name text NOT NULL,
|
||||||
|
event_description text,
|
||||||
|
event_start_date timestamptz NOT NULL,
|
||||||
|
event_end_date timestamptz NOT NULL,
|
||||||
|
|
||||||
|
--Auditing
|
||||||
|
modified_by uuid,
|
||||||
|
modified_date timestamptz,
|
||||||
|
created_by uuid NOT NULL,
|
||||||
|
created_date timestamptz NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX idx_game_calendar_event_game_id ON raid_builder.game_calendar_event(game_id);
|
||||||
|
|
||||||
|
GRANT ALL ON TABLE raid_builder.game_calendar_event TO raid_builder;
|
||||||
@@ -75,6 +75,7 @@ public class GameAuthorizationAspect{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Make sure this matches the game
|
||||||
//Return if the account has a matching permission
|
//Return if the account has a matching permission
|
||||||
List<GamePermission> gamePermissions = gamePermissionService.getByAccountId(account.getAccountId());
|
List<GamePermission> gamePermissions = gamePermissionService.getByAccountId(account.getAccountId());
|
||||||
for(GamePermission permission : gamePermissions){
|
for(GamePermission permission : gamePermissions){
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package com.mattrixwv.raidbuilder.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
import com.mattrixwv.raidbuilder.annotation.AccountAuthorization;
|
||||||
|
import com.mattrixwv.raidbuilder.annotation.GameAuthorization;
|
||||||
|
import com.mattrixwv.raidbuilder.entity.GameCalendarEvent;
|
||||||
|
import com.mattrixwv.raidbuilder.service.GameCalendarEventService;
|
||||||
|
import com.mattrixwv.raidbuilder.util.DatabaseTypeUtil.AccountPermissionType;
|
||||||
|
import com.mattrixwv.raidbuilder.util.DatabaseTypeUtil.GamePermissionType;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/calendar")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CalendarController{
|
||||||
|
private final ObjectMapper mapper;
|
||||||
|
private final GameCalendarEventService gceService;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/game/{gameId}")
|
||||||
|
@AccountAuthorization(permissions = {AccountPermissionType.ADMIN, AccountPermissionType.USER})
|
||||||
|
public List<GameCalendarEvent> getGameCalendarEvents(@PathVariable("gameId") UUID gameId){
|
||||||
|
log.info("Getting calendar events for game {}", gameId);
|
||||||
|
|
||||||
|
|
||||||
|
return gceService.getByGameId(gameId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/game/{gameId}")
|
||||||
|
@AccountAuthorization(permissions = {AccountPermissionType.ADMIN, AccountPermissionType.USER})
|
||||||
|
@GameAuthorization(permissions = {GamePermissionType.ADMIN})
|
||||||
|
public ObjectNode createGameCalendarEvent(@PathVariable("gameId") UUID gameId, @RequestBody GameCalendarEvent gameCalendarEvent){
|
||||||
|
log.info("Creating calendar event for game {}", gameId);
|
||||||
|
|
||||||
|
|
||||||
|
gameCalendarEvent.setGameId(gameId);
|
||||||
|
gceService.createGameCalendarEvent(gameCalendarEvent);
|
||||||
|
|
||||||
|
ObjectNode returnNode = mapper.createObjectNode();
|
||||||
|
returnNode.put("status", "success");
|
||||||
|
|
||||||
|
return returnNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/game/{gameId}")
|
||||||
|
@AccountAuthorization(permissions = {AccountPermissionType.ADMIN, AccountPermissionType.USER})
|
||||||
|
@GameAuthorization(permissions = {GamePermissionType.ADMIN})
|
||||||
|
public ObjectNode updateGameCalendarEvent(@PathVariable("gameId") UUID gameId, @RequestBody GameCalendarEvent gameCalendarEvent){
|
||||||
|
log.info("Updating calendar event for game {}", gameId);
|
||||||
|
|
||||||
|
|
||||||
|
gameCalendarEvent.setGameId(gameId);
|
||||||
|
gceService.updateGameCalendarEvent(gameCalendarEvent);
|
||||||
|
|
||||||
|
ObjectNode returnNode = mapper.createObjectNode();
|
||||||
|
returnNode.put("status", "success");
|
||||||
|
|
||||||
|
return returnNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/game/{gameId}/{calendarEventId}")
|
||||||
|
@AccountAuthorization(permissions = {AccountPermissionType.ADMIN, AccountPermissionType.USER})
|
||||||
|
@GameAuthorization(permissions = {GamePermissionType.ADMIN})
|
||||||
|
public ObjectNode deleteGameCalendarEvent(@PathVariable("gameId") UUID gameId, @PathVariable("calendarEventId") UUID calendarEventId){
|
||||||
|
log.info("Deleting calendar event for game {}", gameId);
|
||||||
|
|
||||||
|
|
||||||
|
gceService.deleteGameCalendarEvent(calendarEventId);
|
||||||
|
|
||||||
|
ObjectNode returnNode = mapper.createObjectNode();
|
||||||
|
returnNode.put("status", "success");
|
||||||
|
|
||||||
|
return returnNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -148,4 +148,44 @@ public class RaidGroupController{
|
|||||||
|
|
||||||
return returnNode;
|
return returnNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/game/{gameId}")
|
||||||
|
@AccountAuthorization(permissions = {AccountPermissionType.ADMIN, AccountPermissionType.USER})
|
||||||
|
public List<RaidGroup> getRaidGroupsByGame(@PathVariable("gameId") UUID gameId, @RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam(value = "searchTerm", required = false) String searchTermString){
|
||||||
|
log.info("Getting raid groups for game {} page {} of size {} with search term {}", gameId, page, pageSize, searchTermString);
|
||||||
|
|
||||||
|
|
||||||
|
List<RaidGroup> raidGroups;
|
||||||
|
if((searchTermString == null) || (searchTermString.isBlank())){
|
||||||
|
raidGroups = raidGroupService.getRaidGroupsByGame(gameId, page, pageSize);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
raidGroups = raidGroupService.getRaidGroupsByGame(gameId, page, pageSize, searchTermString);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return raidGroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/game/{gameId}/count")
|
||||||
|
@AccountAuthorization(permissions = {AccountPermissionType.ADMIN, AccountPermissionType.USER})
|
||||||
|
public ObjectNode getRaidGroupsCountByGame(@PathVariable("gameId") UUID gameId, @RequestParam(value = "searchTerm", required = false) String searchTerm){
|
||||||
|
log.info("Getting raid groups count for game {} with search term {}", gameId, searchTerm);
|
||||||
|
|
||||||
|
|
||||||
|
Long raidGroupsCount;
|
||||||
|
if((searchTerm == null) || (searchTerm.isBlank())){
|
||||||
|
raidGroupsCount = raidGroupService.getRaidGroupsCountByGame(gameId);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
raidGroupsCount = raidGroupService.getRaidGroupsCountByGame(gameId, searchTerm);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectNode countNode = mapper.createObjectNode();
|
||||||
|
countNode.put("count", raidGroupsCount);
|
||||||
|
countNode.put("status", "success");
|
||||||
|
|
||||||
|
|
||||||
|
return countNode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.mattrixwv.raidbuilder.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.EntityListeners;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "game_calendar_event", schema = "raid_builder")
|
||||||
|
@EntityListeners(AuditableEntityListener.class)
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class GameCalendarEvent extends AuditableEntity{
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.UUID)
|
||||||
|
@Column(name = "game_calendar_event_id")
|
||||||
|
private UUID gameCalendarEventId;
|
||||||
|
@Column(name = "game_id")
|
||||||
|
private UUID gameId;
|
||||||
|
@Column(name = "event_name")
|
||||||
|
private String eventName;
|
||||||
|
@Column(name = "event_description")
|
||||||
|
private String eventDescription;
|
||||||
|
@Column(name = "event_start_date")
|
||||||
|
private ZonedDateTime eventStartDate;
|
||||||
|
@Column(name = "event_end_date")
|
||||||
|
private ZonedDateTime eventEndDate;
|
||||||
|
|
||||||
|
|
||||||
|
public UUID getCalendarEventId(){
|
||||||
|
return gameCalendarEventId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,5 +10,8 @@ import com.mattrixwv.raidbuilder.entity.AccountPermission;
|
|||||||
|
|
||||||
|
|
||||||
public interface AccountPermissionRepository extends AccountPermissionCustomRepository, JpaRepository<AccountPermission, UUID>{
|
public interface AccountPermissionRepository extends AccountPermissionCustomRepository, JpaRepository<AccountPermission, UUID>{
|
||||||
|
public void deleteAllByAccountId(UUID accountId);
|
||||||
|
|
||||||
|
|
||||||
public List<AccountPermission> findAllByAccountId(UUID accountId);
|
public List<AccountPermission> findAllByAccountId(UUID accountId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ import com.mattrixwv.raidbuilder.entity.AccountTutorialStatus;
|
|||||||
|
|
||||||
|
|
||||||
public interface AccountTutorialStatusRepository extends AccountTutorialStatusCustomRepository, JpaRepository<AccountTutorialStatus, UUID>{
|
public interface AccountTutorialStatusRepository extends AccountTutorialStatusCustomRepository, JpaRepository<AccountTutorialStatus, UUID>{
|
||||||
|
public void deleteAllByAccountId(UUID accountId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.mattrixwv.raidbuilder.repository.game_calendar_event;
|
||||||
|
|
||||||
|
|
||||||
|
public interface GameCalendarEventCustomRepository{
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.mattrixwv.raidbuilder.repository.game_calendar_event;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import com.mattrixwv.raidbuilder.entity.GameCalendarEvent;
|
||||||
|
|
||||||
|
|
||||||
|
public interface GameCalendarEventRepository extends GameCalendarEventCustomRepository, JpaRepository<GameCalendarEvent, UUID>{
|
||||||
|
public void deleteAllByGameId(UUID gameId);
|
||||||
|
|
||||||
|
|
||||||
|
public List<GameCalendarEvent> findAllByGameId(UUID gameId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.mattrixwv.raidbuilder.repository.game_calendar_event;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class GameCalendarEventRepositoryImpl{
|
||||||
|
}
|
||||||
@@ -10,5 +10,9 @@ import com.mattrixwv.raidbuilder.entity.GamePermission;
|
|||||||
|
|
||||||
|
|
||||||
public interface GamePermissionRepository extends GamePermissionCustomRepository, JpaRepository<GamePermission, UUID>{
|
public interface GamePermissionRepository extends GamePermissionCustomRepository, JpaRepository<GamePermission, UUID>{
|
||||||
|
public void deleteAllByAccountId(UUID accountId);
|
||||||
|
public void deleteAllByGameId(UUID gameId);
|
||||||
|
|
||||||
|
|
||||||
public List<GamePermission> findAllByAccountId(UUID accountId);
|
public List<GamePermission> findAllByAccountId(UUID accountId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ import com.mattrixwv.raidbuilder.entity.RaidGroup;
|
|||||||
|
|
||||||
|
|
||||||
public interface RaidGroupRepository extends RaidGroupCustomRepository, JpaRepository<RaidGroup, UUID>{
|
public interface RaidGroupRepository extends RaidGroupCustomRepository, JpaRepository<RaidGroup, UUID>{
|
||||||
|
public List<RaidGroup> findAllByGameId(UUID gameId);
|
||||||
|
public List<RaidGroup> findAllByGameId(UUID gameId, PageRequest pageRequest);
|
||||||
public List<RaidGroup> findAllByRaidGroupNameContainingIgnoreCase(String searchTerm, PageRequest pageRequest);
|
public List<RaidGroup> findAllByRaidGroupNameContainingIgnoreCase(String searchTerm, PageRequest pageRequest);
|
||||||
|
public List<RaidGroup> findAllByGameIdAndRaidGroupNameContainingIgnoreCase(UUID gameId, String searchTerm, PageRequest pageRequest);
|
||||||
|
|
||||||
public long countAllByRaidGroupNameContainingIgnoreCase(String searchTerm);
|
public long countAllByRaidGroupNameContainingIgnoreCase(String searchTerm);
|
||||||
|
public long countAllByGameId(UUID gameId);
|
||||||
|
public long countAllByGameIdAndRaidGroupNameContainingIgnoreCase(UUID gameId, String searchTerm);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,10 @@ import com.mattrixwv.raidbuilder.entity.RaidGroupPermission;
|
|||||||
|
|
||||||
|
|
||||||
public interface RaidGroupPermissionRepository extends RaidGroupPermissionCustomRepository, JpaRepository<RaidGroupPermission, UUID>{
|
public interface RaidGroupPermissionRepository extends RaidGroupPermissionCustomRepository, JpaRepository<RaidGroupPermission, UUID>{
|
||||||
|
public void deleteAllByAccountId(UUID accountId);
|
||||||
|
public void deleteAllByRaidGroupId(UUID raidGroupId);
|
||||||
|
public void deleteAllByRaidGroupIdIn(Iterable<UUID> raidGroupIds);
|
||||||
|
|
||||||
|
|
||||||
public List<RaidGroupPermission> findAllByAccountId(UUID accountId);
|
public List<RaidGroupPermission> findAllByAccountId(UUID accountId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,17 @@ public class AccountPermissionService{
|
|||||||
private final AccountPermissionRepository accountPermissionRepository;
|
private final AccountPermissionRepository accountPermissionRepository;
|
||||||
|
|
||||||
|
|
||||||
|
//Write
|
||||||
public AccountPermission createAccountPermission(AccountPermission accountPermission){
|
public AccountPermission createAccountPermission(AccountPermission accountPermission){
|
||||||
return accountPermissionRepository.save(accountPermission);
|
return accountPermissionRepository.save(accountPermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteByAccountId(UUID accountId){
|
||||||
|
accountPermissionRepository.deleteAllByAccountId(accountId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Read
|
||||||
public List<AccountPermission> getByAccountId(UUID accountId){
|
public List<AccountPermission> getByAccountId(UUID accountId){
|
||||||
return accountPermissionRepository.findAllByAccountId(accountId);
|
return accountPermissionRepository.findAllByAccountId(accountId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ public class AccountService implements UserDetailsService{
|
|||||||
private final AccountTutorialStatusService accountTutorialStatusService;
|
private final AccountTutorialStatusService accountTutorialStatusService;
|
||||||
//Related services
|
//Related services
|
||||||
private final AccountPermissionService accountPermissionService;
|
private final AccountPermissionService accountPermissionService;
|
||||||
|
private final GamePermissionService gamePermissionService;
|
||||||
|
private final RaidGroupPermissionService raidGroupPermissionService;
|
||||||
//Fields
|
//Fields
|
||||||
@Value("${jwt.refreshTokenDuration}")
|
@Value("${jwt.refreshTokenDuration}")
|
||||||
private Duration refreshTokenDuration;
|
private Duration refreshTokenDuration;
|
||||||
@@ -102,6 +104,12 @@ public class AccountService implements UserDetailsService{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAccount(UUID accountId){
|
public void deleteAccount(UUID accountId){
|
||||||
|
accountTutorialStatusService.deleteByAccountId(accountId);
|
||||||
|
accountPermissionService.deleteByAccountId(accountId);
|
||||||
|
gamePermissionService.deleteByAccountId(accountId);
|
||||||
|
raidGroupPermissionService.deleteByAccountId(accountId);
|
||||||
|
accountRepository.flush();
|
||||||
|
|
||||||
accountRepository.deleteById(accountId);
|
accountRepository.deleteById(accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.mattrixwv.raidbuilder.service;
|
package com.mattrixwv.raidbuilder.service;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -17,7 +19,12 @@ public class AccountTutorialStatusService{
|
|||||||
private final AccountTutorialStatusRepository accountTutorialStatusRepository;
|
private final AccountTutorialStatusRepository accountTutorialStatusRepository;
|
||||||
|
|
||||||
|
|
||||||
|
//Write
|
||||||
public AccountTutorialStatus createAccountTutorialStatus(AccountTutorialStatus accountTutorialStatus){
|
public AccountTutorialStatus createAccountTutorialStatus(AccountTutorialStatus accountTutorialStatus){
|
||||||
return accountTutorialStatusRepository.save(accountTutorialStatus);
|
return accountTutorialStatusRepository.save(accountTutorialStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteByAccountId(UUID accountId){
|
||||||
|
accountTutorialStatusRepository.deleteAllByAccountId(accountId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.mattrixwv.raidbuilder.service;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import com.mattrixwv.raidbuilder.entity.GameCalendarEvent;
|
||||||
|
import com.mattrixwv.raidbuilder.repository.game_calendar_event.GameCalendarEventRepository;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GameCalendarEventService{
|
||||||
|
private final GameCalendarEventRepository gceRepository;
|
||||||
|
|
||||||
|
|
||||||
|
//Write
|
||||||
|
public void createGameCalendarEvent(GameCalendarEvent gce){
|
||||||
|
gceRepository.save(gce);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateGameCalendarEvent(GameCalendarEvent gce){
|
||||||
|
gceRepository.save(gce);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteGameCalendarEvent(UUID gceId){
|
||||||
|
gceRepository.deleteById(gceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteByGameId(UUID gameId){
|
||||||
|
gceRepository.deleteAllByGameId(gameId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Read
|
||||||
|
public List<GameCalendarEvent> getByGameId(UUID gameId){
|
||||||
|
return gceRepository.findAllByGameId(gameId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,6 +33,14 @@ public class GamePermissionService{
|
|||||||
gamePermissionRepository.delete(gamePermission);
|
gamePermissionRepository.delete(gamePermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteByAccountId(UUID accountId){
|
||||||
|
gamePermissionRepository.deleteAllByAccountId(accountId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteByGameId(UUID gameId){
|
||||||
|
gamePermissionRepository.deleteAllByGameId(gameId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Read
|
//Read
|
||||||
public List<GamePermission> getByAccountId(UUID accountId){
|
public List<GamePermission> getByAccountId(UUID accountId){
|
||||||
|
|||||||
@@ -27,6 +27,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class GameService{
|
public class GameService{
|
||||||
private final GameRepository gameRepository;
|
private final GameRepository gameRepository;
|
||||||
|
//Related Services
|
||||||
|
private final GameCalendarEventService gameCalendarEventService;
|
||||||
|
private final GamePermissionService gamePermissionService;
|
||||||
|
private final RaidGroupService raidGroupService;
|
||||||
|
//Values
|
||||||
@Value("${uploadFileDirectory}")
|
@Value("${uploadFileDirectory}")
|
||||||
private String uploadFileDirectory;
|
private String uploadFileDirectory;
|
||||||
|
|
||||||
@@ -86,6 +91,12 @@ public class GameService{
|
|||||||
existingFile.delete();
|
existingFile.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gameCalendarEventService.deleteByGameId(gameId);
|
||||||
|
gamePermissionService.deleteByGameId(gameId);
|
||||||
|
raidGroupService.deleteByGameId(gameId);
|
||||||
|
gameRepository.flush();
|
||||||
|
|
||||||
gameRepository.deleteById(gameId);
|
gameRepository.deleteById(gameId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,25 @@ public class RaidGroupPermissionService{
|
|||||||
private final RaidGroupPermissionRepository raidGroupPermissionRepository;
|
private final RaidGroupPermissionRepository raidGroupPermissionRepository;
|
||||||
|
|
||||||
|
|
||||||
|
//Write
|
||||||
|
public void deleteByAccountId(UUID accountId){
|
||||||
|
raidGroupPermissionRepository.deleteAllByAccountId(accountId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteByRaidGroupId(UUID raidGroupId){
|
||||||
|
raidGroupPermissionRepository.deleteAllByRaidGroupId(raidGroupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteByRaidGroupIds(Iterable<UUID> raidGroupIds){
|
||||||
|
raidGroupPermissionRepository.deleteAllByRaidGroupIdIn(raidGroupIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Read
|
||||||
public RaidGroupPermission createRaidGroupPermission(RaidGroupPermission raidGroupPermission){
|
public RaidGroupPermission createRaidGroupPermission(RaidGroupPermission raidGroupPermission){
|
||||||
return raidGroupPermissionRepository.save(raidGroupPermission);
|
return raidGroupPermissionRepository.save(raidGroupPermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<RaidGroupPermission> getByAccountId(UUID accountId){
|
public List<RaidGroupPermission> getByAccountId(UUID accountId){
|
||||||
return raidGroupPermissionRepository.findAllByAccountId(accountId);
|
return raidGroupPermissionRepository.findAllByAccountId(accountId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class RaidGroupService{
|
public class RaidGroupService{
|
||||||
private final RaidGroupRepository raidGroupRepository;
|
private final RaidGroupRepository raidGroupRepository;
|
||||||
|
//Related Services
|
||||||
|
private final RaidGroupPermissionService raidGroupPermissionService;
|
||||||
|
//Values
|
||||||
@Value("${uploadFileDirectory}")
|
@Value("${uploadFileDirectory}")
|
||||||
private String uploadFileDirectory;
|
private String uploadFileDirectory;
|
||||||
|
|
||||||
@@ -87,10 +90,21 @@ public class RaidGroupService{
|
|||||||
existingFile.delete();
|
existingFile.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
raidGroupPermissionService.deleteByRaidGroupId(raidGroupId);
|
||||||
|
raidGroupRepository.flush();
|
||||||
|
|
||||||
raidGroupRepository.deleteById(raidGroupId);
|
raidGroupRepository.deleteById(raidGroupId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteByGameId(UUID gameId){
|
||||||
|
List<RaidGroup> raidGroups = raidGroupRepository.findAllByGameId(gameId);
|
||||||
|
raidGroupPermissionService.deleteByRaidGroupIds(raidGroups.stream().map(RaidGroup::getRaidGroupId).toList());
|
||||||
|
raidGroupRepository.flush();
|
||||||
|
|
||||||
|
raidGroupRepository.deleteAll(raidGroups);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Read
|
//Read
|
||||||
public RaidGroup getByRaidGroupId(UUID raidGroupId){
|
public RaidGroup getByRaidGroupId(UUID raidGroupId){
|
||||||
@@ -108,6 +122,18 @@ public class RaidGroupService{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RaidGroup> getRaidGroupsByGame(UUID gameId, int page, int pageSize){
|
||||||
|
return raidGroupRepository.findAllByGameId(gameId, PageRequest.of(page, pageSize, Sort.by("raidGroupName").ascending()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RaidGroup> getRaidGroupsByGame(UUID gameId, int page, int pageSize, String searchTerm){
|
||||||
|
return raidGroupRepository.findAllByGameIdAndRaidGroupNameContainingIgnoreCase(
|
||||||
|
gameId,
|
||||||
|
searchTerm,
|
||||||
|
PageRequest.of(page, pageSize, Sort.by("raidGroupName").ascending())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public long getRaidGroupsCount(){
|
public long getRaidGroupsCount(){
|
||||||
return raidGroupRepository.count();
|
return raidGroupRepository.count();
|
||||||
}
|
}
|
||||||
@@ -115,4 +141,12 @@ public class RaidGroupService{
|
|||||||
public long getRaidGroupsCount(String searchTerm){
|
public long getRaidGroupsCount(String searchTerm){
|
||||||
return raidGroupRepository.countAllByRaidGroupNameContainingIgnoreCase(searchTerm);
|
return raidGroupRepository.countAllByRaidGroupNameContainingIgnoreCase(searchTerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getRaidGroupsCountByGame(UUID gameId){
|
||||||
|
return raidGroupRepository.countAllByGameId(gameId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getRaidGroupsCountByGame(UUID gameId, String searchTerm){
|
||||||
|
return raidGroupRepository.countAllByGameIdAndRaidGroupNameContainingIgnoreCase(gameId, searchTerm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user