[O] Remove unnecessarily long constructors

This commit is contained in:
Azalea
2024-03-16 22:50:08 -04:00
parent 8dd4bb9d61
commit 0f1d6c0984
23 changed files with 39 additions and 407 deletions

View File

@@ -2,6 +2,7 @@ package icu.samnyan.aqua.api.controller.general;
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerScreenShotRepository;
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerScreenShot;
import lombok.AllArgsConstructor;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.http.MediaType;
@@ -19,14 +20,10 @@ import java.util.Optional;
*/
@RestController
@RequestMapping("api/static")
@AllArgsConstructor
public class StaticController {
private final PlayerScreenShotRepository playerScreenShotRepository;
public StaticController(PlayerScreenShotRepository playerScreenShotRepository) {
this.playerScreenShotRepository = playerScreenShotRepository;
}
@GetMapping(value = "screenshot/{filename}", produces = MediaType.IMAGE_JPEG_VALUE)
public ResponseEntity<Resource> getScreenshotFile(@PathVariable String filename) {
Optional<PlayerScreenShot> ss = playerScreenShotRepository.findByFileName(filename);

View File

@@ -2,6 +2,7 @@ package icu.samnyan.aqua.api.controller.sega;
import icu.samnyan.aqua.sega.general.model.Card;
import icu.samnyan.aqua.sega.general.service.CardService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -16,14 +17,11 @@ import java.util.Optional;
*/
@RestController
@RequestMapping("api/sega/aime")
@AllArgsConstructor
public class ApiAimeController {
private final CardService cardService;
public ApiAimeController(CardService cardService) {
this.cardService = cardService;
}
@PostMapping("getByAccessCode")
public Optional<Card> getByAccessCode(@RequestBody Map<String, String> request) {
return cardService.getCardByAccessCode(request.get("accessCode").replaceAll("-", "").replaceAll(" ", ""));

View File

@@ -6,6 +6,7 @@ import icu.samnyan.aqua.sega.chunithm.model.gamedata.Character;
import icu.samnyan.aqua.sega.chunithm.model.gamedata.CharacterSkill;
import icu.samnyan.aqua.sega.chunithm.model.gamedata.Music;
import icu.samnyan.aqua.sega.chunithm.service.GameMusicService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -17,18 +18,13 @@ import java.util.List;
*/
@RestController
@RequestMapping("api/game/chuni/v1/data")
@AllArgsConstructor
public class ApiChuniV1GameDataController {
private final GameMusicService gameMusicService;
private final GameCharacterRepository gameCharacterRepository;
private final GameCharacterSkillRepository gameCharacterSkillRepository;
public ApiChuniV1GameDataController(GameMusicService gameMusicService, GameCharacterRepository gameCharacterRepository, GameCharacterSkillRepository gameCharacterSkillRepository) {
this.gameMusicService = gameMusicService;
this.gameCharacterRepository = gameCharacterRepository;
this.gameCharacterSkillRepository = gameCharacterSkillRepository;
}
@GetMapping("music")
public List<Music> getMusic() {
return gameMusicService.getAll();
@@ -43,15 +39,4 @@ public class ApiChuniV1GameDataController {
public List<CharacterSkill> getSkill() {
return gameCharacterSkillRepository.findAll();
}
// @PostMapping("character")
// public List<Character> importCharacter(@RequestBody List<Character> req) {
// return gameCharacterRepository.saveAll(req);
// }
//
// @PostMapping("skill")
// public List<CharacterSkill> importSkill(@RequestBody List<CharacterSkill> req) {
// return gameCharacterSkillRepository.saveAll(req);
// }
}

View File

@@ -18,6 +18,7 @@ import icu.samnyan.aqua.sega.general.model.Card;
import icu.samnyan.aqua.sega.general.service.CardService;
import icu.samnyan.aqua.sega.util.VersionInfo;
import icu.samnyan.aqua.sega.util.VersionUtil;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,6 +40,7 @@ import java.util.stream.Collectors;
*/
@RestController
@RequestMapping("api/game/chuni/v1")
@AllArgsConstructor
public class ApiChuniV1PlayerDataController {
private static final Logger logger = LoggerFactory.getLogger(ApiChuniV1PlayerDataController.class);
@@ -64,28 +66,6 @@ public class ApiChuniV1PlayerDataController {
private final GameMusicService gameMusicService;
@Autowired
public ApiChuniV1PlayerDataController(ApiMapper mapper, CardService cardService, UserActivityService userActivityService, UserCharacterService userCharacterService, UserChargeService userChargeService, UserDataService userDataService, UserDataExService userDataExService, UserGameOptionExService userGameOptionExService, UserMapService userMapService, UserPlaylogService userPlaylogService, UserMusicDetailService userMusicDetailService, UserCourseService userCourseService, UserDuelService userDuelService, UserGameOptionService userGameOptionService, UserItemService userItemService, UserGeneralDataService userGeneralDataService, GameMusicService gameMusicService) {
this.mapper = mapper;
this.cardService = cardService;
this.userActivityService = userActivityService;
this.userCharacterService = userCharacterService;
this.userChargeService = userChargeService;
this.userDataService = userDataService;
this.userDataExService = userDataExService;
this.userGameOptionExService = userGameOptionExService;
this.userMapService = userMapService;
this.userPlaylogService = userPlaylogService;
this.userMusicDetailService = userMusicDetailService;
this.userCourseService = userCourseService;
this.userDuelService = userDuelService;
this.userGameOptionService = userGameOptionService;
this.userItemService = userItemService;
this.userGeneralDataService = userGeneralDataService;
this.gameMusicService = gameMusicService;
}
// Keep it here for legacy
@GetMapping("music")
public List<Music> getMusicList() {

View File

@@ -3,6 +3,7 @@ package icu.samnyan.aqua.api.controller.sega.game.chuni.v2;
import icu.samnyan.aqua.sega.chusan.model.*;
import icu.samnyan.aqua.sega.chusan.model.gamedata.Character;
import icu.samnyan.aqua.sega.chusan.model.gamedata.*;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -14,6 +15,7 @@ import java.util.List;
*/
@RestController
@RequestMapping("api/game/chuni/v2/data")
@AllArgsConstructor
public class ApiChuniV2GameDataController {
private final Chu3GameMusicRepo gameMusicRepository;
@@ -25,17 +27,6 @@ public class ApiChuniV2GameDataController {
private final Chu3GameFrameRepo gameFrameRepository;
private final Chu3GameAvatarAccRepo gameAvatarAccRepository;
public ApiChuniV2GameDataController(Chu3GameMusicRepo gameMusicRepository, Chu3GameCharacterRepo gameCharacterRepository, Chu3GameTrophyRepo gameTrophyRepository, Chu3GameNamePlateRepo gameNamePlateRepository, Chu3GameSystemVoiceRepo gameSystemVoiceRepository, Chu3GameMapIconRepo gameMapIconRepository, Chu3GameFrameRepo gameFrameRepository, Chu3GameAvatarAccRepo gameAvatarAccRepository) {
this.gameMusicRepository = gameMusicRepository;
this.gameCharacterRepository = gameCharacterRepository;
this.gameTrophyRepository = gameTrophyRepository;
this.gameNamePlateRepository = gameNamePlateRepository;
this.gameSystemVoiceRepository = gameSystemVoiceRepository;
this.gameMapIconRepository = gameMapIconRepository;
this.gameFrameRepository = gameFrameRepository;
this.gameAvatarAccRepository = gameAvatarAccRepository;
}
@GetMapping("music")
public List<Music> getMusic() {
return gameMusicRepository.findAll();

View File

@@ -18,6 +18,7 @@ import icu.samnyan.aqua.sega.general.model.Card;
import icu.samnyan.aqua.sega.general.service.CardService;
import icu.samnyan.aqua.sega.util.VersionInfo;
import icu.samnyan.aqua.sega.util.VersionUtil;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,6 +40,7 @@ import java.util.stream.Collectors;
*/
@RestController
@RequestMapping("api/game/chuni/v2")
@AllArgsConstructor
public class ApiChuniV2PlayerDataController {
private static final Logger logger = LoggerFactory.getLogger(ApiChuniV2PlayerDataController.class);
@@ -61,33 +63,6 @@ public class ApiChuniV2PlayerDataController {
private final UserGeneralDataService userGeneralDataService;
private final GameMusicService gameMusicService;
@Autowired
public ApiChuniV2PlayerDataController(ApiMapper mapper, CardService cardService, UserActivityService userActivityService, UserCharacterService userCharacterService, UserChargeService userChargeService, UserDataService userDataService, UserMapAreaService userMapAreaService, UserPlaylogService userPlaylogService, UserMusicDetailService userMusicDetailService, UserCourseService userCourseService, UserDuelService userDuelService, UserGameOptionService userGameOptionService, UserItemService userItemService, UserGeneralDataService userGeneralDataService, GameMusicService gameMusicService) {
this.mapper = mapper;
this.cardService = cardService;
this.userActivityService = userActivityService;
this.userCharacterService = userCharacterService;
this.userChargeService = userChargeService;
this.userDataService = userDataService;
this.userMapAreaService = userMapAreaService;
this.userPlaylogService = userPlaylogService;
this.userMusicDetailService = userMusicDetailService;
this.userCourseService = userCourseService;
this.userDuelService = userDuelService;
this.userGameOptionService = userGameOptionService;
this.userItemService = userItemService;
this.userGeneralDataService = userGeneralDataService;
this.gameMusicService = gameMusicService;
}
/*
// Keep it here for legacy
@GetMapping("music")
public List<Music> getMusicList() {
return gameMusicService.getAll();
}
*/
/**
* Get Basic info
*

View File

@@ -6,6 +6,7 @@ import icu.samnyan.aqua.sega.diva.dao.gamedata.DivaPvRepository;
import icu.samnyan.aqua.sega.diva.model.gamedata.DivaCustomize;
import icu.samnyan.aqua.sega.diva.model.gamedata.DivaModule;
import icu.samnyan.aqua.sega.diva.model.gamedata.Pv;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -17,18 +18,13 @@ import java.util.List;
*/
@RestController
@RequestMapping("api/game/diva/data")
@AllArgsConstructor
public class ApiDivaGameDataController {
private final DivaModuleRepository divaModuleRepository;
private final DivaCustomizeRepository divaCustomizeRepository;
private final DivaPvRepository divaPvRepository;
public ApiDivaGameDataController(DivaModuleRepository divaModuleRepository, DivaCustomizeRepository divaCustomizeRepository, DivaPvRepository divaPvRepository) {
this.divaModuleRepository = divaModuleRepository;
this.divaCustomizeRepository = divaCustomizeRepository;
this.divaPvRepository = divaPvRepository;
}
@GetMapping(value = "musicList")
public List<Pv> musicList() {
return divaPvRepository.findAll();

View File

@@ -8,6 +8,7 @@ import icu.samnyan.aqua.sega.diva.model.common.Difficulty;
import icu.samnyan.aqua.sega.diva.model.common.Edition;
import icu.samnyan.aqua.sega.diva.model.userdata.*;
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.HttpStatus;
@@ -21,6 +22,7 @@ import java.util.*;
*/
@RestController
@RequestMapping("api/game/diva")
@AllArgsConstructor
public class ApiDivaPlayerDataController {
private final PlayerProfileService playerProfileService;
@@ -33,17 +35,6 @@ public class ApiDivaPlayerDataController {
private final PlayerCustomizeRepository playerCustomizeRepository;
private final PlayerScreenShotRepository playerScreenShotRepository;
public ApiDivaPlayerDataController(PlayerProfileService playerProfileService, GameSessionRepository gameSessionRepository, PlayLogRepository playLogRepository, PlayerPvRecordRepository playerPvRecordRepository, PlayerPvCustomizeRepository playerPvCustomizeRepository, PlayerModuleRepository playerModuleRepository, PlayerCustomizeRepository playerCustomizeRepository, PlayerScreenShotRepository playerScreenShotRepository) {
this.playerProfileService = playerProfileService;
this.gameSessionRepository = gameSessionRepository;
this.playLogRepository = playLogRepository;
this.playerPvRecordRepository = playerPvRecordRepository;
this.playerPvCustomizeRepository = playerPvCustomizeRepository;
this.playerModuleRepository = playerModuleRepository;
this.playerCustomizeRepository = playerCustomizeRepository;
this.playerScreenShotRepository = playerScreenShotRepository;
}
@PostMapping("forceUnlock")
public ResponseEntity<MessageResponse> forceUnlock(@RequestParam int pdId) {
PlayerProfile profile = playerProfileService.findByPdId(pdId).orElseThrow();

View File

@@ -83,10 +83,10 @@ public class ApiMaimai2PlayerDataController {
.map(Path::getFileName)
.map(Path::toString)
.sorted(Comparator.reverseOrder())
.collect(Collectors.toList());
.toList();
Photo.setTotalImage(matchedFiles.size());
Photo.setImageIndex(imageIndex);
if(matchedFiles.size() > imageIndex){
if(matchedFiles.size() > imageIndex) {
byte[] targetImageContent = Files.readAllBytes(Paths.get("data/" + matchedFiles.get(imageIndex)));
String divData = Base64.getEncoder().encodeToString(targetImageContent);
Photo.setDivData(divData);

View File

@@ -2,6 +2,7 @@ package icu.samnyan.aqua.api.controller.sega.game.ongeki;
import icu.samnyan.aqua.sega.ongeki.dao.gamedata.*;
import icu.samnyan.aqua.sega.ongeki.model.gamedata.*;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -11,6 +12,7 @@ import java.util.List;
*/
@RestController
@RequestMapping("api/game/ongeki/data")
@AllArgsConstructor
public class ApiOngekiGameDataController {
private final GameCardRepository gameCardRepository;
@@ -19,14 +21,6 @@ public class ApiOngekiGameDataController {
private final GameMusicRepository gameMusicRepository;
private final GameSkillRepository gameSkillRepository;
public ApiOngekiGameDataController(GameCardRepository gameCardRepository, GameCharaRepository gameCharaRepository, GameEventRepository gameEventRepository, GameMusicRepository gameMusicRepository, GameSkillRepository gameSkillRepository) {
this.gameCardRepository = gameCardRepository;
this.gameCharaRepository = gameCharaRepository;
this.gameEventRepository = gameEventRepository;
this.gameMusicRepository = gameMusicRepository;
this.gameSkillRepository = gameSkillRepository;
}
@GetMapping("cardList")
public List<GameCard> getCardList() {
return gameCardRepository.findAll();

View File

@@ -16,6 +16,7 @@ import icu.samnyan.aqua.sega.ongeki.dao.userdata.*;
import icu.samnyan.aqua.sega.ongeki.model.gamedata.GameCard;
import icu.samnyan.aqua.sega.ongeki.model.response.data.UserRivalData;
import icu.samnyan.aqua.sega.ongeki.model.userdata.*;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@@ -35,6 +36,7 @@ import java.util.stream.Collectors;
*/
@RestController
@RequestMapping("api/game/ongeki")
@AllArgsConstructor
public class ApiOngekiPlayerDataController {
private final ApiMapper mapper;
@@ -76,38 +78,6 @@ public class ApiOngekiPlayerDataController {
private final GameCardRepository gameCardRepository;
public ApiOngekiPlayerDataController(ApiMapper mapper, CardService cardService, UserRivalDataRepository userRivalDataRepository, UserActivityRepository userActivityRepository, UserCardRepository userCardRepository, UserChapterRepository userChapterRepository, UserCharacterRepository userCharacterRepository, UserDataRepository userDataRepository, UserDeckRepository userDeckRepository, UserEventPointRepository userEventPointRepository, UserItemRepository userItemRepository, UserLoginBonusRepository userLoginBonusRepository, UserMissionPointRepository userMissionPointRepository, UserMusicDetailRepository userMusicDetailRepository, UserMusicItemRepository userMusicItemRepository, UserOptionRepository userOptionRepository, UserPlaylogRepository userPlaylogRepository, UserStoryRepository userStoryRepository, UserTrainingRoomRepository userTrainingRoomRepository, UserGeneralDataRepository userGeneralDataRepository, GameCardRepository gameCardRepository, UserTradeItemRepository userTradeItemRepository, UserEventMusicRepository userEventMusicRepository, UserTechEventRepository userTechEventRepository, UserKopRepository userKopRepository, UserMemoryChapterRepository userMemoryChapterRepository, UserScenarioRepository userScenarioRepository, UserBossRepository userBossRepository, UserTechCountRepository userTechCountRepository) {
this.mapper = mapper;
this.cardService = cardService;
this.userActivityRepository = userActivityRepository;
this.userCardRepository = userCardRepository;
this.userChapterRepository = userChapterRepository;
this.userCharacterRepository = userCharacterRepository;
this.userDataRepository = userDataRepository;
this.userDeckRepository = userDeckRepository;
this.userEventPointRepository = userEventPointRepository;
this.userItemRepository = userItemRepository;
this.userLoginBonusRepository = userLoginBonusRepository;
this.userMissionPointRepository = userMissionPointRepository;
this.userMusicDetailRepository = userMusicDetailRepository;
this.userMusicItemRepository = userMusicItemRepository;
this.userOptionRepository = userOptionRepository;
this.userPlaylogRepository = userPlaylogRepository;
this.userStoryRepository = userStoryRepository;
this.userTrainingRoomRepository = userTrainingRoomRepository;
this.userGeneralDataRepository = userGeneralDataRepository;
this.gameCardRepository = gameCardRepository;
this.userTradeItemRepository = userTradeItemRepository;
this.userEventMusicRepository = userEventMusicRepository;
this.userTechEventRepository = userTechEventRepository;
this.userKopRepository = userKopRepository;
this.userMemoryChapterRepository = userMemoryChapterRepository;
this.userScenarioRepository = userScenarioRepository;
this.userBossRepository = userBossRepository;
this.userTechCountRepository = userTechCountRepository;
this.userRivalDataRepository = userRivalDataRepository;
}
@GetMapping("profile")
public ProfileResp getProfile(@RequestParam long aimeId) {
return mapper.convert(userDataRepository.findByCard_ExtId(aimeId).orElseThrow(), new TypeReference<>() {

View File

@@ -7,6 +7,7 @@ import icu.samnyan.aqua.sega.chunithm.model.userdata.UserMusicDetail;
import icu.samnyan.aqua.sega.chunithm.service.GameMusicService;
import icu.samnyan.aqua.sega.chunithm.service.UserDataService;
import icu.samnyan.aqua.sega.chunithm.service.UserMusicDetailService;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
@@ -24,6 +25,7 @@ import java.util.Optional;
*/
@RestController
@RequestMapping("api/manage/chuni/v1")
@AllArgsConstructor
public class ApiChuniV1ManageController {
private static final Logger logger = LoggerFactory.getLogger(ApiChuniV1ManageController.class);
@@ -34,12 +36,6 @@ public class ApiChuniV1ManageController {
private final GameMusicService gameMusicService;
public ApiChuniV1ManageController(UserDataService userDataService, UserMusicDetailService userMusicDetailService, GameMusicService gameMusicService) {
this.userDataService = userDataService;
this.userMusicDetailService = userMusicDetailService;
this.gameMusicService = gameMusicService;
}
/**
* A request to fill fake score to all chart. only use for testing
* @param aimeId The internal id of a card

View File

@@ -10,6 +10,7 @@ import icu.samnyan.aqua.sega.diva.model.common.Edition;
import icu.samnyan.aqua.sega.diva.model.gamedata.*;
import icu.samnyan.aqua.sega.general.dao.PropertyEntryRepository;
import icu.samnyan.aqua.sega.general.model.PropertyEntry;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
@@ -21,6 +22,7 @@ import java.util.Optional;
*/
@RestController
@RequestMapping("api/manage/diva/")
@AllArgsConstructor
public class ApiDivaManageController {
private final PvEntryRepository pvEntryRepository;
@@ -29,17 +31,6 @@ public class ApiDivaManageController {
private final FestaRepository festaRepository;
private final ContestRepository contestRepository;
private final PropertyEntryRepository propertyEntryRepository;
private final DivaPvRepository divaPvRepository;
public ApiDivaManageController(PvEntryRepository pvEntryRepository, DivaModuleRepository moduleRepository, DivaCustomizeRepository customizeRepository, FestaRepository festaRepository, ContestRepository contestRepository, PropertyEntryRepository propertyEntryRepository, DivaPvRepository divaPvRepository) {
this.pvEntryRepository = pvEntryRepository;
this.moduleRepository = moduleRepository;
this.customizeRepository = customizeRepository;
this.festaRepository = festaRepository;
this.contestRepository = contestRepository;
this.propertyEntryRepository = propertyEntryRepository;
this.divaPvRepository = divaPvRepository;
}
@PostMapping("pvList")
public List<PvEntry> updatePvList(@RequestBody PvListRequest request) {