Commit d54d0f7e by Lee Munkyeong

invite-user

parent ea4909b8
......@@ -66,6 +66,7 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.GetMessagesParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetNameCardParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetOperationDataParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetTaskFileParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.InviteUsersParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.NewAppStoreLoginParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.PasswordChangeParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.PostEnqueteReplyParameters;
......@@ -648,6 +649,22 @@ public class AcmsClient implements AcmsClientResponseListener {
}
/**
* ユーザ招待。
*
* @param sid
* @param roomId
* @param roomName
* @param userIds
* @return 成功有無
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public boolean inviteUsers(String sid, Integer roomId, String roomName, String userIds) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetUser, new InviteUsersParameters(sid, AcmsApis.UserCmds.inviteUsers, roomId, roomName, userIds));
return response.httpResponseCode == 200;
}
/**
* お気に入りユーザ追加。。
*
* @param sid
......
package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.adf.net.http.HttpParameterObject;
/**
* @author Lee-mk
* @version 1.0.0
*/
public class InviteUsersParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
private Integer newRoomId;
private String newRoomName;
private String loginIdList;
/**
* {@link InviteUsersParameters} のインスタンスを初期化します。
* @param sid
* @param cmd
* @param roomId
* @param newRoomName
* @param loginIdList
* @since 1.0.0
*/
public InviteUsersParameters(String sid, String cmd, Integer newRoomId, String newRoomName, String loginIdList) {
this.sid = sid;
this.cmd = cmd;
this.newRoomId = newRoomId;
this.newRoomName = newRoomName;
this.loginIdList = loginIdList;
}
/**
* セッションIDを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getSid() {
return sid;
}
/**
* コマンドを返します。
* @return コマンド。
* @since 1.0.0
*/
public String getCmd() {
return cmd;
}
/**
* roomIdを返します。
* @return roomId。
* @since 1.0.0
*/
public Integer getNewRoomId() {
return newRoomId;
}
/**
* newRoomNameを返します。
* @return newRoomName。
* @since 1.0.0
*/
public String getNewRoomName() {
return newRoomName;
}
/**
* loginIdListを返します。
* @return loginIdList。
* @since 1.0.0
*/
public String getLoginIdList() {
return loginIdList;
}
}
......@@ -176,6 +176,7 @@ public class AcmsApis {
public static final String ApigetFavorite = "favorite";
public static final class UserCmds {
public static final String inviteUsers = "3";
public static final String getMyInfo = "9";
public static final String getGroupInfo = "10";
public static final String getNameCard = "11";
......
......@@ -131,6 +131,16 @@ public class ShopMemberDao extends AbstractDao {
return rawQueryGetDtoList("select * from m_shop_member where favorite_register_date NOT NULL", null, ShopMemberDto.class);
}
public List<ShopMemberDto> getfavoriteUserListNotInRoom(Integer roomId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT * ");
sql.append(" FROM m_shop_member sm ");
sql.append(" WHERE favorite_register_date NOT NULL ");
sql.append(" AND sm.shop_member_id NOT IN");
sql.append(" (SELECT shop_member_id FROM r_chat_room_shop_member WHERE chat_room_id = ?)");
return rawQueryGetDtoList(sql.toString(), new String[] {"" + roomId}, ShopMemberDto.class);
}
public List<ShopMemberDto> getUserListByGroupId(Integer groupId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
......@@ -149,6 +159,25 @@ public class ShopMemberDao extends AbstractDao {
return list;
}
public List<ShopMemberDto> getUserListNotInRoomByGroupId(Integer groupId, Integer roomId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" sm.shop_member_id ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url");
sql.append(" ,sm.favorite_register_date");
sql.append(" FROM ");
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 =?");
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(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), new String[]{"" + groupId, "" + roomId}, ShopMemberDto.class);
return list;
}
public List<ShopMemberDto> getUserInMyGroupByName(String shopMemberName) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT DISTINCT");
......@@ -168,6 +197,26 @@ public class ShopMemberDao extends AbstractDao {
return list;
}
public List<ShopMemberDto> getUserInMyGroupNotInRoomByName(String shopMemberName, Integer roomId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT DISTINCT");
sql.append(" sm.shop_member_id ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url");
sql.append(" ,sm.favorite_register_date");
sql.append(" FROM ");
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_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+"%' ");
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) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT DISTINCT");
......@@ -186,6 +235,25 @@ public class ShopMemberDao extends AbstractDao {
return list;
}
public List<ShopMemberDto> getUserInAllGroupNotInRoomByName(String shopMemberName, Integer roomId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT DISTINCT");
sql.append(" sm.shop_member_id ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url");
sql.append(" ,sm.favorite_register_date");
sql.append(" FROM ");
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(" AND sm.self_flg != 1");
sql.append(" AND sm.shop_member_name LIKE '%"+shopMemberName+"%' ");
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);
return list;
}
public List<ShopMemberDto> getMyGroupUsers() {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
......
......@@ -209,6 +209,37 @@ public class CommunicationLogic extends AbstractLogic {
return myInfoStr;
}
public String getMyGroupUsersNotInRoom(Integer roomId) {
List<GroupDto> myGroupIds = groupDao.getUserGroups();
JSONArray myGroupUsersJson = new JSONArray();
for (GroupDto groupDto : myGroupIds) {
JSONObject groupUserJson = new JSONObject();
groupUserJson.put(ABookCommConstants.KEY.GROUP_ID, groupDto.groupId);
groupUserJson.put(ABookCommConstants.KEY.GROUP_NAME, groupDto.groupName);
List<ShopMemberDto> groupUsers = shopMemberDao.getUserListNotInRoomByGroupId(groupDto.groupId, roomId);
JSONArray groupUserArray = new JSONArray();
for (ShopMemberDto groupUser : groupUsers) {
Map<String, Object> myGroupUserMap = new HashMap<String, Object>();
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, groupUser.shopMemberId);
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, groupUser.shopMemberName);
myGroupUserMap.put(ABookCommConstants.KEY.CHECKED, "");
myGroupUserMap.put(ABookCommConstants.KEY.PROFILE_URL, groupUser.profileUrl);
myGroupUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupUser);
if (StringUtil.isNullOrEmpty(groupUser.favoriteRegisterDate)) {
myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
JSONObject jsonObject = new JSONObject(myGroupUserMap);
groupUserArray.put(jsonObject);
}
groupUserJson.put(ABookCommConstants.KEY.GROUP_USER_LIST, groupUserArray);
myGroupUsersJson.put(groupUserJson);
}
String myInfoStr = myGroupUsersJson.toString();
return myInfoStr;
}
public String getMyGroupUserByName(String shopMemberName) {
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInMyGroupByName(shopMemberName);
......@@ -241,6 +272,37 @@ public class CommunicationLogic extends AbstractLogic {
return searchUserStr;
}
public String getMyGroupUserNotInRoomByName(String shopMemberName, Integer roomId) {
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInMyGroupNotInRoomByName(shopMemberName, roomId);
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
Map<String, Object> userMap = new HashMap<String, Object>();
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, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
JSONObject jsonObject = new JSONObject(userMap);
resultJsonArray.put(jsonObject);
}
String searchUserStr = resultJsonArray.toString();
return searchUserStr;
}
public String getAllGroupShopMemberByName(String shopMemberName) {
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInAllGroupByName(shopMemberName);
......@@ -274,6 +336,38 @@ public class CommunicationLogic extends AbstractLogic {
return searchUserStr;
}
public String getAllGroupShopMemberNotInRoomByName(String shopMemberName, Integer roomId) {
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInAllGroupNotInRoomByName(shopMemberName, roomId);
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
Map<String, Object> userMap = new HashMap<String, Object>();
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, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
JSONObject jsonObject = new JSONObject(userMap);
resultJsonArray.put(jsonObject);
}
String searchUserStr = resultJsonArray.toString();
return searchUserStr;
}
public String getGroupByName(String groupName) {
List<GroupDto> searchGroups = groupDao.getGroupByName(groupName);
......@@ -345,6 +439,36 @@ public class CommunicationLogic extends AbstractLogic {
return favoriteUsersStr;
}
public String getFavoriteUsersNotInRoom(Integer roomId) {
List<ShopMemberDto> favoriteUsers = shopMemberDao.getfavoriteUserListNotInRoom(roomId);
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto favoriteUser : favoriteUsers) {
Map<String, Object> favoriteUserMap = new HashMap<String, Object>();
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.CHECKED, "");
favoriteUserMap.put(ABookCommConstants.KEY.PROFILE_URL, favoriteUser.profileUrl);
favoriteUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
favoriteUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
JSONObject jsonObject = new JSONObject(favoriteUserMap);
resultJsonArray.put(jsonObject);
}
String favoriteUsersStr = resultJsonArray.toString();
return favoriteUsersStr;
}
public String getFavoriteGroups() {
List<GroupDto> favoriteGroups = groupDao.getFavoriteGroup();
......@@ -459,6 +583,15 @@ public class CommunicationLogic extends AbstractLogic {
chatRoomDao.insertChatRoom(chatRoomDto);
}
public void addUserInRoom(String userIds, Integer roomId) {
String[] userIdArray = userIds.split(",");
List<Integer> userIdList = new ArrayList<Integer>();
for (String userId : userIdArray) {
userIdList.add(Integer.parseInt(userId));
}
chatRoomDao.insertChatRoomUsers(userIdList, roomId);
}
public void insertChatMessage(ChatMessageDto chatMessageDto) {
chatMessageDao.insertChatMessage(chatMessageDto);
}
......
......@@ -788,6 +788,19 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public void inviteUsers(String userIds) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).inviteUsers(sid, roomId.intValue(), roomName, userIds);
if (!result) { return; }
communicationLogic.addUserInRoom(userIds, roomId.intValue());
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl(CHAT_ROOM_PAGE_URL);
}
});
}
@JavascriptInterface
public String getRoomType() {
return roomType;
}
......@@ -821,6 +834,12 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public String getFavoriteUsersNotInRoom() {
String favoriteUsersStr = communicationLogic.getFavoriteUsersNotInRoom(roomId.intValue());
return favoriteUsersStr;
}
@JavascriptInterface
public String getMyInfo() {
String myInfoStr = communicationLogic.getMyInfo();
return myInfoStr;
......@@ -839,18 +858,36 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public String getMyGroupUsersNotInRoom() {
String myGroupUsersStr = communicationLogic.getMyGroupUsersNotInRoom(roomId.intValue());
return myGroupUsersStr;
}
@JavascriptInterface
public String getMyGroupShopMemberByName(String shopMemberName) {
String searchUserStr = communicationLogic.getMyGroupUserByName(shopMemberName);
return searchUserStr;
}
@JavascriptInterface
public String getMyGroupShopMemberNotInRoomByName(String shopMemberName) {
String searchUserStr = communicationLogic.getMyGroupUserNotInRoomByName(shopMemberName, roomId.intValue());
return searchUserStr;
}
@JavascriptInterface
public String getAllGroupShopMemberByName(String shopMemberName) {
String searchUserStr = communicationLogic.getAllGroupShopMemberByName(shopMemberName);
return searchUserStr;
}
@JavascriptInterface
public String getAllGroupShopMemberNotInRoomByName(String shopMemberName) {
String searchUserStr = communicationLogic.getAllGroupShopMemberNotInRoomByName(shopMemberName, roomId.intValue());
return searchUserStr;
}
@JavascriptInterface
public String getGroupByName(String groupName) {
String searchGroupStr = communicationLogic.getGroupByName(groupName);
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