@Override public Response<List<Address>> countries() { Response<List<Address>> result = new Response<List<Address>>(); try { List<Address> countries = addressDao.findByLevel(0); result.setResult(countries); return result; } catch (Exception e) { log.error("find provinces fail, cause", e); result.setError("province.query.fail"); return result; } }
@Autowired public AddressServiceImpl(final AddressDao dao) { this.addressDao = dao; this.provinces = addressDao.findByLevel(1); this.childrenCache = CacheBuilder.newBuilder() .build( new CacheLoader<Integer, List<Address>>() { @Override public List<Address> load(Integer id) throws Exception { return addressDao.findByParentId(id); } }); this.addressCache = CacheBuilder.newBuilder() .build( new CacheLoader<Integer, Address>() { @Override public Address load(Integer id) throws Exception { return addressDao.findById(id); } }); }