diff --git a/src/main/java/org/ntlab/nemophila/models/accounts/Account.java b/src/main/java/org/ntlab/nemophila/models/accounts/Account.java index 752f52c..5a2c70b 100644 --- a/src/main/java/org/ntlab/nemophila/models/accounts/Account.java +++ b/src/main/java/org/ntlab/nemophila/models/accounts/Account.java @@ -1,10 +1,94 @@ package org.ntlab.nemophila.models.accounts; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.ntlab.nemophila.models.shops.Shop; + +import java.util.Collection; +import java.util.HashMap; + public class Account { + @JsonProperty("name") + private String name; + @JsonProperty("id") + private String id; + + private String pw; + @JsonProperty("token") + private String token; + + //コンストラクタ + public Account(String name, String pw) { + this.name = name; + this.pw = pw; + } + + //Getter + public String getId() { + return id; + } + public String getName() { + return name; + } + + //Setter + public void setName(String name) { + this.name = name; + } + public void setId(String id) { + this.id = id; + } + public void setPw(String pw) { + this.pw = pw; + } + public void setToken(String token) { + this.token = token; + } + + private HashMap posts = new HashMap<>(); + + + //新規投稿 + public Post createPost(int rate, String genre, String comment, String image1, String image2, String image3, Shop shop) { + Post post = new Post(); + + post.setRate(rate); + post.setGenre(genre); + //コメントと写真は必須ではない。nullで登録できる??? + //無理ならnull時「なし」に変換させて登録で。 + post.setComment(comment); + post.setImage1(image1); + post.setImage2(image2); + post.setImage3(image3); + post.setId(shop.getId()); + + posts.put(post.getId(), post); + + return post;//必要ないけど一応 + } + + //pidを指定して投稿を一つ取得 + Post getPost(String pid) { + return posts.get(pid); + } + + //そのaccountの投稿を全て取得 + Collection getPosts() { + return posts.values(); + } + + //投稿削除 + public void deletePost(Post post) { + posts.remove(post); + } + //投稿数の取得 + public int getPostsCount() { + return posts.size(); + } + //Accountから対応するFriendManagerを1つ呼び出す(初期化) FriendManager friendManager = new FriendManager(); public FriendManager getFriendManager() { return friendManager; } -} +} \ No newline at end of file