Commit 349ec5cb by Lee Munkyeong

バグ修正。

parent b80b9811
......@@ -27,6 +27,7 @@ public interface ABookCommConstants {
String PROFILE_URL = "profileUrl";
String GROUP_NAME = "groupName";
String GROUP_ID = "groupId";
String GROUP_PATH = "groupPath";
String GROUP_IDS = "groupIds";
String GROUP_PATH_LIST = "groupPathList";
String IS_FAVORITE = "isFavorite";
......
package jp.agentec.abook.abv.bl.data.dao;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.Cursor;
......@@ -7,6 +8,7 @@ import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.adf.util.StringUtil;
public class ChatRoomDao extends AbstractDao {
......@@ -86,6 +88,54 @@ public class ChatRoomDao extends AbstractDao {
return list;
}
public ChatRoomDto getChatRoom(Integer roomId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" cr.chat_room_id ");
sql.append(" ,cr.chat_room_name ");
sql.append(" ,cr.type ");
sql.append(" FROM ");
sql.append(" t_chat_room AS cr ");
sql.append(" WHERE cr.chat_room_id =? ");
ChatRoomDto list = rawQueryGetDto(sql.toString(), new String[]{""+ roomId}, ChatRoomDto.class);
return list;
}
public List<ChatRoomDto> getAllChatRoombyKeyword(String[] keywords) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" cr.chat_room_id ");
sql.append(" ,cr.chat_room_name ");
sql.append(" ,cr.type ");
sql.append(" ,coalesce (cr.favorite_register_date,'') favorite_register_date");
sql.append(" ,coalesce (cr.unread_count,0) unread_count");
sql.append(" ,coalesce (cm.message,'') message");
sql.append(" ,coalesce (cm.message_type,0) message_type");
sql.append(" ,coalesce (cm.insert_date,'') insert_date");
sql.append(" ,coalesce (cr.user_count,0) user_count ");
sql.append(" FROM ");
sql.append(" t_chat_room AS cr ");
sql.append(" LEFT JOIN ");
sql.append(" ( SELECT max(insert_date) insert_date, message, message_type, chat_room_id FROM t_chat_message GROUP BY chat_room_id ) AS cm ");
sql.append(" ON cr.chat_room_id = cm.chat_room_id ");
sql.append(" LEFT JOIN r_chat_room_shop_member rcrsm ");
sql.append(" ON cr.chat_room_id = rcrsm.chat_room_id ");
sql.append(" INNER JOIN m_shop_member sm ");
sql.append(" ON rcrsm.shop_member_id = sm.shop_member_id ");
sql.append(" WHERE ");
List<String> whereSqlList = new ArrayList<String>();
for (String keyword : keywords) {
whereSqlList.add("cr.chat_room_name LIKE '%" + keyword + "%'");
whereSqlList.add("sm.shop_member_name LIKE '%" + keyword + "%'");
}
String whereSql = StringUtil.join(" OR ", whereSqlList);
sql.append(whereSql);
sql.append(" GROUP BY cr.chat_room_id ");
sql.append(" ORDER BY CASE WHEN unread_count = 0 THEN 0 ELSE 1 END DESC, cm.insert_date DESC ");
List<ChatRoomDto> list = rawQueryGetDtoList(sql.toString(), null, ChatRoomDto.class);
return list;
}
public ChatRoomDto getFavoriteChatRoom() {
return rawQueryGetDto("select * from t_chat_room where favorite_register_date is NOT NULL", null, ChatRoomDto.class);
}
......
......@@ -90,13 +90,13 @@ public class GroupDao extends AbstractDao {
return rawQueryGetStringList(sql.toString(), null);
}
public List<String> getUserGroupPathList(Integer shopMemberId) {
public List<GroupDto> getUserGroupPathList(Integer shopMemberId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" CASE WHEN (grandparentgroup.group_name IS NOT NULL) THEN grandparentgroup.group_name || ' / ' || parentgroup.group_name || ' / ' || usergroup.group_name ");
sql.append(" WHEN (parentgroup.group_name IS NOT NULL) THEN parentgroup.group_name || ' / ' || usergroup.group_name ");
sql.append(" ELSE usergroup.group_name ");
sql.append(" END AS group_path_list ");
sql.append(" END AS group_path, usergroup.group_id ");
sql.append(" FROM m_group usergroup ");
sql.append(" LEFT JOIN m_group parentgroup on usergroup.parent_group_id = parentgroup.group_id ");
sql.append(" LEFT JOIN m_group grandparentgroup on parentgroup.parent_group_id = grandparentgroup.group_id ");
......@@ -104,7 +104,7 @@ public class GroupDao extends AbstractDao {
sql.append(" (SELECT group_id ");
sql.append(" FROM m_shop_member sm INNER JOIN r_shop_member_group rsmg on sm.shop_member_id = rsmg.shop_member_id ");
sql.append(" WHERE sm.shop_member_id = ? ) ");
return rawQueryGetStringList(sql.toString(), new String[] { "" + shopMemberId});
return rawQueryGetDtoList(sql.toString(), new String[] { "" + shopMemberId}, GroupDto.class);
}
private String generateGetGroupsQuery(QueryType queryType, int[] groupRelationids, int[] parentGroupIds, Boolean downloaded, String searchKeyword, SearchDivisionType searchDivisionType, boolean isOnlineSearched) {
......
......@@ -137,7 +137,7 @@ public class ShopMemberDao extends AbstractDao {
public List<ShopMemberDto> getUserInMyGroupByName(String shopMemberName) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" SELECT DISTINCT");
sql.append(" sm.shop_member_id ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url");
......@@ -156,7 +156,7 @@ public class ShopMemberDao extends AbstractDao {
public List<ShopMemberDto> getUserInAllGroupByName(String shopMemberName) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" SELECT DISTINCT");
sql.append(" sm.shop_member_id ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url");
......
......@@ -19,6 +19,8 @@ import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.adf.util.ArrayUtil;
import jp.agentec.adf.util.CollectionUtil;
import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.StringUtil;
......@@ -43,9 +45,14 @@ public class CommunicationLogic extends AbstractLogic {
/*package*/ CommunicationLogic() {
}
public String getChatRoomList(Integer roomType) {
List<ChatRoomDto> chatRoomList = chatRoomDao.getAllChatRoom(roomType);
public String getChatRoomList(Integer roomType, String keyword) {
List<ChatRoomDto> chatRoomList;
if (StringUtil.isNullOrEmpty(keyword)) {
chatRoomList = chatRoomDao.getAllChatRoom(roomType);
} else {
String[] replacedKeyword = keyword.replaceAll(" ", " ").split(" ");
chatRoomList = chatRoomDao.getAllChatRoombyKeyword(replacedKeyword);
}
JSONArray resultJsonArray = new JSONArray();
for (ChatRoomDto chatRoomDto : chatRoomList) {
Map<String, Object> chatRoomMap = new HashMap<String, Object>();
......@@ -118,11 +125,19 @@ public class CommunicationLogic extends AbstractLogic {
public String getNameCardInfo(Integer shopMemberId) {
JSONObject resultJson = new JSONObject();
ShopMemberDto shopMemberDto = shopMemberDao.getShopMember(shopMemberId);
List<String> groupPathList = groupDao.getUserGroupPathList(shopMemberId);
List<GroupDto> groupPathList = groupDao.getUserGroupPathList(shopMemberId);
JSONArray groupPathArray = new JSONArray();
for (GroupDto groupDto : groupPathList){
Map<String, Object> groupMap = new HashMap<String, Object>();
groupMap.put(ABookCommConstants.KEY.GROUP_ID, groupDto.groupId);
groupMap.put(ABookCommConstants.KEY.GROUP_PATH, groupDto.groupPath);
JSONObject jsonObject = new JSONObject(groupMap);
groupPathArray.put(jsonObject);
}
resultJson.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMemberDto.shopMemberId);
resultJson.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMemberDto.shopMemberName);
resultJson.put(ABookCommConstants.KEY.PROFILE_URL, shopMemberDto.profileUrl);
resultJson.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList);
resultJson.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMemberDto.favoriteRegisterDate)) {
resultJson.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
......@@ -180,11 +195,19 @@ public class CommunicationLogic extends AbstractLogic {
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
Map<String, Object> userMap = new HashMap<String, Object>();
List<String> groupPathList = groupDao.getUserGroupPathList(shopMember.shopMemberId);
List<GroupDto> groupPathList = groupDao.getUserGroupPathList(shopMember.shopMemberId);
JSONArray groupPathArray = new JSONArray();
for (GroupDto groupDto : groupPathList){
Map<String, Object> groupMap = new HashMap<String, Object>();
groupMap.put(ABookCommConstants.KEY.GROUP_ID, groupDto.groupId);
groupMap.put(ABookCommConstants.KEY.GROUP_PATH, groupDto.groupPath);
JSONObject jsonObject = new JSONObject(groupMap);
groupPathArray.put(jsonObject);
}
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId);
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, shopMember.profileUrl);
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList);
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
......@@ -205,11 +228,19 @@ public class CommunicationLogic extends AbstractLogic {
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
Map<String, Object> userMap = new HashMap<String, Object>();
List<String> groupPathList = groupDao.getUserGroupPathList(shopMember.shopMemberId);
List<GroupDto> groupPathList = groupDao.getUserGroupPathList(shopMember.shopMemberId);
JSONArray groupPathArray = new JSONArray();
for (GroupDto groupDto : groupPathList){
Map<String, Object> groupMap = new HashMap<String, Object>();
groupMap.put(ABookCommConstants.KEY.GROUP_ID, groupDto.groupId);
groupMap.put(ABookCommConstants.KEY.GROUP_PATH, groupDto.groupPath);
JSONObject jsonObject = new JSONObject(groupMap);
groupPathArray.put(jsonObject);
}
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId);
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, shopMember.profileUrl);
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList);
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
......@@ -261,6 +292,9 @@ public class CommunicationLogic extends AbstractLogic {
return groupDao.getAllGroups();
}
public ChatRoomDto getChatRoom(Integer roomId) {
return chatRoomDao.getChatRoom(roomId);
}
public String getFavoriteUsers() {
List<ShopMemberDto> favoriteUsers = shopMemberDao.getfavoriteUserList();
......@@ -268,11 +302,19 @@ public class CommunicationLogic extends AbstractLogic {
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto favoriteUser : favoriteUsers) {
Map<String, Object> favoriteUserMap = new HashMap<String, Object>();
List<String> groupPathList = groupDao.getUserGroupPathList(favoriteUser.shopMemberId);
List<GroupDto> groupPathList = groupDao.getUserGroupPathList(favoriteUser.shopMemberId);
JSONArray groupPathArray = new JSONArray();
for (GroupDto groupDto : groupPathList){
Map<String, Object> groupMap = new HashMap<String, Object>();
groupMap.put(ABookCommConstants.KEY.GROUP_ID, groupDto.groupId);
groupMap.put(ABookCommConstants.KEY.GROUP_PATH, groupDto.groupPath);
JSONObject jsonObject = new JSONObject(groupMap);
groupPathArray.put(jsonObject);
}
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);
favoriteUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList);
favoriteUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
favoriteUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
JSONObject jsonObject = new JSONObject(favoriteUserMap);
resultJsonArray.put(jsonObject);
......
......@@ -54,7 +54,6 @@ import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.abook.abv.bl.dto.PushMessageDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.CommunicationLogic;
import jp.agentec.abook.abv.cl.util.PreferenceUtil;
......@@ -101,6 +100,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private String shopName;
private boolean isOnline;
private Long roomId;
private String roomType;
private Integer shopMemberId;
public AlertDialog myAlertDialog;
......@@ -702,8 +702,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public String getRoomList(String roomType) {
String chatRoomListStr = communicationLogic.getChatRoomList(Integer.parseInt(roomType));
public String getRoomList(String roomType, String keyword) {
String chatRoomListStr = communicationLogic.getChatRoomList(Integer.parseInt(roomType), keyword);
return chatRoomListStr;
}
......@@ -748,9 +748,10 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@JavascriptInterface
public void joinRoom(String joinRoomId, String joinRoomName) {
ChatRoomDto chatRoom = communicationLogic.getChatRoom(Integer.parseInt(joinRoomId));
roomId = Long.parseLong(joinRoomId);
roomName = joinRoomName;
System.out.println("-----------joinROOM ON android-------"+roomId+"-"+roomName);
roomType = chatRoom.type.toString();
mChatWebView.post(new Runnable() {
@Override
public void run() {
......@@ -760,8 +761,12 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public void updateMessages(String roomId) throws NetworkDisconnectedException, AcmsException {
public String getRoomType() {
return roomType;
}
@JavascriptInterface
public void updateMessages(String roomId) throws NetworkDisconnectedException, AcmsException {
MessageInfoListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMessages(sid, roomId);
for (ChatMessageDto chatMessageDto : resultJson.chatMessageDtoArrayList) {
chatMessageDto.chatRoomId = Integer.parseInt(roomId);
......
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