fixed some bugs with FinderUtil
This commit is contained in:
parent
22ed8e41e2
commit
eaaa1fb2bb
@ -8,35 +8,71 @@ import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
public class FinderUtil {
|
||||
|
||||
@Autowired
|
||||
static CacheRepository cacheRepository;
|
||||
|
||||
@Autowired
|
||||
static RewardRepository rewardRepository;
|
||||
|
||||
@Autowired
|
||||
static StationRepository stationRepository;
|
||||
|
||||
@Autowired
|
||||
static BearbeitetRepository bearbeitetRepository;
|
||||
|
||||
@Autowired
|
||||
static CacheAccesDefinitionRepository cacheAccesDefinitionRepository;
|
||||
|
||||
@Autowired
|
||||
static TeamRepository teamRepository;
|
||||
|
||||
@Autowired
|
||||
static UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
static User_InfoRepository user_infoRepository;
|
||||
|
||||
|
||||
@Autowired
|
||||
public void setCacheRepository(CacheRepository cacheRepository) {
|
||||
FinderUtil.cacheRepository= cacheRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setRewardRepository(RewardRepository rewardRepository) {
|
||||
FinderUtil.rewardRepository = rewardRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setStationRepository(StationRepository stationRepository) {
|
||||
FinderUtil.stationRepository = stationRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setBearbeitetRepository(BearbeitetRepository bearbeitetRepository) {
|
||||
FinderUtil.bearbeitetRepository = bearbeitetRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setCacheAccesDefinitionRepository(CacheAccesDefinitionRepository cacheAccesDefinitionRepository) {
|
||||
FinderUtil.cacheAccesDefinitionRepository = cacheAccesDefinitionRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setTeamRepository(TeamRepository teamRepository) {
|
||||
FinderUtil.teamRepository = teamRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setUserRepository(UserRepository userRepository) {
|
||||
FinderUtil.userRepository = userRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setUser_infoRepository(User_InfoRepository user_infoRepository) {
|
||||
FinderUtil.user_infoRepository = user_infoRepository;
|
||||
}
|
||||
|
||||
|
||||
public static ResponseEntity findCacheById(String cacheID) {
|
||||
|
||||
Optional<Cache> cacheOptional = cacheRepository.findById(Integer.valueOf(cacheID));
|
||||
@ -102,8 +138,8 @@ public class FinderUtil {
|
||||
String userString = (String) claims.get("user");
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject userObject = (JSONObject) parser.parse(userString);
|
||||
int userID = (Integer) userObject.get("userID");
|
||||
Optional<User> userOptional = userRepository.findById(userID);
|
||||
long userID = (Long) userObject.get("userId");
|
||||
Optional<User> userOptional = userRepository.findById(Math.toIntExact(userID));
|
||||
if (userOptional.isPresent()) {
|
||||
User user = userOptional.get();
|
||||
return ResponseEntity.status(200).body(user);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user