Java Code Examples for com.akaxin.proto.core.PluginProto#ProxyPluginPackage
The following examples show how to use
com.akaxin.proto.core.PluginProto#ProxyPluginPackage .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserManageController.java From openzaly with Apache License 2.0 | 6 votes |
@RequestMapping(method = RequestMethod.POST, value = "delUser") @ResponseBody public String deleteUser(HttpServletRequest request, @RequestBody byte[] bodyParam) { try { PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); String siteUserId = getRequestSiteUserId(pluginPackage); if (isManager(siteUserId)) { Map<String, String> reqMap = getRequestDataMap(pluginPackage); String delUserID = reqMap.get("siteUserId"); if (userService.delUser(delUserID)) { return SUCCESS; } } else { return NO_PERMISSION; } } catch (Exception e) { logger.error("del User error", e); } return ERROR; }
Example 2
Source File: UserManageController.java From openzaly with Apache License 2.0 | 6 votes |
@RequestMapping(method = RequestMethod.POST, value = "delUser") @ResponseBody public String deleteUser(HttpServletRequest request, @RequestBody byte[] bodyParam) { try { PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); String siteUserId = getRequestSiteUserId(pluginPackage); if (isManager(siteUserId)) { Map<String, String> reqMap = getRequestDataMap(pluginPackage); String delUserID = reqMap.get("siteUserId"); if (userService.delUser(delUserID)) { return SUCCESS; } } else { return NO_PERMISSION; } } catch (Exception e) { logger.error("del User error", e); } return ERROR; }
Example 3
Source File: ConfigManageController.java From openzaly with Apache License 2.0 | 6 votes |
@RequestMapping("/index") public String homePage(@RequestBody byte[] bodyParam) { PluginProto.ProxyPluginPackage pluginPackage = null; try { pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); String siteUserId = getRequestSiteUserId(pluginPackage); boolean isManager = SiteConfig.isSiteManager(siteUserId); if (!isManager) { throw new UserPermissionException("Current user is not a manager"); } return "admin"; } catch (InvalidProtocolBufferException e) { logger.error("to basic manage error", e); } catch (UserPermissionException u) { logger.error("to basic manage error : " + u.getMessage()); } return "error"; }
Example 4
Source File: UserSquareController.java From wind-im with Apache License 2.0 | 6 votes |
@RequestMapping("/index") public ModelAndView toIndex(@RequestBody byte[] bodyParam) { ModelAndView modelAndView = new ModelAndView("siteMember/siteMember"); Map<String, Object> model = modelAndView.getModel(); PluginProto.ProxyPluginPackage pluginPackage = null; try { pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap(); String siteUserId = headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE); UserProfileBean userProfile = userService.getUserProfile(siteUserId); model.put("site_user_id", siteUserId); model.put("site_user_name", userProfile.getUserName()); } catch (InvalidProtocolBufferException e) { logger.error("to user square error", e); return new ModelAndView("siteMember/error"); } return modelAndView; }
Example 5
Source File: ConfigManageController.java From openzaly with Apache License 2.0 | 6 votes |
@RequestMapping("/index") public String homePage(@RequestBody byte[] bodyParam) { PluginProto.ProxyPluginPackage pluginPackage = null; try { pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); String siteUserId = getRequestSiteUserId(pluginPackage); boolean isManager = SiteConfig.isSiteManager(siteUserId); if (!isManager) { throw new UserPermissionException("Current user is not a manager"); } return "admin"; } catch (InvalidProtocolBufferException e) { logger.error("to basic manage error", e); } catch (UserPermissionException u) { logger.error("to basic manage error : " + u.getMessage()); } return "error"; }
Example 6
Source File: UserSquareController.java From openzaly with Apache License 2.0 | 6 votes |
@RequestMapping("/index") public ModelAndView toIndex(@RequestBody byte[] bodyParam) { ModelAndView modelAndView = new ModelAndView("siteMember/siteMember"); Map<String, Object> model = modelAndView.getModel(); PluginProto.ProxyPluginPackage pluginPackage = null; try { pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap(); String siteUserId = headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE); UserProfileBean userProfile = userService.getUserProfile(siteUserId); model.put("site_user_id", siteUserId); model.put("site_user_name", userProfile.getUserName()); } catch (InvalidProtocolBufferException e) { logger.error("to user square error", e); return new ModelAndView("siteMember/error"); } return modelAndView; }
Example 7
Source File: ConfigManageController.java From wind-im with Apache License 2.0 | 6 votes |
@RequestMapping("/index") public String homePage(@RequestBody byte[] bodyParam) { PluginProto.ProxyPluginPackage pluginPackage = null; try { pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); String siteUserId = getRequestSiteUserId(pluginPackage); boolean isManager = SiteConfig.isSiteManager(siteUserId); if (!isManager) { throw new UserPermissionException("Current user is not a manager"); } return "admin"; } catch (InvalidProtocolBufferException e) { logger.error("to basic manage error", e); } catch (UserPermissionException u) { logger.error("to basic manage error : " + u.getMessage()); } return "error"; }
Example 8
Source File: UserManageController.java From wind-im with Apache License 2.0 | 6 votes |
@RequestMapping(method = RequestMethod.POST, value = "delUser") @ResponseBody public String deleteUser(HttpServletRequest request, @RequestBody byte[] bodyParam) { try { PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); String siteUserId = getRequestSiteUserId(pluginPackage); if (isManager(siteUserId)) { Map<String, String> reqMap = getRequestDataMap(pluginPackage); String delUserID = reqMap.get("siteUserId"); if (userService.delUser(delUserID)) { return SUCCESS; } } else { return NO_PERMISSION; } } catch (Exception e) { logger.error("del User error", e); } return ERROR; }
Example 9
Source File: UserSquareController.java From wind-im with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @RequestMapping(method = RequestMethod.POST, value = "/pullMemberList") @ResponseBody public Map<String, Object> getMemberList(HttpServletRequest request, @RequestBody byte[] bodyParam) { Map<String, Object> results = new HashMap<String, Object>(); boolean nodata = true; int pageSize = 20; try { PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap(); String siteUserId = headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE); Map<String, String> ReqMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class); int pageNum = Integer.valueOf(ReqMap.get("pageNum")); List<SimpleUserBean> userList = userService.getUserList(pageNum, pageSize); List<Map<String, String>> data = new ArrayList<Map<String, String>>(); if (userList != null && userList.size() > 0) { nodata = false; for (SimpleUserBean bean : userList) { Map<String, String> memberMap = new HashMap<String, String>(); if (siteUserId != bean.getUserId()) { memberMap.put("site_user_id", bean.getUserId()); memberMap.put("site_user_name", bean.getUserName()); memberMap.put("site_user_photo", bean.getUserPhoto()); UserProto.UserRelation userRelation = UserFriendDao.getInstance().getUserRelation(siteUserId, bean.getUserId()); memberMap.put("site_user_relation", String.valueOf(userRelation.getNumber())); } data.add(memberMap); } } results.put("Data", data); } catch (Exception e) { logger.error("get Member list error", e); } results.put("loading", nodata); return results; }
Example 10
Source File: UserSquareController.java From wind-im with Apache License 2.0 | 5 votes |
@RequestMapping("/applyFriend") @ResponseBody public String[] applyFriend(@RequestBody byte[] bodyParam) { PluginProto.ProxyPluginPackage pluginPackage = null; try { pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap(); String siteUserId = headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE); Map<String, String> ReqMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class); String friendSiteUserId = ReqMap.get("site_user_id"); String apply_reason = ReqMap.get("apply_reason"); if (StringUtils.isBlank(siteUserId)) { return new String[] { "添加失败", "0" }; } else if (siteUserId.equals(friendSiteUserId)) { } else { int applyTimes = UserFriendDao.getInstance().getApplyCount(friendSiteUserId, siteUserId); if (applyTimes >= 5) { return new String[] { "失败,次数过多", "0" }; } else { if (UserFriendDao.getInstance().saveFriendApply(siteUserId, friendSiteUserId, apply_reason)) { new User2Notice().applyFriendNotice(siteUserId, friendSiteUserId); // 同时下发一条PUSH消息 if (applyTimes < 2) { PushNotification.sendAddFriend(siteUserId, friendSiteUserId); } return new String[] { "成功", friendSiteUserId }; } } } } catch (InvalidProtocolBufferException e) { logger.error("Friend apply error.", e); } return new String[] { "添加失败", "0" }; }
Example 11
Source File: UserSquareController.java From openzaly with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @RequestMapping(method = RequestMethod.POST, value = "/pullMemberList") @ResponseBody public Map<String, Object> getMemberList(HttpServletRequest request, @RequestBody byte[] bodyParam) { Map<String, Object> results = new HashMap<String, Object>(); boolean nodata = true; try { PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap(); String siteUserId = headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE); Map<String, String> ReqMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class); int pageNum = Integer.valueOf(ReqMap.get("page")); List<SimpleUserBean> userList = userService.getUserList(pageNum, 20); List<Map<String, String>> data = new ArrayList<Map<String, String>>(); if (userList != null && userList.size() > 0) { if (20 == userList.size()) { nodata = false; } for (SimpleUserBean bean : userList) { Map<String, String> memberMap = new HashMap<String, String>(); if (siteUserId != bean.getUserId()) { memberMap.put("site_user_id", bean.getUserId()); memberMap.put("site_user_name", bean.getUserName()); UserProto.UserRelation userRelation = UserFriendDao.getInstance().getUserRelation(siteUserId, bean.getUserId()); memberMap.put("site_user_relation", String.valueOf(userRelation.getNumber())); } data.add(memberMap); } } results.put("Data", data); } catch (Exception e) { logger.error("get Member list error", e); } results.put("loading", nodata); return results; }
Example 12
Source File: UserSquareController.java From openzaly with Apache License 2.0 | 5 votes |
@RequestMapping("/applyFriend") @ResponseBody public String[] applyFriend(@RequestBody byte[] bodyParam) { PluginProto.ProxyPluginPackage pluginPackage = null; try { pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap(); String siteUserId = headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE); Map<String, String> ReqMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class); String friendSiteUserId = ReqMap.get("site_user_id"); String apply_reason = ReqMap.get("apply_reason"); if (StringUtils.isBlank(siteUserId)) { return new String[] { "添加失败", "0" }; } else if (siteUserId.equals(friendSiteUserId)) { } else { int applyTimes = UserFriendDao.getInstance().getApplyCount(friendSiteUserId, siteUserId); if (applyTimes >= 5) { return new String[] { "失败,次数过多", "0" }; } else { if (UserFriendDao.getInstance().saveFriendApply(siteUserId, friendSiteUserId, apply_reason)) { new User2Notice().applyFriendNotice(siteUserId, friendSiteUserId); // 同时下发一条PUSH消息 if (applyTimes < 2) { PushNotification.sendAddFriend(siteUserId, friendSiteUserId); } return new String[] { "成功", friendSiteUserId }; } } } } catch (InvalidProtocolBufferException e) { logger.error("Friend apply error.", e); } return new String[] { "添加失败", "0" }; }
Example 13
Source File: ConfigManageController.java From wind-im with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @RequestMapping(method = RequestMethod.POST, value = "/updateConfig") @ResponseBody public String updateSiteConfig(HttpServletRequest request, @RequestBody byte[] bodyParam) { try { PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); String siteUserId = getRequestSiteUserId(pluginPackage); if (!isManager(siteUserId)) { throw new UserPermissionException("Current user is not a manager"); } Map<String, String> dataMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class); logger.info("siteUserId={} update config={}", siteUserId, dataMap); Map<Integer, String> configMap = new HashMap<Integer, String>(); if (StringUtils.isNotEmpty(trim(dataMap.get("site_name")))) { configMap.put(ConfigProto.ConfigKey.SITE_NAME_VALUE, trim(dataMap.get("site_name"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("site_address")))) { configMap.put(ConfigProto.ConfigKey.SITE_ADDRESS_VALUE, trim(dataMap.get("site_address"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("site_port")))) { configMap.put(ConfigProto.ConfigKey.SITE_PORT_VALUE, trim(dataMap.get("site_port"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("group_members_count")))) { configMap.put(ConfigProto.ConfigKey.GROUP_MEMBERS_COUNT_VALUE, trim(dataMap.get("group_members_count"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("pic_path")))) { configMap.put(ConfigProto.ConfigKey.PIC_PATH_VALUE, trim(dataMap.get("pic_path"))); } if (StringUtils.isNotEmpty(dataMap.get("site_logo"))) { configMap.put(ConfigProto.ConfigKey.SITE_LOGO_VALUE, dataMap.get("site_logo")); } if (StringUtils.isNotEmpty(dataMap.get("uic_status"))) { configMap.put(ConfigProto.ConfigKey.INVITE_CODE_STATUS_VALUE, dataMap.get("uic_status")); } if (StringUtils.isNotEmpty(dataMap.get("realName_status"))) { configMap.put(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE, dataMap.get("realName_status")); } if (StringUtils.isNotEmpty(dataMap.get("u2_encryption_status"))) { configMap.put(ConfigProto.ConfigKey.U2_ENCRYPTION_STATUS_VALUE, dataMap.get("u2_encryption_status")); } if (StringUtils.isNotEmpty(dataMap.get("add_friends_status"))) { configMap.put(ConfigProto.ConfigKey.CONFIG_FRIEND_REQUEST_VALUE, dataMap.get("add_friends_status")); } if (StringUtils.isNotEmpty(dataMap.get("create_groups_status"))) { configMap.put(ConfigProto.ConfigKey.CONFIG_CREATE_GROUP_VALUE, dataMap.get("create_groups_status")); } if (StringUtils.isNotEmpty(dataMap.get("group_qrcode_expire_time"))) { configMap.put(ConfigProto.ConfigKey.GROUP_QR_EXPIRE_TIME_VALUE, dataMap.get("group_qrcode_expire_time")); } if (StringUtils.isNotEmpty(dataMap.get("push_client_status"))) { configMap.put(ConfigProto.ConfigKey.PUSH_CLIENT_STATUS_VALUE, dataMap.get("push_client_status")); } if (StringUtils.isNotEmpty(dataMap.get("log_level"))) { String logLevel = dataMap.get("log_level"); configMap.put(ConfigProto.ConfigKey.LOG_LEVEL_VALUE, logLevel); Level level = Level.INFO; if ("DEBUG".equalsIgnoreCase(logLevel)) { level = Level.DEBUG; } else if ("ERROR".equalsIgnoreCase(logLevel)) { level = Level.ERROR; } // 更新日志级别 AkxLog4jManager.setLogLevel(level); } // 普通管理员无权限 if (isAdmin(siteUserId) && StringUtils.isNotEmpty(trim(dataMap.get("site_manager")))) { configMap.put(ConfigProto.ConfigKey.SITE_MANAGER_VALUE, trim(dataMap.get("site_manager"))); } if (configManageService.updateSiteConfig(siteUserId, configMap)) { return SUCCESS; } } catch (InvalidProtocolBufferException e) { logger.error("update site config error", e); } catch (UserPermissionException u) { logger.error("update site config error : " + u.getMessage()); return NO_PERMISSION; } return ERROR; }
Example 14
Source File: GroupManageController.java From openzaly with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public Map<String, Object> getRequestDataMapObj(PluginProto.ProxyPluginPackage pluginPackage) { return GsonUtils.fromJson(pluginPackage.getData(), Map.class); }
Example 15
Source File: AbstractController.java From openzaly with Apache License 2.0 | 4 votes |
public String getRequestSiteUserId(PluginProto.ProxyPluginPackage pluginPackage) { Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap(); return headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE); }
Example 16
Source File: AbstractController.java From openzaly with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public Map<String, String> getRequestDataMap(PluginProto.ProxyPluginPackage pluginPackage) { return GsonUtils.fromJson(pluginPackage.getData(), Map.class); }
Example 17
Source File: AbstractController.java From openzaly with Apache License 2.0 | 4 votes |
public String getRequestSiteUserId(PluginProto.ProxyPluginPackage pluginPackage) { Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap(); return headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE); }
Example 18
Source File: AbstractController.java From openzaly with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public Map<String, String> getRequestDataMap(PluginProto.ProxyPluginPackage pluginPackage) { return GsonUtils.fromJson(pluginPackage.getData(), Map.class); }
Example 19
Source File: ConfigManageController.java From openzaly with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @RequestMapping(method = RequestMethod.POST, value = "/updateConfig") @ResponseBody public String updateSiteConfig(HttpServletRequest request, @RequestBody byte[] bodyParam) { try { PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); String siteUserId = getRequestSiteUserId(pluginPackage); if (!isManager(siteUserId)) { throw new UserPermissionException("Current user is not a manager"); } Map<String, String> dataMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class); logger.info("siteUserId={} update config={}", siteUserId, dataMap); Map<Integer, String> configMap = new HashMap<Integer, String>(); if (StringUtils.isNotEmpty(trim(dataMap.get("site_name")))) { configMap.put(ConfigProto.ConfigKey.SITE_NAME_VALUE, trim(dataMap.get("site_name"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("site_address")))) { configMap.put(ConfigProto.ConfigKey.SITE_ADDRESS_VALUE, trim(dataMap.get("site_address"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("site_port")))) { configMap.put(ConfigProto.ConfigKey.SITE_PORT_VALUE, trim(dataMap.get("site_port"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("group_members_count")))) { configMap.put(ConfigProto.ConfigKey.GROUP_MEMBERS_COUNT_VALUE, trim(dataMap.get("group_members_count"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("pic_path")))) { configMap.put(ConfigProto.ConfigKey.PIC_PATH_VALUE, trim(dataMap.get("pic_path"))); } if (StringUtils.isNotEmpty(dataMap.get("site_logo"))) { configMap.put(ConfigProto.ConfigKey.SITE_LOGO_VALUE, dataMap.get("site_logo")); } if (StringUtils.isNotEmpty(dataMap.get("uic_status"))) { configMap.put(ConfigProto.ConfigKey.INVITE_CODE_STATUS_VALUE, dataMap.get("uic_status")); } if (StringUtils.isNotEmpty(dataMap.get("realName_status"))) { configMap.put(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE, dataMap.get("realName_status")); } if (StringUtils.isNotEmpty(dataMap.get("u2_encryption_status"))) { configMap.put(ConfigProto.ConfigKey.U2_ENCRYPTION_STATUS_VALUE, dataMap.get("u2_encryption_status")); } if (StringUtils.isNotEmpty(dataMap.get("push_client_status"))) { configMap.put(ConfigProto.ConfigKey.PUSH_CLIENT_STATUS_VALUE, dataMap.get("push_client_status")); } if (StringUtils.isNotEmpty(dataMap.get("log_level"))) { String logLevel = dataMap.get("log_level"); configMap.put(ConfigProto.ConfigKey.LOG_LEVEL_VALUE, logLevel); Level level = Level.INFO; if ("DEBUG".equalsIgnoreCase(logLevel)) { level = Level.DEBUG; } else if ("ERROR".equalsIgnoreCase(logLevel)) { level = Level.ERROR; } // 更新日志级别 AkxLog4jManager.setLogLevel(level); } // 普通管理员无权限 if (isAdmin(siteUserId) && StringUtils.isNotEmpty(trim(dataMap.get("site_manager")))) { configMap.put(ConfigProto.ConfigKey.SITE_MANAGER_VALUE, trim(dataMap.get("site_manager"))); } if (configManageService.updateSiteConfig(siteUserId, configMap)) { return SUCCESS; } } catch (InvalidProtocolBufferException e) { logger.error("update site config error", e); } catch (UserPermissionException u) { logger.error("update site config error : " + u.getMessage()); return NO_PERMISSION; } return ERROR; }
Example 20
Source File: GroupManageController.java From openzaly with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public Map<String, Object> getRequestDataMapObj(PluginProto.ProxyPluginPackage pluginPackage) { return GsonUtils.fromJson(pluginPackage.getData(), Map.class); }