AnnotationService.java 732 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package edu.nju.service;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.stereotype.Service;
  4. import edu.nju.dao.AnnotationDao;
  5. import edu.nju.entities.ImageAnnotation;
  6. @Service
  7. public class AnnotationService {
  8. @Autowired
  9. AnnotationDao andao;
  10. public boolean save(String id, String width, String height, String[] xs, String[] ys) {
  11. try {
  12. andao.save(new ImageAnnotation(id, width, height, xs, ys));
  13. return true;
  14. } catch (Exception e) {
  15. return false;
  16. }
  17. }
  18. public boolean delete(String id) {
  19. try {
  20. andao.remove(id);
  21. return true;
  22. } catch (Exception e) {
  23. return false;
  24. }
  25. }
  26. public ImageAnnotation get(String id) {
  27. return andao.findById(id);
  28. }
  29. }