Merge branch 'master' into hinernetTests
commit c199db464bc43d07a1ca3f259b37f5cfc2cf1005
2 parents 30bb913 + 44aacde
Narumasa kande authored on 4 Jun 2019
Showing 6 changed files
View
2
■■■
.idea/gradle.xml
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="C:/ProgramData/chocolatey/lib/gradle/tools/gradle-4.10.2" />
<option name="gradleJvm" value="12" />
<option name="gradleJvm" value="1.8" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
View
8
src/main/java/com/example/cosmos_serversb/entities/User.java
import java.util.List;
 
 
public class User {
public String uId, uri, name, pw, iconImage, iconUri;
public boolean login = false;
public String uId, uri, name, pw, iconUri;
public boolean login = true;
public List<String> token = new ArrayList<String>();
 
public User(String name, String uId,String uri,String pw,ArrayList token,String iconImage,String iconUri) {
public User(String name, String uId,String uri,String pw,ArrayList token,String iconUri) {
this.name = name;
this.uId = uId;
this.uri=uri;
this.pw=pw;
this.token = new ArrayList<String>();//test
this.iconImage=iconImage;
//this.iconImage=iconImage;
this.iconUri=iconUri;
}
}
View
43
src/main/java/com/example/cosmos_serversb/models/Groups.java
package com.example.cosmos_serversb.models;
 
import java.util.*;
import javax.inject.Singleton;
import javax.persistence.Column;
import com.example.cosmos_serversb.entities.*;
 
 
@Singleton
public class Groups {
private static Groups thaInstance = null;
}
return thaInstance;
}
 
 
public static HashMap<String, String> getGroupsListByUid(String uId){
return null;
return createTestHashMap();
}
 
public static Group createGroup(String name, String uId){
//先にGidとuriの発行を行う
Group testGroup = new Group("123456789", "http://test,com", name, uId);
Group testGroup = new Group("123456789", "http://test.com", name, uId);
groups.add(testGroup);
return testGroup;
}
 
return DeleteResult.SUCCESS;
}
 
public static HashMap<String, String> getMembersListByGid(String gId){
return null;
return createTestHashMap();
}
 
public static HashMap<String, String> addMember(String gId, String uId){
return null;
return createTestHashMap();
}
 
public static HashMap<String, String> deleteMember(String gId, String uId){
return null;
return createTestHashMap();
}
 
public static HashMap<String, String> getRequestsListByGid(String gId){
return null;
return createTestHashMap();
}
 
public static Request addRequests(String gId, String uId, String product,
String deadline, int location){
public static Request addRequests(String gId, String uId, String product, String deadline, int location){
//テスト用
Request testRequest = new Request("123456789", "http://test,com", "1999/01/01/15:00:00",
Request testRequest = new Request("123456789", "http://test.com", "1999/01/01/15:00:00",
uId, product, "1999/01/01/15:00:00", 999);
return testRequest;
}
 
public static Request getRequestDetailByGidAndRid(String gId, String rId){
return null;
}
 
public static Request updateRequest(String gId, String rId, String uId, String product,
String deadline, int location, boolean done){
public static Request updateRequest(String gId, String rId, String uId, String product, String deadline, int location, boolean done){
 
//テスト用
Request testRequest = new Request("123456789", "http://test,com", "1999/01/01/15:00:00",
Request testRequest = new Request("123456789", "http://test.com", "1999/01/01/15:00:00",
uId, product, "1999/01/01/15:00:00", 999);
 
return testRequest;
}
 
public static DeleteResult deleteRequest(String gId, String rId){
return DeleteResult.SUCCESS;
}
 
//テスト用にHashMapの作成
public static HashMap<String, String> createTestHashMap(){
HashMap<String, String> testMap = new HashMap<>();
testMap.put("123456780", "http://test0.com");
testMap.put("123456781", "http://test1.com");
testMap.put("123456782", "http://test2.com");
/*
//Key, valueの取り出し方例(拡張for文)
for (String key : TestMap.keySet()) {
System.out.println(key + " " + TestMap.get(key));
}
*/
return testMap;
}
 
}
View
20
src/main/java/com/example/cosmos_serversb/models/Users.java
return uId;
}
 
public static User createUser(String name, String pw, String iconImage) {
User testUser = new User("test", getInstance().createUId(), "http://test.com", "testpw", null, "123456789", "http://iconuri/123456789.com");
User testUser = new User("test", getInstance().createUId(), "http://test.com", "testpw", null, "http://localhost:8080/iconImage/b4bb7db0-cc0c-4ee1-816f-8304add12da8.jpg");
testUser.token.add(getInstance().createToken(testUser.uId));
testUser.token.add(getInstance().createToken(testUser.uId));
return testUser;
}
 
public static User setUser(String uId, String name, String pw, String iconImage) {
User testUser = new User("test", getInstance().createUId(), "http://test.com", "testpw", null, "123456789", "http://iconuri/123456789.com");
User testUser = new User("test", getInstance().createUId(), "http://test.com", "testpw", null, "http://localhost:8080/iconImage/b4bb7db0-cc0c-4ee1-816f-8304add12da8.jpg");
testUser.token.add(getInstance().createToken(testUser.uId));
testUser.token.add(getInstance().createToken(testUser.uId));
return testUser;
}
 
public static User getUserById(String uId) {
//与えられたuIdのUser情報を返す
User testUser = new User("test", getInstance().createUId(), "http://test.com", "testpw", null, "123456789", "http://iconuri/123456789.com");
User testUser = new User("test", getInstance().createUId(), "http://test.com", "testpw", null, "http://localhost:8080/iconImage/b4bb7db0-cc0c-4ee1-816f-8304add12da8.jpg");
testUser.token.add(getInstance().createToken(testUser.uId));
testUser.token.add(getInstance().createToken(testUser.uId));
return testUser;
}
 
public static User getUserByToken(String token) {
//与えられたTokenに紐づくUser情報を返す
User testUser = new User("test", getInstance().createUId(), "http://test.com", "testpw", null, "123456789", "http://iconuri/123456789.com");
User testUser = new User("test", getInstance().createUId(), "http://test.com", "testpw", null, "http://localhost:8080/iconImage/b4bb7db0-cc0c-4ee1-816f-8304add12da8.jpg");
testUser.token.add(getInstance().createToken(testUser.uId));
testUser.token.add(getInstance().createToken(testUser.uId));
return testUser;
}
return getInstance().createToken(uId);//testToken
}
 
public static DeleteResult logout(String token) {
return DeleteResult.SUCCESS;
if(Users.getInstance().getUserByToken(token).uId == null) {
return DeleteResult.FAILURE;
}else{
Users.getInstance().getUserByToken(token).token.remove(Users.getInstance().getUserByToken(token).token.indexOf(token));
return DeleteResult.SUCCESS;
}
}
 
public static boolean checkToken(String uId, String token) {
//与えられたtokenとUserのtokenを比較し結果を返す
View
13
src/main/java/com/example/cosmos_serversb/resources/UsersRest.java
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Component;
 
import javax.ws.rs.*;
 
import com.example.cosmos_serversb.models.*;
 
@Component
 
@FormParam("name") String name,
@FormParam("pw") String pw,
@FormParam("iconImage") String iconImage) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(Users.createUser(name,pw,iconImage));
String json = mapper.writeValueAsString(Users.getInstance().createUser(name, pw, iconImage));
 
return json;
}
 
public String getUsersInfo(
@PathParam("uId") String uId,
@QueryParam("token") String token) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(Users.getUserById("1234"));
String json = mapper.writeValueAsString(Users.getInstance().getUserById(uId));
 
return json;
}
 
@FormParam("name") String name,
@FormParam("pw") String pw,
@FormParam("iconImage") String iconImage) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(Users.setUser("1234","1234","1234","1234"));
String json = mapper.writeValueAsString(Users.getInstance().setUser(uId, name, pw, iconImage));
 
return json;
}
 
public String deleteUsersInfo(
@PathParam("uId") String uId,
@FormParam("token") String token) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(Users.deleteUser("1234"));
String json = mapper.writeValueAsString(Users.getInstance().deleteUser(uId));
 
return json;
}
 
public String login(
@PathParam("uId") String uId,
@FormParam("pw") String pw) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(Users.login("1234"));
String json = mapper.writeValueAsString(Users.getInstance().login(uId));
 
return json;
}
 
public String logout(
@PathParam("uId") String uId,
@FormParam("token") String token) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(Users.logout("1234"));
String json = mapper.writeValueAsString(Users.getInstance().logout(token));
 
return json;
}
}
View
static/iconImage/b4bb7db0-cc0c-4ee1-816f-8304add12da8.jpg 0 → 100644