diff --git a/src/main/java/org/ntlab/amaryllis/server/entities/Voicememo.java b/src/main/java/org/ntlab/amaryllis/server/entities/Voicememo.java index 47cda7f..019ae38 100644 --- a/src/main/java/org/ntlab/amaryllis/server/entities/Voicememo.java +++ b/src/main/java/org/ntlab/amaryllis/server/entities/Voicememo.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; +import java.awt.datatransfer.FlavorListener; import java.util.ArrayList; import java.util.Calendar; @@ -18,7 +19,7 @@ private Integer times; @JsonIgnore private ArrayList favolist; - private Integer favos;//favoslistの要素数 + private Integer favos; private ArrayList categories; private ArrayList comments_commentNo; private ArrayList comments_uid; @@ -38,7 +39,7 @@ setTitle(title); setSummary(summary); this.times = 0; -// this.favos = 0; + this.favos = 0; // categories = new ArrayList<>(); // comments_commentNo = new ArrayList<>(); // comments_uid = new ArrayList<>(); @@ -134,26 +135,36 @@ times++; } -// public ArrayList getFavolist(){ return favolist; } -// -// public boolean checkFavo(String uid){ -// for (String a : favolist) { -// if (a.equals(vid)) { -// return true; -// } -// } -// return false; -// } -// -// private void addFavolist(String uid){ -// favolist.add(uid); -// calcFavos(); -// } -// -// public Integer getFavos(){ return favos; } -// private void calcFavos(){ -// favos = favolist.size(); -// } + public ArrayList getFavolist(){ return favolist; } + + public boolean checkFavo(String uid){ + for (String a : favolist) { + if (a.equals(vid)) { + return true; + } + } + return false; + } + + public void addFavolist(String uid){ + if(checkFavo(uid)){ + return; + } + favolist.add(uid); + setFavos(); + + } + + public void removeFavolist(String uid) { + favolist.remove(uid); + setFavos(); + } + + public Integer getFavos(){ return favos; } + + private void setFavos(){ + favos = favolist.size(); + } // // public ArrayList getCategory(){ return categories; } //