Commit ceddbc2f by Lee Munkyeong

チャットルーム開設API追加

parent b18009f9
......@@ -21,6 +21,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.CategoriesJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ChatPushDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ContentCheckDeliverableJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ContentVersionsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.CreatedRoomJSON;
import jp.agentec.abook.abv.bl.acms.client.json.FixPushMessageJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GroupListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GroupsJSON;
......@@ -61,6 +62,7 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.PostEnqueteReplyParameters
import jp.agentec.abook.abv.bl.acms.client.parameters.SendPushMessageParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.ServerTimeParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.UpdateDeviceTokenParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.createRoomParameters;
import jp.agentec.abook.abv.bl.acms.type.AcmsApis;
import jp.agentec.abook.abv.bl.acms.type.LoginStatus;
import jp.agentec.abook.abv.bl.acms.type.RequirePasswordChangeCode;
......@@ -572,6 +574,20 @@ public class AcmsClient implements AcmsClientResponseListener {
}
/**
* ルーム作成。
*
* @param sid
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public CreatedRoomJSON createRoom(String sid, Integer roomType, String inviteMemberIds, String newRoomName) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetChatRooms, new createRoomParameters(sid,AcmsApis.Cmds.createRoom,roomType,inviteMemberIds,newRoomName));
CreatedRoomJSON json = new CreatedRoomJSON(response.httpResponseBody);
return json;
}
/**
* 作業報告データ送信
* @param sid
* @param operationId
......
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONArray;
import org.json.adf.JSONObject;
import java.util.ArrayList;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
public class CreatedRoomJSON extends AcmsCommonJSON {
private static final String Body = "body";
private static final String CHAT_ROOM_INFO = "chatRoomInfo";
private static final String ROOM_ID = "roomId";
private static final String ROOM_NAME = "roomName";
private static final String ATTEND_USERS = "attendUsers";
private static final String MEMBER_NAME = "memberName";
private static final String SHOP_MEMBER_ID = "shopMemberId";
private static final String PROFILE_IMAGE_PATH = "profileImagePath";
private static final String DEL_FLG = "del_flg";
private static final String TYPE = "type";
public ArrayList<ShopMemberDto> attendUsers;
public ChatRoomDto chatRoomDto;
public CreatedRoomJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
// ルーム一覧情報を取得
if (!json.has(Body)) { return; }
JSONObject createdRoomJson = json.getJSONObject(Body).getJSONObject(CHAT_ROOM_INFO);
if (createdRoomJson == null) { return; }
JSONArray groupListJsonArray = createdRoomJson.getJSONArray(ATTEND_USERS);
chatRoomDto = new ChatRoomDto();
chatRoomDto.userCount = groupListJsonArray.length();
chatRoomDto.chatRoomId = createdRoomJson.getInt(ROOM_ID);
chatRoomDto.chatRoomName = createdRoomJson.getString(ROOM_NAME);
chatRoomDto.type = createdRoomJson.getInt(TYPE);
chatRoomDto.unreadCount = 0;
}
}
......@@ -33,20 +33,20 @@ public class GroupListJSON extends AcmsCommonJSON {
// ルーム一覧情報を取得
if (!json.has(Body)) { return; }
JSONArray GroupListJsonArray = json.getJSONObject(Body).getJSONArray(GROUP_INFO_LIST);
if (GroupListJsonArray == null) { return; }
JSONArray groupListJsonArray = json.getJSONObject(Body).getJSONArray(GROUP_INFO_LIST);
if (groupListJsonArray == null) { return; }
groupList = new ArrayList<GroupDto>();
for (int listCount = 0; listCount < GroupListJsonArray.length(); listCount++) {
if (GroupListJsonArray.getJSONObject(listCount).length() == 0) {
for (int listCount = 0; listCount < groupListJsonArray.length(); listCount++) {
if (groupListJsonArray.getJSONObject(listCount).length() == 0) {
break;
}
GroupDto groupDto = new GroupDto();
groupDto.groupId = GroupListJsonArray.getJSONObject(listCount).getInt(GROUP_ID);
groupDto.parentGroupId = GroupListJsonArray.getJSONObject(listCount).getInt(PARENT_GROUP_ID);
groupDto.groupName = GroupListJsonArray.getJSONObject(listCount).getString(GROUP_NAME);
groupDto.delFlg = GroupListJsonArray.getJSONObject(listCount).getInt(DEL_FLG);
groupDto.groupId = groupListJsonArray.getJSONObject(listCount).getInt(GROUP_ID);
groupDto.parentGroupId = groupListJsonArray.getJSONObject(listCount).getInt(PARENT_GROUP_ID);
groupDto.groupName = groupListJsonArray.getJSONObject(listCount).getString(GROUP_NAME);
groupDto.delFlg = groupListJsonArray.getJSONObject(listCount).getInt(DEL_FLG);
groupList.add(groupDto);
}
......
package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.abook.abv.bl.acms.type.AcmsApis;
import jp.agentec.adf.net.http.HttpParameterObject;
/**
* ACMSのAPIに渡す共通的なパラメータを格納します。ACMSのAPIのパラメータ用クラスを作成するときはこのクラスを継承してください。<br>
* ただし、このクラスはログイン状態の確認用として使われる {@link createRoomParameters#sid} を持っているため、ログイン用のパラメータ {@link MobileLoginParameters} は、このクラスを継承する必要はありません。
* @author Taejin Hong
* @version 1.0.0
*/
public class createRoomParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
private Integer roomType;
private String inviteMemberIds;
private String newRoomName;
/**
* {@link createRoomParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @since 1.0.0
*/
public createRoomParameters(String sid) {
this.sid = sid;
}
/**
* {@link createRoomParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @param cmd Apiリクエストに必要なコマンド(ABOOK COMM専用)。
* @since 1.0.0
*/
public createRoomParameters(String sid, String cmd, Integer roomType, String inviteMemberIds, String newRoomName) {
this.sid = sid;
this.cmd = cmd;
this.roomType = roomType;
this.inviteMemberIds = inviteMemberIds;
this.newRoomName = newRoomName;
}
/**
* セッションIDを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getSid() {
return sid;
}
/**
* コマンドを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getCmd() {
return cmd;
}
public Integer getRoomType() {
return roomType;
}
public String getInviteMemberIds() {
return inviteMemberIds;
}
public String getNewRoomName() {
return newRoomName;
}
}
......@@ -177,6 +177,7 @@ public class AcmsApis {
public static final String getRoomList = "5";
public static final String getMyInfo = "9";
public static final String getGroupInfo = "10";
public static final String createRoom = "2";
}
// download
......
......@@ -103,9 +103,12 @@ public class CommunicationLogic extends AbstractLogic {
chatMessageDao.insertChatMessage(insertMessageList);
}
public void insertChatRoom(ChatRoomDto chatRoomDto) {
chatRoomDao.insertChatRoom(chatRoomDto);
}
public void insertShopMember(ShopMemberDto shopMemberDto) {
shopMemberDao.insertShopMember(shopMemberDto);
}
public void updateGroup(List<GroupDto> GroupList) {
......
......@@ -39,6 +39,7 @@ import java.util.Objects;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.AcmsCommonJSON;
import jp.agentec.abook.abv.bl.acms.client.json.CreatedRoomJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GroupListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MyInfoJSON;
import jp.agentec.abook.abv.bl.acms.client.json.RoomListJSON;
......@@ -705,7 +706,6 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@JavascriptInterface
public void updateMyInfo() throws NetworkDisconnectedException, AcmsException {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMyInfo(sid);
communicationLogic.insertShopMember(resultJson.shopMemberDto);
}
......@@ -714,6 +714,12 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid,"0");
communicationLogic.updateGroup(resultJson.groupList);
}
@JavascriptInterface
public void createRoom(Integer roomType, String userIdList, String encodedRoomName) throws NetworkDisconnectedException, AcmsException {
CreatedRoomJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).createRoom(sid, roomType, userIdList, encodedRoomName);
communicationLogic.insertChatRoom(resultJson.chatRoomDto);
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment