DummyPost #86

Merged w-katsumasa merged 3 commits into nitta-lab-2023:master from nitta-lab-2023:dummyPost on 25 May 2023
Showing 5 changed files
View
5
src/main/java/org/ntlab/nemophila/models/accounts/Account.java
@JsonIgnore
private String pw;
@JsonProperty("token")
private String token;
 
@JsonIgnore
private HashMap<String, Post> posts = new HashMap<>();
 
//Accountから対応するFriendManagerを1つ呼び出す(初期化)
@JsonIgnore
FriendManager friendManager = new FriendManager();
}
public void setToken(String token) {
this.token = token;
}
 
private HashMap<String, Post> posts = new HashMap<>();
 
//新規投稿
public Post createPost(Shop shop, int rate, String genre, String comment, String image1, String image2, String image3) {
Post post = new Post(this, genre, rate, shop);
View
33
src/main/java/org/ntlab/nemophila/models/accounts/AccountManager.java
package org.ntlab.nemophila.models.accounts;
 
import org.ntlab.nemophila.models.shops.Shop;
import org.ntlab.nemophila.models.shops.ShopManager;
 
import java.util.HashMap;
import java.util.UUID;
 
private HashMap<String,Account> accountsMap = new HashMap<>();
private int newId = 1111;
 
private AccountManager() {
//ダミーアカウントとの作成
//ダミーのお店を作成
ShopManager sm = ShopManager.getInstance();
Shop shopA = sm.createShop("店A", 12.3, 34.5);
Shop shopB = sm.createShop("店B", 56.7, 78.9);
Shop shopC = sm.createShop("店C", 12.3, 34.5);
Shop shopD = sm.createShop("店D", 56.7, 78.9);
 
//ダミーアカウントの作成
this.createAccount("a","a");
Account testAc1 = this.getAccount("1111");
testAc1.createPost(shopA, 5, "ラーメン", "おいしかった", null, null, null);
 
this.createAccount("b","b");
Account testAc2 = this.getAccount("1112");
testAc2.createPost(shopB, 2, "そば", "濃かった", null, null, null);
 
this.createAccount("c","c");
Account testAc3 = this.getAccount("1113");
testAc3.createPost(shopC, 3, "中華", "王将の方がおいしい", null, null, null);
 
this.createAccount("d","d");
Account testAc4 = this.getAccount("1114");
testAc4.createPost(shopD, 5, "カレー", "なかなかおいしかった", null, null, null);
}
 
//シングルトン化
public static AccountManager getInstance() {
if(theInstance == null){
theInstance = new AccountManager();
}
return theInstance;
}
 
// //全てのアカウントの取得
//全てのアカウントの取得
public HashMap<String, Account> getAccountsMap() {
return accountsMap;
}
 
View
2
■■■
src/main/java/org/ntlab/nemophila/models/shops/Shop.java
@JsonProperty("longitude")
private double longitude;
@JsonProperty("latitude")
private double latitude;
@JsonProperty("posts")
@JsonIgnore
private ArrayList<Post> posts = new ArrayList<>();
 
//Getter
public String getId() {
View
3
■■
src/main/java/org/ntlab/nemophila/models/shops/ShopManager.java
private HashMap<String, Shop> shopsMap = new HashMap<>();
 
//コンストラクタにアクセス制限をつけることで,インスタンス生成できなくする
private ShopManager() {
//ダミーカウント作成
this.createShop("店A", 12.3, 45.6);
this.createShop("店B", 78.9, 10.1);
}
 
//インスタンスがなければ作成する
public static ShopManager getInstance() {
View
1
■■■■
src/main/java/org/ntlab/nemophila/resources/shops/ShopPostsRest.java
//入力したsidに対する投稿が存在すれば、投稿情報を取得する
if (shop != null) {
return shop.getPosts();
}
 
return null;
}
 
@DELETE