Commit de8abff4 by Lee Munkyeong

Merge branch 'features/abcomm_sp3_contactUI' of…

Merge branch 'features/abcomm_sp3_contactUI' of https://gitlab.agentec.jp/abook_android/abook_check into features/abcomm_sp3_contactUI

# Conflicts:
#	ABVJE_BL/src/jp/agentec/abook/abv/bl/acms/client/AcmsClient.java
parents c0a58918 ec9b0c65
......@@ -545,7 +545,6 @@ public class AcmsClient implements AcmsClientResponseListener {
HttpResponse response = send(AcmsApis.ApigetChatRooms, new AcmsParameters(sid, AcmsApis.RoomCmds.getRoomList));
RoomListJSON json = new RoomListJSON(response.httpResponseBody);
return json;
}
/**
......@@ -562,6 +561,15 @@ public class AcmsClient implements AcmsClientResponseListener {
return json;
}
/**
* サーバよりネームカード情報取得。
*
* @param sid
* @param shopMemberId
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public MyInfoJSON getNameCard(String sid, String shopMemberId) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetUser, new GetNameCardParameters(sid, AcmsApis.UserCmds.getNameCard, shopMemberId));
MyInfoJSON json = new MyInfoJSON(response.httpResponseBody);
......@@ -572,6 +580,8 @@ public class AcmsClient implements AcmsClientResponseListener {
* 全てのグループ更新。
*
* @param sid
* @param groupId
* @param updatedDate
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
......@@ -586,6 +596,9 @@ public class AcmsClient implements AcmsClientResponseListener {
* ルーム作成。
*
* @param sid
* @param roomType
* @param inviteMemberIds
* @param newRoomName
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
......@@ -600,6 +613,7 @@ public class AcmsClient implements AcmsClientResponseListener {
* ルーム作成。
*
* @param sid
* @param roomId
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
......
......@@ -5,6 +5,7 @@ import org.json.adf.JSONObject;
import java.util.ArrayList;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
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;
......@@ -12,17 +13,6 @@ 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 ROOM_TYPE = "roomType";
public ArrayList<ShopMemberDto> attendUsers;
public ChatRoomDto chatRoomDto;
......@@ -35,20 +25,18 @@ public class CreatedRoomJSON extends AcmsCommonJSON {
protected void parse(JSONObject json) throws JSONValidationException {
// ルーム一覧情報を取得
if (!json.has(Body)) { return; }
if (!json.has(ABookCommConstants.KEY.BODY)) { return; }
JSONObject createdRoomJson = json.getJSONObject(Body).getJSONObject(CHAT_ROOM_INFO);
JSONObject createdRoomJson = json.getJSONObject(ABookCommConstants.KEY.BODY).getJSONObject(ABookCommConstants.KEY.CHAT_ROOM_INFO);
if (createdRoomJson == null) { return; }
JSONArray groupListJsonArray = createdRoomJson.getJSONArray(ATTEND_USERS);
JSONArray groupListJsonArray = createdRoomJson.getJSONArray(ABookCommConstants.KEY.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(ROOM_TYPE);
chatRoomDto.unreadCount = 0;
chatRoomDto.chatRoomId = createdRoomJson.getInt(ABookCommConstants.KEY.ROOM_ID);
chatRoomDto.chatRoomName = createdRoomJson.getString(ABookCommConstants.KEY.ROOM_NAME);
chatRoomDto.type = createdRoomJson.getInt(ABookCommConstants.KEY.ROOM_TYPE);
}
}
......
......@@ -5,6 +5,7 @@ import org.json.adf.JSONObject;
import java.util.ArrayList;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
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.ChatMessageDto;
......@@ -14,20 +15,9 @@ import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.adf.util.DateTimeUtil;
public class GroupListJSON extends AcmsCommonJSON {
private static final String Body = "body";
private static final String GROUP_INFO_LIST = "groupInfoList";
private static final String GROUP_ID = "groupId";
private static final String GROUP_NAME = "groupName";
private static final String PARENT_GROUP_ID = "parentGroupId";
private static final String DEL_FLG = "delFlg";
private static final String GROUP_MEMBER_LIST = "groupMemberList";
private static final String SHOP_MEMBER_ID = "shopMemberId";
private static final String MEMBER_NAME = "memberName";
private static final String PROFILE_IMAGE_PATH = "profileImagePath";
public ArrayList<GroupDto> groupList;
public ArrayList<GroupDto> groupList;
public GroupListJSON(String jsonString) throws AcmsException {
super(jsonString);
......@@ -37,9 +27,9 @@ public class GroupListJSON extends AcmsCommonJSON {
protected void parse(JSONObject json) throws JSONValidationException {
// ルーム一覧情報を取得
if (!json.has(Body)) { return; }
if (!json.has(ABookCommConstants.KEY.BODY)) { return; }
JSONArray groupListJsonArray = json.getJSONObject(Body).getJSONArray(GROUP_INFO_LIST);
JSONArray groupListJsonArray = json.getJSONObject(ABookCommConstants.KEY.BODY).getJSONArray(ABookCommConstants.KEY.GROUP_INFO_LIST);
if (groupListJsonArray == null) { return; }
groupList = new ArrayList<GroupDto>();
......@@ -47,24 +37,27 @@ public class GroupListJSON extends AcmsCommonJSON {
if (groupListJsonArray.getJSONObject(listCount).length() == 0) {
break;
}
JSONObject groupJSON = groupListJsonArray.getJSONObject(listCount);
GroupDto groupDto = new GroupDto();
groupDto.groupId = groupListJsonArray.getJSONObject(listCount).getInt(GROUP_ID);
if (groupListJsonArray.getJSONObject(listCount).has(PARENT_GROUP_ID)) {
groupDto.parentGroupId = groupListJsonArray.getJSONObject(listCount).getInt(PARENT_GROUP_ID);
groupDto.groupId = groupJSON.getInt(ABookCommConstants.KEY.GROUP_ID);
if (groupJSON.has(ABookCommConstants.KEY.PARENT_GROUP_ID)) {
groupDto.parentGroupId = groupJSON.getInt(ABookCommConstants.KEY.PARENT_GROUP_ID);
}
groupDto.groupName = groupListJsonArray.getJSONObject(listCount).getString(GROUP_NAME);
groupDto.delFlg = groupListJsonArray.getJSONObject(listCount).getInt(DEL_FLG);
groupDto.groupName = groupJSON.getString(ABookCommConstants.KEY.GROUP_NAME);
groupDto.delFlg = groupJSON.getInt(ABookCommConstants.KEY.DEL_FLG);
if (groupListJsonArray.getJSONObject(listCount).has(GROUP_MEMBER_LIST)) {
JSONArray groupMemberJsonArray = groupListJsonArray.getJSONObject(listCount).getJSONArray(GROUP_MEMBER_LIST);
if (groupJSON.has(ABookCommConstants.KEY.GROUP_MEMBER_LIST)) {
JSONArray groupMemberJsonArray = groupJSON.getJSONArray(ABookCommConstants.KEY.GROUP_MEMBER_LIST);
ArrayList<ShopMemberDto> groupMembers = new ArrayList<ShopMemberDto>();
for (int groupMemberCount = 0; groupMemberCount < groupMemberJsonArray.length(); groupMemberCount++) {
JSONObject groupMember = groupMemberJsonArray.getJSONObject(groupMemberCount);
ShopMemberDto shopMemberDto = new ShopMemberDto();
shopMemberDto.shopMemberId = groupMemberJsonArray.getJSONObject(groupMemberCount).getInt(SHOP_MEMBER_ID);
shopMemberDto.shopMemberName = groupMemberJsonArray.getJSONObject(groupMemberCount).getString(MEMBER_NAME);
if (groupMemberJsonArray.getJSONObject(groupMemberCount).has(PROFILE_IMAGE_PATH)) {
shopMemberDto.profileUrl = groupMemberJsonArray.getJSONObject(groupMemberCount).getString(PROFILE_IMAGE_PATH);
shopMemberDto.shopMemberId = groupMember.getInt(ABookCommConstants.KEY.SHOP_MEMBER_ID);
shopMemberDto.shopMemberName = groupMember.getString(ABookCommConstants.KEY.MEMBER_NAME);
if (groupMember.has(ABookCommConstants.KEY.PROFILE_IMAGE_PATH)) {
shopMemberDto.profileUrl = groupMember.getString(ABookCommConstants.KEY.PROFILE_IMAGE_PATH);
}
ArrayList groupIds = new ArrayList();
groupIds.add(groupDto.groupId);
......
......@@ -6,6 +6,7 @@ import org.json.adf.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
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.ChatMessageDto;
......@@ -13,17 +14,7 @@ import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.adf.util.DateTimeUtil;
public class MessageInfoListJSON extends AcmsCommonJSON {
private static final String Body = "body";
private static final String MESSAGE_INFO_LIST = "messageInfoList";
private static final String MESSAGE = "message";
private static final String MESSAGE_ID = "messageId";
private static final String SHOP_ID = "shopId";
private static final String SHOP_MEMBER_ID = "shopMemberId";
private static final String MESSAGE_TYPE = "messageType";
private static final String TIME = "time";
private static final String MEMBER_NAME = "memberName";
private static final String PROFILE_IMAGE_PATH = "profileImagePath";
public ArrayList<ChatMessageDto> chatMessageDtoArrayList;
public ArrayList<ShopMemberDto> shopMemberDtoArrayList;
......@@ -36,9 +27,9 @@ public class MessageInfoListJSON extends AcmsCommonJSON {
protected void parse(JSONObject json) throws JSONValidationException {
// メッセージ情報を取得
if (!json.has(Body)) { return; }
if (!json.has(ABookCommConstants.KEY.BODY)) { return; }
HashMap<Integer, Integer> existShopMmeberMap = new HashMap<Integer, Integer>();
JSONArray messageInfoList = json.getJSONObject(Body).getJSONArray(MESSAGE_INFO_LIST);
JSONArray messageInfoList = json.getJSONObject(ABookCommConstants.KEY.BODY).getJSONArray(ABookCommConstants.KEY.MESSAGE_INFO_LIST);
if (messageInfoList == null) { return; }
chatMessageDtoArrayList = new ArrayList<ChatMessageDto>();
......@@ -53,22 +44,22 @@ public class MessageInfoListJSON extends AcmsCommonJSON {
JSONObject messageInfoJSON = messageInfoList.getJSONObject(listCount);
if (messageInfoJSON == null) { continue; }
chatMessageDto.shopMemberId = messageInfoJSON.getInt(SHOP_MEMBER_ID);
chatMessageDto.chatMessageId = messageInfoJSON.getInt(MESSAGE_ID);
chatMessageDto.message = messageInfoJSON.getString(MESSAGE);
chatMessageDto.messageType = messageInfoJSON.getInt(MESSAGE_TYPE);
if (messageInfoJSON.has(TIME)) {
chatMessageDto.insertDate = DateTimeUtil.millToDateString(messageInfoJSON.getJSONObject(TIME).getLong(TIME));
chatMessageDto.shopMemberId = messageInfoJSON.getInt(ABookCommConstants.KEY.SHOP_MEMBER_ID);
chatMessageDto.chatMessageId = messageInfoJSON.getInt(ABookCommConstants.KEY.MESSAGE_ID);
chatMessageDto.message = messageInfoJSON.getString(ABookCommConstants.KEY.MESSAGE);
chatMessageDto.messageType = messageInfoJSON.getInt(ABookCommConstants.KEY.MESSAGE_TYPE);
if (messageInfoJSON.has(ABookCommConstants.KEY.TIME)) {
chatMessageDto.insertDate = DateTimeUtil.millToDateString(messageInfoJSON.getJSONObject(ABookCommConstants.KEY.TIME).getLong(ABookCommConstants.KEY.TIME));
}
chatMessageDtoArrayList.add(chatMessageDto);
if (existShopMmeberMap.get(chatMessageDto.shopMemberId) != null) { continue; }
ShopMemberDto shopMemberDto = new ShopMemberDto();
shopMemberDto.shopMemberId = messageInfoJSON.getInt(SHOP_MEMBER_ID);
shopMemberDto.shopMemberName = messageInfoJSON.getString(MEMBER_NAME);
if (messageInfoJSON.has(PROFILE_IMAGE_PATH)) {
shopMemberDto.profileUrl = messageInfoJSON.getString(PROFILE_IMAGE_PATH);
shopMemberDto.shopMemberId = messageInfoJSON.getInt(ABookCommConstants.KEY.SHOP_MEMBER_ID);
shopMemberDto.shopMemberName = messageInfoJSON.getString(ABookCommConstants.KEY.MEMBER_NAME);
if (messageInfoJSON.has(ABookCommConstants.KEY.PROFILE_IMAGE_PATH)) {
shopMemberDto.profileUrl = messageInfoJSON.getString(ABookCommConstants.KEY.PROFILE_IMAGE_PATH);
}
existShopMmeberMap.put(shopMemberDto.shopMemberId,shopMemberDto.shopMemberId);
shopMemberDtoArrayList.add(shopMemberDto);
......
......@@ -5,21 +5,12 @@ import org.json.adf.JSONObject;
import java.util.ArrayList;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
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.ShopMemberDto;
public class MyInfoJSON extends AcmsCommonJSON {
private static final String BODY = "body";
private static final String SHOP_MEMBER_ID = "shopMemberId";
private static final String MEMBER_NAME = "memberName";
private static final String PROFILE_IMAGE_PATH = "profileImagePath";
private static final String GROUP_ID_LIST = "groupIdList";
private static final Integer SELF_FLG_ON = 1;
public ShopMemberDto shopMemberDto;
......@@ -30,24 +21,22 @@ public class MyInfoJSON extends AcmsCommonJSON {
@Override
protected void parse(JSONObject json) throws JSONValidationException {
if (!json.has(BODY)) { return; }
if (!json.has(ABookCommConstants.KEY.BODY)) { return; }
JSONObject MyInfoJson = json.getJSONObject(BODY);
JSONObject MyInfoJson = json.getJSONObject(ABookCommConstants.KEY.BODY);
if (MyInfoJson == null) { return; }
shopMemberDto = new ShopMemberDto();
ArrayList<Integer> groupIdList = new ArrayList<Integer>();
JSONArray groupIdJsonArray = (JSONArray) MyInfoJson.get(GROUP_ID_LIST);
JSONArray groupIdJsonArray = (JSONArray) MyInfoJson.get(ABookCommConstants.KEY.GROUP_ID_LIST);
for (int i = 0; i < groupIdJsonArray.length(); i++) {
groupIdList.add(groupIdJsonArray.getInt(i));
}
shopMemberDto.groupIdList = groupIdList;
shopMemberDto.selfFlg = SELF_FLG_ON;
shopMemberDto.favoriteRegisterDate = null;
shopMemberDto.profileUrl = MyInfoJson.getString(PROFILE_IMAGE_PATH);
shopMemberDto.shopMemberId = MyInfoJson.getInt(SHOP_MEMBER_ID);
shopMemberDto.shopMemberName = MyInfoJson.getString(MEMBER_NAME);
shopMemberDto.selfFlg = ABookCommConstants.FLAG.SELF_FLAG.ON;
shopMemberDto.profileUrl = MyInfoJson.getString(ABookCommConstants.KEY.PROFILE_IMAGE_PATH);
shopMemberDto.shopMemberId = MyInfoJson.getInt(ABookCommConstants.KEY.SHOP_MEMBER_ID);
shopMemberDto.shopMemberName = MyInfoJson.getString(ABookCommConstants.KEY.MEMBER_NAME);
}
}
......@@ -5,6 +5,7 @@ import org.json.adf.JSONObject;
import java.util.ArrayList;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
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.ChatMessageDto;
......@@ -12,21 +13,7 @@ import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.adf.util.DateTimeUtil;
public class RoomListJSON extends AcmsCommonJSON {
private static final String Body = "body";
private static final String ChatRoomInfoList = "chatRoomInfoList";
private static final String InsertDate = "insertDate";
private static final String Time = "time";
private static final String RoomId = "roomId";
private static final String RoomName = "roomName";
private static final String RoomType = "roomType";
private static final String LastMessageInfo = "lastMessageInfo";
private static final String Message = "message";
private static final String MessageId = "messageId";
private static final String ShopMemberId = "shopMemberId";
private static final String MessageType = "messageType";
private static final String UnreadCount = "unreadCount";
private static final String AttendUsers = "attendUsers";
public ArrayList<ChatRoomDto> roomList;
......@@ -38,9 +25,9 @@ public class RoomListJSON extends AcmsCommonJSON {
protected void parse(JSONObject json) throws JSONValidationException {
// ルーム一覧情報を取得
if (!json.has(Body)) { return; }
if (!json.has(ABookCommConstants.KEY.BODY)) { return; }
JSONArray roomListJsonArray = json.getJSONObject(Body).getJSONArray(ChatRoomInfoList);
JSONArray roomListJsonArray = json.getJSONObject(ABookCommConstants.KEY.BODY).getJSONArray(ABookCommConstants.KEY.CHAT_ROOM_INFO_LIST);
if (roomListJsonArray == null) { return; }
roomList = new ArrayList<ChatRoomDto>();
......@@ -51,23 +38,23 @@ public class RoomListJSON extends AcmsCommonJSON {
ChatRoomDto chatRoomDto = new ChatRoomDto();
ChatMessageDto chatMessageDto = new ChatMessageDto();
chatRoomDto.chatRoomId = roomListJsonArray.getJSONObject(listCount).getInt(RoomId);
chatRoomDto.chatRoomName = roomListJsonArray.getJSONObject(listCount).getString(RoomName);
chatRoomDto.type = roomListJsonArray.getJSONObject(listCount).getInt(RoomType);
chatRoomDto.unreadCount = roomListJsonArray.getJSONObject(listCount).has(UnreadCount) ? roomListJsonArray.getJSONObject(listCount).getInt(UnreadCount) : 0;
chatRoomDto.userCount = roomListJsonArray.getJSONObject(listCount).getJSONArray(AttendUsers).length();
chatRoomDto.chatRoomId = roomListJsonArray.getJSONObject(listCount).getInt(ABookCommConstants.KEY.ROOM_ID);
chatRoomDto.chatRoomName = roomListJsonArray.getJSONObject(listCount).getString(ABookCommConstants.KEY.ROOM_NAME);
chatRoomDto.type = roomListJsonArray.getJSONObject(listCount).getInt(ABookCommConstants.KEY.ROOM_TYPE);
chatRoomDto.unreadCount = roomListJsonArray.getJSONObject(listCount).has(ABookCommConstants.KEY.UNREAD_COUNT) ? roomListJsonArray.getJSONObject(listCount).getInt(ABookCommConstants.KEY.UNREAD_COUNT) : 0;
chatRoomDto.userCount = roomListJsonArray.getJSONObject(listCount).getJSONArray(ABookCommConstants.KEY.ATTEND_USERS).length();
//最後メッセージ情報がある場合の処理
JSONObject lastMessageInfoJSON = roomListJsonArray.getJSONObject(listCount).has(LastMessageInfo) ? roomListJsonArray.getJSONObject(listCount).getJSONObject(LastMessageInfo) : null;
if (lastMessageInfoJSON != null && lastMessageInfoJSON.has(MessageId)) {
JSONObject lastMessageInfoJSON = roomListJsonArray.getJSONObject(listCount).has(ABookCommConstants.KEY.LAST_MESSAGE_INFO) ? roomListJsonArray.getJSONObject(listCount).getJSONObject(ABookCommConstants.KEY.LAST_MESSAGE_INFO) : null;
if (lastMessageInfoJSON != null && lastMessageInfoJSON.has(ABookCommConstants.KEY.MESSAGE_ID)) {
chatMessageDto.chatRoomId = chatRoomDto.chatRoomId;
chatMessageDto.message = lastMessageInfoJSON.getString(Message);
chatMessageDto.messageType = lastMessageInfoJSON.getInt(MessageType);
if (lastMessageInfoJSON.has(InsertDate)) {
chatMessageDto.insertDate = DateTimeUtil.millToDateString(lastMessageInfoJSON.getJSONObject(InsertDate).getLong(Time));
chatMessageDto.message = lastMessageInfoJSON.getString(ABookCommConstants.KEY.MESSAGE);
chatMessageDto.messageType = lastMessageInfoJSON.getInt(ABookCommConstants.KEY.MESSAGE_TYPE);
if (lastMessageInfoJSON.has(ABookCommConstants.KEY.INSERT_DATE)) {
chatMessageDto.insertDate = DateTimeUtil.millToDateString(lastMessageInfoJSON.getJSONObject(ABookCommConstants.KEY.INSERT_DATE).getLong(ABookCommConstants.KEY.TIME));
}
chatMessageDto.shopMemberId = lastMessageInfoJSON.getInt(ShopMemberId);
chatMessageDto.chatMessageId = lastMessageInfoJSON.getInt(MessageId);
chatMessageDto.shopMemberId = lastMessageInfoJSON.getInt(ABookCommConstants.KEY.SHOP_MEMBER_ID);
chatMessageDto.chatMessageId = lastMessageInfoJSON.getInt(ABookCommConstants.KEY.MESSAGE_ID);
chatRoomDto.lastMessageInfo = chatMessageDto;
}
roomList.add(chatRoomDto);
......
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.ShopMemberDto;
public class ShopMemberInfoJSON extends AcmsCommonJSON {
private static final String BODY = "body";
private static final String SHOP_MEMBER_ID = "shopMemberId";
private static final String MEMBER_NAME = "memberName";
private static final String PROFILE_IMAGE_PATH = "profileImagePath";
private static final String GROUP_ID_LIST = "groupIdList";
private static final Integer SELF_FLG_ON = 1;
public ShopMemberDto shopMemberDto;
public ShopMemberInfoJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
if (!json.has(BODY)) { return; }
JSONObject MyInfoJson = json.getJSONObject(BODY);
if (MyInfoJson == null) { return; }
shopMemberDto = new ShopMemberDto();
ArrayList<Integer> groupIdList = new ArrayList<Integer>();
JSONArray groupIdJsonArray = (JSONArray) MyInfoJson.get(GROUP_ID_LIST);
for (int i = 0; i < groupIdJsonArray.length(); i++) {
groupIdList.add(groupIdJsonArray.getInt(i));
}
shopMemberDto.groupIdList = groupIdList;
shopMemberDto.selfFlg = SELF_FLG_ON;
shopMemberDto.favoriteRegisterDate = null;
shopMemberDto.profileUrl = MyInfoJson.getString(PROFILE_IMAGE_PATH);
shopMemberDto.shopMemberId = MyInfoJson.getInt(SHOP_MEMBER_ID);
shopMemberDto.shopMemberName = MyInfoJson.getString(MEMBER_NAME);
}
}
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.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.adf.util.DateTimeUtil;
public class ShopMemberListJSON extends AcmsCommonJSON {
private static final String Body = "body";
private static final String ChatRoomInfoList = "chatRoomInfoList";
private static final String InsertDate = "insertDate";
private static final String Time = "time";
private static final String RoomId = "roomId";
private static final String RoomName = "roomName";
private static final String RoomType = "roomType";
private static final String LastMessageInfo = "lastMessageInfo";
private static final String Message = "message";
private static final String MessageId = "messageId";
private static final String ShopMemberId = "shopMemberId";
private static final String MessageType = "messageType";
private static final String UnreadCount = "unreadCount";
private static final String AttendUsers = "attendUsers";
public ArrayList<ChatRoomDto> roomList;
public ShopMemberListJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
// ルーム一覧情報を取得
if (!json.has(Body)) { return; }
JSONArray roomListJsonArray = json.getJSONObject(Body).getJSONArray(ChatRoomInfoList);
if (roomListJsonArray == null) { return; }
roomList = new ArrayList<ChatRoomDto>();
for (int listCount = 0; listCount < roomListJsonArray.length(); listCount++) {
if (roomListJsonArray.getJSONObject(listCount).length() == 0) {
break;
}
ChatRoomDto chatRoomDto = new ChatRoomDto();
ChatMessageDto chatMessageDto = new ChatMessageDto();
chatRoomDto.chatRoomId = roomListJsonArray.getJSONObject(listCount).getInt(RoomId);
chatRoomDto.chatRoomName = roomListJsonArray.getJSONObject(listCount).getString(RoomName);
chatRoomDto.type = roomListJsonArray.getJSONObject(listCount).getInt(RoomType);
chatRoomDto.unreadCount = roomListJsonArray.getJSONObject(listCount).has(UnreadCount) ? roomListJsonArray.getJSONObject(listCount).getInt(UnreadCount) : 0;
chatRoomDto.userCount = roomListJsonArray.getJSONObject(listCount).getJSONArray(AttendUsers).length();
//最後メッセージ情報がある場合の処理
JSONObject lastMessageInfoJSON = roomListJsonArray.getJSONObject(listCount).has(LastMessageInfo) ? roomListJsonArray.getJSONObject(listCount).getJSONObject(LastMessageInfo) : null;
if (lastMessageInfoJSON != null && lastMessageInfoJSON.has(MessageId)) {
chatMessageDto.chatRoomId = chatRoomDto.chatRoomId;
chatMessageDto.message = lastMessageInfoJSON.getString(Message);
chatMessageDto.messageType = lastMessageInfoJSON.getInt(MessageType);
if (lastMessageInfoJSON.has(InsertDate)) {
chatMessageDto.insertDate = DateTimeUtil.millToDateString(lastMessageInfoJSON.getJSONObject(InsertDate).getLong(Time));
}
chatMessageDto.shopMemberId = lastMessageInfoJSON.getInt(ShopMemberId);
chatMessageDto.chatMessageId = lastMessageInfoJSON.getInt(MessageId);
chatRoomDto.lastMessageInfo = chatMessageDto;
}
roomList.add(chatRoomDto);
}
}
}
package jp.agentec.abook.abv.bl.common.constant;
/**
* Created by leemk on 2021/03/03.
*/
public interface ABookCommConstants {
//AbookComm専用の共通インターフェース
interface KEY {
String CHAT_ROOM_ID = "chatRoomId";
String CHAT_ROOM_NAME = "chatRoomName";
String TYPE = "type";
String FAVORITE_REGISTER_DATE = "favoriteRegisterDate";
String UNREAD_COUNT = "unreadCount";
String MESSAGE = "message";
String MESSAGE_TYPE = "messageType";
String INSERT_DATE = "insertDate";
String USER_COUNT = "userCount";
String LOGIN_ID = "loginId";
String PROFILE_IMAGE_PATH = "profileImagePath";
String SELF_FLG = "selfFlg";
String SHOP_MEMBER_NAME = "shopMemberName";
String SHOP_MEMBER_ID = "shopMemberId";
String PROFILE_URL = "profileUrl";
String GROUP_NAME = "groupName";
String GROUP_ID = "groupId";
String GROUP_PATH_LIST = "groupPathList";
String CHILD_GROUP_LIST = "childGroupList";
String GROUP_USER_LIST = "groupUserList";
String BODY = "body";
String CHAT_ROOM_INFO = "chatRoomInfo";
String ROOM_ID = "roomId";
String ROOM_NAME = "roomName";
String ATTEND_USERS = "attendUsers";
String MEMBER_NAME = "memberName";
String DEL_FLG = "del_flg";
String ROOM_TYPE = "roomType";
String GROUP_ID_LIST = "groupIdList";
String MESSAGE_INFO_LIST = "messageInfoList";
String MESSAGE_ID = "messageId";
String SHOP_ID = "shopId";
String TIME = "time";
String GROUP_INFO_LIST = "groupInfoList";
String PARENT_GROUP_ID = "parentGroupId";
String GROUP_MEMBER_LIST = "groupMemberList";
String CHAT_ROOM_INFO_LIST = "chatRoomInfoList";
String LAST_MESSAGE_INFO = "lastMessageInfo";
}
interface FLAG {
interface SELF_FLAG {
Integer OFF = 0;
Integer ON = 1;
}
}
}
......@@ -506,7 +506,23 @@ public class GroupDao extends AbstractDao {
list = rawQueryGetDtoList("select * from m_group mg where (mg.group_id = ?) UNION select * from m_group mg where (mg.parent_group_id = ?)", new String[]{""+ baseId, ""+ parentId}, GroupDto.class);
return list;
}
public List<GroupDto> getGroupTree(Integer groupId) {
List<GroupDto> list;
StringBuffer sql = new StringBuffer();
sql.append(" WITH group_loop AS ");
sql.append(" ( ");
sql.append(" SELECT 1 rownum,group_id,group_name,parent_group_id,user_group_flg from m_group where group_id = ? ");
sql.append(" UNION ALL ");
sql.append(" SELECT rownum+1 rownum,parent.group_id,parent. group_name,parent.parent_group_id,parent.user_group_flg ");
sql.append(" FROM group_loop inner join m_group parent on parent.group_id = group_loop.parent_group_id ");
sql.append(" ) ");
sql.append(" SELECT * FROM group_loop ORDER BY group_loop.rownum DESC ");
list = rawQueryGetDtoList(sql.toString(), new String[]{""+ groupId}, GroupDto.class);
return list;
}
public List<GroupDto> getGroupChildList(int parentId) {
List<GroupDto> list;
list = rawQueryGetDtoList("select * from m_group mg where (mg.parent_group_id = ?)", new String[]{""+ parentId}, GroupDto.class);
......@@ -536,12 +552,12 @@ public class GroupDao extends AbstractDao {
public void insertGroupList(List<GroupDto> groupList) {
StringBuffer sql = new StringBuffer();
sql.append(" INSERT OR IGNORE INTO m_group (group_id, parent_group_id, group_name, group_path, group_level, user_group_flg) ");
sql.append(" INSERT INTO m_group (group_id, parent_group_id, group_name, group_path, group_level, user_group_flg) ");
sql.append(" VALUES (?,?,?,?,?,?) ");
try {
beginTransaction();
for (GroupDto groupDto : groupList) {
insert(sql.toString(), new Object[] { groupDto.groupId, groupDto.parentGroupId, groupDto.groupName, "", 0, 0 });
insert(sql.toString(), new Object[] { groupDto.groupId, groupDto.parentGroupId, groupDto.groupName, ""+ groupDto.groupId, 0, 0 });
}
commit();
} catch (Exception e) {
......
......@@ -113,6 +113,7 @@ public class ShopMemberDao extends AbstractDao {
sql.append(" INNER JOIN r_shop_member_group AS rsmg ");
sql.append(" ON sm.shop_member_id = rsmg.shop_member_id ");
sql.append(" WHERE rsmg.group_id =?");
sql.append(" AND sm.self_flg != 1");
sql.append(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), new String[]{""+ groupId}, ShopMemberDto.class);
return list;
......@@ -128,7 +129,7 @@ public class ShopMemberDao extends AbstractDao {
sql.append(" m_shop_member AS sm ");
sql.append(" INNER JOIN r_shop_member_group AS rsmg ");
sql.append(" ON sm.shop_member_id = rsmg.shop_member_id ");
sql.append(" WHERE rsmg.group_id IN (SELECT group_id FROM m_shop_member INNER JOIN r_shop_member_group WHERE self_flg = 1 GROUP BY group_id)");
sql.append(" WHERE rsmg.group_id IN (SELECT group_id FROM m_shop_member INNER JOIN r_shop_member_group ON m_shop_member.shop_member_id = r_shop_member_group.shop_member_id WHERE self_flg = 1 GROUP BY group_id)");
sql.append(" AND sm.self_flg != 1 ");
sql.append(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), null, ShopMemberDto.class);
......
......@@ -9,7 +9,7 @@ public class ChatRoomDto extends AbstractDto {
public String chatRoomName;
public Integer type;
public String favoriteRegisterDate = "";
public Integer unreadCount;
public Integer unreadCount = 0;
public Integer userCount;
public String message;
public Integer messageType;
......
......@@ -20,6 +20,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.DownloadedContentInfoJSON;
import jp.agentec.abook.abv.bl.acms.client.json.content.ContentJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsContentCheckParameters;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
import jp.agentec.abook.abv.bl.common.log.Logger;
......@@ -75,15 +76,15 @@ public class CommunicationLogic extends AbstractLogic {
JSONArray resultJsonArray = new JSONArray();
for (ChatRoomDto chatRoomDto : chatRoomList) {
Map<String, Object> chatRoomMap = new HashMap<String, Object>();
chatRoomMap.put("chatRoomId", chatRoomDto.chatRoomId);
chatRoomMap.put("chatRoomName", chatRoomDto.chatRoomName);
chatRoomMap.put("type", chatRoomDto.type);
chatRoomMap.put("favoriteRegisterDate", chatRoomDto.favoriteRegisterDate);
chatRoomMap.put("unreadCount", chatRoomDto.unreadCount);
chatRoomMap.put("message", chatRoomDto.message);
chatRoomMap.put("messageType", chatRoomDto.messageType);
chatRoomMap.put("insertDate", chatRoomDto.insertDate);
chatRoomMap.put("userCount", chatRoomDto.userCount);
chatRoomMap.put(ABookCommConstants.KEY.CHAT_ROOM_ID, chatRoomDto.chatRoomId);
chatRoomMap.put(ABookCommConstants.KEY.CHAT_ROOM_NAME, chatRoomDto.chatRoomName);
chatRoomMap.put(ABookCommConstants.KEY.TYPE, chatRoomDto.type);
chatRoomMap.put(ABookCommConstants.KEY.FAVORITE_REGISTER_DATE, chatRoomDto.favoriteRegisterDate);
chatRoomMap.put(ABookCommConstants.KEY.UNREAD_COUNT, chatRoomDto.unreadCount);
chatRoomMap.put(ABookCommConstants.KEY.MESSAGE, chatRoomDto.message);
chatRoomMap.put(ABookCommConstants.KEY.MESSAGE_TYPE, chatRoomDto.messageType);
chatRoomMap.put(ABookCommConstants.KEY.INSERT_DATE, chatRoomDto.insertDate);
chatRoomMap.put(ABookCommConstants.KEY.USER_COUNT, chatRoomDto.userCount);
JSONObject jsonObject = new JSONObject(chatRoomMap);
resultJsonArray.put(jsonObject);
}
......@@ -98,13 +99,13 @@ public class CommunicationLogic extends AbstractLogic {
JSONArray resultJsonArray = new JSONArray();
for (ChatMessageDto chatMessageDto : chatMessageDtoList) {
Map<String, Object> chatMessageMap = new HashMap<String, Object>();
chatMessageMap.put("chatRoomId", chatMessageDto.chatRoomId);
chatMessageMap.put("loginId", chatMessageDto.shopMemberName);
chatMessageMap.put("message", chatMessageDto.message);
chatMessageMap.put("messageType", chatMessageDto.messageType);
chatMessageMap.put("insertDate", chatMessageDto.insertDate);
chatMessageMap.put("profileImagePath", chatMessageDto.profileUrl);
chatMessageMap.put("selfFlg", chatMessageDto.selfFlg);
chatMessageMap.put(ABookCommConstants.KEY.CHAT_ROOM_ID, chatMessageDto.chatRoomId);
chatMessageMap.put(ABookCommConstants.KEY.LOGIN_ID, chatMessageDto.shopMemberName);
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE, chatMessageDto.message);
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE_TYPE, chatMessageDto.messageType);
chatMessageMap.put(ABookCommConstants.KEY.INSERT_DATE, chatMessageDto.insertDate);
chatMessageMap.put(ABookCommConstants.KEY.PROFILE_IMAGE_PATH, chatMessageDto.profileUrl);
chatMessageMap.put(ABookCommConstants.KEY.SELF_FLG, chatMessageDto.selfFlg);
JSONObject jsonObject = new JSONObject(chatMessageMap);
resultJsonArray.put(jsonObject);
}
......@@ -117,10 +118,10 @@ public class CommunicationLogic extends AbstractLogic {
ShopMemberDto myInfo = shopMemberDao.getMyInfo();
List<String> groupPathList = groupDao.getMyGroupPathList();
JSONObject myInfoJson = new JSONObject();
myInfoJson.put("shopMemberId", myInfo.shopMemberId);
myInfoJson.put("shopMemberName", myInfo.shopMemberName);
myInfoJson.put("profileUrl", myInfo.profileUrl);
myInfoJson.put("groupPathList", groupPathList);
myInfoJson.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, myInfo.shopMemberId);
myInfoJson.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, myInfo.shopMemberName);
myInfoJson.put(ABookCommConstants.KEY.PROFILE_URL, myInfo.profileUrl);
myInfoJson.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList);
String myInfoStr = myInfoJson.toString();
return myInfoStr;
}
......@@ -130,9 +131,9 @@ public class CommunicationLogic extends AbstractLogic {
JSONArray myGroupUsersJson = new JSONArray();
for (ShopMemberDto myGroupUser : myGroupUsers) {
Map<String, Object> myGroupUserMap = new HashMap<String, Object>();
myGroupUserMap.put("shopMemberId", myGroupUser.shopMemberId);
myGroupUserMap.put("shopMemberName", myGroupUser.shopMemberName);
myGroupUserMap.put("profileUrl", myGroupUser.profileUrl);
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, myGroupUser.shopMemberId);
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, myGroupUser.shopMemberName);
myGroupUserMap.put(ABookCommConstants.KEY.PROFILE_URL, myGroupUser.profileUrl);
JSONObject jsonObject = new JSONObject(myGroupUserMap);
myGroupUsersJson.put(jsonObject);
}
......@@ -159,9 +160,9 @@ public class CommunicationLogic extends AbstractLogic {
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto favoriteUser : favoriteUsers) {
Map<String, Object> favoriteUserMap = new HashMap<String, Object>();
favoriteUserMap.put("shopMemberId", favoriteUser.shopMemberId);
favoriteUserMap.put("shopMemberName", favoriteUser.shopMemberName);
favoriteUserMap.put("profileUrl", favoriteUser.profileUrl);
favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, favoriteUser.shopMemberId);
favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, favoriteUser.shopMemberName);
favoriteUserMap.put(ABookCommConstants.KEY.PROFILE_URL, favoriteUser.profileUrl);
JSONObject jsonObject = new JSONObject(favoriteUserMap);
resultJsonArray.put(jsonObject);
}
......@@ -177,8 +178,8 @@ public class CommunicationLogic extends AbstractLogic {
JSONArray resultJsonArray = new JSONArray();
for (GroupDto favoriteGroup : favoriteGroups) {
Map<String, Object> favoriteGroupMap = new HashMap<String, Object>();
favoriteGroupMap.put("groupName", favoriteGroup.groupName);
favoriteGroupMap.put("groupId", favoriteGroup.groupId);
favoriteGroupMap.put(ABookCommConstants.KEY.GROUP_NAME, favoriteGroup.groupName);
favoriteGroupMap.put(ABookCommConstants.KEY.GROUP_ID, favoriteGroup.groupId);
JSONObject jsonObject = new JSONObject(favoriteGroupMap);
resultJsonArray.put(jsonObject);
}
......@@ -187,6 +188,59 @@ public class CommunicationLogic extends AbstractLogic {
return favoriteGroupsStr;
}
public String getGroupSearchData(Integer groupId) {
//レスポンスになるJSON
JSONObject groupSearchData = new JSONObject();
//パラメータグループIDが0であれば自分のグループ情報を取得。
GroupDto myGroup = groupDao.getUserGroups().get(0);
Integer targetGroupId;
if (groupId == 0) {
targetGroupId = myGroup.groupId;
} else {
targetGroupId = groupId;
}
//グループ
List<GroupDto> groupPathList = groupDao.getGroupTree(targetGroupId);
JSONArray groupPathJSONArray = new JSONArray();
for (GroupDto group : groupPathList) {
Map<String, Object> groupTreeMap = new HashMap<String, Object>();
groupTreeMap.put(ABookCommConstants.KEY.GROUP_NAME, group.groupName);
groupTreeMap.put(ABookCommConstants.KEY.GROUP_ID, group.groupId);
JSONObject jsonObject = new JSONObject(groupTreeMap);
groupPathJSONArray.put(jsonObject);
}
groupSearchData.put(ABookCommConstants.KEY.GROUP_PATH_LIST,groupPathJSONArray);
List<GroupDto> childGroupList = groupDao.getGroupChildList(targetGroupId);
JSONArray childGroupJSONArray = new JSONArray();
for (GroupDto group : childGroupList) {
Map<String, Object> groupTreeMap = new HashMap<String, Object>();
groupTreeMap.put(ABookCommConstants.KEY.GROUP_NAME, group.groupName);
groupTreeMap.put(ABookCommConstants.KEY.GROUP_ID, group.groupId);
JSONObject jsonObject = new JSONObject(groupTreeMap);
childGroupJSONArray.put(jsonObject);
}
groupSearchData.put(ABookCommConstants.KEY.CHILD_GROUP_LIST,childGroupJSONArray);
List<ShopMemberDto> shopMemberList = shopMemberDao.getUserListByGroupId(targetGroupId);
JSONArray shopMemberJSONArray = new JSONArray();
for (ShopMemberDto shopMember : shopMemberList) {
Map<String, Object> shopMemberMap = new HashMap<String, Object>();
shopMemberMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId);
shopMemberMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
shopMemberMap.put(ABookCommConstants.KEY.PROFILE_URL, shopMember.profileUrl);
JSONObject jsonObject = new JSONObject(shopMemberMap);
shopMemberJSONArray.put(jsonObject);
}
groupSearchData.put(ABookCommConstants.KEY.GROUP_USER_LIST,shopMemberJSONArray);
String groupSearchDataStr = groupSearchData.toString();
return groupSearchDataStr;
}
public void insertChatRoomList(List<ChatRoomDto> roomList) {
List<ChatMessageDto> insertMessageList = new ArrayList<ChatMessageDto>();
......
......@@ -706,8 +706,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public void updateGroupInfo() throws NetworkDisconnectedException, AcmsException {
updateGroupInfoFromServer("0");
public void updateGroupInfo(String groupId) throws NetworkDisconnectedException, AcmsException {
updateGroupInfoFromServer(groupId);
}
@JavascriptInterface
......@@ -775,6 +775,12 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
updateUserInfoFromServer(shopMemberId);
}
@JavascriptInterface
public String getGroupInfo(String groupId) throws NetworkDisconnectedException, AcmsException {
String groupInfoStr = communicationLogic.getGroupSearchData(Integer.parseInt(groupId));
return groupInfoStr;
}
}
/**
......
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