Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// class AccountGeo
- public class AccountGeo{
- String id;
- IFacilitiesGeoConfig geoParam;
- public AccountGeo() {
- }
- public AccountGeo(String id, IFacilitiesGeoConfig geoParam) {
- this.id = id;
- this.geoParam = geoParam;
- }
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public IFacilitiesGeoConfig getGeoParam() {
- return geoParam;
- }
- public void setGeoParam(IFacilitiesGeoConfig geoParam) {
- this.geoParam = geoParam;
- }
- @Override
- public String toString() {
- return "AccountGeo{" +
- "id='" + id + '\'' +
- ", geoParam=" + geoParam +
- '}';
- }
- }
- //accountDbservice
- public List<AccountGeo> getAccountGeosByAccountIds(String[] accountIds) {
- List<AccountGeo> accountGeos = new ArrayList<>();
- try {
- accountGeos = jdbcTemplate.query("SELECT id, MALatitude__c, MALongitude__c FROM batch.ACCOUNT where id in ('" + String.join("','", accountIds) + "')", (rs, rowNum) -> {
- IFacilitiesGeoConfig geo = new IFacilitiesGeoConfig();
- geo.setLatitude(rs.getDouble("MALatitude__c"));
- geo.setLongitude(rs.getDouble("MALongitude__c"));
- AccountGeo accountGeo = new AccountGeo();
- accountGeo.setGeoParam(geo);
- accountGeo.setId(rs.getString("id"));
- return accountGeo;
- });
- LOGGER.info(String.format("Select form database - ok"));
- } catch (DataAccessException e) {
- LOGGER.error(String.format("Error occurred when fetching accounts from database: %s", e.getMessage()));
- }
- return accountGeos;
- }
- //accountcontroller
- @PostMapping(value = "accGeos")
- List<AccountGeo> findAccountWithGeos(@RequestBody String[] ids) {
- return accountDBService.getAccountGeosByAccountIds(ids);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement