Skip to content

Commit

Permalink
Merge pull request #1009 from DenverCoder544/myplaces_use_database_di…
Browse files Browse the repository at this point in the history
…rectly

implement delete
  • Loading branch information
ZakarFin authored Oct 3, 2023
2 parents a862fe1 + b15fbc9 commit 63fd396
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void handleDelete(ActionParameters params) throws ActionException {
int deleted;
try {
LOG.debug("Deleting MyPlaces:", ids);
deleted = featureService.delete(ids);
deleted = mybatisFeatureService.delete(ids);
LOG.info("Deleted", deleted, "/", ids.length);
} catch (ServiceException e) {
LOG.warn(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,10 @@ public interface MyPlaceMapper {
" WHERE "+
" id = #{id} ")
Long updateMyPlace(MyPlace myPlace);

@Delete("DELETE FROM my_places "+
" WHERE "+
" id = #{id} ")
Long deleteMyPlace(long id);

}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,19 @@ public int update(List<MyPlace> places) throws ServiceException {

@Override
public int delete(long[] ids) throws ServiceException {
return 0;
try (SqlSession session = factory.openSession()) {
LOG.debug("Deleting from myPlaces: ", ids);
final MyPlaceMapper mapper = session.getMapper(MyPlaceMapper.class);
for (long id : ids) {
mapper.deleteMyPlace(id);
LOG.info("deleted myplace: ", id);
}
session.commit();
return ids.length;
} catch (Exception e) {
LOG.warn(e, "Exception when trying to add MyPlaces ");
throw new ServiceException(e.getMessage());
}
}

private Geometry doGeometryTransform(Geometry geometry) throws ServiceException {
Expand Down

0 comments on commit 63fd396

Please sign in to comment.