diff --git a/src/main/java/org/ntlab/acanthus_server/entities/Account.java b/src/main/java/org/ntlab/acanthus_server/entities/Account.java index 225f6df..7be6334 100644 --- a/src/main/java/org/ntlab/acanthus_server/entities/Account.java +++ b/src/main/java/org/ntlab/acanthus_server/entities/Account.java @@ -45,8 +45,13 @@ private String email; @JsonProperty("work") private HashMap workHashMap = new HashMap<>(); - @JsonProperty("follows") + + //@JsonProperty("follows") + @JsonIgnore //アカウント情報取得時のループ対策 private HashMap followsHashMap = new HashMap<>(); + //@JsonProperty("followers") + @JsonIgnore + private HashMap followersHashMap =new HashMap<>(); @JsonIgnore private Integer uid; @@ -104,6 +109,11 @@ this.followsHashMap.put(uid, account); } + public void addFollowersHashMap(Account account) { + var uid = account.getUid(); + this.followersHashMap.put(uid, account); + } + //----------------------------------------------------------------- // getter public Integer getUid() { @@ -135,6 +145,10 @@ return this.followsHashMap; } + public HashMap getFollowersHashMap() { + return this.followersHashMap; + } + //----------------------------------------------------------------- // 招待されている作品を返す @JsonIgnore diff --git a/src/main/java/org/ntlab/acanthus_server/entities/FollowAddJson.java b/src/main/java/org/ntlab/acanthus_server/entities/FollowAddJson.java index a31cbab..741246c 100644 --- a/src/main/java/org/ntlab/acanthus_server/entities/FollowAddJson.java +++ b/src/main/java/org/ntlab/acanthus_server/entities/FollowAddJson.java @@ -30,4 +30,5 @@ public void setFollowUid(Integer followUid) { this.followUid = followUid; } + } diff --git a/src/main/java/org/ntlab/acanthus_server/entities/FollowUidJson.java b/src/main/java/org/ntlab/acanthus_server/entities/FollowUidJson.java index dfd8d84..995d5ac 100644 --- a/src/main/java/org/ntlab/acanthus_server/entities/FollowUidJson.java +++ b/src/main/java/org/ntlab/acanthus_server/entities/FollowUidJson.java @@ -23,4 +23,5 @@ public void setUidList(Collection uidList) { this.uidList = uidList; } + } diff --git a/src/main/java/org/ntlab/acanthus_server/resources/accounts/FollowsRest.java b/src/main/java/org/ntlab/acanthus_server/resources/accounts/FollowsRest.java index ca37ded..b36033b 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/accounts/FollowsRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/accounts/FollowsRest.java @@ -7,7 +7,6 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.util.ArrayList; import java.util.Collection; @Component @@ -47,7 +46,7 @@ if (account.getFollowsHashMap().get(followUid) == null) {//既にフォローしているユーザーか確認 if (uid != followUid){//誤って自分自身をフォローしているか確認 account.addFollowsHashMap(followAccount); - + followAccount.addFollowersHashMap(account); return new FollowAddJson(account, followAccount); }else { @@ -80,7 +79,7 @@ if (account != null && account.getToken().equals(token)){ if (followAccount != null){//フォロー内にユーザーが登録されているか確認 account.getFollowsHashMap().remove(followUid); - + followAccount.getFollowersHashMap().remove(uid); return "フォローを解除しました"; }else {