mirror of
https://github.com/cekis/swg-api
synced 2026-07-14 15:01:32 -04:00
Properties management nearly complete.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package swg.service;
|
||||
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import swg.dao.CityObjectDao;
|
||||
import swg.dao.PropertyListDao;
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user