Commit 02678fc5 by Lee Munkyeong

プロフィールカード関連実装

parent 31f79590
...@@ -54,7 +54,9 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.EnterpriseNewLoginParamete ...@@ -54,7 +54,9 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.EnterpriseNewLoginParamete
import jp.agentec.abook.abv.bl.acms.client.parameters.GetApertureMasterDataParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.GetApertureMasterDataParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetContentParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.GetContentParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetEnqueteReplyParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.GetEnqueteReplyParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetGroupInfoParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetMessagesParameters; 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.GetOperationDataParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetTaskFileParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.GetTaskFileParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.NewAppStoreLoginParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.NewAppStoreLoginParameters;
...@@ -540,7 +542,7 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -540,7 +542,7 @@ public class AcmsClient implements AcmsClientResponseListener {
* @throws AcmsException * @throws AcmsException
*/ */
public RoomListJSON getRoomList(String sid) throws NetworkDisconnectedException, AcmsException { public RoomListJSON getRoomList(String sid) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetChatRooms, new AcmsParameters(sid,AcmsApis.Cmds.getRoomList)); HttpResponse response = send(AcmsApis.ApigetChatRooms, new AcmsParameters(sid,AcmsApis.RoomCmds.getRoomList));
RoomListJSON json = new RoomListJSON(response.httpResponseBody); RoomListJSON json = new RoomListJSON(response.httpResponseBody);
return json; return json;
...@@ -555,7 +557,13 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -555,7 +557,13 @@ public class AcmsClient implements AcmsClientResponseListener {
* @throws AcmsException * @throws AcmsException
*/ */
public MyInfoJSON getMyInfo(String sid) throws NetworkDisconnectedException, AcmsException { public MyInfoJSON getMyInfo(String sid) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetUser, new AcmsParameters(sid,AcmsApis.Cmds.getMyInfo)); HttpResponse response = send(AcmsApis.ApigetUser, new AcmsParameters(sid,AcmsApis.UserCmds.getMyInfo));
MyInfoJSON json = new MyInfoJSON(response.httpResponseBody);
return json;
}
public MyInfoJSON getNameCard(String sid,String shopMemberId) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetUser, new GetNameCardParameters(sid,AcmsApis.UserCmds.getNameCard,shopMemberId));
MyInfoJSON json = new MyInfoJSON(response.httpResponseBody); MyInfoJSON json = new MyInfoJSON(response.httpResponseBody);
return json; return json;
} }
...@@ -569,7 +577,7 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -569,7 +577,7 @@ public class AcmsClient implements AcmsClientResponseListener {
* @throws AcmsException * @throws AcmsException
*/ */
public GroupListJSON getGroupInfo(String sid,String groupId,String updatedDate) throws NetworkDisconnectedException, AcmsException { public GroupListJSON getGroupInfo(String sid,String groupId,String updatedDate) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetUser, new AcmsParameters(sid,AcmsApis.Cmds.getGroupInfo,groupId,updatedDate)); HttpResponse response = send(AcmsApis.ApigetUser, new GetGroupInfoParameters(sid,AcmsApis.UserCmds.getGroupInfo,groupId,updatedDate));
GroupListJSON json = new GroupListJSON(response.httpResponseBody); GroupListJSON json = new GroupListJSON(response.httpResponseBody);
return json; return json;
} }
...@@ -583,7 +591,7 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -583,7 +591,7 @@ public class AcmsClient implements AcmsClientResponseListener {
* @throws AcmsException * @throws AcmsException
*/ */
public CreatedRoomJSON createRoom(String sid, String roomType, String inviteMemberIds, String newRoomName) throws NetworkDisconnectedException, AcmsException { public CreatedRoomJSON createRoom(String sid, String roomType, String inviteMemberIds, String newRoomName) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetChatRooms, new CreateRoomParameters(sid,AcmsApis.Cmds.createRoom,roomType,inviteMemberIds,newRoomName)); HttpResponse response = send(AcmsApis.ApigetChatRooms, new CreateRoomParameters(sid,AcmsApis.RoomCmds.createRoom,roomType,inviteMemberIds,newRoomName));
CreatedRoomJSON json = new CreatedRoomJSON(response.httpResponseBody); CreatedRoomJSON json = new CreatedRoomJSON(response.httpResponseBody);
return json; return json;
} }
...@@ -597,7 +605,7 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -597,7 +605,7 @@ public class AcmsClient implements AcmsClientResponseListener {
* @throws AcmsException * @throws AcmsException
*/ */
public MessageInfoListJSON getMessages(String sid, String roomId) throws NetworkDisconnectedException, AcmsException { public MessageInfoListJSON getMessages(String sid, String roomId) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetMessage, new GetMessagesParameters(sid,AcmsApis.Cmds.getMessages,roomId,"0")); HttpResponse response = send(AcmsApis.ApigetMessage, new GetMessagesParameters(sid,AcmsApis.MessageCmds.getMessages,roomId,"0"));
MessageInfoListJSON json = new MessageInfoListJSON(response.httpResponseBody); MessageInfoListJSON json = new MessageInfoListJSON(response.httpResponseBody);
return json; return json;
} }
......
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONArray;
import org.json.adf.JSONObject;
import java.util.ArrayList;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
public class ShopMemberInfoJSON extends AcmsCommonJSON {
private static final String BODY = "body";
private static final String SHOP_MEMBER_ID = "shopMemberId";
private static final String MEMBER_NAME = "memberName";
private static final String PROFILE_IMAGE_PATH = "profileImagePath";
private static final String GROUP_ID_LIST = "groupIdList";
private static final Integer SELF_FLG_ON = 1;
public ShopMemberDto shopMemberDto;
public ShopMemberInfoJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
if (!json.has(BODY)) { return; }
JSONObject MyInfoJson = json.getJSONObject(BODY);
if (MyInfoJson == null) { return; }
shopMemberDto = new ShopMemberDto();
ArrayList<Integer> groupIdList = new ArrayList<Integer>();
JSONArray groupIdJsonArray = (JSONArray) MyInfoJson.get(GROUP_ID_LIST);
for (int i = 0; i < groupIdJsonArray.length(); i++) {
groupIdList.add(groupIdJsonArray.getInt(i));
}
shopMemberDto.groupIdList = groupIdList;
shopMemberDto.selfFlg = SELF_FLG_ON;
shopMemberDto.favoriteRegisterDate = null;
shopMemberDto.profileUrl = MyInfoJson.getString(PROFILE_IMAGE_PATH);
shopMemberDto.shopMemberId = MyInfoJson.getInt(SHOP_MEMBER_ID);
shopMemberDto.shopMemberName = MyInfoJson.getString(MEMBER_NAME);
}
}
package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.adf.net.http.HttpParameterObject;
/**
* ACMSのAPIに渡す共通的なパラメータを格納します。ACMSのAPIのパラメータ用クラスを作成するときはこのクラスを継承してください。<br>
* ただし、このクラスはログイン状態の確認用として使われる {@link GetGroupInfoParameters#sid} を持っているため、ログイン用のパラメータ {@link MobileLoginParameters} は、このクラスを継承する必要はありません。
* @author Taejin Hong
* @version 1.0.0
*/
public class GetGroupInfoParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
private String groupIds;
private String updatedDate;
/**
* {@link GetGroupInfoParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @since 1.0.0
*/
public GetGroupInfoParameters(String sid) {
this.sid = sid;
}
/**
* {@link GetGroupInfoParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @param cmd Apiリクエストに必要なコマンド(ABOOK COMM専用)。
* @since 1.0.0
*/
public GetGroupInfoParameters(String sid, String cmd) {
this.sid = sid;
this.cmd = cmd;
}
public GetGroupInfoParameters(String sid, String cmd, String groupId, String updatedDate) {
this.sid = sid;
this.cmd = cmd;
this.groupIds = groupId;
this.updatedDate = updatedDate;
}
/**
* セッションIDを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getSid() {
return sid;
}
/**
* コマンドを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getCmd() {
return cmd;
}
public String getUpdatedDate() {
return updatedDate;
}
public String getGroupIds() {
return groupIds;
}
}
package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.adf.net.http.HttpParameterObject;
/**
* ACMSのAPIに渡す共通的なパラメータを格納します。ACMSのAPIのパラメータ用クラスを作成するときはこのクラスを継承してください。<br>
* ただし、このクラスはログイン状態の確認用として使われる {@link GetNameCardParameters#sid} を持っているため、ログイン用のパラメータ {@link MobileLoginParameters} は、このクラスを継承する必要はありません。
* @author Taejin Hong
* @version 1.0.0
*/
public class GetNameCardParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
private String nameCardMemberId;
/**
* {@link GetNameCardParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @since 1.0.0
*/
public GetNameCardParameters(String sid) {
this.sid = sid;
}
/**
* {@link GetNameCardParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @param cmd Apiリクエストに必要なコマンド(ABOOK COMM専用)。
* @param nameCardMemberId 対象ユーザID。
* @since 1.0.0
*/
public GetNameCardParameters(String sid, String cmd, String nameCardMemberId) {
this.sid = sid;
this.cmd = cmd;
this.nameCardMemberId = nameCardMemberId;
}
public String getSid() {
return sid;
}
public String getCmd() {
return cmd;
}
public String getNameCardMemberId() {
return nameCardMemberId;
}
}
...@@ -174,11 +174,18 @@ public class AcmsApis { ...@@ -174,11 +174,18 @@ public class AcmsApis {
public static final String ApigetUser = "user"; public static final String ApigetUser = "user";
public static final String ApigetMessage = "message"; public static final String ApigetMessage = "message";
public static final class Cmds { public static final class UserCmds {
public static final String getRoomList = "5";
public static final String getMyInfo = "9"; public static final String getMyInfo = "9";
public static final String getGroupInfo = "10"; public static final String getGroupInfo = "10";
public static final String getNameCard = "11";
}
public static final class RoomCmds {
public static final String getRoomList = "5";
public static final String createRoom = "2"; public static final String createRoom = "2";
}
public static final class MessageCmds {
public static final String getMessages = "2"; public static final String getMessages = "2";
} }
......
...@@ -371,7 +371,35 @@ public class AbstractDao { ...@@ -371,7 +371,35 @@ public class AbstractDao {
} }
} }
} }
/**
* クエリを実行し、最初の行の最初の列の値をString型リストで返します。
*
* @param sql
* @param bindArgs
* @return
*/
public List<String> rawQueryGetStringList(String sql, String[] bindArgs) {
SQLiteDatabase db = dbConn.getDatabase();
Cursor cursor = null;
try {
List<String> list = new ArrayList<String>();
if (Logger.isVerboseEnabled()) {
Logger.v(TAG, "%s [%s]", sql, join(bindArgs));
}
cursor = db.rawQuery(sql, bindArgs);
while (cursor.moveToNext()) {
list.add(cursor.getString(0));
}
return list;
}
finally {
if (cursor != null) {
cursor.close();
}
}
}
/** /**
* クエリを実行し、DTOのリストとして返却します。 * クエリを実行し、DTOのリストとして返却します。
* cursorからDTOへの変換は、convertメソッドを使用するため、当該Daoはconvert()メソッドを実装する必要があります。 * cursorからDTOへの変換は、convertメソッドを使用するため、当該Daoはconvert()メソッドを実装する必要があります。
......
...@@ -74,7 +74,22 @@ public class GroupDao extends AbstractDao { ...@@ -74,7 +74,22 @@ public class GroupDao extends AbstractDao {
public List<GroupDto> getExistContentGroup(long contentId) { public List<GroupDto> getExistContentGroup(long contentId) {
return rawQueryGetDtoList("select * from m_group where group_relation_id in (select group_relation_id from r_content_group where content_id = " + contentId + ") order by group_id", null, GroupDto.class); return rawQueryGetDtoList("select * from m_group where group_relation_id in (select group_relation_id from r_content_group where content_id = " + contentId + ") order by group_id", null, GroupDto.class);
} }
public List<String> getMyGroupPathList() {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" CASE WHEN (grandparentgroup.group_name IS NOT NULL) THEN grandparentgroup.group_name || ' / ' || parentgroup.group_name || ' / ' || mygroup.group_name ");
sql.append(" WHEN (parentgroup.group_name IS NOT NULL) THEN parentgroup.group_name || ' / ' || mygroup.group_name ");
sql.append(" ELSE mygroup.group_name ");
sql.append(" END AS group_path_list ");
sql.append(" FROM m_group mygroup ");
sql.append(" LEFT JOIN m_group parentgroup on mygroup.parent_group_id = parentgroup.group_id ");
sql.append(" LEFT JOIN m_group grandparentgroup on parentgroup.parent_group_id = grandparentgroup.group_id ");
sql.append(" WHERE mygroup.user_group_flg = 1 ");
return rawQueryGetStringList(sql.toString(), null);
}
private String generateGetGroupsQuery(QueryType queryType, int[] groupRelationids, int[] parentGroupIds, Boolean downloaded, String searchKeyword, SearchDivisionType searchDivisionType, boolean isOnlineSearched) { private String generateGetGroupsQuery(QueryType queryType, int[] groupRelationids, int[] parentGroupIds, Boolean downloaded, String searchKeyword, SearchDivisionType searchDivisionType, boolean isOnlineSearched) {
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
......
...@@ -129,6 +129,7 @@ public class ShopMemberDao extends AbstractDao { ...@@ -129,6 +129,7 @@ public class ShopMemberDao extends AbstractDao {
sql.append(" INNER JOIN r_shop_member_group AS rsmg "); sql.append(" INNER JOIN r_shop_member_group AS rsmg ");
sql.append(" ON sm.shop_member_id = rsmg.shop_member_id "); sql.append(" ON sm.shop_member_id = rsmg.shop_member_id ");
sql.append(" WHERE rsmg.group_id IN (SELECT group_id FROM m_shop_member INNER JOIN r_shop_member_group WHERE self_flg = 1 GROUP BY group_id)"); sql.append(" WHERE rsmg.group_id IN (SELECT group_id FROM m_shop_member INNER JOIN r_shop_member_group WHERE self_flg = 1 GROUP BY group_id)");
sql.append(" AND sm.self_flg != 1 ");
sql.append(" ORDER BY sm.shop_member_name DESC "); sql.append(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), null, ShopMemberDto.class); List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), null, ShopMemberDto.class);
return list; return list;
......
...@@ -21,6 +21,7 @@ public class GroupDto extends AbstractDto { ...@@ -21,6 +21,7 @@ public class GroupDto extends AbstractDto {
public boolean userGroupFlg; public boolean userGroupFlg;
public int delFlg; public int delFlg;
public List<ShopMemberDto> groupMembers; public List<ShopMemberDto> groupMembers;
public List<String> groupPathList;
public GroupDto() { public GroupDto() {
} }
......
...@@ -114,13 +114,13 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -114,13 +114,13 @@ public class CommunicationLogic extends AbstractLogic {
public String getMyInfo() { public String getMyInfo() {
ShopMemberDto myInfo = shopMemberDao.getMyInfo(); ShopMemberDto myInfo = shopMemberDao.getMyInfo();
List<String> groupPathList = groupDao.getMyGroupPathList();
JSONObject myInfoJson = new JSONObject(); JSONObject myInfoJson = new JSONObject();
myInfoJson.put("shopMemberId",myInfo.shopMemberId); myInfoJson.put("shopMemberId",myInfo.shopMemberId);
myInfoJson.put("shopMemberName",myInfo.shopMemberName); myInfoJson.put("shopMemberName",myInfo.shopMemberName);
myInfoJson.put("profileUrl",myInfo.profileUrl); myInfoJson.put("profileUrl",myInfo.profileUrl);
myInfoJson.put("groupPathList",groupPathList);
String myInfoStr = myInfoJson.toString(); String myInfoStr = myInfoJson.toString();
return myInfoStr; return myInfoStr;
} }
...@@ -216,6 +216,8 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -216,6 +216,8 @@ public class CommunicationLogic extends AbstractLogic {
} }
shopMemberDao.insertShopMember(shopMemberDto); shopMemberDao.insertShopMember(shopMemberDto);
} }
public void insertShopMember(List<ShopMemberDto> shopMemberDtoList) { public void insertShopMember(List<ShopMemberDto> shopMemberDtoList) {
ShopMemberDto myInfo = shopMemberDao.getMyInfo(); ShopMemberDto myInfo = shopMemberDao.getMyInfo();
for (ShopMemberDto shopMemberDto : shopMemberDtoList) { for (ShopMemberDto shopMemberDto : shopMemberDtoList) {
...@@ -259,6 +261,10 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -259,6 +261,10 @@ public class CommunicationLogic extends AbstractLogic {
chatRoomDao.deleteChatRoom(); chatRoomDao.deleteChatRoom();
} }
public void insertMyInfo(ShopMemberDto shopMemberDto) {
shopMemberDto.selfFlg = 1;
shopMemberDao.insertShopMember(shopMemberDto);
}
} }
...@@ -770,7 +770,10 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -770,7 +770,10 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
String favoriteGroupsStr = communicationLogic.getFavoriteGroups(); String favoriteGroupsStr = communicationLogic.getFavoriteGroups();
return favoriteGroupsStr; return favoriteGroupsStr;
} }
@JavascriptInterface
public void updateUserInfo(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
updateUserInfoFromServer(shopMemberId);
}
} }
...@@ -788,6 +791,11 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -788,6 +791,11 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private void updateMyInfoFromServer() throws NetworkDisconnectedException, AcmsException { private void updateMyInfoFromServer() throws NetworkDisconnectedException, AcmsException {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMyInfo(sid); MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMyInfo(sid);
communicationLogic.insertMyInfo(resultJson.shopMemberDto);
}
private void updateUserInfoFromServer(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getNameCard(sid,shopMemberId);
communicationLogic.insertShopMember(resultJson.shopMemberDto); communicationLogic.insertShopMember(resultJson.shopMemberDto);
} }
......
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