Commit cd300e10 by Lee Munkyeong

コードレビュー対応。

parent a368af94
...@@ -39,40 +39,39 @@ public class RoomListJSON extends AcmsCommonJSON { ...@@ -39,40 +39,39 @@ public class RoomListJSON extends AcmsCommonJSON {
protected void parse(JSONObject json) throws JSONValidationException { protected void parse(JSONObject json) throws JSONValidationException {
// ルーム一覧情報を取得 // ルーム一覧情報を取得
if (json.has(Body)) { if (!json.has(Body)) { return; }
JSONArray roomListJsonArray = json.getJSONObject(Body).getJSONArray(ChatRoomInfoList);
if (roomListJsonArray != null) {
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); JSONArray roomListJsonArray = json.getJSONObject(Body).getJSONArray(ChatRoomInfoList);
chatRoomDto.chatRoomName = roomListJsonArray.getJSONObject(listCount).getString(RoomName); if (roomListJsonArray == null) { return; }
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();
//最後メッセージ情報がある場合の処理 roomList = new ArrayList<ChatRoomDto>();
JSONObject lastMessageInfoJSON = roomListJsonArray.getJSONObject(listCount).has(LastMessageInfo) ? roomListJsonArray.getJSONObject(listCount).getJSONObject(LastMessageInfo) : null; for (int listCount = 0; listCount < roomListJsonArray.length(); listCount++) {
if (lastMessageInfoJSON != null && lastMessageInfoJSON.has(MessageId)) { if (roomListJsonArray.getJSONObject(listCount).length() == 0) {
chatMessageDto.chatRoomId = chatRoomDto.chatRoomId; break;
chatMessageDto.message = lastMessageInfoJSON.getString(Message); }
chatMessageDto.messageType = lastMessageInfoJSON.getInt(MessageType); ChatRoomDto chatRoomDto = new ChatRoomDto();
if (lastMessageInfoJSON.has(InsertDate)) { ChatMessageDto chatMessageDto = new ChatMessageDto();
chatMessageDto.insertDate = DateTimeUtil.millToDateString(lastMessageInfoJSON.getJSONObject(InsertDate).getLong(Time));
} chatRoomDto.chatRoomId = roomListJsonArray.getJSONObject(listCount).getInt(RoomId);
chatMessageDto.shopMemberId = lastMessageInfoJSON.getInt(ShopMemberId); chatRoomDto.chatRoomName = roomListJsonArray.getJSONObject(listCount).getString(RoomName);
chatMessageDto.chatMessageId = lastMessageInfoJSON.getInt(MessageId); chatRoomDto.type = roomListJsonArray.getJSONObject(listCount).getInt(RoomType);
chatRoomDto.lastMessageInfo = chatMessageDto; chatRoomDto.unreadCount = roomListJsonArray.getJSONObject(listCount).has(UnreadCount) ? roomListJsonArray.getJSONObject(listCount).getInt(UnreadCount) : 0;
} chatRoomDto.userCount = roomListJsonArray.getJSONObject(listCount).getJSONArray(AttendUsers).length();
roomList.add(chatRoomDto); //最後メッセージ情報がある場合の処理
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);
} }
} }
} }
......
...@@ -15,18 +15,17 @@ public class ChatMessageDto extends AbstractDto { ...@@ -15,18 +15,17 @@ public class ChatMessageDto extends AbstractDto {
@Override @Override
public Object[] getInsertValues() { public Object[] getInsertValues() {
Object[] test = new Object[]{chatMessageId, chatRoomId, shopMemberId, message, messageType, imageName, downloadFileName, savePath, insertDate}; return new Object[] { chatMessageId, chatRoomId, shopMemberId, message, messageType, imageName, downloadFileName, savePath, insertDate };
return new Object[]{chatMessageId, chatRoomId, shopMemberId, message, messageType, imageName, downloadFileName, savePath, insertDate};
} }
@Override @Override
public Object[] getUpdateValues() { public Object[] getUpdateValues() {
return new Object[]{chatRoomId, shopMemberId, message, messageType, imageName, downloadFileName, savePath, insertDate, chatMessageId}; return new Object[] { chatRoomId, shopMemberId, message, messageType, imageName, downloadFileName, savePath, insertDate, chatMessageId };
} }
@Override @Override
public String[] getKeyValues() { public String[] getKeyValues() {
return new String[]{""+ chatMessageId}; return new String[]{ "" + chatMessageId };
} }
} }
...@@ -18,17 +18,17 @@ public class ChatRoomDto extends AbstractDto { ...@@ -18,17 +18,17 @@ public class ChatRoomDto extends AbstractDto {
@Override @Override
public Object[] getInsertValues() { public Object[] getInsertValues() {
return new Object[]{chatRoomId, chatRoomName, type, unreadCount, userCount, favoriteRegisterDate}; return new Object[] { chatRoomId, chatRoomName, type, unreadCount, userCount, favoriteRegisterDate };
} }
@Override @Override
public Object[] getUpdateValues() { public Object[] getUpdateValues() {
return new Object[]{favoriteRegisterDate, chatRoomName, type, unreadCount, userCount, chatRoomId}; return new Object[] { favoriteRegisterDate, chatRoomName, type, unreadCount, userCount, chatRoomId };
} }
@Override @Override
public String[] getKeyValues() { public String[] getKeyValues() {
return new String[]{""+ chatRoomId}; return new String[] { "" + chatRoomId };
} }
} }
...@@ -8,17 +8,17 @@ public class CollaborationDetailDto extends AbstractDto { ...@@ -8,17 +8,17 @@ public class CollaborationDetailDto extends AbstractDto {
@Override @Override
public Object[] getInsertValues() { public Object[] getInsertValues() {
return new Object[]{collaborationDetialId, collaborationId, collaborationType, collaborationDuration}; return new Object[] { collaborationDetialId, collaborationId, collaborationType, collaborationDuration };
} }
@Override @Override
public Object[] getUpdateValues() { public Object[] getUpdateValues() {
return new Object[]{collaborationDuration, collaborationId, collaborationType, collaborationDetialId}; return new Object[] { collaborationDuration, collaborationId, collaborationType, collaborationDetialId };
} }
@Override @Override
public String[] getKeyValues() { public String[] getKeyValues() {
return new String[]{""+ collaborationDetialId}; return new String[]{ "" + collaborationDetialId };
} }
} }
...@@ -10,17 +10,17 @@ public class ShopMemberDto extends AbstractDto { ...@@ -10,17 +10,17 @@ public class ShopMemberDto extends AbstractDto {
@Override @Override
public Object[] getInsertValues() { public Object[] getInsertValues() {
return new Object[]{shopMemberId, shopMemberName, profileUrl, favoriteRegisterDate}; return new Object[] { shopMemberId, shopMemberName, profileUrl, favoriteRegisterDate };
} }
@Override @Override
public Object[] getUpdateValues() { public Object[] getUpdateValues() {
return new Object[]{shopMemberName, profileUrl, favoriteRegisterDate, shopMemberId}; return new Object[] { shopMemberName, profileUrl, favoriteRegisterDate, shopMemberId };
} }
@Override @Override
public String[] getKeyValues() { public String[] getKeyValues() {
return new String[]{""+ shopMemberId}; return new String[]{ "" + shopMemberId };
} }
} }
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