package com.example.cosmos_serversb.models; import java.util.UUID; import javax.inject.Singleton; import com.example.cosmos_serversb.entities.*; @Singleton public class Users { private static Users theInstance = null; private Users() { } public static Users getInstance() { if (theInstance == null) { theInstance = new Users(); } return theInstance; } public static User createUser(String name, String pw, String iconImage) { User testUser = new User("test", "123456789", "http://test.com", "testpw", null, "123456789", "http://iconuri/123456789.com"); testUser.token.add(getInstance().createToken(testUser.uId)); testUser.token.add(getInstance().createToken(testUser.uId)); return testUser; } public static String createToken(String uId) { //Tokenを作成しuIdと関連付けしDBに保存し作成したTokenを返す String token = UUID.randomUUID().toString(); return token; } public static User setUser(String uId, String name, String pw, String iconImage) { User testUser = new User("test", "123456789", "http://test.com", "testpw", null, "123456789", "http://iconuri/123456789.com"); testUser.token.add(getInstance().createToken(testUser.uId)); testUser.token.add(getInstance().createToken(testUser.uId)); return testUser; } public static User getUserById(String uId) { User testUser = new User("test", "123456789", "http://test.com", "testpw", null, "123456789", "http://iconuri/123456789.com"); testUser.token.add(getInstance().createToken(testUser.uId)); testUser.token.add(getInstance().createToken(testUser.uId)); return testUser; } public static User getUserByToken(String token) { User testUser = new User("test", "123456789", "http://test.com", "testpw", null, "123456789", "http://iconuri/123456789.com"); testUser.token.add(getInstance().createToken(testUser.uId)); testUser.token.add(getInstance().createToken(testUser.uId)); return testUser; } public static DeleteResult deleteUser(String uId) { return DeleteResult.SUCCESS; } public static String login(String uId) { return getInstance().createToken(uId);//testToken } public static DeleteResult logout(String token) { return DeleteResult.SUCCESS; } public static boolean checkToken(String uId, String token) { return true; } public static boolean checkPassword(String uId, String pw) { return true; } }