mirror of
https://github.com/cekis/swg-api
synced 2026-07-13 22:01:02 -04:00
34 lines
1.1 KiB
Java
34 lines
1.1 KiB
Java
package swg.service;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import swg.repository.CityObjectDao;
|
|
import swg.entity.CityObject;
|
|
import swg.entity.PropertyList;
|
|
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
|
|
@Service
|
|
public class CityObjectService {
|
|
@Autowired
|
|
CityObjectDao cityObjectDao;
|
|
|
|
public List<CityObject> getAllCityObjects() { return this.cityObjectDao.findAll(); }
|
|
public CityObject getCityObjectByObjectId(Long objectId) {
|
|
return this.cityObjectDao.findByObjectId(objectId);
|
|
}
|
|
public CityObject getCityObjectByCityName(String name) {
|
|
List<CityObject> cobs = getAllCityObjects();
|
|
for (CityObject cob : cobs) {
|
|
Optional<PropertyList> pl = cob.getPropertyLists().stream().filter(p -> p.getListId() == 12).findAny();
|
|
if(pl.isPresent()) {
|
|
PropertyList p = pl.get();
|
|
if(p.getValue().split(":")[2].equals(name)) {
|
|
return cob;
|
|
}
|
|
};
|
|
}
|
|
return null;
|
|
}
|
|
} |