Commit ac7f1409 by Lee Munkyeong

検索処理修正。

parent 6a0918a8
......@@ -79,6 +79,11 @@ public interface ABookCommConstants {
Integer EXIST = 0;
Integer DELETE = 1;
}
interface ROOM_TYPE {
Integer GROUP = 0;
Integer DM = 1;
Integer ALL = 2;
}
Integer GROUP_REQUEST_ALL = 0;
}
......
......@@ -126,7 +126,7 @@ public class ChatMessageDao extends AbstractDao {
for (String keyword : keywords) {
whereSqlList.add("cm.message LIKE '%" + keyword + "%'");
}
String whereSql = StringUtil.join(" OR ", whereSqlList);
String whereSql = StringUtil.join(" AND ", whereSqlList);
if (!StringUtil.isNullOrEmpty(whereSql)) {
sql.append("AND (" + whereSql + ")");
}
......
......@@ -130,10 +130,10 @@ public class ChatRoomDao extends AbstractDao {
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 = "( cr.chat_room_name LIKE '%" + keyword + "%'" + "OR cr.chat_room_name LIKE '%" + keyword + "%' )";
whereSqlList.add(whereSql);
}
String whereSql = StringUtil.join(" OR ", whereSqlList);
String whereSql = StringUtil.join(" AND ", whereSqlList);
sql.append(whereSql);
sql.append(" AND (cr.view_flg IS null OR cr.view_flg != 1 )");
sql.append(" GROUP BY cr.chat_room_id ");
......
......@@ -8,6 +8,7 @@ import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.adf.util.CollectionUtil;
import jp.agentec.adf.util.NumericUtil;
import jp.agentec.adf.util.StringUtil;
......@@ -518,8 +519,23 @@ public class GroupDao extends AbstractDao {
return rawQueryGetDtoList("select * from m_group where favorite_register_date IS NOT NULL ORDER BY favorite_register_date ", null, GroupDto.class);
}
public List<GroupDto> getGroupByName(String groupName) {
return rawQueryGetDtoList("select * from m_group where group_name LIKE '%"+groupName+"%'ORDER BY group_id ", null, GroupDto.class);
public List<GroupDto> getGroupByName(String[] keywords) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT * ");
sql.append(" FROM m_group ");
ArrayList<String> whereSqlList = new ArrayList<String>();
for (String keyword : keywords) {
if(StringUtil.isNullOrEmpty(keyword)){
continue;
}
String whereSql = "group_name LIKE '%"+keyword+"%'";
whereSqlList.add(whereSql);
}
if (CollectionUtil.isNotEmpty(whereSqlList)) {
sql.append("WHERE " + StringUtil.join(" AND ", whereSqlList));
}
sql.append(" ORDER BY group_id ");
return rawQueryGetDtoList(sql.toString(), null, GroupDto.class);
}
public List<GroupDto> getGroupSpareList(int baseId, int parentId) {
......
package jp.agentec.abook.abv.bl.data.dao;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -8,8 +9,10 @@ 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.CollectionUtil;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.StringUtil;
public class ShopMemberDao extends AbstractDao {
......@@ -178,7 +181,7 @@ public class ShopMemberDao extends AbstractDao {
return list;
}
public List<ShopMemberDto> getUserInMyGroupByName(String shopMemberName) {
public List<ShopMemberDto> getUserInMyGroupByName(String[] keywords) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT DISTINCT");
sql.append(" sm.shop_member_id ");
......@@ -189,15 +192,25 @@ 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_group WHERE user_group_flg = 1)");
sql.append(" AND sm.self_flg != 1");
sql.append(" AND sm.shop_member_name LIKE '%"+shopMemberName+"%' ");
sql.append(" WHERE rsmg.group_id IN (SELECT group_id FROM m_group WHERE user_group_flg = 1) ");
sql.append(" AND sm.self_flg != 1 ");
ArrayList<String> whereSqlList = new ArrayList<String>();
for (String keyword : keywords) {
if (StringUtil.isNullOrEmpty(keyword)){
continue;
}
String whereSql = " sm.shop_member_name LIKE '%"+keyword+"%' ";
whereSqlList.add(whereSql);
}
if (CollectionUtil.isNotEmpty(whereSqlList)) {
sql.append(" AND" + StringUtil.join(" AND ", whereSqlList));
}
sql.append(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), new String[]{}, ShopMemberDto.class);
return list;
}
public List<ShopMemberDto> getUserInMyGroupNotInRoomByName(String shopMemberName, Integer roomId) {
public List<ShopMemberDto> getUserInMyGroupNotInRoomByName(String[] keywords, Integer roomId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT DISTINCT");
sql.append(" sm.shop_member_id ");
......@@ -211,13 +224,23 @@ public class ShopMemberDao extends AbstractDao {
sql.append(" WHERE rsmg.group_id IN (SELECT group_id FROM m_group WHERE user_group_flg = 1)");
sql.append(" AND sm.self_flg != 1");
sql.append(" AND sm.shop_member_id NOT IN (SELECT shop_member_id FROM r_chat_room_shop_member WHERE chat_room_id = ?)");
sql.append(" AND sm.shop_member_name LIKE '%"+shopMemberName+"%' ");
ArrayList<String> whereSqlList = new ArrayList<String>();
for (String keyword : keywords) {
if (StringUtil.isNullOrEmpty(keyword)){
continue;
}
String whereSql = " sm.shop_member_name LIKE '%"+keyword+"%' ";
whereSqlList.add(whereSql);
}
if (CollectionUtil.isNotEmpty(whereSqlList)) {
sql.append(" AND" + StringUtil.join(" AND ", whereSqlList));
}
sql.append(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), new String[]{"" + roomId}, ShopMemberDto.class);
return list;
}
public List<ShopMemberDto> getUserInAllGroupByName(String shopMemberName) {
public List<ShopMemberDto> getUserInAllGroupByName(String[] keywords) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT DISTINCT");
sql.append(" sm.shop_member_id ");
......@@ -229,13 +252,19 @@ 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(" AND sm.self_flg != 1");
sql.append(" AND sm.shop_member_name LIKE '%"+shopMemberName+"%' ");
sql.append(" AND ");
ArrayList<String> whereSqlList = new ArrayList<String>();
for (String keyword : keywords) {
String whereSql = "sm.shop_member_name LIKE '%"+keyword+"%'";
whereSqlList.add(whereSql);
}
sql.append(StringUtil.join(" AND ", whereSqlList));
sql.append(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), new String[]{}, ShopMemberDto.class);
return list;
}
public List<ShopMemberDto> getUserInAllGroupNotInRoomByName(String shopMemberName, Integer roomId) {
public List<ShopMemberDto> getUserInAllGroupNotInRoomByName(String[] keywords, Integer roomId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT DISTINCT");
sql.append(" sm.shop_member_id ");
......@@ -247,7 +276,17 @@ 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(" AND sm.self_flg != 1");
sql.append(" AND sm.shop_member_name LIKE '%"+shopMemberName+"%' ");
ArrayList<String> whereSqlList = new ArrayList<String>();
for (String keyword : keywords) {
if (StringUtil.isNullOrEmpty(keyword)){
continue;
}
String whereSql = " sm.shop_member_name LIKE '%"+keyword+"%' ";
whereSqlList.add(whereSql);
}
if (CollectionUtil.isNotEmpty(whereSqlList)) {
sql.append(" AND" + StringUtil.join(" AND ", whereSqlList));
}
sql.append(" AND sm.shop_member_id NOT IN (SELECT shop_member_id FROM r_chat_room_shop_member WHERE chat_room_id = ?) ");
sql.append(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), new String[] {"" + roomId}, ShopMemberDto.class);
......
......@@ -47,7 +47,7 @@ public class CommunicationLogic extends AbstractLogic {
public String getChatRoomList(Integer roomType, String keyword) {
List<ChatRoomDto> chatRoomList;
if (StringUtil.isNullOrEmpty(keyword)) {
if (StringUtil.isNullOrEmpty(keyword) && !ABookCommConstants.FLAG.ROOM_TYPE.ALL.equals(roomType)) {
chatRoomList = chatRoomDao.getAllChatRoom(roomType);
} else {
String[] replacedKeyword = keyword.replaceAll(" ", " ").split(" ");
......@@ -240,8 +240,10 @@ public class CommunicationLogic extends AbstractLogic {
return myInfoStr;
}
public String getMyGroupUserByName(String shopMemberName) {
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInMyGroupByName(shopMemberName);
public String getMyGroupUserByName(String keyword) {
String[] replacedKeyword = keyword.replaceAll(" ", " ").split(" ");
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInMyGroupByName(replacedKeyword);
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
......@@ -272,8 +274,10 @@ public class CommunicationLogic extends AbstractLogic {
return searchUserStr;
}
public String getMyGroupUserNotInRoomByName(String shopMemberName, Integer roomId) {
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInMyGroupNotInRoomByName(shopMemberName, roomId);
public String getMyGroupUserNotInRoomByName(String keywords, Integer roomId) {
String[] replacedKeyword = keywords.replaceAll(" ", " ").split(" ");
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInMyGroupNotInRoomByName(replacedKeyword, roomId);
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
......@@ -304,8 +308,9 @@ public class CommunicationLogic extends AbstractLogic {
return searchUserStr;
}
public String getAllGroupShopMemberByName(String shopMemberName) {
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInAllGroupByName(shopMemberName);
public String getAllGroupShopMemberByName(String keyword) {
String[] replacedKeyword = keyword.replaceAll(" ", " ").split(" ");
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInAllGroupByName(replacedKeyword);
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
......@@ -336,8 +341,11 @@ public class CommunicationLogic extends AbstractLogic {
return searchUserStr;
}
public String getAllGroupShopMemberNotInRoomByName(String shopMemberName, Integer roomId) {
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInAllGroupNotInRoomByName(shopMemberName, roomId);
public String getAllGroupShopMemberNotInRoomByName(String keywords, Integer roomId) {
String[] replacedKeyword = keywords.replaceAll(" ", " ").split(" ");
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInAllGroupNotInRoomByName(replacedKeyword, roomId);
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
......@@ -368,9 +376,9 @@ public class CommunicationLogic extends AbstractLogic {
return searchUserStr;
}
public String getGroupByName(String groupName) {
List<GroupDto> searchGroups = groupDao.getGroupByName(groupName);
public String getGroupByName(String keyword) {
String[] replacedKeyword = keyword.replaceAll(" ", " ").split(" ");
List<GroupDto> searchGroups = groupDao.getGroupByName(replacedKeyword);
JSONArray resultJsonArray = new JSONArray();
for (GroupDto group : searchGroups) {
......
......@@ -160,7 +160,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
mChatWebView.setVerticalScrollBarEnabled(false); //スクロールバーを消す。
WebSettings settings = mChatWebView.getSettings();
settings.setJavaScriptEnabled(true); //Javascriptを有効にする。
settings.setAppCacheEnabled(false);
settings.setAppCacheEnabled(true);
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
......@@ -187,6 +187,11 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
String fixedParam = "&platform=android&isMobile=true&chatServerUrl=" + ABVEnvironment.getInstance().websocketServerHttpUrl;
//ページをロード
if(roomId != 0 && roomName != null) { // by push message
try {
jsInf.updateRoomList();
} catch (Exception e) {
e.printStackTrace();
}
String parameterData = "sid=" + sid + "&loginId=" + loginId + "&shopName=" + shopName + "&roomId=" + roomId + "&roomName=" + roomName + fixedParam;
mChatWebView.postUrl(CHAT_ROOM_PAGE_URL, parameterData.getBytes());
}
......@@ -754,6 +759,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
public void createChatRoom(String roomType, String userIdList, String encodedRoomName) throws NetworkDisconnectedException, AcmsException {
CreatedRoomJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).createRoom(sid, roomType, userIdList, encodedRoomName, loginId);
communicationLogic.insertChatRoom(resultJson.chatRoomDto);
communicationLogic.addUserInRoom(StringUtil.join(",", userIdList, shopMemberId.toString()), resultJson.chatRoomDto.chatRoomId);
final Integer chatRoomId = resultJson.chatRoomDto.chatRoomId;
final String chatRoomName = resultJson.chatRoomDto.chatRoomName;
mChatWebView.post(new Runnable() {
......@@ -876,14 +882,14 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public String getMyGroupShopMemberByName(String shopMemberName) {
String searchUserStr = communicationLogic.getMyGroupUserByName(shopMemberName);
public String getMyGroupShopMemberByName(String keyword) {
String searchUserStr = communicationLogic.getMyGroupUserByName(keyword);
return searchUserStr;
}
@JavascriptInterface
public String getMyGroupShopMemberNotInRoomByName(String shopMemberName) {
String searchUserStr = communicationLogic.getMyGroupUserNotInRoomByName(shopMemberName, roomId.intValue());
public String getMyGroupShopMemberNotInRoomByName(String keywords) {
String searchUserStr = communicationLogic.getMyGroupUserNotInRoomByName(keywords, roomId.intValue());
return searchUserStr;
}
......@@ -894,14 +900,14 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public String getAllGroupShopMemberNotInRoomByName(String shopMemberName) {
String searchUserStr = communicationLogic.getAllGroupShopMemberNotInRoomByName(shopMemberName, roomId.intValue());
public String getAllGroupShopMemberNotInRoomByName(String keywords) {
String searchUserStr = communicationLogic.getAllGroupShopMemberNotInRoomByName(keywords, roomId.intValue());
return searchUserStr;
}
@JavascriptInterface
public String getGroupByName(String groupName) {
String searchGroupStr = communicationLogic.getGroupByName(groupName);
public String getGroupByName(String keyword) {
String searchGroupStr = communicationLogic.getGroupByName(keyword);
return searchGroupStr;
}
......
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