Commit 381469fa by Lee Munkyeong

DAO処理にトランザクション処理を追加

parent cd300e10
...@@ -9,7 +9,6 @@ import jp.agentec.abook.abv.bl.common.exception.AcmsException; ...@@ -9,7 +9,6 @@ import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException; import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto; import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto; import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil; import jp.agentec.adf.util.DateTimeUtil;
public class RoomListJSON extends AcmsCommonJSON { public class RoomListJSON extends AcmsCommonJSON {
......
...@@ -70,6 +70,20 @@ public class ChatMessageDao extends AbstractDao { ...@@ -70,6 +70,20 @@ public class ChatMessageDao extends AbstractDao {
insert("insert into t_chat_message (chat_message_id, chat_room_id, shop_member_id, message, message_type, image_name, download_file_name, save_path, insert_date) values (?,?,?,?,?,?,?,?,?)", dto.getInsertValues()); insert("insert into t_chat_message (chat_message_id, chat_room_id, shop_member_id, message, message_type, image_name, download_file_name, save_path, insert_date) values (?,?,?,?,?,?,?,?,?)", dto.getInsertValues());
} }
public void insertChatMessage(List<ChatMessageDto> chatMessageDtoList) {
try {
beginTransaction();
for (ChatMessageDto chatMessageDto : chatMessageDtoList) {
insertChatMessage(chatMessageDto);
}
commit();
} catch (Exception e) {
rollback();
Logger.e("insertChatRoomList failed.", e);
throw new RuntimeException(e);
}
}
public boolean updateChatMessage(ChatMessageDto dto) { public boolean updateChatMessage(ChatMessageDto dto) {
long count = update("update t_chat_message set chat_room_id=?, shop_member_id=?, message=?, message_type=?, image_name=?, download_file_name=?, save_path=?, insert_date=? where chat_message_id=?", dto.getUpdateValues()); long count = update("update t_chat_message set chat_room_id=?, shop_member_id=?, message=?, message_type=?, image_name=?, download_file_name=?, save_path=?, insert_date=? where chat_message_id=?", dto.getUpdateValues());
return count > 0; return count > 0;
......
...@@ -73,7 +73,7 @@ public class ChatRoomDao extends AbstractDao { ...@@ -73,7 +73,7 @@ public class ChatRoomDao extends AbstractDao {
sql.append(" ,coalesce (cm.message,'') message"); sql.append(" ,coalesce (cm.message,'') message");
sql.append(" ,coalesce (cm.message_type,0) message_type"); sql.append(" ,coalesce (cm.message_type,0) message_type");
sql.append(" ,coalesce (cm.insert_date,'') insert_date"); sql.append(" ,coalesce (cm.insert_date,'') insert_date");
sql.append(" ,coalesce (cr.user_count,0)user_count "); sql.append(" ,coalesce (cr.user_count,0) user_count ");
sql.append(" FROM "); sql.append(" FROM ");
sql.append(" t_chat_room AS cr "); sql.append(" t_chat_room AS cr ");
sql.append(" LEFT JOIN "); sql.append(" LEFT JOIN ");
...@@ -97,6 +97,20 @@ public class ChatRoomDao extends AbstractDao { ...@@ -97,6 +97,20 @@ public class ChatRoomDao extends AbstractDao {
insert("insert into t_chat_room (chat_room_id, chat_room_name, type, unread_count, user_count, favorite_register_date) values (?,?,?,?,?,?)", dto.getInsertValues()); insert("insert into t_chat_room (chat_room_id, chat_room_name, type, unread_count, user_count, favorite_register_date) values (?,?,?,?,?,?)", dto.getInsertValues());
} }
public void insertChatRoom(List<ChatRoomDto> chatRoomDtoList) {
try {
beginTransaction();
for (ChatRoomDto chatRoomDto : chatRoomDtoList) {
insertChatRoom(chatRoomDto);
}
commit();
} catch (Exception e) {
rollback();
Logger.e("insertChatRoomList failed.", e);
throw new RuntimeException(e);
}
}
public boolean updateChatRoom(ChatRoomDto dto) { public boolean updateChatRoom(ChatRoomDto dto) {
long count = update("update t_chat_room set chat_room_name=?, type=?, unread_count=?, user_count=?, favorite_register_date=? where chat_room_id=?", dto.getUpdateValues()); long count = update("update t_chat_room set chat_room_name=?, type=?, unread_count=?, user_count=?, favorite_register_date=? where chat_room_id=?", dto.getUpdateValues());
return count > 0; return count > 0;
......
...@@ -35,6 +35,7 @@ import jp.agentec.abook.abv.bl.data.dao.ContentMarkingDao; ...@@ -35,6 +35,7 @@ import jp.agentec.abook.abv.bl.data.dao.ContentMarkingDao;
import jp.agentec.abook.abv.bl.data.dao.ContentPageDao; import jp.agentec.abook.abv.bl.data.dao.ContentPageDao;
import jp.agentec.abook.abv.bl.data.dao.ContentResourceDao; import jp.agentec.abook.abv.bl.data.dao.ContentResourceDao;
import jp.agentec.abook.abv.bl.data.dao.ContentTagDao; import jp.agentec.abook.abv.bl.data.dao.ContentTagDao;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto; import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.ContentDto; import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.ContentPageDto; import jp.agentec.abook.abv.bl.dto.ContentPageDto;
...@@ -86,12 +87,14 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -86,12 +87,14 @@ public class CommunicationLogic extends AbstractLogic {
} }
public void insertChatRoomList(List<ChatRoomDto> roomList) { public void insertChatRoomList(List<ChatRoomDto> roomList) {
List<ChatMessageDto> insertMessageList = new ArrayList<ChatMessageDto>();
for (ChatRoomDto chatRoomDto : roomList) { for (ChatRoomDto chatRoomDto : roomList) {
chatRoomDao.insertChatRoom(chatRoomDto);
if (chatRoomDto.lastMessageInfo != null) { if (chatRoomDto.lastMessageInfo != null) {
chatMessageDao.insertChatMessage(chatRoomDto.lastMessageInfo); insertMessageList.add(chatRoomDto.lastMessageInfo);
} }
} }
chatRoomDao.insertChatRoom(roomList);
chatMessageDao.insertChatMessage(insertMessageList);
} }
public void deleteChatRoomList() { public void deleteChatRoomList() {
......
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