├── .gitignore ├── LICENSE ├── NOTICE ├── README.md ├── build.sh ├── openzaly-admin ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── akaxin │ │ └── site │ │ └── web │ │ ├── OpenzalyAdminApplication.java │ │ ├── admin │ │ ├── bean │ │ │ └── WebMessageBean.java │ │ ├── common │ │ │ ├── MsgUtils.java │ │ │ └── Timeutils.java │ │ ├── controller │ │ │ ├── AbstractController.java │ │ │ ├── CommomController.java │ │ │ ├── ConfigManageController.java │ │ │ ├── GroupManageController.java │ │ │ ├── MonitorController.java │ │ │ ├── PluginManageController.java │ │ │ ├── UICManageController.java │ │ │ ├── UserManageController.java │ │ │ └── UserSquareController.java │ │ ├── exception │ │ │ ├── ManagerException.java │ │ │ └── UserPermissionException.java │ │ └── service │ │ │ ├── IConfigService.java │ │ │ ├── IGroupService.java │ │ │ ├── IMessageManageService.java │ │ │ ├── IMonitorService.java │ │ │ ├── IPluginService.java │ │ │ ├── IUICService.java │ │ │ ├── IUserService.java │ │ │ └── impl │ │ │ ├── ConfigManageService.java │ │ │ ├── GroupManageService.java │ │ │ ├── MessageManageService.java │ │ │ ├── MonitorService.java │ │ │ ├── PluginManageService.java │ │ │ ├── UICManageService.java │ │ │ └── UserManageService.java │ │ └── utils │ │ └── ArraysUtils.java │ └── resources │ ├── application.properties │ └── webapp │ ├── static │ └── Public │ │ ├── css │ │ └── style.css │ │ └── images │ │ ├── group.png │ │ ├── invite.png │ │ ├── monitor.png │ │ ├── plugin.png │ │ ├── setting.png │ │ └── user.png │ └── views │ ├── admin.html │ ├── basic │ └── config.html │ ├── error.html │ ├── group │ ├── addMember.html │ ├── index.html │ ├── manage.html │ ├── memberList.html │ └── profile.html │ ├── jump │ └── jump.html │ ├── monitor │ └── index.html │ ├── plugin │ ├── add.html │ ├── error.html │ ├── index.html │ ├── list.html │ └── update.html │ ├── siteMember │ ├── error.html │ └── siteMember.html │ ├── uic │ ├── index.html │ ├── unused_list.html │ └── used_list.html │ ├── user │ ├── error.html │ ├── index.html │ └── profile.html │ └── webMsg │ └── test.html ├── openzaly-boot ├── .gitignore ├── openzaly-server.config ├── pom.xml └── src │ ├── assembly-zip.xml │ ├── main │ ├── java │ │ └── com │ │ │ └── akaxin │ │ │ └── site │ │ │ └── boot │ │ │ ├── config │ │ │ ├── AkxProject.java │ │ │ ├── ConfigHelper.java │ │ │ ├── ConfigKey.java │ │ │ ├── ConfigListener.java │ │ │ └── SiteDefaultIcon.java │ │ │ ├── main │ │ │ └── Bootstrap.java │ │ │ ├── spring │ │ │ ├── CustomizationWebServerBean.java │ │ │ ├── OpenzalyConfiguration.java │ │ │ └── OpenzalySpringBoot.java │ │ │ └── utils │ │ │ ├── BootLog.java │ │ │ ├── Helper.java │ │ │ └── PropertiesUtils.java │ └── resources │ │ ├── application.properties │ │ ├── log4j.properties │ │ ├── logo.txt │ │ └── openzaly-server.config │ └── test │ └── java │ └── com │ └── akaxin │ └── site │ └── boot │ └── test │ ├── TestDefaultIcon.java │ ├── TestFile.java │ ├── TestHttpClient.java │ └── TestSystemPro.java ├── openzaly-business ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── akaxin │ │ └── site │ │ └── business │ │ ├── api │ │ └── IRequest.java │ │ ├── bean │ │ ├── MsgNoticeBean.java │ │ └── PlatformPhoneBean.java │ │ ├── cache │ │ └── WebSessionCache.java │ │ ├── constant │ │ ├── AkxProject.java │ │ ├── GroupConfig.java │ │ └── NoticeText.java │ │ ├── dao │ │ ├── ExpireTokenDao.java │ │ ├── MonitorDao.java │ │ ├── SiteConfigDao.java │ │ ├── SiteLoginDao.java │ │ ├── SitePluginDao.java │ │ ├── SiteUicDao.java │ │ ├── SiteUserDao.java │ │ ├── UserDeviceDao.java │ │ ├── UserFriendDao.java │ │ ├── UserGroupDao.java │ │ ├── UserProfileDao.java │ │ └── UserSessionDao.java │ │ ├── impl │ │ ├── AbstractRequest.java │ │ ├── IRequestService.java │ │ ├── hai │ │ │ ├── HttpFriendService.java │ │ │ ├── HttpGroupService.java │ │ │ ├── HttpMessageService.java │ │ │ ├── HttpPushService.java │ │ │ ├── HttpSessionService.java │ │ │ ├── HttpSiteService.java │ │ │ └── HttpUserService.java │ │ ├── notice │ │ │ ├── GroupNotice.java │ │ │ └── User2Notice.java │ │ ├── site │ │ │ ├── PlatformUserPhone.java │ │ │ ├── SiteConfig.java │ │ │ └── UserUic.java │ │ └── tai │ │ │ ├── ApiDeviceService.java │ │ │ ├── ApiFileService.java │ │ │ ├── ApiFriendService.java │ │ │ ├── ApiGroupService.java │ │ │ ├── ApiPluginService.java │ │ │ ├── ApiSecretChatService.java │ │ │ ├── ApiSiteService.java │ │ │ ├── ApiUserService.java │ │ │ └── ApiWebService.java │ │ ├── push │ │ ├── PushNotification.java │ │ └── PushText.java │ │ ├── service │ │ ├── ApiRequestService.java │ │ ├── ApiServiceFactory.java │ │ └── HttpRequestService.java │ │ └── utils │ │ ├── FilePathUtils.java │ │ ├── FileServerUtils.java │ │ ├── HexUtils.java │ │ └── StringRandomUtils.java │ └── test │ └── java │ └── com │ └── akaxin │ └── site │ └── business │ └── test │ └── TestHttpProto.java ├── openzaly-common ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── akaxin │ │ └── common │ │ ├── channel │ │ ├── ChannelManager.java │ │ ├── ChannelSession.java │ │ ├── ChannelWriter.java │ │ └── WebChannelManager.java │ │ ├── command │ │ ├── Command.java │ │ ├── CommandResponse.java │ │ └── RedisCommand.java │ │ ├── constant │ │ ├── CharsetCoding.java │ │ ├── CommandConst.java │ │ ├── ConfigConst.java │ │ ├── ErrorCode2.java │ │ ├── HttpUriAction.java │ │ ├── IErrorCode.java │ │ └── RequestAction.java │ │ ├── crypto │ │ ├── AESCrypto.java │ │ ├── HashCrypto.java │ │ └── RSACrypto.java │ │ ├── exceptions │ │ ├── ZalyException.java │ │ └── ZalyException2.java │ │ ├── executor │ │ ├── AbstracteExecutor.java │ │ ├── IExecutor.java │ │ ├── SimpleExecutor.java │ │ └── chain │ │ │ ├── AbstractHandlerChain.java │ │ │ ├── CustomRHandlerChain.java │ │ │ ├── SimpleHandlerChain.java │ │ │ └── handler │ │ │ ├── IHandler.java │ │ │ └── MethodReflectHandler.java │ │ ├── http │ │ └── ZalyHttpClient.java │ │ ├── logs │ │ ├── AkxLog4jManager.java │ │ ├── LogCreater.java │ │ └── LogUtils.java │ │ ├── netty │ │ ├── IRedisCommandResponse.java │ │ ├── NettyClient2.java │ │ ├── NettyClientHandler.java │ │ ├── PlatformClientHandler.java │ │ ├── PlatformSSLClient.java │ │ ├── RedisCommandResponse.java │ │ └── codec │ │ │ ├── MessageDecoder.java │ │ │ ├── MessageEncoder.java │ │ │ ├── ProtocolParser.java │ │ │ └── ReplaySignal.java │ │ ├── resp │ │ ├── AbstractParameter.java │ │ ├── RedisBytesParameter.java │ │ ├── RedisDoubleParameter.java │ │ ├── RedisIntegerParameter.java │ │ └── RedisStringParameter.java │ │ ├── ssl │ │ ├── ZalySSLContext.java │ │ └── ZalyTrustManagerFactory.java │ │ └── utils │ │ ├── GsonUtils.java │ │ ├── IpUtils.java │ │ ├── PrintUtils.java │ │ ├── ServerAddress.java │ │ ├── ServerAddressUtils.java │ │ ├── StringHelper.java │ │ ├── TimeFormats.java │ │ ├── URLRegexUtils.java │ │ ├── UserIdUtils.java │ │ └── ValidatorPattern.java │ └── test │ └── java │ └── com │ └── akaxin │ └── common │ └── test │ └── TestInetAddress.java ├── openzaly-connector ├── .gitignore ├── bin │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── zaly │ │ └── site │ │ └── connector │ │ └── client │ │ └── UserMessage.class ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── akaxin │ │ │ └── site │ │ │ └── connector │ │ │ ├── cache │ │ │ └── PluginCache.java │ │ │ ├── codec │ │ │ ├── parser │ │ │ │ ├── ChannelConst.java │ │ │ │ ├── IProtocolParser.java │ │ │ │ └── ProtocolParser.java │ │ │ └── protocol │ │ │ │ ├── MessageDecoder.java │ │ │ │ ├── MessageEncoder.java │ │ │ │ └── ReplaySignal.java │ │ │ ├── constant │ │ │ ├── AkxProject.java │ │ │ ├── HttpConst.java │ │ │ └── PluginConst.java │ │ │ ├── exception │ │ │ ├── HttpServerException.java │ │ │ └── TcpServerException.java │ │ │ ├── handler │ │ │ ├── AbstractCommonHandler.java │ │ │ ├── ApiRequestHandler.java │ │ │ ├── HttpRequestHandler.java │ │ │ ├── ImMessageHandler.java │ │ │ ├── ImSiteAuthHandler.java │ │ │ └── WSRequestHandler.java │ │ │ ├── http │ │ │ ├── HttpServer.java │ │ │ └── handler │ │ │ │ └── HttpServerHandler.java │ │ │ ├── netty │ │ │ ├── NettyServer.java │ │ │ ├── PrefixThreadFactory.java │ │ │ └── handler │ │ │ │ └── NettyServerHandler.java │ │ │ ├── session │ │ │ ├── PluginSession.java │ │ │ ├── SessionManager.java │ │ │ └── UserSession.java │ │ │ ├── ssl │ │ │ ├── NettySocketSslContext.java │ │ │ ├── SslKeyStore.java │ │ │ └── StreamReader.java │ │ │ ├── utils │ │ │ └── HexUtils.java │ │ │ └── ws │ │ │ ├── WsServer.java │ │ │ └── handler │ │ │ └── WsServerHandler.java │ └── resources │ │ └── chatchrome1.jks │ └── test │ └── java │ └── com │ └── zaly │ └── test │ ├── HttpClient.java │ ├── HttpTestPost.java │ └── WSTest.java ├── openzaly-message ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── akaxin │ │ └── site │ │ └── message │ │ ├── api │ │ └── IMessageService.java │ │ ├── bean │ │ └── WebBean.java │ │ ├── dao │ │ ├── ImUserFriendDao.java │ │ ├── ImUserGroupDao.java │ │ ├── ImUserProfileDao.java │ │ ├── ImUserSessionDao.java │ │ ├── SessionDeviceDao.java │ │ └── SiteConfigDao.java │ │ ├── executor │ │ └── MessageExecutor.java │ │ ├── group │ │ └── handler │ │ │ ├── AbstractGroupHandler.java │ │ │ ├── GroupDetectionHandler.java │ │ │ ├── GroupMessageImageHandler.java │ │ │ ├── GroupMessageImageSecretHandler.java │ │ │ ├── GroupMessageNoticeHandler.java │ │ │ ├── GroupMessageTextHandler.java │ │ │ ├── GroupMessageTextSecretHandler.java │ │ │ ├── GroupMessageVoiceHandler.java │ │ │ ├── GroupMessageVoiceSecretHandler.java │ │ │ ├── GroupMessageWebHandler.java │ │ │ ├── GroupMessageWebNoticeHandler.java │ │ │ ├── GroupPsnHandler.java │ │ │ └── GroupPushHandler.java │ │ ├── notice │ │ └── handler │ │ │ ├── AbstractNoticeHandler.java │ │ │ ├── NoticeHandler.java │ │ │ └── NoticePushHandler.java │ │ ├── platform │ │ └── PlatformClient.java │ │ ├── push │ │ └── PushClient.java │ │ ├── service │ │ ├── ImMessageService.java │ │ └── MessageDispatcher.java │ │ ├── sync │ │ └── handler │ │ │ ├── AbstractSyncHandler.java │ │ │ ├── SyncFinishHandler.java │ │ │ ├── SyncGroupMessageHandler.java │ │ │ ├── SyncMsgStatusHandler.java │ │ │ ├── SyncNoticeHandler.java │ │ │ └── SyncU2MessageHandler.java │ │ ├── threads │ │ └── MultiPushThreadExecutor.java │ │ ├── user2 │ │ └── handler │ │ │ ├── AbstractU2Handler.java │ │ │ ├── U2MessageImageHandler.java │ │ │ ├── U2MessageImageSecretHandler.java │ │ │ ├── U2MessageNoticeHandler.java │ │ │ ├── U2MessageTextHandler.java │ │ │ ├── U2MessageTextSecretHandler.java │ │ │ ├── U2MessageVoiceHandler.java │ │ │ ├── U2MessageVoiceSecretHandler.java │ │ │ ├── U2MessageWebHandler.java │ │ │ ├── U2MessageWebNoticeHandler.java │ │ │ ├── UserDetectionHandler.java │ │ │ ├── UserPsnHandler.java │ │ │ └── UserPushHandler.java │ │ ├── utils │ │ ├── HexUtils.java │ │ ├── NumUtils.java │ │ └── SiteConfigHelper.java │ │ └── web │ │ ├── bean │ │ ├── WebGroupTextBean.java │ │ ├── WebResponseBean.java │ │ └── WebU2TextBean.java │ │ └── chat │ │ ├── WebChatReceiveMessageHandler.java │ │ └── WebChatSendMessageHandler.java │ └── resources │ └── chatchrome1.jks ├── openzaly-protobuf ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── akaxin │ └── proto │ ├── client │ ├── ImMsgFinishProto.java │ ├── ImPtcPongProto.java │ ├── ImPtcPushProto.java │ ├── ImStcMessageProto.java │ ├── ImStcNoticeProto.java │ ├── ImStcPongProto.java │ └── ImStcPsnProto.java │ ├── core │ ├── ClientProto.java │ ├── ConfigProto.java │ ├── CoreProto.java │ ├── DeviceProto.java │ ├── FileProto.java │ ├── GroupProto.java │ ├── PhoneProto.java │ ├── PluginProto.java │ ├── PushProto.java │ ├── TokenProto.java │ ├── UicProto.java │ └── UserProto.java │ ├── platform │ ├── ApiPhoneConfirmTokenProto.java │ ├── ApiPushNotificationProto.java │ └── ApiPushNotificationsProto.java │ ├── plugin │ ├── HaiFriendAddProto.java │ ├── HaiFriendApplyProto.java │ ├── HaiFriendRelationsProto.java │ ├── HaiGroupAddMemberProto.java │ ├── HaiGroupCheckMemberProto.java │ ├── HaiGroupDeleteProto.java │ ├── HaiGroupListProto.java │ ├── HaiGroupMembersProto.java │ ├── HaiGroupNonmembersProto.java │ ├── HaiGroupProfileProto.java │ ├── HaiGroupRemoveMemberProto.java │ ├── HaiGroupUpdateProto.java │ ├── HaiMessageProxyProto.java │ ├── HaiPushNoticesProto.java │ ├── HaiSessionProfileProto.java │ ├── HaiSiteGetConfigProto.java │ ├── HaiUserAvatarProto.java │ ├── HaiUserFriendsProto.java │ ├── HaiUserGroupsProto.java │ ├── HaiUserListProto.java │ ├── HaiUserPhoneProto.java │ ├── HaiUserProfileProto.java │ └── HaiUserUpdateProto.java │ └── site │ ├── ApiDeviceBoundListProto.java │ ├── ApiDeviceListProto.java │ ├── ApiDeviceProfileProto.java │ ├── ApiFileDownloadProto.java │ ├── ApiFileUploadProto.java │ ├── ApiFriendApplyCountProto.java │ ├── ApiFriendApplyListProto.java │ ├── ApiFriendApplyProto.java │ ├── ApiFriendApplyResultProto.java │ ├── ApiFriendDeleteProto.java │ ├── ApiFriendListProto.java │ ├── ApiFriendMuteProto.java │ ├── ApiFriendProfileProto.java │ ├── ApiFriendRemarkProto.java │ ├── ApiFriendSettingProto.java │ ├── ApiFriendUpdateMuteProto.java │ ├── ApiFriendUpdateSettingProto.java │ ├── ApiGroupAddMemberProto.java │ ├── ApiGroupApplyTokenProto.java │ ├── ApiGroupCreateProto.java │ ├── ApiGroupDeleteProto.java │ ├── ApiGroupJoinByTokenProto.java │ ├── ApiGroupListProto.java │ ├── ApiGroupMembersProto.java │ ├── ApiGroupMuteProto.java │ ├── ApiGroupNonMembersProto.java │ ├── ApiGroupProfileProto.java │ ├── ApiGroupQuitProto.java │ ├── ApiGroupRemoveMemberProto.java │ ├── ApiGroupSettingProto.java │ ├── ApiGroupUpdateMuteProto.java │ ├── ApiGroupUpdateProfileProto.java │ ├── ApiGroupUpdateSettingProto.java │ ├── ApiPlatformRegisterByPhoneProto.java │ ├── ApiPluginDeleteProto.java │ ├── ApiPluginListProto.java │ ├── ApiPluginPageProto.java │ ├── ApiPluginProxyProto.java │ ├── ApiSecretChatApplyU2Proto.java │ ├── ApiSiteConfigProto.java │ ├── ApiSiteLoginProto.java │ ├── ApiSiteLogoutProto.java │ ├── ApiSiteRegisterProto.java │ ├── ApiUserMuteProto.java │ ├── ApiUserProfileProto.java │ ├── ApiUserSearchProto.java │ ├── ApiUserUpdateMuteProto.java │ ├── ApiUserUpdateProfileProto.java │ ├── ApiWebAuthProto.java │ ├── ImCtpPingProto.java │ ├── ImCtsMessageProto.java │ ├── ImCtsPingProto.java │ ├── ImSiteAuthProto.java │ ├── ImSiteHelloProto.java │ ├── ImSyncFinishProto.java │ ├── ImSyncMessageProto.java │ └── ImSyncMsgStatusProto.java ├── openzaly-storage ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── akaxin │ │ └── site │ │ └── storage │ │ ├── DataSourceManager.java │ │ ├── api │ │ ├── IFriendApplyDao.java │ │ ├── IGroupDao.java │ │ ├── IGroupProfileDao.java │ │ ├── IMessageDao.java │ │ ├── IPluginDao.java │ │ ├── ISiteConfigDao.java │ │ ├── ISiteUsersDao.java │ │ ├── ITokenDao.java │ │ ├── IUicDao.java │ │ ├── IUserDeviceDao.java │ │ ├── IUserFriendDao.java │ │ ├── IUserGroupDao.java │ │ ├── IUserProfileDao.java │ │ └── IUserSessionDao.java │ │ ├── bean │ │ ├── ApplyFriendBean.java │ │ ├── ApplyUserBean.java │ │ ├── ExpireToken.java │ │ ├── GroupMemberBean.java │ │ ├── GroupMessageBean.java │ │ ├── GroupProfileBean.java │ │ ├── MonitorBean.java │ │ ├── PluginBean.java │ │ ├── SimpleAuthBean.java │ │ ├── SimpleGroupBean.java │ │ ├── SimpleUserBean.java │ │ ├── SimpleUserRelationBean.java │ │ ├── SiteConfigBean.java │ │ ├── U2MessageBean.java │ │ ├── UicBean.java │ │ ├── UserDeviceBean.java │ │ ├── UserFriendBean.java │ │ ├── UserGroupBean.java │ │ ├── UserProfileBean.java │ │ └── UserSessionBean.java │ │ ├── connection │ │ └── DatabaseConnection.java │ │ ├── dao │ │ ├── SiteConfigDao.java │ │ ├── SiteFriendApplyDao.java │ │ ├── SiteGroupMessageDao.java │ │ ├── SiteGroupProfileDao.java │ │ ├── SitePluginDao.java │ │ ├── SiteTokenDao.java │ │ ├── SiteU2MessageDao.java │ │ ├── SiteUICDao.java │ │ ├── SiteUserDeviceDao.java │ │ ├── SiteUserFriendDao.java │ │ ├── SiteUserGroupDao.java │ │ ├── SiteUserProfileDao.java │ │ ├── SiteUserSessionDao.java │ │ ├── SiteUsersDao.java │ │ ├── config │ │ │ ├── DBConfig.java │ │ │ ├── DBType.java │ │ │ ├── JdbcConst.java │ │ │ └── PrepareSiteConfigData.java │ │ ├── mysql │ │ │ └── manager │ │ │ │ ├── AbstractPoolManager.java │ │ │ │ ├── C3P0PoolManager.java │ │ │ │ ├── C3P0PoolSlaveManager.java │ │ │ │ ├── InitDatabaseConnection.java │ │ │ │ └── MysqlManager.java │ │ ├── sql │ │ │ └── SQLConst.java │ │ └── sqlite │ │ │ └── manager │ │ │ ├── PluginArgs.java │ │ │ ├── SQLiteJDBCManager.java │ │ │ ├── SQLiteUnique.java │ │ │ └── SQLiteUpgrade.java │ │ ├── exception │ │ ├── InitDatabaseException.java │ │ ├── MigrateDatabaseException.java │ │ ├── NeedInitMysqlException.java │ │ └── UpgradeDatabaseException.java │ │ ├── service │ │ ├── DeviceDaoService.java │ │ ├── FriendApplyDaoService.java │ │ ├── GroupDaoService.java │ │ ├── MessageDaoService.java │ │ ├── PluginServiceDao.java │ │ ├── SiteConfigDaoService.java │ │ ├── SiteUsersDaoService.java │ │ ├── TokenDaoService.java │ │ ├── UicDaoService.java │ │ ├── UserFriendDaoService.java │ │ ├── UserGroupDaoService.java │ │ ├── UserProfileDaoService.java │ │ └── UserSessionDaoService.java │ │ └── util │ │ ├── FileUtils.java │ │ ├── MigrateUtils.java │ │ ├── SqlLog.java │ │ └── SqlUtils.java │ └── resources │ ├── log4j.properties │ ├── openzaly-mysql.sql │ └── openzaly-sqlite.sql ├── pom.xml ├── restart.sh ├── start.sh └── stop.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *.classpath 2 | *.project 3 | *.settings/ 4 | .idea/ 5 | *.swp 6 | *.iml 7 | target/ 8 | .DS_Store 9 | openzalyDB.sqlite3 10 | stdout.log 11 | openzaly-server.jar 12 | site-file/ 13 | site-logs/ 14 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # ---------------------------------------------------------------------------- 4 | # Copyright 2018-2028 Akaxin Group 5 | # 6 | # Licensed to the Apache Software Foundation (ASF) under one 7 | # or more contributor license agreements. See the NOTICE file 8 | # distributed with this work for additional information 9 | # regarding copyright ownership. The ASF licenses this file 10 | # to you under the Apache License, Version 2.0 (the 11 | # "License"); you may not use this file except in compliance 12 | # with the License. You may obtain a copy of the License at 13 | # 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | # 16 | # Unless required by applicable law or agreed to in writing, 17 | # software distributed under the License is distributed on an 18 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19 | # KIND, either express or implied. See the License for the 20 | # specific language governing permissions and limitations 21 | # under the License. 22 | # ---------------------------------------------------------------------------- 23 | 24 | 25 | cd `dirname $0` 26 | mvn -T 2C clean package 27 | cp openzaly-boot/target/openzaly-boot-*-SNAPSHOT.jar openzaly-server.jar 28 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/OpenzalyAdminApplication.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.web; 17 | 18 | import org.springframework.boot.Banner; 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | 22 | /** 23 | * springboot的支持,放在openzaly-boot中 24 | * 25 | * @author Sam{@link an.guoyue254@gmail.com} 26 | * @since 2018-06-05 19:31:16 27 | */ 28 | @Deprecated 29 | @SpringBootApplication 30 | public class OpenzalyAdminApplication { 31 | 32 | public static void main(String[] args) { 33 | SpringApplication application = new SpringApplication(OpenzalyAdminApplication.class); 34 | application.setBannerMode(Banner.Mode.OFF); 35 | application.run(args); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/bean/WebMessageBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.admin.bean; 2 | 3 | import com.akaxin.common.utils.GsonUtils; 4 | 5 | public class WebMessageBean { 6 | private String siteUserId; 7 | private String siteFriendId; 8 | private String siteGroupId; 9 | private String msgId; 10 | private String webCode; 11 | private int width; 12 | private int height; 13 | private String hrefUrl; 14 | private long msgTime; 15 | 16 | public String getSiteUserId() { 17 | return siteUserId; 18 | } 19 | 20 | public void setSiteUserId(String siteUserId) { 21 | this.siteUserId = siteUserId; 22 | } 23 | 24 | public String getSiteFriendId() { 25 | return siteFriendId; 26 | } 27 | 28 | public void setSiteFriendId(String siteFriendId) { 29 | this.siteFriendId = siteFriendId; 30 | } 31 | 32 | public String getWebCode() { 33 | return webCode; 34 | } 35 | 36 | public void setWebCode(String webCode) { 37 | this.webCode = webCode; 38 | } 39 | 40 | public int getWidth() { 41 | return width; 42 | } 43 | 44 | public void setWidth(int width) { 45 | this.width = width; 46 | } 47 | 48 | public int getHeight() { 49 | return height; 50 | } 51 | 52 | public void setHeight(int height) { 53 | this.height = height; 54 | } 55 | 56 | public String getMsgId() { 57 | return msgId; 58 | } 59 | 60 | public void setMsgId(String msgId) { 61 | this.msgId = msgId; 62 | } 63 | 64 | public long getMsgTime() { 65 | return msgTime; 66 | } 67 | 68 | public void setMsgTime(long msgTime) { 69 | this.msgTime = msgTime; 70 | } 71 | 72 | public String getSiteGroupId() { 73 | return siteGroupId; 74 | } 75 | 76 | public void setSiteGroupId(String siteGroupId) { 77 | this.siteGroupId = siteGroupId; 78 | } 79 | 80 | public String getHrefUrl() { 81 | return hrefUrl; 82 | } 83 | 84 | public void setHrefUrl(String hrefUrl) { 85 | this.hrefUrl = hrefUrl; 86 | } 87 | 88 | public String toString() { 89 | return GsonUtils.toJson(this); 90 | } 91 | 92 | } -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/common/MsgUtils.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.admin.common; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | /** 6 | * 消息工具类 7 | * 8 | * @author Sam{@link an.guoyue254@gmail.com} 9 | * @since 2018-04-25 11:49:21 10 | */ 11 | public class MsgUtils { 12 | public static String buildU2MsgId(String siteUserid) { 13 | StringBuilder sb = new StringBuilder("U2-"); 14 | if (StringUtils.isNotEmpty(siteUserid)) { 15 | int len = siteUserid.length(); 16 | sb.append(siteUserid.substring(0, len >= 8 ? 8 : len)); 17 | sb.append("-"); 18 | } 19 | sb.append(System.currentTimeMillis()); 20 | return sb.toString(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/common/Timeutils.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.admin.common; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.concurrent.TimeUnit; 6 | 7 | public class Timeutils { 8 | //返回前num天的日期 9 | public static String getDate(Integer num) { 10 | if (num != null && num >= 1) { 11 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); 12 | return simpleDateFormat.format(new Date(System.currentTimeMillis()-TimeUnit.DAYS.toMillis(num))); 13 | } 14 | return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/controller/AbstractController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.web.admin.controller; 17 | 18 | import java.util.Map; 19 | 20 | import com.akaxin.common.utils.GsonUtils; 21 | import com.akaxin.proto.core.PluginProto; 22 | import com.akaxin.site.business.impl.site.SiteConfig; 23 | 24 | public class AbstractController { 25 | 26 | protected final int PAGE_SIZE = 20; 27 | 28 | protected final String SUCCESS = "success"; 29 | 30 | protected final String ERROR = "error"; 31 | 32 | protected final String NO_PERMISSION = "no-permission"; 33 | 34 | public boolean isManager(String siteUserId) { 35 | return SiteConfig.isSiteManager(siteUserId); 36 | } 37 | 38 | public boolean isAdmin(String siteUserId) { 39 | return SiteConfig.isSiteSuperAdmin(siteUserId); 40 | } 41 | 42 | public String getRequestSiteUserId(PluginProto.ProxyPluginPackage pluginPackage) { 43 | Map headerMap = pluginPackage.getPluginHeaderMap(); 44 | return headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE); 45 | } 46 | 47 | @SuppressWarnings("unchecked") 48 | public Map getRequestDataMap(PluginProto.ProxyPluginPackage pluginPackage) { 49 | return GsonUtils.fromJson(pluginPackage.getData(), Map.class); 50 | } 51 | 52 | public String trim(String parameter) { 53 | if (parameter == null) { 54 | return parameter; 55 | } 56 | String trim = parameter.replaceAll("[  ]", ""); 57 | return trim; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/controller/CommomController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.web.admin.controller; 17 | 18 | import org.springframework.stereotype.Controller; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | 21 | @Controller 22 | @RequestMapping("common") 23 | public class CommomController { 24 | 25 | @RequestMapping("success") 26 | public String toSuccessPage() { 27 | return "success"; 28 | } 29 | 30 | @RequestMapping("nopermission") 31 | public String toNoPermissionPage() { 32 | return "success"; 33 | } 34 | 35 | @RequestMapping("error") 36 | public String toErrorPage() { 37 | return "error"; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/exception/ManagerException.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.admin.exception; 2 | 3 | import com.akaxin.common.utils.StringHelper; 4 | 5 | public class ManagerException extends Throwable { 6 | /** 7 | * 8 | */ 9 | private static final long serialVersionUID = -5303021403604515796L; 10 | 11 | public ManagerException(String message) { 12 | super(message); 13 | } 14 | 15 | public ManagerException(String messageParttern, Object... obs) { 16 | this(StringHelper.format(messageParttern, obs)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/exception/UserPermissionException.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.admin.exception; 2 | 3 | public class UserPermissionException extends Exception { 4 | /** 5 | * 6 | */ 7 | private static final long serialVersionUID = -5303021403604515796L; 8 | 9 | public UserPermissionException(String message) { 10 | super(message); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/service/IConfigService.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.admin.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | public interface IConfigService { 7 | 8 | Map getSiteConfig(); 9 | 10 | boolean updateSiteConfig(String siteUserId, Map config); 11 | 12 | boolean addUserManager(String siteUserId); 13 | 14 | boolean deleteUserManager(String siteUserId); 15 | 16 | boolean setUserDefaultFriends(String siteUserId); 17 | 18 | boolean deleteUserDefaultFriends(String siteUserId); 19 | 20 | boolean setUserDefaultGroups(String siteGroupId); 21 | 22 | boolean deleteUserDefaultGroup(String siteGroupId); 23 | 24 | List getUserDefaultFriendList(); 25 | 26 | List getUserDefaultGroupList(); 27 | } 28 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/service/IGroupService.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.admin.service; 2 | 3 | import java.util.List; 4 | 5 | import com.akaxin.site.storage.bean.GroupMemberBean; 6 | import com.akaxin.site.storage.bean.GroupProfileBean; 7 | import com.akaxin.site.storage.bean.SimpleGroupBean; 8 | 9 | /** 10 | * 11 | * @author Sam{@link an.guoyue254@gmail.com} 12 | * @since 2018-04-17 18:46:55 13 | */ 14 | public interface IGroupService { 15 | 16 | GroupProfileBean getGroupProfile(String siteGroupId); 17 | 18 | boolean updateGroupProfile(GroupProfileBean bean); 19 | 20 | List getGroupList(int pageNum, int pageSize); 21 | 22 | List getGroupMembers(String siteGroupId, int pageNum, int pageSize); 23 | 24 | List getNonGroupMembers(String siteGroupId, int pageNum, int pageSize); 25 | 26 | boolean addGroupMembers(String siteGroupId, List newMemberList); 27 | 28 | boolean removeGroupMembers(String siteGroupId, List groupMemberList); 29 | 30 | boolean dismissGroup(String siteGroupId); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/service/IMessageManageService.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.admin.service; 2 | 3 | import com.akaxin.site.web.admin.bean.WebMessageBean; 4 | 5 | /** 6 | * 后台管理发送消息接口 7 | * 8 | * @author Sam{@link an.guoyue254@gmail.com} 9 | * @since 2018-04-25 11:11:10 10 | */ 11 | public interface IMessageManageService { 12 | 13 | boolean sendU2WebMessage(WebMessageBean bean); 14 | 15 | boolean sendU2WebNoticeMessage(WebMessageBean bean); 16 | 17 | boolean sendGroupWebMessage(WebMessageBean bean); 18 | 19 | boolean sendGroupWebNoticeMessage(WebMessageBean bean); 20 | } 21 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/service/IMonitorService.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.admin.service; 2 | 3 | public interface IMonitorService { 4 | int queryNumRegisterPerDay(long now, int day); 5 | 6 | int queryNumMessagePerDay(long now, int day); 7 | 8 | int queryGroupMessagePerDay(long now, int day); 9 | 10 | int queryU2MessagePerDay(long now, int day); 11 | 12 | int getSiteUserNum(long now,int day); 13 | 14 | int getGroupNum(long now,int day); 15 | 16 | int friendNum(long now,int day); 17 | } 18 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/service/IPluginService.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.admin.service; 2 | 3 | import java.util.List; 4 | 5 | import com.akaxin.site.storage.bean.PluginBean; 6 | 7 | public interface IPluginService { 8 | boolean addNewPlugin(PluginBean bean); 9 | 10 | boolean deletePlugin(int pluginId); 11 | 12 | boolean updatePlugin(PluginBean bean); 13 | 14 | PluginBean getPlugin(int pluginId); 15 | 16 | List getPluginList(int pageNum, int pageSize); 17 | 18 | String reSetAuthKey(int pluginId); 19 | } 20 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/service/IUICService.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.admin.service; 2 | 3 | import java.util.List; 4 | 5 | import com.akaxin.site.storage.bean.UicBean; 6 | 7 | public interface IUICService { 8 | 9 | boolean addUIC(int num, int length); 10 | 11 | List getUsedUicList(int pageNum, int pageSize, int status); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/service/IUserService.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.admin.service; 2 | 3 | import java.util.List; 4 | 5 | import com.akaxin.site.storage.bean.SimpleUserBean; 6 | import com.akaxin.site.storage.bean.UserProfileBean; 7 | 8 | public interface IUserService { 9 | // 获取用户profile 10 | UserProfileBean getUserProfile(String siteUserId); 11 | 12 | // 更新用户profile 13 | boolean updateProfile(UserProfileBean userProfileBean); 14 | 15 | // 获取用户列表 16 | List getUserList(int pageNum, int pageSize); 17 | 18 | // 封禁用户 19 | boolean sealUpUser(String siteUserId, int status); 20 | // 删除用户 21 | boolean delUser(String siteUserId); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/service/impl/MonitorService.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.admin.service.impl; 2 | 3 | import com.akaxin.site.business.dao.MonitorDao; 4 | import com.akaxin.site.web.admin.service.IMonitorService; 5 | 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class MonitorService implements IMonitorService { 10 | 11 | private MonitorDao monitorDao = MonitorDao.getInstance(); 12 | 13 | @Override 14 | public int queryNumRegisterPerDay(long now, int day) { 15 | return monitorDao.queryNumRegisterPerDay(now, day); 16 | } 17 | 18 | @Override 19 | public int queryNumMessagePerDay(long now, int day) { 20 | return monitorDao.queryNumMessagePerDay(now, day); 21 | } 22 | 23 | @Override 24 | public int queryGroupMessagePerDay(long now, int day) { 25 | return monitorDao.queryGroupMessagePerDay(now, day); 26 | } 27 | 28 | @Override 29 | public int queryU2MessagePerDay(long now, int day) { 30 | return monitorDao.queryU2MessagePerDay(now, day); 31 | } 32 | 33 | @Override 34 | public int getSiteUserNum(long now, int day) { 35 | return monitorDao.getSiteUserNum(now, day); 36 | } 37 | 38 | @Override 39 | public int getGroupNum(long now, int day) { 40 | return monitorDao.getGroupNum(now, day); 41 | } 42 | 43 | @Override 44 | public int friendNum(long now, int day) { 45 | return monitorDao.friendNum(now, day); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/admin/service/impl/UICManageService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.web.admin.service.impl; 17 | 18 | import java.util.List; 19 | 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | import org.springframework.stereotype.Service; 23 | 24 | import com.akaxin.proto.core.UicProto.UicStatus; 25 | import com.akaxin.site.business.dao.SiteUicDao; 26 | import com.akaxin.site.storage.bean.UicBean; 27 | import com.akaxin.site.web.admin.service.IUICService; 28 | 29 | @Service 30 | public class UICManageService implements IUICService { 31 | private static final Logger logger = LoggerFactory.getLogger(UICManageService.class); 32 | 33 | @Override 34 | public boolean addUIC(int num, int length) { 35 | try { 36 | UicBean bean = new UicBean(); 37 | bean.setStatus(UicStatus.UNUSED_VALUE); 38 | bean.setCreateTime(System.currentTimeMillis()); 39 | if (SiteUicDao.getInstance().batchAddUic(bean, num, length)) { 40 | return true; 41 | } 42 | } catch (Exception e) { 43 | logger.error("add uic error", e); 44 | } 45 | return false; 46 | } 47 | 48 | @Override 49 | public List getUsedUicList(int pageNum, int pageSize, int status) { 50 | List uicList = SiteUicDao.getInstance().getUicList(pageNum, pageSize, status); 51 | return uicList; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/java/com/akaxin/site/web/utils/ArraysUtils.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.web.utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class ArraysUtils { 7 | 8 | public static List asList(String[] objs) { 9 | if (objs == null) 10 | return null; 11 | List list = new ArrayList(); 12 | for (String obj : objs) { 13 | list.add(obj); 14 | } 15 | return list; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #配置管理平台启动端口 2 | #server.port=80 3 | #设置输出日志 4 | #logging.file=admin.log 5 | #设置日志的输出级别 6 | #logging.level.root=info 7 | #配置mvc前缀,界面位置 8 | #spring.thymeleaf.prefix=classpath:/webapp/views/ 9 | #静态资源 10 | #spring.resources.static-locations=classpath:/webapp/static/ -------------------------------------------------------------------------------- /openzaly-admin/src/main/resources/webapp/static/Public/css/style.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | height: 100%; 3 | background-color: #f4f4f4; 4 | -webkit-tap-highlight-color: transparent; 5 | } 6 | 7 | .basic-title { 8 | text-align: center; 9 | font-weight: 400; 10 | color: #1E88E5; 11 | margin: 0 15%; 12 | } 13 | 14 | .basic-sub-title { 15 | text-align: center; 16 | color: #1E88E5; 17 | } 18 | 19 | .basic-header { 20 | padding: 35px 0; 21 | }css 22 | 23 | .basic-content-padded { 24 | padding: 15px; 25 | } 26 | .margin_top_30px { 27 | margin-top: 30px; 28 | } 29 | 30 | .basic-second-title { 31 | text-align: center; 32 | color: #1E88E5; 33 | font-weight: 400; 34 | margin: 0 15%; 35 | } 36 | .basic-weui-grid { 37 | position: relative; 38 | float: left; 39 | padding: 5px; 40 | width: 60px; 41 | height: 60px; 42 | } 43 | .basic-color { 44 | background-color: #1E88E5; 45 | color: #FFFFFF; 46 | } 47 | .basic-weui-btn_primary { 48 | background-color: #1E88E5; 49 | } 50 | 51 | .basic-weui-btn { 52 | background-color: #1E88E5; 53 | color: #FFFFFF; 54 | } 55 | .basic-weui-btn:hover { 56 | background-color: #1E88E5; 57 | color: #FFFFFF; 58 | } 59 | 60 | .basic-weui-btn:active { 61 | background-color: #1E88E5!important; 62 | color: #FFFFFF; 63 | } 64 | 65 | .basic-weui-btn_mini { 66 | display: inline-block; 67 | padding: 0 1.32em; 68 | line-height: 2.3; 69 | } 70 | 71 | .weui-dialog__btn { 72 | color: #1E88E5; 73 | } 74 | 75 | footer { 76 | text-align: center; 77 | font-size: 14px; 78 | padding: 20px; 79 | } 80 | 81 | .basic-color_bg { 82 | background-color: #f4f4f4; 83 | } 84 | .weui-loadmore_line .weui-loadmore__tips { 85 | background-color: #f4f4f4; 86 | } 87 | 88 | footer a { 89 | color: #999; 90 | text-decoration: none; 91 | } 92 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/resources/webapp/static/Public/images/group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sengeiou/openzaly/6f53ac993f2e1e5f85d76a529f1f1e29aa947fa5/openzaly-admin/src/main/resources/webapp/static/Public/images/group.png -------------------------------------------------------------------------------- /openzaly-admin/src/main/resources/webapp/static/Public/images/invite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sengeiou/openzaly/6f53ac993f2e1e5f85d76a529f1f1e29aa947fa5/openzaly-admin/src/main/resources/webapp/static/Public/images/invite.png -------------------------------------------------------------------------------- /openzaly-admin/src/main/resources/webapp/static/Public/images/monitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sengeiou/openzaly/6f53ac993f2e1e5f85d76a529f1f1e29aa947fa5/openzaly-admin/src/main/resources/webapp/static/Public/images/monitor.png -------------------------------------------------------------------------------- /openzaly-admin/src/main/resources/webapp/static/Public/images/plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sengeiou/openzaly/6f53ac993f2e1e5f85d76a529f1f1e29aa947fa5/openzaly-admin/src/main/resources/webapp/static/Public/images/plugin.png -------------------------------------------------------------------------------- /openzaly-admin/src/main/resources/webapp/static/Public/images/setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sengeiou/openzaly/6f53ac993f2e1e5f85d76a529f1f1e29aa947fa5/openzaly-admin/src/main/resources/webapp/static/Public/images/setting.png -------------------------------------------------------------------------------- /openzaly-admin/src/main/resources/webapp/static/Public/images/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sengeiou/openzaly/6f53ac993f2e1e5f85d76a529f1f1e29aa947fa5/openzaly-admin/src/main/resources/webapp/static/Public/images/user.png -------------------------------------------------------------------------------- /openzaly-admin/src/main/resources/webapp/views/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 用户管理后台 8 | 9 | 10 | 11 | 50 | 51 | 52 | 53 |
54 |

站点管理后台

55 |
56 |
57 |
58 | 59 |
60 |

无操作权限

61 |

您不是当前站点的管理员,不能进行该操作!

62 |
63 |
64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/resources/webapp/views/plugin/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 扩展管理-错误提示 8 | 9 | 10 | 11 | 47 | 48 | 49 | 50 |
51 |

编辑扩展信息

52 |
53 |
54 |
55 | 56 |
57 |

扩展不存在

58 |

当前扩展已经被删除!

59 |
60 |
61 |
62 | 63 | 64 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/resources/webapp/views/siteMember/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 用户广场 8 | 9 | 10 | 11 | 12 | 13 | 53 | 54 | 55 | 56 |
57 |

用户广场

58 |
59 |
60 |
61 | 62 |
63 |

请求失败

64 |

请联系站点管理人员

65 |
66 |
67 |
68 | 69 | 70 | -------------------------------------------------------------------------------- /openzaly-admin/src/main/resources/webapp/views/user/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 编辑用户信息-报错页面 8 | 9 | 10 | 11 | 12 | 51 | 52 | 53 | 54 |
55 |

编辑用户信息

56 |
57 |
58 |
59 | 60 |
61 |

用户不存在

62 |

当前用户已经删除站点身份,或者当前用户已经处于封禁状态!

63 |
64 |
65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /openzaly-boot/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.classpath 3 | /.DS_Store 4 | /.project 5 | /openzalyDB.sqlite3 6 | /site-logs 7 | /site-file -------------------------------------------------------------------------------- /openzaly-boot/src/assembly-zip.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | make-assembly 6 | 7 | tar.gz 8 | 9 | false 10 | 11 | 12 | src/main/resources/ 13 | . 14 | 15 | 16 | ../lib/ 17 | /lib/ 18 | 19 | 20 | 21 | 22 | /lib/ 23 | runtime 24 | 25 | 26 | -------------------------------------------------------------------------------- /openzaly-boot/src/main/java/com/akaxin/site/boot/config/AkxProject.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.boot.config; 2 | 3 | /** 4 | * 5 | * @author Sam{@link an.guoyue254@gmail.com} 6 | * @since 2018-03-26 19:07:30 7 | */ 8 | public interface AkxProject { 9 | String PROJECT_NAME = "openzaly-boot"; 10 | 11 | String PROJECT_LOG_NAME = "openzaly-boot"; 12 | 13 | String PLN = "[openzaly-boot]"; 14 | } 15 | -------------------------------------------------------------------------------- /openzaly-boot/src/main/java/com/akaxin/site/boot/config/ConfigKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.boot.config; 17 | 18 | /** 19 | * 站点服务,相关配置字段 20 | * 21 | * @author Sam{@link an.guoyue254@gmail.com} 22 | * @since 2018-01-24 19:49:19 23 | */ 24 | public interface ConfigKey { 25 | // 站点版本 26 | public String SITE_VERSION = "openzaly.version"; 27 | // 站点服务地址,提供用户和站点之间连接使用 28 | public String SITE_ADDRESS = "site.address"; 29 | // 站点服务监听端口 30 | public String SITE_PORT = "site.port"; 31 | // 站点启动的http服务地址,内部扩展功能访问使用 32 | public String PLUGIN_API_ADDRESS = "pluginapi.address"; 33 | // http服务监听端口 34 | public String PLUGIN_API_PORT = "pluginapi.port"; 35 | // 站点管理扩展地址&&端口 36 | public String SITE_ADMIN_ADDRESS = "site.admin.address"; 37 | public String SITE_ADMIN_PORT = "site.admin.port"; 38 | // 站点管理员 39 | public String SITE_ADMINISTRATORS = "site.administrators"; 40 | // 站点管理员首次登陆站点,设置的邀请码 41 | public String SITE_ADMIN_UIC = "site.uic"; 42 | // 存放站点图片,音频相关文件路径 43 | public String SITE_BASE_DIR = "site.baseDir"; 44 | // 最大成员人数 45 | public String GROUP_MEMBERS_COUNT = "group.members.count"; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /openzaly-boot/src/main/java/com/akaxin/site/boot/config/ConfigListener.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.boot.config; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.Executors; 5 | import java.util.concurrent.TimeUnit; 6 | 7 | import org.apache.log4j.Logger; 8 | 9 | import com.akaxin.common.logs.LogCreater; 10 | import com.akaxin.common.logs.LogUtils; 11 | import com.akaxin.proto.core.ConfigProto; 12 | import com.akaxin.site.business.impl.site.SiteConfig; 13 | import com.akaxin.site.message.utils.SiteConfigHelper; 14 | 15 | /** 16 | * 站点配置监听器,定时更新缓存中数据 17 | * 18 | * @author Sam{@link an.guoyue254@gmail.com} 19 | * @since 2018-02-01 14:52:50 20 | */ 21 | public class ConfigListener { 22 | private static String logPath; 23 | private static Logger logger; 24 | 25 | static { 26 | Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(new Runnable() { 27 | 28 | @Override 29 | public void run() { 30 | doListenning(); 31 | } 32 | 33 | }, 20, 20, TimeUnit.SECONDS); 34 | } 35 | 36 | public static void startListenning() { 37 | LogUtils.info(getLogger(), "start config listenning"); 38 | } 39 | 40 | public static void doListenning() { 41 | Map imConfigMap = SiteConfigHelper.updateConfig(); 42 | LogUtils.info(getLogger(), "update im site config={}", imConfigMap); 43 | Map apiConfigMap = SiteConfig.updateConfig(); 44 | LogUtils.info(getLogger(), "update api site config={}", apiConfigMap); 45 | } 46 | 47 | private static Logger getLogger() { 48 | String currentPath = SiteConfigHelper.getConfig(ConfigProto.ConfigKey.DB_PATH); 49 | if (logger == null || !currentPath.equals(logPath)) { 50 | logPath = currentPath; 51 | logger = LogCreater.createTimeLogger("config", currentPath + "/site-logs"); 52 | } 53 | 54 | return logger; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /openzaly-boot/src/main/java/com/akaxin/site/boot/spring/CustomizationWebServerBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.boot.spring; 2 | 3 | import java.net.InetAddress; 4 | import java.net.UnknownHostException; 5 | 6 | import org.apache.commons.lang3.StringUtils; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.boot.web.server.WebServerFactoryCustomizer; 10 | import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; 11 | import org.springframework.stereotype.Component; 12 | 13 | import com.akaxin.site.boot.config.ConfigHelper; 14 | import com.akaxin.site.boot.config.ConfigKey; 15 | 16 | @Component 17 | public class CustomizationWebServerBean implements WebServerFactoryCustomizer { 18 | private static Logger logger = LoggerFactory.getLogger(CustomizationWebServerBean.class); 19 | 20 | @Override 21 | public void customize(ConfigurableServletWebServerFactory server) { 22 | String adminAddress = ConfigHelper.getStringConfig(ConfigKey.SITE_ADMIN_ADDRESS); 23 | String adminPort = ConfigHelper.getStringConfig(ConfigKey.SITE_ADMIN_PORT); 24 | 25 | // set admin port 26 | if (StringUtils.isNumeric(adminPort)) { 27 | server.setPort(Integer.valueOf(adminPort)); 28 | } else { 29 | server.setPort(8288); 30 | } 31 | 32 | // set admin address 33 | if (StringUtils.isNotEmpty(adminAddress)) { 34 | try { 35 | InetAddress address = InetAddress.getByName(adminAddress); 36 | server.setAddress(address); 37 | } catch (UnknownHostException e) { 38 | } 39 | } 40 | server.setContextPath("/akaxin"); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /openzaly-boot/src/main/java/com/akaxin/site/boot/spring/OpenzalyConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.boot.spring; 2 | 3 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 4 | import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; 5 | import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | @Configuration 10 | @EnableAutoConfiguration 11 | public class OpenzalyConfiguration { 12 | 13 | // @Bean 14 | // public ConfigurableServletWebServerFactory webServerFactory() { 15 | // TomcatServletWebServerFactory webserver = new TomcatServletWebServerFactory(); 16 | //// webserver.setPort(80822); 17 | //// webserver.setContextPath("/akaxin"); 18 | // return webserver; 19 | // } 20 | } 21 | -------------------------------------------------------------------------------- /openzaly-boot/src/main/java/com/akaxin/site/boot/spring/OpenzalySpringBoot.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.boot.spring; 17 | 18 | import org.springframework.boot.Banner; 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | 22 | /** 23 | *
24 |  * 	openzaly支持springboot框架,在启动main中会同样启动springboot
25 |  * 
26 |  * 	在maven modules中,springboot会存在启动main中扫描不到其他modules中的package,两种方法解决:
27 |  * 		其一:@SpringBootApplication(scanBasePackages={"com.akaxin.site.*"})
28 |  * 		其二:SpringApplication.run(Class...clazzs ,args),clazzs 把需要加载的主类添加上
29 |  * 
30 | * 31 | * @author Sam{@link an.guoyue254@gmail.com} 32 | * @since 2018-06-05 19:25:55 33 | */ 34 | @SpringBootApplication(scanBasePackages = { "com.akaxin.site.*" }) 35 | public class OpenzalySpringBoot { 36 | 37 | public static void main(String[] args) { 38 | 39 | SpringApplication application = new SpringApplication(OpenzalySpringBoot.class); 40 | application.setBannerMode(Banner.Mode.OFF); 41 | // application.setDefaultProperties(properties); 42 | application.run(args); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /openzaly-boot/src/main/java/com/akaxin/site/boot/utils/BootLog.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.boot.utils; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | public class BootLog { 7 | private static final Logger logger = LoggerFactory.getLogger(BootLog.class); 8 | 9 | public static void info(String message) { 10 | logger.info(message); 11 | } 12 | 13 | public static void info(String message, Object... objs) { 14 | logger.info(message, objs); 15 | } 16 | 17 | public static void error(String message, Throwable t) { 18 | logger.error(message, t); 19 | } 20 | 21 | public static void error(String message) { 22 | logger.error(message); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /openzaly-boot/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #配置访问地址 2 | server.address=127.0.0.1 3 | #配置管理平台启动端口 4 | server.port=8288 5 | #设置输出日志 6 | logging.file=${user.dir}/site-logs/admin.log 7 | #logging.file=site-logs/admin.log 8 | #设置日志的输出级别 9 | logging.level.root=warn 10 | #配置mvc前缀,界面位置 11 | spring.thymeleaf.prefix=classpath:/webapp/views/ 12 | #静态资源 13 | spring.resources.static-locations=classpath:/webapp/static/ 14 | 15 | #设置spring的http请求编码 16 | spring.http.encoding.force=true 17 | spring.http.encoding.charset=UTF-8 18 | spring.http.encoding.enabled=true 19 | server.tomcat.uri-encoding=UTF-8 20 | 21 | spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration -------------------------------------------------------------------------------- /openzaly-boot/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # ------ log4j ------ 2 | log4j.rootLogger=INFO,debug,info,warn,error 3 | 4 | #log4j.appender.console=org.apache.log4j.ConsoleAppender 5 | #log4j.appender.console.Target=System.out 6 | #log4j.appender.console.layout=org.apache.log4j.PatternLayout 7 | #log4j.appender.console.layout.ConversionPattern=[%p] %d [%c] %m%n 8 | 9 | log4j.appender.debug=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.debug.File=${user.dir}/site-logs/debug.log 11 | log4j.appender.debug.Threshold=DEBUG 12 | log4j.appender.debug.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.debug.layout.ConversionPattern=[%p] %d [%c] %m%n 14 | 15 | log4j.appender.info=org.apache.log4j.DailyRollingFileAppender 16 | log4j.appender.info.File=${user.dir}/site-logs/info.log 17 | log4j.appender.info.Threshold=INFO 18 | log4j.appender.info.layout=org.apache.log4j.PatternLayout 19 | log4j.appender.info.layout.ConversionPattern=[%p] %d [%c] %m%n 20 | 21 | log4j.appender.warn=org.apache.log4j.DailyRollingFileAppender 22 | log4j.appender.warn.File=${user.dir}/site-logs/error.log 23 | log4j.appender.warn.Threshold=WARN 24 | log4j.appender.warn.layout=org.apache.log4j.PatternLayout 25 | log4j.appender.warn.layout.ConversionPattern=[%p] %d [%c] %m%n 26 | 27 | log4j.appender.error=org.apache.log4j.DailyRollingFileAppender 28 | log4j.appender.error.File=${user.dir}/site-logs/error.log 29 | log4j.appender.error.Threshold=ERROR 30 | log4j.appender.error.layout=org.apache.log4j.PatternLayout 31 | log4j.appender.error.layout.ConversionPattern=[%p] %d [%c] %m%n 32 | -------------------------------------------------------------------------------- /openzaly-boot/src/main/resources/logo.txt: -------------------------------------------------------------------------------- 1 | 2 | / \ 3 | / . \ 4 | \ . \ 5 | / \ \ / _ _ __ _ __ __ ___ _ _ 6 | / . \ | / / \ / \ | |/ / / \ \ \/ / |_ _| | \ | | 7 | / . _ \ / / . \ / _ \ | ' / / _ \ \ / | | | \| | 8 | \ / / \ - . / / ___ \ | . \ / ___ \ / \ | | | |\ | 9 | \ / / | \ / /_/ \_\ |_|\_\ /_/ \_\ /_/\_\ |___| |_| \_| 10 | / . \ \ / 11 | \ . \ 12 | \ / 13 | \ / 14 | 15 | 16 | Akaxin is an open source and free proprietary IM software,you can build private openzaly-server for everyone in any server. -------------------------------------------------------------------------------- /openzaly-boot/src/test/java/com/akaxin/site/boot/test/TestDefaultIcon.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.boot.test; 2 | 3 | import java.util.Base64; 4 | 5 | import com.akaxin.site.business.utils.FileServerUtils; 6 | 7 | public class TestDefaultIcon { 8 | public static void main(String args[]) { 9 | // String fileUrl = "site-admin-icon.jpg"; 10 | String fileUrl = "管理.png"; 11 | byte[] fileBytes = FileServerUtils.fileToBinary(fileUrl); 12 | 13 | String str = Base64.getEncoder().encodeToString(fileBytes); 14 | System.out.println(str); 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /openzaly-boot/src/test/java/com/akaxin/site/boot/test/TestFile.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.boot.test; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import com.akaxin.proto.core.FileProto.FileType; 7 | import com.akaxin.site.business.utils.FilePathUtils; 8 | import com.akaxin.site.business.utils.FileServerUtils; 9 | 10 | public class TestFile { 11 | private static final Logger logger = LoggerFactory.getLogger(TestFile.class); 12 | 13 | private static String getDefaultSiteAdminIcon() { 14 | try { 15 | byte[] iconBytes = FileServerUtils.fileToBinary("Test.jpg"); 16 | String fileId = FileServerUtils.saveFile(iconBytes, FilePathUtils.getPicPath(), FileType.GROUP_PORTRAIT, 17 | null); 18 | return fileId; 19 | } catch (Exception e) { 20 | logger.error("get default icon error", e); 21 | } 22 | return ""; 23 | } 24 | 25 | public static void main(String args[]) { 26 | System.out.println(getDefaultSiteAdminIcon()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /openzaly-boot/src/test/java/com/akaxin/site/boot/test/TestHttpClient.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.boot.test; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.akaxin.common.http.ZalyHttpClient; 7 | import com.akaxin.common.utils.GsonUtils; 8 | 9 | public class TestHttpClient { 10 | public static void main(String args[]) throws Exception { 11 | Map map = new HashMap(); 12 | map.put("test", "aaaaa"); 13 | byte[] body = ZalyHttpClient.getInstance().postString("http://localhost:8080/hai/user/queryList", GsonUtils.toJson(map)); 14 | System.out.println("body=" + new String(body)); 15 | } 16 | } -------------------------------------------------------------------------------- /openzaly-boot/src/test/java/com/akaxin/site/boot/test/TestSystemPro.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.boot.test; 2 | 3 | public class TestSystemPro { 4 | public static void main(String[] args) { 5 | System.out.println(System.getProperty("test.abc")); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /openzaly-business/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /openzaly-business/pom.xml: -------------------------------------------------------------------------------- 1 | 9 | 11 | 4.0.0 12 | 13 | com.akaxin 14 | openzaly-parent 15 | 0.0.1 16 | 17 | com.akaxin.site 18 | openzaly-business 19 | 0.0.1-RELEASE 20 | 21 | 22 | 1.6 23 | 1.6 24 | 25 | 26 | 27 | 28 | com.akaxin.common 29 | openzaly-common 30 | 0.0.1-RELEASE 31 | 32 | 33 | 34 | com.akaxin.proto 35 | openzaly-protobuf 36 | 0.0.1-RELEASE 37 | 38 | 39 | 40 | com.akaxin.site 41 | openzaly-storage 42 | 0.0.1-RELEASE 43 | 44 | 45 | 46 | com.akaxin.site 47 | openzaly-message 48 | 0.0.1-RELEASE 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/api/IRequest.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.business.api; 2 | 3 | import com.akaxin.common.command.Command; 4 | import com.akaxin.common.command.CommandResponse; 5 | 6 | public interface IRequest { 7 | 8 | public CommandResponse process(Command command); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/bean/MsgNoticeBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.business.bean; 2 | 3 | public class MsgNoticeBean { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/bean/PlatformPhoneBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.business.bean; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | import com.akaxin.common.utils.GsonUtils; 6 | 7 | public class PlatformPhoneBean { 8 | 9 | private String phoneId; 10 | private String countryCode; 11 | private String userIdPubk; 12 | 13 | /** 14 | * @return the phoneId 15 | */ 16 | public String getPhoneId() { 17 | return phoneId; 18 | } 19 | 20 | /** 21 | * @param phoneId 22 | * the phoneId to set 23 | */ 24 | public void setPhoneId(String phoneId) { 25 | this.phoneId = phoneId; 26 | } 27 | 28 | /** 29 | * @return the countryCode 30 | */ 31 | public String getCountryCode() { 32 | return countryCode; 33 | } 34 | 35 | /** 36 | * @param countryCode 37 | * the countryCode to set 38 | */ 39 | public void setCountryCode(String countryCode) { 40 | this.countryCode = countryCode; 41 | } 42 | 43 | /** 44 | * @return the countryCode_phoneId 45 | */ 46 | public String getFullPhoneId() { 47 | if (StringUtils.isNotEmpty(this.countryCode)) { 48 | return this.countryCode + "_" + phoneId; 49 | } 50 | return "+86_" + phoneId; 51 | } 52 | 53 | /** 54 | * @return the userIdPubk 55 | */ 56 | public String getUserIdPubk() { 57 | return userIdPubk; 58 | } 59 | 60 | /** 61 | * @param userIdPubk 62 | * the userIdPubk to set 63 | */ 64 | public void setUserIdPubk(String userIdPubk) { 65 | this.userIdPubk = userIdPubk; 66 | } 67 | 68 | public String toString() { 69 | return GsonUtils.toJson(this); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/cache/WebSessionCache.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.business.cache; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import com.google.common.cache.Cache; 10 | import com.google.common.cache.CacheBuilder; 11 | 12 | /** 13 | * 缓存websession,过期1分钟 14 | * 15 | * @author Sam{@link an.guoyue254@gmail.com} 16 | * @since 2018-05-07 19:25:38 17 | */ 18 | public class WebSessionCache { 19 | private static final Logger logger = LoggerFactory.getLogger(WebSessionCache.class); 20 | 21 | /** 22 | * 最大数量1000个 最长过期时间1分钟 23 | * 24 | */ 25 | private static Cache webSessCache = CacheBuilder.newBuilder().maximumSize(1000) 26 | .expireAfterWrite(60, TimeUnit.SECONDS).build(); 27 | 28 | public static String getSiteUserId(String sessionId) { 29 | String siteUserId = webSessCache.getIfPresent(sessionId); 30 | if (StringUtils.isNotEmpty(siteUserId)) { 31 | webSessCache.invalidate(sessionId); 32 | } 33 | return siteUserId; 34 | } 35 | 36 | public static void putWebAuthSession(String sessionId, String siteUserId) { 37 | webSessCache.put(sessionId, siteUserId); 38 | } 39 | 40 | public static void main(String[] args) { 41 | webSessCache.put("101", "hello world!"); 42 | 43 | String hello = getSiteUserId("101"); 44 | System.out.println("hello = " + hello); 45 | 46 | String hello2 = getSiteUserId("101"); 47 | System.out.println("hello = " + hello2); 48 | 49 | String hello3 = getSiteUserId("1012"); 50 | System.out.println("hello = " + hello3); 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/constant/AkxProject.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.business.constant; 2 | 3 | public interface AkxProject { 4 | 5 | // String PLN = "[openzaly-business]"; 6 | } 7 | -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/constant/GroupConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.business.constant; 17 | 18 | public interface GroupConfig { 19 | int GROUP_MAX_MEMBER_COUNT = 200; 20 | 21 | int GROUP_MIN_MEMBER_COUNT = 4; 22 | } 23 | -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/constant/NoticeText.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.business.constant; 17 | 18 | /** 19 | * 通知相关的默认配置文案,{*}表示支持事件点击的位置 20 | * 21 | * @author Sam{@link an.guoyue254@gmail.com} 22 | * @since 2017-12-28 14:38:15 23 | */ 24 | public interface NoticeText { 25 | public String USER_ADD_FRIEND = "我通过了你的好友验证,现在可以开始聊天了"; 26 | public String USER_ADD_GROUP = " 加入了群聊"; 27 | 28 | public String USER_ADD_GROUP_QR_CODE = " 通过群组二维码加入群聊"; 29 | 30 | } -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/dao/SiteUserDao.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.business.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import com.akaxin.site.storage.api.ISiteUsersDao; 9 | import com.akaxin.site.storage.service.SiteUsersDaoService; 10 | 11 | /** 12 | * 获取站点数据库信息,例如所有用户 13 | * 14 | * @author Sam{@link an.guoyue254@gmail.com} 15 | * @since 2018-04-20 18:27:46 16 | */ 17 | public class SiteUserDao { 18 | private static final Logger logger = LoggerFactory.getLogger(SiteUserDao.class); 19 | private ISiteUsersDao siteUsersDao = new SiteUsersDaoService(); 20 | 21 | private static class SingletonHolder { 22 | private static SiteUserDao instance = new SiteUserDao(); 23 | } 24 | 25 | public static SiteUserDao getInstance() { 26 | return SingletonHolder.instance; 27 | } 28 | 29 | public List getSiteUsersByPage(int pageNum, int pageSize) { 30 | try { 31 | return siteUsersDao.getSiteUserByPage(pageNum, pageSize); 32 | } catch (Exception e) { 33 | logger.error("get site user by page error", e); 34 | } 35 | return null; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/dao/UserSessionDao.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.business.dao; 17 | 18 | import java.sql.SQLException; 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | import com.akaxin.site.storage.api.IUserSessionDao; 26 | import com.akaxin.site.storage.service.UserSessionDaoService; 27 | 28 | public class UserSessionDao { 29 | private static final Logger logger = LoggerFactory.getLogger(UserSessionDao.class); 30 | private static UserSessionDao instance = new UserSessionDao(); 31 | private IUserSessionDao userSessionDao = new UserSessionDaoService(); 32 | 33 | public static UserSessionDao getInstance() { 34 | return instance; 35 | } 36 | 37 | public List getSessionDevices(String siteUserId) { 38 | List sessionDevices = new ArrayList(); 39 | try { 40 | sessionDevices = userSessionDao.getSessionDeivceIds(siteUserId); 41 | } catch (SQLException e) { 42 | logger.error("get devices from session error.siteUserId={}", siteUserId); 43 | } 44 | return sessionDevices; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/impl/IRequestService.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.business.impl; 2 | 3 | import com.akaxin.common.command.Command; 4 | import com.akaxin.common.command.CommandResponse; 5 | 6 | public interface IRequestService { 7 | public CommandResponse execute(Command command); 8 | } 9 | -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/push/PushText.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.business.push; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | import com.akaxin.common.utils.StringHelper; 6 | import com.akaxin.site.business.dao.UserProfileDao; 7 | import com.akaxin.site.business.impl.site.SiteConfig; 8 | import com.akaxin.site.storage.bean.SimpleUserBean; 9 | 10 | /** 11 | * 12 | * @author Sam{@link an.guoyue254@gmail.com} 13 | * @since 2018-04-25 17:41:20 14 | */ 15 | public class PushText { 16 | private static String ADD_FRIEND_TEXT = "{} 申请添加你为好友"; 17 | private static String AGGREE_FRIEND_TEXT = "{} 同意了你的好友申请"; 18 | private static String DEFAULT_ADD_FRIEND_TEXT = "你收到一条好友申请"; 19 | 20 | public static String applyFriendText(String siteUserId) { 21 | SimpleUserBean bean = UserProfileDao.getInstance().getSimpleProfileById(siteUserId); 22 | if (bean != null && StringUtils.isNotEmpty(bean.getUserName())) { 23 | return StringHelper.format(ADD_FRIEND_TEXT, bean.getUserName()); 24 | } 25 | return DEFAULT_ADD_FRIEND_TEXT; 26 | } 27 | 28 | public static String applyFriendGoto(String siteUserId) { 29 | String siteAddress = SiteConfig.getSiteAddress(); 30 | return StringHelper.format("zaly://{}/goto?page=friend_apply", siteAddress); 31 | } 32 | 33 | // 同意好友添加push文案 34 | public static String agreeFriendText(String siteUserId) { 35 | SimpleUserBean bean = UserProfileDao.getInstance().getSimpleProfileById(siteUserId); 36 | if (bean != null && StringUtils.isNotEmpty(bean.getUserName())) { 37 | return StringHelper.format(AGGREE_FRIEND_TEXT, bean.getUserName()); 38 | } 39 | return DEFAULT_ADD_FRIEND_TEXT; 40 | } 41 | 42 | public static String messageGoto(String siteUserId) { 43 | String siteAddress = SiteConfig.getSiteAddress(); 44 | return StringHelper.format("zaly://{}/goto?page=u2_msg&site_user_id={}", siteAddress, siteUserId); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/service/ApiRequestService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.business.service; 17 | 18 | import org.slf4j.Logger; 19 | import org.slf4j.LoggerFactory; 20 | 21 | import com.akaxin.common.command.Command; 22 | import com.akaxin.common.command.CommandResponse; 23 | import com.akaxin.common.constant.CommandConst; 24 | import com.akaxin.common.constant.ErrorCode2; 25 | import com.akaxin.common.utils.StringHelper; 26 | import com.akaxin.site.business.api.IRequest; 27 | 28 | /** 29 | * API处理业务逻辑 30 | * 31 | * @author Sam{@link an.guoyue254@gmail.com} 32 | * @since 2017.10.16 33 | * 34 | */ 35 | public class ApiRequestService implements IRequest { 36 | private static final Logger logger = LoggerFactory.getLogger(ApiRequestService.class); 37 | 38 | public CommandResponse process(Command command) { 39 | try { 40 | return ApiServiceFactory.getService(command.getService()).execute(command); 41 | } catch (Exception e) { 42 | logger.error(StringHelper.format("api request service error.command={}", command), e); 43 | } 44 | return new CommandResponse().setVersion(CommandConst.PROTOCOL_VERSION).setAction(CommandConst.ACTION_RES) 45 | .setErrCode2(ErrorCode2.ERROR); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/utils/HexUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.business.utils; 17 | 18 | /** 19 | * byte数组与字符串之间转换 20 | */ 21 | public class HexUtils { 22 | 23 | public static String bytesToHexString(byte[] b) { 24 | StringBuffer returnValue = new StringBuffer(); 25 | for (int i = 0; i < b.length; i++) { 26 | String hex = Integer.toHexString(b[i] & 0xFF); 27 | if (hex.length() == 1) { 28 | hex = '0' + hex; 29 | } 30 | returnValue.append(hex.toUpperCase() + " "); 31 | } 32 | 33 | return returnValue.toString(); 34 | } 35 | 36 | public static void main(String[] args) { 37 | String test = "你好,我是中国人"; 38 | 39 | System.out.println(bytesToHexString(test.getBytes())); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /openzaly-business/src/main/java/com/akaxin/site/business/utils/StringRandomUtils.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.business.utils; 2 | 3 | import java.security.NoSuchAlgorithmException; 4 | import java.security.SecureRandom; 5 | 6 | public class StringRandomUtils { 7 | 8 | private static final String STR_62_RANDOM = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 9 | 10 | // 随机生成N位字符串(A-Z,a-z,0-9) 11 | public static String generateRandomString(int length) throws NoSuchAlgorithmException { 12 | SecureRandom sRandom = SecureRandom.getInstance("SHA1PRNG"); 13 | StringBuffer newRandomStr = new StringBuffer(); 14 | for (int i = 0; i < length; ++i) { 15 | int number = sRandom.nextInt(STR_62_RANDOM.length()); 16 | newRandomStr.append(STR_62_RANDOM.charAt(number)); 17 | } 18 | return newRandomStr.toString(); 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /openzaly-business/src/test/java/com/akaxin/site/business/test/TestHttpProto.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.business.test; 2 | 3 | import java.io.IOException; 4 | 5 | import com.akaxin.common.http.ZalyHttpClient; 6 | import com.akaxin.proto.core.PluginProto; 7 | 8 | public class TestHttpProto { 9 | public static void main(String args[]) throws Exception { 10 | testHttpPost(); 11 | // testHttpGet(); 12 | } 13 | 14 | private static byte[] testHttpPost() throws IOException { 15 | // String pluginUrl = "http://192.168.1.106/siteMember/applyAddFriend"; 16 | // String siteUserId = "test1111"; 17 | // String requestParams = "Test"; 18 | // PluginProto.ProxyPackage proxyPackage = PluginProto.ProxyPackage.newBuilder() 19 | // .putProxyContent(PluginProto.ProxyKey.CLIENT_SITE_USER_ID_VALUE, siteUserId).setData(requestParams) 20 | // .build(); 21 | // byte[] httpResposne = ZalyHttpClient.getInstance().postBytes(pluginUrl, proxyPackage.toByteArray()); 22 | // 23 | // System.out.println("response = " + httpResposne.length); 24 | 25 | return null; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /openzaly-common/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /openzaly-common/pom.xml: -------------------------------------------------------------------------------- 1 | 9 | 11 | 4.0.0 12 | 13 | com.akaxin 14 | openzaly-parent 15 | 0.0.1 16 | 17 | com.akaxin.common 18 | openzaly-common 19 | 0.0.1-RELEASE 20 | 21 | 22 | 23 | commons-codec 24 | commons-codec 25 | 26 | 27 | 28 | org.apache.commons 29 | commons-lang3 30 | 31 | 32 | 33 | org.apache.commons 34 | commons-collections4 35 | 36 | 37 | 38 | com.akaxin.proto 39 | openzaly-protobuf 40 | 0.0.1-RELEASE 41 | 42 | 43 | 44 | org.bouncycastle 45 | bcprov-jdk16 46 | 47 | 48 | 49 | 50 | com.belerweb 51 | pinyin4j 52 | 2.5.0 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/channel/ChannelManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.channel; 17 | 18 | import java.util.Map; 19 | import java.util.Set; 20 | import java.util.concurrent.ConcurrentHashMap; 21 | 22 | /** 23 | * @author Sam{@link an.guoyue254@gmail.com} 24 | * @since 2018-01-31 12:26:34 25 | */ 26 | public class ChannelManager { 27 | 28 | private static Map clientChannelSessions = new ConcurrentHashMap(); 29 | 30 | private ChannelManager() { 31 | 32 | } 33 | 34 | public static Map addChannelSession(String deviceId, ChannelSession channelSession) { 35 | clientChannelSessions.put(deviceId, channelSession); 36 | return clientChannelSessions; 37 | } 38 | 39 | public static Map delChannelSession(String userId) { 40 | clientChannelSessions.remove(userId); 41 | return clientChannelSessions; 42 | } 43 | 44 | public static ChannelSession getChannelSession(String deviceId) { 45 | return clientChannelSessions.get(deviceId); 46 | } 47 | 48 | public static Set getChannelSessionKeySet() { 49 | return clientChannelSessions.keySet(); 50 | } 51 | 52 | public static Map getChannelSessions() { 53 | return clientChannelSessions; 54 | } 55 | 56 | public static long getChannelSessionSize() { 57 | return clientChannelSessions.size(); 58 | } 59 | } -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/channel/WebChannelManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.channel; 17 | 18 | import java.util.Map; 19 | import java.util.Set; 20 | import java.util.concurrent.ConcurrentHashMap; 21 | 22 | import org.apache.commons.lang3.StringUtils; 23 | 24 | /** 25 | * @author Sam{@link an.guoyue254@gmail.com} 26 | * @since 2018-01-31 12:26:34 27 | */ 28 | public class WebChannelManager { 29 | 30 | private static Map webChannelSessions = new ConcurrentHashMap(); 31 | 32 | private WebChannelManager() { 33 | 34 | } 35 | 36 | public static Map addChannelSession(String siteUserId, ChannelSession channelSession) { 37 | webChannelSessions.put(siteUserId, channelSession); 38 | return webChannelSessions; 39 | } 40 | 41 | public static Map delChannelSession(String siteUserId) { 42 | if (StringUtils.isNotEmpty(siteUserId)) { 43 | webChannelSessions.remove(siteUserId); 44 | } 45 | return webChannelSessions; 46 | } 47 | 48 | public static ChannelSession getChannelSession(String siteUserId) { 49 | return webChannelSessions.get(siteUserId); 50 | } 51 | 52 | public static Set getChannelSessionKeySet() { 53 | return webChannelSessions.keySet(); 54 | } 55 | 56 | public static Map getChannelSessionMap() { 57 | return webChannelSessions; 58 | } 59 | 60 | public static long getChannelSessionSize() { 61 | return webChannelSessions.size(); 62 | } 63 | } -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/constant/CharsetCoding.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.common.constant; 2 | 3 | /** 4 | * 5 | * @author Sam{@link an.guoyue254@gmail.com} 6 | * @since 2018-03-23 14:21:52 7 | */ 8 | public interface CharsetCoding { 9 | String UTF_8 = "UTF-8"; 10 | 11 | String ISO_8859_1 = "ISO-8859-1"; 12 | } 13 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/constant/CommandConst.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.constant; 17 | 18 | public interface CommandConst { 19 | public String PROTOCOL_VERSION = "1.0";// 网络协议版本 20 | public String SITE_VERSION = "0.9.5";// 站点版本(特指proto版本) 21 | 22 | public String PROXY_SITE_USER_ID = "proxy_site_user_id"; 23 | public String SITE_FRIEND_ID = "site_friend_id"; 24 | public String SITE_GROUP_ID = "site_group_id"; 25 | public String CHAHHEL_SESSION = "channel_session"; 26 | public String CHANNEL_CONTEXT = "channel_context"; 27 | public String CLIENT_IP = "client_ip"; 28 | public String CLIENT_VERSION = "client_version"; 29 | 30 | public String MSG_TYPE = "msg_type"; 31 | public String START_TIME = "start_time"; 32 | public String END_TIME = "end_time"; 33 | 34 | public String IS_PROXY = "is_proxy"; 35 | 36 | public String IS_MASTER_DB = "is_master_db"; 37 | 38 | // plugin 39 | public String PLUGIN_AUTH_KEY = "plugin_auth_key"; 40 | public String PLUGIN_ID = "plugin_id"; 41 | 42 | public String IM_MSG_TOCLIENT = "im.stc.message"; 43 | public String IM_MSG_TOSITE = "im.cts.message"; 44 | 45 | public String IM_MSG_FINISH = "im.msg.finish"; 46 | 47 | public String IM_STC_PSN = "im.stc.psn"; 48 | 49 | public String IM_NOTICE = "im.stc.notice"; 50 | 51 | public String API_PUSH_NOTIFICATION = "api.push.notification"; 52 | public String API_PUSH_NOTIFICATIONS = "api.push.notifications"; 53 | 54 | public String API_PHONE_CONFIRETOKEN = "api.phone.confirmToken"; 55 | 56 | public String ACTION_RES = "_"; 57 | } 58 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/constant/ConfigConst.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.constant; 17 | 18 | public interface ConfigConst { 19 | public String DEFAULT_SITE_ADMIN = "ZALY_SHAOYE"; 20 | } -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/constant/HttpUriAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.constant; 17 | 18 | /** 19 | * @author Sam{@link an.guoyue254@gmail.com} 20 | * @since 2018-01-31 12:28:44 21 | */ 22 | public enum HttpUriAction { 23 | HTTP_ACTION("akaxin-plugin-api", ""), // 24 | 25 | HAI_SITE_SERVICE("hai", "site"), // 站点配置服务 26 | 27 | HAI_USER_SERVICE("hai", "user"), // 用户服务 28 | 29 | HAI_GROUP_SERVICE("hai", "group"), // 群组服务 30 | 31 | HAI_FRIEND_SERVICE("hai", "friend"), // 好友服务 32 | 33 | HAI_MESSAGE_SERVICE("hai", "message"), // 好友服务 34 | 35 | HAI_PUSH_SERVICE("hai", "push"), // push通知推送 36 | 37 | HAI_UIC_SERVICE("hai", "uic"), // 邀请码服务 38 | 39 | HAI_PLUGIN_SERVICE("hai", "plugin"), // 扩展服务 40 | 41 | HAI_SESSION_SERVICE("hai", "session");// Session服务 42 | 43 | private String rety; 44 | private String service; 45 | 46 | HttpUriAction(String rety, String service) { 47 | this.rety = rety; 48 | this.service = service; 49 | } 50 | 51 | public String getRety() { 52 | return this.rety; 53 | } 54 | 55 | public String getService() { 56 | return this.service; 57 | } 58 | 59 | public static HttpUriAction getUriActionEnum(String rety, String service) { 60 | for (HttpUriAction hua : HttpUriAction.values()) { 61 | if (hua.getService().equals(service)) { 62 | return hua; 63 | } 64 | } 65 | return null; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/constant/IErrorCode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.constant; 17 | 18 | public interface IErrorCode { 19 | public String getCode(); 20 | 21 | public String getInfo(); 22 | 23 | public boolean isSuccess(); 24 | 25 | public String toString(); 26 | } 27 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/crypto/HashCrypto.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.crypto; 17 | 18 | import org.apache.commons.codec.binary.Hex; 19 | import org.apache.commons.codec.digest.DigestUtils; 20 | 21 | /** 22 | * SHA1 && MD5 23 | * 24 | * @author Sam{@link an.guoyue254@gmail.com} 25 | * @since 2018-01-31 12:30:50 26 | */ 27 | public class HashCrypto { 28 | 29 | public static String SHA1(String key) { 30 | byte[] data = DigestUtils.sha1(key); 31 | return Hex.encodeHexString(data); 32 | } 33 | 34 | public static byte[] SHA1Bytes(String key) { 35 | return DigestUtils.sha1(key); 36 | } 37 | 38 | public static String MD5(String key) { 39 | byte[] md5Data = DigestUtils.md5(key); 40 | return Hex.encodeHexString(md5Data); 41 | } 42 | 43 | public static byte[] MD5Bytes(String key) { 44 | return DigestUtils.md5(key); 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/exceptions/ZalyException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.exceptions; 17 | 18 | import com.akaxin.common.constant.IErrorCode; 19 | 20 | /** 21 | * 自定义API请求过程中产生的特殊异常 22 | * 23 | * @author Sam{@link an.guoyue254@gmail.com} 24 | * @since 2018-04-09 12:32:08 25 | */ 26 | public class ZalyException extends Exception { 27 | /** 28 | * 29 | */ 30 | private static final long serialVersionUID = 1L; 31 | private IErrorCode errCode; 32 | 33 | public ZalyException(IErrorCode errCode) { 34 | super(errCode.toString()); 35 | this.errCode = errCode; 36 | } 37 | 38 | public IErrorCode getErrCode() { 39 | return this.errCode; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/exceptions/ZalyException2.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.exceptions; 17 | 18 | import com.akaxin.common.constant.IErrorCode; 19 | 20 | /** 21 | * 22 | * @author Sam{@link an.guoyue254@gmail.com} 23 | * @since 2018-05-26 13:31:49 24 | */ 25 | public class ZalyException2 extends Throwable { 26 | /** 27 | * 28 | */ 29 | private static final long serialVersionUID = 1L; 30 | private IErrorCode errCode; 31 | 32 | public ZalyException2(IErrorCode errCode) { 33 | super(errCode.toString()); 34 | this.errCode = errCode; 35 | } 36 | 37 | public IErrorCode getErrCode() { 38 | return this.errCode; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/executor/AbstracteExecutor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.executor; 17 | 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | 21 | import com.akaxin.common.executor.chain.handler.IHandler; 22 | 23 | /** 24 | * @author Sam{@link an.guoyue254@gmail.com} 25 | * @since 2018-01-31 12:31:26 26 | * @param 27 | */ 28 | public abstract class AbstracteExecutor implements IExecutor { 29 | 30 | protected Map> executors = new HashMap>(); 31 | protected Map> regexExecutors = new HashMap>(); 32 | 33 | public abstract R execute(String name, T t); 34 | 35 | public AbstracteExecutor addChain(String name, IHandler chain) { 36 | executors.put(name, chain); 37 | return this; 38 | } 39 | 40 | public AbstracteExecutor addRegexChain(String regexName, IHandler regexChain) { 41 | regexExecutors.put(regexName, regexChain); 42 | return this; 43 | } 44 | 45 | public IHandler getChain(String name) { 46 | IHandler handler = executors.get(name); 47 | return handler; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/executor/IExecutor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.executor; 17 | 18 | public interface IExecutor { 19 | public R execute(String name, T t); 20 | } -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/executor/SimpleExecutor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.executor; 17 | 18 | import com.akaxin.common.executor.chain.handler.IHandler; 19 | 20 | /** 21 | * 定义一个简单统一的执行器 22 | * 23 | * @author Sam 24 | * @since 2017.09.29 25 | * 26 | */ 27 | public class SimpleExecutor extends AbstracteExecutor { 28 | 29 | @Override 30 | public R execute(String name, T t) { 31 | IHandler chain = getChain(name); 32 | return chain.handle(t); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/executor/chain/AbstractHandlerChain.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.executor.chain; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import com.akaxin.common.executor.chain.handler.IHandler; 22 | 23 | /** 24 | * @author Sam{@link an.guoyue254@gmail.com} 25 | * @since 2018-01-31 12:24:59 26 | */ 27 | public abstract class AbstractHandlerChain implements IHandler { 28 | 29 | private List> handlers = new ArrayList>(); 30 | 31 | public abstract R handle(T t); 32 | 33 | public boolean addHandler(IHandler handler) { 34 | return handlers.add(handler); 35 | } 36 | 37 | public List> getHandlers() { 38 | return handlers; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/executor/chain/CustomRHandlerChain.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.executor.chain; 17 | 18 | import com.akaxin.common.executor.chain.handler.IHandler; 19 | 20 | /** 21 | * 自定义返回值的handler 22 | * 23 | * @author Sam 24 | * @since 2017-09.30 25 | * @param 26 | */ 27 | public class CustomRHandlerChain extends AbstractHandlerChain { 28 | 29 | @Override 30 | public R handle(T t) { 31 | 32 | for (IHandler handler : getHandlers()) { 33 | return handler.handle(t); 34 | } 35 | return null; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/executor/chain/SimpleHandlerChain.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.executor.chain; 17 | 18 | import com.akaxin.common.executor.chain.handler.IHandler; 19 | 20 | /** 21 | *
22 |  * 	简单的来说(Chain中每个Handler的返回值)
23 |  * 		返回true,此条消息链才算处理成功,继续执行
24 |  * 		返回false,则消息链终止执行,返回false
25 |  * 
26 | * 27 | * @author Sam 28 | * @since 2017-09.30 29 | * @param 30 | */ 31 | public class SimpleHandlerChain extends AbstractHandlerChain { 32 | 33 | @Override 34 | public Boolean handle(T t) { 35 | // hander.handle(t) == false ,return fasle and break 36 | // hander.handle(t) == true ,return true and go on 37 | for (IHandler handler : getHandlers()) { 38 | if (!handler.handle(t)) { 39 | return false; 40 | } 41 | } 42 | return true; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/executor/chain/handler/IHandler.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.common.executor.chain.handler; 2 | 3 | /** 4 | * 5 | * @author Sam{@link an.guoyue254@gmail.com} 6 | * @since 2018-03-28 18:47:49 7 | * @param 8 | * 执行参数的类型 9 | * @param 10 | * 返回类型的参数 11 | */ 12 | public interface IHandler { 13 | public R handle(T t); 14 | } 15 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/executor/chain/handler/MethodReflectHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.executor.chain.handler; 17 | 18 | import java.lang.reflect.InvocationTargetException; 19 | import java.lang.reflect.Method; 20 | 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | import com.akaxin.common.command.Command; 25 | 26 | /** 27 | * @author Sam{@link an.guoyue254@gmail.com} 28 | * @since 2018-01-31 12:26:07 29 | * @param 30 | */ 31 | public class MethodReflectHandler implements IHandler { 32 | private static final Logger logger = LoggerFactory.getLogger(MethodReflectHandler.class); 33 | 34 | @SuppressWarnings("unchecked") 35 | public R handle(T t) { 36 | try { 37 | Command cmd = (Command) t; 38 | String methodName = cmd.getMethod(); 39 | 40 | Method m = this.getClass().getDeclaredMethod(methodName, cmd.getClass()); 41 | Object result = m.invoke(this, t); 42 | 43 | if (result != null) { 44 | return (R) result; 45 | } 46 | } catch (NoSuchMethodException e) { 47 | logger.error("method handler NoSuchMethod error.", e); 48 | } catch (SecurityException e) { 49 | logger.error("method handler Security error.", e); 50 | } catch (IllegalAccessException e) { 51 | logger.error("method handler IllegalAccess error.", e); 52 | } catch (IllegalArgumentException e) { 53 | logger.error("method handler IllegalArgument error.", e); 54 | } catch (InvocationTargetException e) { 55 | logger.error("method handler InvocationTarget error.", e); 56 | } 57 | return null; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/netty/IRedisCommandResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.netty; 17 | 18 | import com.akaxin.common.command.RedisCommand; 19 | 20 | /** 21 | * 22 | * @author Sam{@link an.guoyue254@gmail.com} 23 | * @since 2018-01-19 17:35:20 24 | * @param 25 | */ 26 | public interface IRedisCommandResponse { 27 | 28 | public RedisCommand getRedisCommand(); 29 | 30 | public boolean isSuccess(); 31 | 32 | public String getErrInfo(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/netty/RedisCommandResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.netty; 17 | 18 | import com.akaxin.common.command.RedisCommand; 19 | import com.google.gson.Gson; 20 | 21 | public class RedisCommandResponse implements IRedisCommandResponse { 22 | 23 | private final RedisCommand redisCommand; 24 | private final String errCode; 25 | private final String errInfo; 26 | 27 | public RedisCommandResponse(RedisCommand redisCommand, String errCode, String errInfo) { 28 | this.redisCommand = redisCommand; 29 | this.errCode = errCode; 30 | this.errInfo = errInfo; 31 | } 32 | 33 | @Override 34 | public RedisCommand getRedisCommand() { 35 | return this.redisCommand; 36 | } 37 | 38 | @Override 39 | public boolean isSuccess() { 40 | return "success".equals(this.errCode); 41 | } 42 | 43 | @Override 44 | public String getErrInfo() { 45 | return this.errInfo; 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return new Gson().toJson(this); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/netty/codec/MessageDecoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.netty.codec; 17 | 18 | import java.util.List; 19 | 20 | import io.netty.buffer.ByteBuf; 21 | import io.netty.channel.ChannelHandlerContext; 22 | import io.netty.handler.codec.ReplayingDecoder; 23 | 24 | /** 25 | * 解码器,使用ReplayingDecoder,每一个deccode必须是 26 | * 27 | * @author Sam 28 | * @since 2017.09.27 29 | * 30 | */ 31 | public class MessageDecoder extends ReplayingDecoder { 32 | 33 | private ProtocolParser parser = new ProtocolParser(); 34 | 35 | public MessageDecoder() { 36 | super.state(ReplaySignal.START_POINT); 37 | } 38 | 39 | @Override 40 | public void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { 41 | parser.readAndOut(ctx.channel(), in, out, this); 42 | 43 | } 44 | 45 | @Override 46 | public void checkpoint(ReplaySignal bp) { 47 | super.checkpoint(bp); 48 | } 49 | 50 | @Override 51 | public ReplaySignal state() { 52 | return super.state(); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/netty/codec/ReplaySignal.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.netty.codec; 17 | 18 | /** 19 | * 20 | * @author Sam{@link anguoyue254@gmail.com} 21 | * @since 2017-09-27 22 | * 23 | */ 24 | public enum ReplaySignal { 25 | START_POINT, // start 26 | HEADER_POINT, // head 27 | BODY_POINT;// body 28 | } 29 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/resp/AbstractParameter.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.common.resp; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.nio.charset.Charset; 5 | 6 | public abstract class AbstractParameter { 7 | protected static final Charset UTF8 = Charset.forName("UTF-8"); 8 | protected static final byte[] CRLF = "\r\n".getBytes(UTF8); 9 | 10 | public abstract void encode(ByteBuffer buffer); 11 | 12 | public abstract int getSize(); 13 | 14 | public String getValue() { 15 | return null; 16 | } 17 | 18 | public byte[] getBytesValue() { 19 | return null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/resp/RedisBytesParameter.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.common.resp; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | public class RedisBytesParameter extends AbstractParameter { 6 | 7 | final byte[] value; 8 | 9 | public RedisBytesParameter(byte[] value) { 10 | this.value = value; 11 | } 12 | 13 | public static RedisBytesParameter of(byte[] value) { 14 | return new RedisBytesParameter(value); 15 | } 16 | 17 | @Override 18 | public void encode(ByteBuffer buffer) { 19 | writeBytes(buffer, value); 20 | } 21 | 22 | public static void writeBytes(ByteBuffer buffer, byte[] value) { 23 | 24 | buffer.put((byte) '$'); 25 | 26 | RedisIntegerParameter.writeInteger(buffer, value.length); 27 | buffer.put(CRLF); 28 | 29 | buffer.put(value); 30 | buffer.put(CRLF); 31 | } 32 | 33 | public static int getByteSize(byte[] value) { 34 | int byteSize = CRLF.length * 2 + 1; 35 | byteSize += RedisIntegerParameter.getIntegerByteSize(value.length); 36 | byteSize += value.length; 37 | return byteSize; 38 | } 39 | 40 | @Override 41 | public String getValue() { 42 | return new String(value); 43 | } 44 | 45 | @Override 46 | public byte[] getBytesValue() { 47 | return this.value; 48 | } 49 | 50 | @Override 51 | public int getSize() { 52 | return getByteSize(this.value); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/resp/RedisDoubleParameter.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.common.resp; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | public class RedisDoubleParameter extends AbstractParameter { 6 | final double value; 7 | 8 | private RedisDoubleParameter(double value) { 9 | this.value = value; 10 | } 11 | 12 | public static RedisDoubleParameter of(double val) { 13 | return new RedisDoubleParameter(val); 14 | } 15 | 16 | @Override 17 | public void encode(ByteBuffer target) { 18 | RedisStringParameter.writeString(target, Double.toString(value)); 19 | } 20 | 21 | @Override 22 | public String getValue() { 23 | return String.valueOf(value); 24 | } 25 | 26 | @Override 27 | public int getSize() { 28 | return RedisStringParameter.getStringByteSize(String.valueOf(value)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/resp/RedisIntegerParameter.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.common.resp; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | public class RedisIntegerParameter extends AbstractParameter { 6 | final long value; 7 | 8 | private RedisIntegerParameter(long value) { 9 | this.value = value; 10 | } 11 | 12 | public static RedisIntegerParameter of(long val) { 13 | 14 | if (val >= 0 && val < IntegerCache.cache.length) { 15 | return IntegerCache.cache[(int) val]; 16 | } 17 | 18 | if (val < 0 && -val < IntegerCache.cache.length) { 19 | return IntegerCache.negativeCache[(int) -val]; 20 | } 21 | 22 | return new RedisIntegerParameter(val); 23 | } 24 | 25 | @Override 26 | public void encode(ByteBuffer target) { 27 | RedisStringParameter.writeString(target, Long.toString(value)); 28 | } 29 | 30 | public static void writeInteger(ByteBuffer target, long value) { 31 | if (value < 10) { 32 | target.put((byte) ('0' + value)); 33 | return; 34 | } 35 | 36 | String asString = Long.toString(value); 37 | 38 | for (int i = 0; i < asString.length(); i++) { 39 | target.put((byte) asString.charAt(i)); 40 | } 41 | 42 | } 43 | 44 | public static int getIntegerByteSize(long value) { 45 | int size = 1; 46 | if (value < 10) { 47 | return size; 48 | } 49 | 50 | String asString = Long.toString(value); 51 | 52 | for (int i = 0; i < asString.length(); i++) { 53 | size++; 54 | } 55 | 56 | return size; 57 | } 58 | 59 | static class IntegerCache { 60 | 61 | static final RedisIntegerParameter cache[]; 62 | static final RedisIntegerParameter negativeCache[]; 63 | 64 | static { 65 | int high = Integer.getInteger("biz.paluch.redis.CommandArgs.IntegerCache", 128); 66 | cache = new RedisIntegerParameter[high]; 67 | negativeCache = new RedisIntegerParameter[high]; 68 | for (int i = 0; i < high; i++) { 69 | cache[i] = new RedisIntegerParameter(i); 70 | negativeCache[i] = new RedisIntegerParameter(-i); 71 | } 72 | } 73 | } 74 | 75 | @Override 76 | public String getValue() { 77 | return String.valueOf(value); 78 | } 79 | 80 | @Override 81 | public int getSize() { 82 | return getIntegerByteSize(this.value); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/resp/RedisStringParameter.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.common.resp; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | public class RedisStringParameter extends AbstractParameter { 6 | 7 | public final String value; 8 | 9 | public RedisStringParameter(String val) { 10 | this.value = val; 11 | } 12 | 13 | public static RedisStringParameter of(String val) { 14 | return new RedisStringParameter(val); 15 | } 16 | 17 | @Override 18 | public void encode(ByteBuffer target) { 19 | writeString(target, value); 20 | } 21 | 22 | public static void writeString(ByteBuffer target, String value) { 23 | target.put((byte) '$'); 24 | byte[] valueByte = value.getBytes(UTF8); 25 | RedisIntegerParameter.writeInteger(target, valueByte.length); 26 | target.put(CRLF); 27 | target.put(valueByte); 28 | target.put(CRLF); 29 | } 30 | 31 | public static int getStringByteSize(String value) { 32 | int byteSize = CRLF.length * 2 + 1; 33 | byte[] valueByte = value.getBytes(UTF8); 34 | byteSize += RedisIntegerParameter.getIntegerByteSize(valueByte.length); 35 | byteSize += valueByte.length; 36 | return byteSize; 37 | } 38 | 39 | @Override 40 | public String getValue() { 41 | return value; 42 | } 43 | 44 | @Override 45 | public int getSize() { 46 | return getStringByteSize(this.value); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/ssl/ZalySSLContext.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.common.ssl; 2 | 3 | import io.netty.handler.ssl.SslContext; 4 | import io.netty.handler.ssl.SslContextBuilder; 5 | 6 | /** 7 | * 获取SSL访问使用的Context 8 | * 9 | * @author Sam{@link an.guoyue254@gmail.com} 10 | * @since 2018-06-20 21:04:43 11 | */ 12 | public class ZalySSLContext { 13 | 14 | private static SslContext sslContext; 15 | 16 | private ZalySSLContext() { 17 | 18 | } 19 | 20 | public static SslContext getSSLContext() { 21 | try { 22 | if (sslContext == null) { 23 | sslContext = SslContextBuilder.forClient().trustManager(ZalyTrustManagerFactory.INSTANCE).build(); 24 | } 25 | } catch (Exception e) { 26 | throw new Error("Failed to initialize platform SSLContext", e); 27 | } 28 | 29 | return sslContext; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/utils/GsonUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.utils; 17 | 18 | import com.google.gson.Gson; 19 | 20 | /** 21 | * 22 | * @author Sam{@link an.guoyue254@gmail.com} 23 | * @since 2018-01-31 12:34:31 24 | */ 25 | public class GsonUtils { 26 | public static String toJson(Object obj) { 27 | Gson gson = new Gson(); 28 | return gson.toJson(obj); 29 | } 30 | 31 | public static T fromJson(String str, Class clazz) { 32 | return new Gson().fromJson(str, clazz); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/utils/IpUtils.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.common.utils; 2 | 3 | import java.net.Inet4Address; 4 | import java.net.UnknownHostException; 5 | 6 | public class IpUtils { 7 | 8 | // public static String getLocalAddress() { 9 | // 10 | // try { 11 | // return Inet4Address.getLocalHost().getHostAddress(); 12 | // } catch (UnknownHostException e) { 13 | // e.printStackTrace(); 14 | // } 15 | // 16 | // return null; 17 | // } 18 | // 19 | // public static int getPort() { 20 | // return 8448; 21 | // } 22 | } 23 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/utils/PrintUtils.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.common.utils; 2 | 3 | import java.io.PrintWriter; 4 | 5 | /** 6 | * 控制台输出信息 7 | * 8 | * @author Sam{@link an.guoyue254@gmail.com} 9 | * @since 2018-06-15 15:14:53 10 | */ 11 | public class PrintUtils { 12 | 13 | private static PrintWriter pw; 14 | 15 | public static PrintWriter getPW() { 16 | if (pw == null) { 17 | pw = new PrintWriter(System.out); 18 | } 19 | return pw; 20 | } 21 | 22 | public static void print(String messagePattern, Object... objects) { 23 | getPW().println(StringHelper.format(messagePattern, objects)); 24 | } 25 | 26 | public static void print() { 27 | getPW().println(); 28 | } 29 | 30 | public static void flush() { 31 | getPW().flush(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/utils/ServerAddressUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.utils; 17 | 18 | /** 19 | *
20 |  * 	提供Netty启动的服务地址以及端口号
21 |  * 
22 |  * 	Address and Port of Netty server
23 |  * 
24 | * 25 | * @author Sam{@link an.guoyue254@gmail.com} 26 | * @since 2018-01-31 12:35:32 27 | */ 28 | public class ServerAddressUtils { 29 | 30 | private static String address = "0.0.0.0"; 31 | private static int port = 2021; // default port 32 | 33 | public static String getAddress() { 34 | return address; 35 | } 36 | 37 | public static void setAddress(String address) { 38 | ServerAddressUtils.address = address; 39 | } 40 | 41 | public static void setPort(int currPort) { 42 | ServerAddressUtils.port = currPort; 43 | } 44 | 45 | public static int getPort() { 46 | return port; 47 | } 48 | 49 | public static String getAddressPort() { 50 | return address + ":" + port; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/utils/TimeFormats.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.utils; 17 | 18 | import java.text.SimpleDateFormat; 19 | import java.util.Calendar; 20 | import java.util.Date; 21 | import java.util.TimeZone; 22 | 23 | /** 24 | * @author Sam{@link an.guoyue254@gmail.com} 25 | * @since 2018-01-31 12:36:18 26 | */ 27 | public class TimeFormats { 28 | public static String formatToSeconds(long time) { 29 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 30 | return format.format(new Date(time)); 31 | } 32 | 33 | //获取当日0点的毫秒值 34 | public static long getStartTimeOfDay(long now) { 35 | TimeZone timeZone = TimeZone.getTimeZone("GMT+8"); 36 | Calendar calendar = Calendar.getInstance(timeZone); 37 | calendar.setTimeInMillis(now); 38 | calendar.set(Calendar.HOUR_OF_DAY, 0); 39 | calendar.set(Calendar.MINUTE, 0); 40 | calendar.set(Calendar.SECOND, 0); 41 | calendar.set(Calendar.MILLISECOND, 0); 42 | return calendar.getTimeInMillis(); 43 | } 44 | 45 | //获取当日23:59:59的毫秒值 46 | public static long getEndTimeOfDay(long now) { 47 | TimeZone timeZone = TimeZone.getTimeZone("GMT+8"); 48 | Calendar calendar = Calendar.getInstance(timeZone); 49 | calendar.setTimeInMillis(now); 50 | calendar.set(Calendar.HOUR_OF_DAY, 23); 51 | calendar.set(Calendar.MINUTE, 59); 52 | calendar.set(Calendar.SECOND, 59); 53 | calendar.set(Calendar.MILLISECOND, 999); 54 | return calendar.getTimeInMillis(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/utils/URLRegexUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.utils; 17 | 18 | import java.util.regex.Matcher; 19 | import java.util.regex.Pattern; 20 | 21 | /** 22 | * @author Sam{@link an.guoyue254@gmail.com} 23 | * @since 2018-01-31 12:36:48 24 | */ 25 | public class URLRegexUtils { 26 | public static String getParam(String url, String name) { 27 | String reg_pattern = "(^|&|\\?)" + name + "=([^&]*)(&|$)"; 28 | Pattern pattern = Pattern.compile(reg_pattern); 29 | Matcher matcher = pattern.matcher(url); 30 | if (matcher.find()) { 31 | String[] fistParam = matcher.group().split("="); 32 | if (fistParam != null && fistParam.length == 2) { 33 | return fistParam[1]; 34 | } 35 | } 36 | return ""; 37 | } 38 | 39 | public static void main(String[] args) { 40 | String test = URLRegexUtils.getParam("/test?siteUserId=hellosericksiekdjhfsk", "siteUserId"); 41 | 42 | System.out.println(test); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /openzaly-common/src/main/java/com/akaxin/common/utils/UserIdUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.common.utils; 17 | 18 | import java.util.UUID; 19 | import java.util.zip.CRC32; 20 | 21 | import com.akaxin.common.crypto.HashCrypto; 22 | 23 | /** 24 | *

25 |  * 		生产各种不同类型的用户ID
26 |  * 		siteUserId && GlobalUserId
27 |  * 
28 | * 29 | * @author Sam{@link an.guoyue254@gmail.com} 30 | * @since 2018-01-26 15:38:49 31 | */ 32 | public class UserIdUtils { 33 | // 用户在每个站点的id为UUID 34 | public static String createSiteUserId() { 35 | return UUID.randomUUID().toString(); 36 | } 37 | 38 | // 通过用户公钥,生成用户 39 | public static String getV1GlobalUserId(String userIdPubk) { 40 | String body = userIdPubk; 41 | String SHA1UserPubKey = HashCrypto.SHA1(body); 42 | CRC32 c32 = new CRC32(); 43 | c32.update(body.getBytes(), 0, body.getBytes().length); 44 | String CRC32UserPubKey = String.valueOf(c32.getValue()); 45 | return SHA1UserPubKey + "-" + CRC32UserPubKey; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /openzaly-common/src/test/java/com/akaxin/common/test/TestInetAddress.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.common.test; 2 | 3 | public class TestInetAddress { 4 | } 5 | -------------------------------------------------------------------------------- /openzaly-connector/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /openzaly-connector/bin/src/main/java/com/zaly/site/connector/client/UserMessage.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sengeiou/openzaly/6f53ac993f2e1e5f85d76a529f1f1e29aa947fa5/openzaly-connector/bin/src/main/java/com/zaly/site/connector/client/UserMessage.class -------------------------------------------------------------------------------- /openzaly-connector/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 18 | 4.0.0 19 | 20 | com.akaxin 21 | openzaly-parent 22 | 0.0.1 23 | 24 | com.akaxin.site 25 | openzaly-connector 26 | 0.0.1-RELEASE 27 | 28 | 29 | 1.6 30 | 1.6 31 | 32 | 33 | 34 | 35 | com.akaxin.common 36 | openzaly-common 37 | 0.0.1-RELEASE 38 | 39 | 40 | 41 | com.akaxin.site 42 | openzaly-message 43 | 0.0.1-RELEASE 44 | 45 | 46 | 47 | com.akaxin.site 48 | openzaly-business 49 | 0.0.1-RELEASE 50 | 51 | 52 | 53 | com.akaxin.site 54 | openzaly-storage 55 | 0.0.1-RELEASE 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/cache/PluginCache.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.connector.cache; 2 | 3 | public class PluginCache { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/codec/parser/ChannelConst.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.connector.codec.parser; 2 | 3 | import com.akaxin.common.channel.ChannelSession; 4 | 5 | import io.netty.util.AttributeKey; 6 | 7 | /** 8 | * bind ChannelSession to channel by AttributeKey 9 | * 10 | * @author Sam{@link an.guoyue254@gmail.com} 11 | * @since 2018-01-08 16:14:29 12 | */ 13 | public class ChannelConst { 14 | 15 | public static final AttributeKey CHANNELSESSION = AttributeKey.valueOf("channelSession"); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/codec/parser/IProtocolParser.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.connector.codec.parser; 17 | 18 | import java.util.List; 19 | 20 | import com.akaxin.site.connector.codec.protocol.MessageDecoder; 21 | 22 | import io.netty.buffer.ByteBuf; 23 | import io.netty.channel.Channel; 24 | 25 | /** 26 | * Decoder中使用IProtocolParser,将Byte转成protocolPacket,并交给out传递给InboundHandler 27 | * 28 | * @author Sam{@link an.guoyue254@gmail.com} 29 | * @since 2017.09.27 30 | */ 31 | public interface IProtocolParser { 32 | 33 | public void readAndOut(Channel ch, ByteBuf inByte, List out, MessageDecoder decoder) throws Exception; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/codec/protocol/MessageDecoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.connector.codec.protocol; 17 | 18 | import java.util.List; 19 | 20 | import com.akaxin.site.connector.codec.parser.IProtocolParser; 21 | import com.akaxin.site.connector.codec.parser.ProtocolParser; 22 | 23 | import io.netty.buffer.ByteBuf; 24 | import io.netty.channel.ChannelHandlerContext; 25 | import io.netty.handler.codec.ReplayingDecoder; 26 | 27 | /** 28 | * 解码器,使用ReplayingDecoder,每一个deccode必须是 29 | * 30 | * @author Sam 31 | * @since 2017.09.27 32 | * 33 | */ 34 | public class MessageDecoder extends ReplayingDecoder { 35 | 36 | private IProtocolParser parser = new ProtocolParser(); 37 | 38 | public MessageDecoder() { 39 | super.state(ReplaySignal.START_POINT); 40 | } 41 | 42 | @Override 43 | public void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { 44 | parser.readAndOut(ctx.channel(), in, out, this); 45 | 46 | } 47 | 48 | @Override 49 | public void checkpoint(ReplaySignal bp) { 50 | super.checkpoint(bp); 51 | } 52 | 53 | @Override 54 | public ReplaySignal state() { 55 | return super.state(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/codec/protocol/ReplaySignal.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.connector.codec.protocol; 17 | 18 | /** 19 | * 20 | * @author Sam{@link anguoyue254@gmail.com} 21 | * @since 2017-09-27 22 | * 23 | */ 24 | public enum ReplaySignal { 25 | START_POINT, // start 26 | HEADER_POINT, // head 27 | BODY_POINT;// body 28 | } 29 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/constant/AkxProject.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.connector.constant; 2 | 3 | public interface AkxProject { 4 | 5 | String PLN = "[openzaly-connector]"; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/constant/HttpConst.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.connector.constant; 2 | 3 | public interface HttpConst { 4 | 5 | String HTTP_H_FORWARDED = "X-Forwarded-For"; 6 | String HTTP_H_CONTENT_TYPE = "application/json"; 7 | 8 | String HTTP_M_POST = "POST"; 9 | } 10 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/constant/PluginConst.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.connector.constant; 2 | 3 | public interface PluginConst { 4 | 5 | String SITE_PLUGIN_ID = "site-plugin-id"; 6 | 7 | String PLUGIN_AUTH_KEY = "auth-key"; 8 | } 9 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/exception/HttpServerException.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.connector.exception; 2 | 3 | /** 4 | * define custom exception for httpserver 5 | * 6 | * @author Sam{@link an.guoyue254@gmail.com} 7 | * @since 2018-05-19 11:50:13 8 | */ 9 | public class HttpServerException extends Throwable { 10 | 11 | /** 12 | * 13 | */ 14 | private static final long serialVersionUID = 6242277890587744071L; 15 | 16 | public HttpServerException(String message) { 17 | super(message); 18 | } 19 | 20 | public HttpServerException(String message, Throwable throwable) { 21 | super(message, throwable); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/exception/TcpServerException.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.connector.exception; 2 | 3 | public class TcpServerException extends Throwable { 4 | 5 | /** 6 | * 7 | */ 8 | private static final long serialVersionUID = 7366967641018300790L; 9 | 10 | public TcpServerException(String message) { 11 | super(message); 12 | } 13 | 14 | public TcpServerException(String message, Throwable throwable) { 15 | super(message, throwable); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/handler/AbstractCommonHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.connector.handler; 17 | 18 | import com.akaxin.common.command.CommandResponse; 19 | import com.akaxin.common.constant.CommandConst; 20 | import com.akaxin.common.constant.ErrorCode2; 21 | import com.akaxin.common.executor.chain.handler.IHandler; 22 | 23 | import io.netty.channel.Channel; 24 | 25 | public abstract class AbstractCommonHandler implements IHandler { 26 | 27 | // default error ressponse by ErrorCode2.ERROR 28 | protected CommandResponse defaultErrorResponse() { 29 | CommandResponse commandResponse = new CommandResponse().setVersion(CommandConst.PROTOCOL_VERSION) 30 | .setAction(CommandConst.ACTION_RES); 31 | commandResponse.setErrCode2(ErrorCode2.ERROR); 32 | return commandResponse; 33 | } 34 | 35 | // defined by user 36 | protected CommandResponse customResponse(ErrorCode2 errCode) { 37 | CommandResponse commandResponse = new CommandResponse().setVersion(CommandConst.PROTOCOL_VERSION) 38 | .setAction(CommandConst.ACTION_RES); 39 | commandResponse.setErrCode2(errCode); 40 | return commandResponse; 41 | } 42 | 43 | protected void closeChannel(Channel channel) { 44 | channel.close(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/handler/WSRequestHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.connector.handler; 17 | 18 | import org.slf4j.Logger; 19 | import org.slf4j.LoggerFactory; 20 | 21 | import com.akaxin.common.command.Command; 22 | import com.akaxin.common.command.CommandResponse; 23 | import com.akaxin.common.constant.CommandConst; 24 | import com.akaxin.common.constant.ErrorCode2; 25 | 26 | import io.netty.channel.Channel; 27 | import io.netty.util.concurrent.Future; 28 | import io.netty.util.concurrent.GenericFutureListener; 29 | 30 | /** 31 | * 使用TCP处理API请求,TCP代处理HTTP请求 32 | * 33 | * @author Sam 34 | * @since 2017.10.19 35 | * 36 | * @param 37 | */ 38 | public class WSRequestHandler extends AbstractCommonHandler { 39 | private static final Logger logger = LoggerFactory.getLogger(WSRequestHandler.class); 40 | 41 | public CommandResponse handle(Command command) { 42 | try { 43 | System.out.println(command.toString()); 44 | System.out.println(command.getClientIp() + "," + command.getStartTime()); 45 | } catch (Exception e) { 46 | logger.error("process ws request handler error", e); 47 | } 48 | return customResponse(ErrorCode2.ERROR); 49 | } 50 | 51 | private void tellClientSessionError(final Channel channel) { 52 | String action = CommandConst.ACTION_RES; 53 | channel.writeAndFlush("").addListener(new GenericFutureListener>() { 54 | 55 | public void operationComplete(Future future) throws Exception { 56 | channel.close(); 57 | } 58 | }); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/netty/PrefixThreadFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.connector.netty; 17 | 18 | import java.util.concurrent.ThreadFactory; 19 | import java.util.concurrent.atomic.AtomicInteger; 20 | 21 | public class PrefixThreadFactory implements ThreadFactory { 22 | 23 | private final ThreadGroup threadGroup; 24 | private final String prefix; 25 | private final boolean isDaemon; 26 | private final AtomicInteger sequence = new AtomicInteger(0); 27 | 28 | public PrefixThreadFactory(String namePrefix) { 29 | this(namePrefix, false); 30 | } 31 | 32 | public PrefixThreadFactory(String threadNamePrefix, boolean isDaemon) { 33 | SecurityManager securityManager = System.getSecurityManager(); 34 | this.threadGroup = (securityManager == null) ? Thread.currentThread().getThreadGroup() 35 | : securityManager.getThreadGroup(); 36 | this.prefix = threadNamePrefix + "-thread-"; 37 | this.isDaemon = isDaemon; 38 | } 39 | 40 | public ThreadGroup getThreadGroup() { 41 | return threadGroup; 42 | } 43 | 44 | public Thread newThread(Runnable r) { 45 | final String name = prefix + sequence.getAndIncrement(); 46 | Thread thread = new Thread(threadGroup, r, name, 0); 47 | thread.setDaemon(isDaemon); 48 | return thread; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/session/SessionManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.connector.session; 17 | 18 | import com.akaxin.site.storage.bean.SimpleAuthBean; 19 | 20 | /** 21 | * 管理用户session,设置用户在线/离线状态。 22 | * 23 | * @author Sam{@link an.guoyue254@gmail.com} 24 | * @since 2017.11.04 11:24:35 25 | */ 26 | public class SessionManager { 27 | 28 | public static SessionManager getInstance() { 29 | return SingletonHolder.instance; 30 | } 31 | 32 | static class SingletonHolder { 33 | private static SessionManager instance = new SessionManager(); 34 | } 35 | 36 | public SimpleAuthBean getAuthSession(String sessionId) { 37 | return UserSession.getInstance().getUserSession(sessionId); 38 | } 39 | 40 | public boolean setUserOnline(String siteUserId, String deviceId) { 41 | return UserSession.getInstance().updateSessionOnline(siteUserId, deviceId); 42 | } 43 | 44 | public boolean setUserOffline(String siteUserId, String deviceId) { 45 | return UserSession.getInstance().updateSessionOffline(siteUserId, deviceId); 46 | } 47 | 48 | public boolean updateActiveTime(String siteUserId, String deviceId) { 49 | return UserSession.getInstance().updateActiveTime(siteUserId, deviceId); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/ssl/StreamReader.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.connector.ssl; 2 | 3 | import java.io.InputStream; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | /** 9 | * 10 | * 11 | */ 12 | public class StreamReader { 13 | private static final Logger logger = LoggerFactory.getLogger(StreamReader.class); 14 | 15 | // public String toByteArray(InputStream is) { 16 | // int i = 0; 17 | // StringBuilder buf = new StringBuilder(); 18 | // try { 19 | // while ((i = is.read()) != -1) { 20 | // if (buf.length() > 0) 21 | // buf.append(","); 22 | // buf.append("(byte)"); 23 | // buf.append(i); 24 | // } 25 | // 26 | // } catch (Throwable e) { 27 | // logger.error("trun to byte array from inputStream error", e); 28 | // } 29 | // 30 | // return buf.toString(); 31 | // } 32 | 33 | public static void main(String[] args) { 34 | // StreamReader reader = new StreamReader(); 35 | // System.out.println(reader.toByteArray(StreamReader.class.getResourceAsStream("/securesocket.jks"))); 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/java/com/akaxin/site/connector/utils/HexUtils.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.connector.utils; 2 | 3 | public class HexUtils { 4 | 5 | public static String printHexString(byte[] b) { 6 | StringBuffer returnValue = new StringBuffer(); 7 | for (int i = 0; i < b.length; i++) { 8 | String hex = Integer.toHexString(b[i] & 0xFF); 9 | if (hex.length() == 1) { 10 | hex = '0' + hex; 11 | } 12 | returnValue.append(hex.toUpperCase() + " "); 13 | } 14 | 15 | return "[" + returnValue.toString() + "]"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /openzaly-connector/src/main/resources/chatchrome1.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sengeiou/openzaly/6f53ac993f2e1e5f85d76a529f1f1e29aa947fa5/openzaly-connector/src/main/resources/chatchrome1.jks -------------------------------------------------------------------------------- /openzaly-connector/src/test/java/com/zaly/test/HttpTestPost.java: -------------------------------------------------------------------------------- 1 | package com.zaly.test; 2 | 3 | import java.io.IOException; 4 | 5 | import com.squareup.okhttp.MediaType; 6 | import com.squareup.okhttp.OkHttpClient; 7 | import com.squareup.okhttp.Request; 8 | import com.squareup.okhttp.RequestBody; 9 | import com.squareup.okhttp.Response; 10 | 11 | public class HttpTestPost { 12 | public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); 13 | static OkHttpClient client = new OkHttpClient(); 14 | 15 | static String post(String url, String json) throws IOException { 16 | RequestBody body = RequestBody.create(JSON, json); 17 | Request request = new Request.Builder().url(url).post(body).build(); 18 | Response response = client.newCall(request).execute(); 19 | System.out.println("response = " + response.isSuccessful()); 20 | if (response.isSuccessful()) { 21 | return response.body().string(); 22 | } else { 23 | throw new IOException("Unexpected code " + response); 24 | } 25 | } 26 | 27 | public static void main(String args[]) { 28 | String url = "http://119.27.185.209:516/siteMember/applyAddFriend"; 29 | try { 30 | post(url, "hello"); 31 | } catch (IOException e) { 32 | // TODO Auto-generated catch block 33 | e.printStackTrace(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /openzaly-connector/src/test/java/com/zaly/test/WSTest.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sengeiou/openzaly/6f53ac993f2e1e5f85d76a529f1f1e29aa947fa5/openzaly-connector/src/test/java/com/zaly/test/WSTest.java -------------------------------------------------------------------------------- /openzaly-message/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /openzaly-message/src/main/java/com/akaxin/site/message/api/IMessageService.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.message.api; 2 | 3 | import com.akaxin.common.command.Command; 4 | 5 | public interface IMessageService { 6 | public boolean execute(Command command); 7 | } 8 | -------------------------------------------------------------------------------- /openzaly-message/src/main/java/com/akaxin/site/message/bean/WebBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.message.bean; 2 | 3 | import com.akaxin.common.utils.GsonUtils; 4 | 5 | public class WebBean { 6 | private String webCode; 7 | private int width; 8 | private int height; 9 | private String hrefUrl;// 点击跳转链接 10 | 11 | public String getWebCode() { 12 | return webCode; 13 | } 14 | 15 | public void setWebCode(String webCode) { 16 | this.webCode = webCode; 17 | } 18 | 19 | public int getWidth() { 20 | return width; 21 | } 22 | 23 | public void setWidth(int width) { 24 | this.width = width; 25 | } 26 | 27 | public int getHeight() { 28 | return height; 29 | } 30 | 31 | public void setHeight(int height) { 32 | this.height = height; 33 | } 34 | 35 | public String getHrefUrl() { 36 | return hrefUrl; 37 | } 38 | 39 | public void setHrefUrl(String hrefUrl) { 40 | this.hrefUrl = hrefUrl; 41 | } 42 | 43 | public String toString() { 44 | return GsonUtils.toJson(this); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /openzaly-message/src/main/java/com/akaxin/site/message/dao/ImUserSessionDao.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.message.dao; 17 | 18 | import java.sql.SQLException; 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | import com.akaxin.site.storage.api.IUserSessionDao; 26 | import com.akaxin.site.storage.service.UserSessionDaoService; 27 | 28 | public class ImUserSessionDao { 29 | private static final Logger logger = LoggerFactory.getLogger(ImUserSessionDao.class); 30 | private static ImUserSessionDao instance = new ImUserSessionDao(); 31 | private IUserSessionDao userSessionDao = new UserSessionDaoService(); 32 | 33 | public static ImUserSessionDao getInstance() { 34 | return instance; 35 | } 36 | 37 | public List getSessionDevices(String siteUserId) { 38 | List sessionDevices = new ArrayList(); 39 | try { 40 | sessionDevices = userSessionDao.getSessionDeivceIds(siteUserId); 41 | } catch (SQLException e) { 42 | logger.error("get session devices error.", e); 43 | } 44 | return sessionDevices; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /openzaly-message/src/main/java/com/akaxin/site/message/dao/SessionDeviceDao.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.message.dao; 17 | 18 | import java.sql.SQLException; 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | import com.akaxin.site.storage.api.IUserSessionDao; 26 | import com.akaxin.site.storage.service.UserSessionDaoService; 27 | 28 | /** 29 | * 30 | * 从session表中,获取在先的设备 31 | * 32 | * @author Sam{@link an.guoyue254@gmail.com} 33 | * @since 2018-04-03 19:12:44 34 | */ 35 | public class SessionDeviceDao { 36 | private static final Logger logger = LoggerFactory.getLogger(SessionDeviceDao.class); 37 | private static SessionDeviceDao instance = new SessionDeviceDao(); 38 | private IUserSessionDao userSessionDao = new UserSessionDaoService(); 39 | 40 | public static SessionDeviceDao getInstance() { 41 | return instance; 42 | } 43 | 44 | public List getSessionDevices(String siteUserId) { 45 | List sessionDevices = new ArrayList(); 46 | try { 47 | sessionDevices = userSessionDao.getSessionDeivceIds(siteUserId); 48 | } catch (SQLException e) { 49 | logger.error("get devices from session error.siteUserId={}", siteUserId); 50 | } 51 | return sessionDevices; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /openzaly-message/src/main/java/com/akaxin/site/message/dao/SiteConfigDao.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.message.dao; 17 | 18 | import java.sql.SQLException; 19 | import java.util.Map; 20 | 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | import com.akaxin.site.storage.api.ISiteConfigDao; 25 | import com.akaxin.site.storage.service.SiteConfigDaoService; 26 | 27 | /** 28 | * 站点配置相关操作 29 | * 30 | * @author Sam{@link an.guoyue254@gmail.com} 31 | * @since 2018-01-24 19:16:06 32 | */ 33 | public class SiteConfigDao { 34 | private static final Logger logger = LoggerFactory.getLogger(SiteConfigDao.class); 35 | 36 | private SiteConfigDao() { 37 | } 38 | 39 | public static SiteConfigDao getInstance() { 40 | return SingletonHolder.instance; 41 | } 42 | 43 | static class SingletonHolder { 44 | private static SiteConfigDao instance = new SiteConfigDao(); 45 | } 46 | 47 | private ISiteConfigDao siteConfigDao = new SiteConfigDaoService(); 48 | 49 | public Map getSiteConfig() { 50 | try { 51 | return siteConfigDao.getSiteConfig(); 52 | } catch (SQLException e) { 53 | logger.error("get site profile error.", e); 54 | } 55 | return null; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /openzaly-message/src/main/java/com/akaxin/site/message/notice/handler/AbstractNoticeHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.message.notice.handler; 17 | 18 | import com.akaxin.common.executor.chain.handler.IHandler; 19 | 20 | public abstract class AbstractNoticeHandler implements IHandler { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /openzaly-message/src/main/java/com/akaxin/site/message/service/ImMessageService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.message.service; 17 | 18 | import com.akaxin.common.command.Command; 19 | import com.akaxin.site.message.api.IMessageService; 20 | 21 | /** 22 | * 负责接受所有从connector下来的业务请求,请负责分发 23 | * 24 | * @author Sam 25 | * 26 | */ 27 | public class ImMessageService implements IMessageService { 28 | 29 | public boolean execute(Command command) { 30 | return MessageDispatcher.dispatch(command); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /openzaly-message/src/main/java/com/akaxin/site/message/threads/MultiPushThreadExecutor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.message.threads; 17 | 18 | import java.util.concurrent.Executor; 19 | import java.util.concurrent.LinkedBlockingQueue; 20 | import java.util.concurrent.ThreadPoolExecutor; 21 | import java.util.concurrent.TimeUnit; 22 | 23 | /** 24 | * 多线程push发送处理器 25 | * 26 | * @author Sam{@link an.guoyue254@gmail.com} 27 | * @since 2018-01-27 20:34:25 28 | */ 29 | public class MultiPushThreadExecutor { 30 | /** 31 | *
32 | 	 * int corePoolSize = 5
33 | 	 * int maximumPoolSize=(n+1)*5 
34 | 	 * long keepAliveTime=10 
35 | 	 * TimeUnit unit=S
36 | 	 * BlockingQueue workQueue
37 | 	 * 
38 | */ 39 | private static int maxThreadNum = (Runtime.getRuntime().availableProcessors() + 1) * 5; 40 | private static Executor threadPoolExecutor = new ThreadPoolExecutor(5, maxThreadNum, 10, TimeUnit.SECONDS, 41 | new LinkedBlockingQueue()); 42 | 43 | private MultiPushThreadExecutor() { 44 | } 45 | 46 | public static Executor getExecutor() { 47 | return threadPoolExecutor; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /openzaly-message/src/main/java/com/akaxin/site/message/utils/HexUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.message.utils; 17 | 18 | public class HexUtils { 19 | 20 | public static String printHexString(byte[] b) { 21 | StringBuffer returnValue = new StringBuffer(); 22 | for (int i = 0; i < b.length; i++) { 23 | String hex = Integer.toHexString(b[i] & 0xFF); 24 | if (hex.length() == 1) { 25 | hex = '0' + hex; 26 | } 27 | returnValue.append(hex.toUpperCase() + " "); 28 | } 29 | 30 | return "[" + returnValue.toString() + "]"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /openzaly-message/src/main/java/com/akaxin/site/message/utils/NumUtils.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.message.utils; 2 | 3 | public class NumUtils { 4 | 5 | public static long getMax(long num1, long num2) { 6 | return num1 > num2 ? num1 : num2; 7 | } 8 | 9 | public static long getMax(int num1, int num2) { 10 | return num1 > num2 ? num1 : num2; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /openzaly-message/src/main/java/com/akaxin/site/message/web/bean/WebGroupTextBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.message.web.bean; 2 | 3 | public class WebGroupTextBean { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /openzaly-message/src/main/java/com/akaxin/site/message/web/bean/WebResponseBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.message.web.bean; 2 | 3 | public class WebResponseBean { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /openzaly-message/src/main/java/com/akaxin/site/message/web/bean/WebU2TextBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.message.web.bean; 2 | 3 | public class WebU2TextBean { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /openzaly-message/src/main/resources/chatchrome1.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sengeiou/openzaly/6f53ac993f2e1e5f85d76a529f1f1e29aa947fa5/openzaly-message/src/main/resources/chatchrome1.jks -------------------------------------------------------------------------------- /openzaly-protobuf/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /openzaly-protobuf/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 18 | 4.0.0 19 | 20 | com.akaxin 21 | openzaly-parent 22 | 0.0.1 23 | 24 | com.akaxin.proto 25 | openzaly-protobuf 26 | 0.0.1-RELEASE 27 | 28 | 29 | UTF-8 30 | 3.4.0 31 | 32 | 1.8 33 | 1.8 34 | 35 | 36 | 37 | 38 | com.google.protobuf 39 | protobuf-java 40 | ${protobuf.version} 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /openzaly-storage/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/api/IFriendApplyDao.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.api; 2 | 3 | import java.sql.SQLException; 4 | import java.util.List; 5 | 6 | import com.akaxin.site.storage.bean.ApplyFriendBean; 7 | import com.akaxin.site.storage.bean.ApplyUserBean; 8 | 9 | public interface IFriendApplyDao { 10 | 11 | boolean saveApply(String siteUserId, String siteFriendId, String applyReason) throws SQLException; 12 | 13 | boolean deleteApply(String siteUserId, String siteFriendId) throws SQLException; 14 | 15 | int getApplyCount(String siteUserId, String siteFriendId) throws SQLException; 16 | 17 | ApplyFriendBean getApplyInfo(String siteUserId, String siteFriendId, boolean isMaster) throws SQLException; 18 | 19 | List getApplyUsers(String siteUserId) throws SQLException; 20 | 21 | int getApplyCount(String siteUserId) throws SQLException; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/api/IGroupProfileDao.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.api; 2 | 3 | public interface IGroupProfileDao { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/api/IMessageDao.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.api; 2 | 3 | import java.sql.SQLException; 4 | import java.util.List; 5 | 6 | import com.akaxin.site.storage.bean.GroupMessageBean; 7 | import com.akaxin.site.storage.bean.U2MessageBean; 8 | 9 | /** 10 | * 处理二人消息,群消息等 11 | * 12 | * @author Sam{@link an.guoyue254@gmail.com} 13 | * @since 2017-11-20 12:49:15 14 | */ 15 | public interface IMessageDao { 16 | // u2 message 17 | public boolean saveU2Message(U2MessageBean u2Bean) throws SQLException; 18 | 19 | public boolean updateU2Pointer(String id, String deviceId, long finish) throws SQLException; 20 | 21 | public List queryU2Message(String id, String deviceId, long start, long limit) throws SQLException; 22 | 23 | long queryU2Pointer(String userId, String deviceId) throws SQLException; 24 | 25 | long queryMaxU2Pointer(String userId) throws SQLException; 26 | 27 | long queryMaxU2MessageId(String userId) throws SQLException; 28 | 29 | List queryU2MessageByMsgId(List msgIds) throws SQLException; 30 | 31 | // group message 32 | public boolean saveGroupMessage(GroupMessageBean gmsgBean) throws SQLException; 33 | 34 | public List queryGroupMessage(String groupId, String userId, String deviceId, long start, 35 | int limit) throws SQLException; 36 | 37 | public long queryGroupMessagePointer(String groupId, String siteUserId, String deviceId) throws SQLException; 38 | 39 | public boolean updateGroupPointer(String gid, String userId, String deviceId, long finish) throws SQLException; 40 | 41 | public long queryMaxGroupPointer(String groupId) throws SQLException; 42 | 43 | public long queryMaxUserGroupPointer(String groupId, String siteUserId) throws SQLException; 44 | 45 | List queryGroupMesageByMsgId(List msgIds) throws SQLException; 46 | 47 | // manager 48 | public int queryU2MessagePerDay(long now, int day) throws SQLException; 49 | 50 | boolean delUserMessage(String siteUserId) throws SQLException; 51 | 52 | List queryMessageFile(String siteUserId) throws SQLException; 53 | } -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/api/IPluginDao.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.api; 2 | 3 | import java.sql.SQLException; 4 | import java.util.List; 5 | 6 | import com.akaxin.site.storage.bean.PluginBean; 7 | 8 | public interface IPluginDao { 9 | 10 | public boolean addPlugin(PluginBean bean) throws SQLException; 11 | 12 | public boolean updatePlugin(PluginBean bean) throws SQLException; 13 | 14 | public boolean deletePlugin(int pluginId) throws SQLException; 15 | 16 | public PluginBean getPluginProfile(int pluginId) throws SQLException; 17 | 18 | public List getPluginPageList(int pageNum, int pageSize, int position, int permissionStatus) 19 | throws SQLException; 20 | 21 | public List getPluginPageList(int pageNum, int pageSize, int position) throws SQLException; 22 | 23 | public List getAllPluginList(int pageNum, int pageSize) throws SQLException; 24 | 25 | String reSetAuthKey(int pluginId) throws SQLException; 26 | } 27 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/api/ISiteConfigDao.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.api; 2 | 3 | import java.sql.SQLException; 4 | import java.util.Map; 5 | 6 | public interface ISiteConfigDao { 7 | Map getSiteConfig() throws SQLException; 8 | 9 | String getSiteConfigValue(int key) throws SQLException; 10 | 11 | int updateSiteConfig(Map configMap, boolean isAdmin) throws SQLException; 12 | 13 | int updateSiteConfig(int key, String value) throws SQLException; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/api/ISiteUsersDao.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.api; 2 | 3 | import java.sql.SQLException; 4 | import java.util.List; 5 | 6 | public interface ISiteUsersDao { 7 | 8 | public List getSiteUserByPage(int pageNum, int pageSize) throws SQLException; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/api/ITokenDao.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.api; 2 | 3 | import java.sql.SQLException; 4 | 5 | import com.akaxin.site.storage.bean.ExpireToken; 6 | 7 | public interface ITokenDao { 8 | 9 | boolean addToken(ExpireToken bean) throws SQLException; 10 | 11 | ExpireToken getExpireToken(String token) throws SQLException; 12 | 13 | ExpireToken getExpireTokenByBid(String bid, long time) throws SQLException; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/api/IUicDao.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.api; 2 | 3 | import java.sql.SQLException; 4 | import java.util.List; 5 | 6 | import com.akaxin.site.storage.bean.UicBean; 7 | 8 | public interface IUicDao { 9 | 10 | public boolean addUic(UicBean bean) throws SQLException; 11 | 12 | public boolean batchAddUic(UicBean bean, int num, int length) throws SQLException; 13 | 14 | public boolean updateUic(UicBean bean) throws SQLException; 15 | 16 | public UicBean getUicInfo(String uic) throws SQLException; 17 | 18 | public List getUicPageList(int pageNum, int pageSize, int status) throws SQLException; 19 | 20 | List getAllUicPageList(int pageNum, int pageSize) throws SQLException; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/api/IUserDeviceDao.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.api; 2 | 3 | import java.sql.SQLException; 4 | import java.util.List; 5 | 6 | import com.akaxin.site.storage.bean.UserDeviceBean; 7 | 8 | public interface IUserDeviceDao { 9 | 10 | boolean saveUserDevice(UserDeviceBean bean) throws SQLException; 11 | 12 | boolean updateUserDevice(UserDeviceBean bean) throws SQLException; 13 | 14 | boolean updateActiveTime(String siteUserId, String deviceId) throws SQLException; 15 | 16 | public UserDeviceBean getDeviceDetails(String siteUserId, String deviceId) throws SQLException; 17 | 18 | public String getDeviceId(String siteUserId, String devicePuk) throws SQLException; 19 | 20 | public UserDeviceBean getLatestDevice(String siteUserId) throws SQLException; 21 | 22 | public List getUserDeviceList(String siteUserId) throws SQLException; 23 | 24 | public List getActiveDeviceList(String siteUserId) throws SQLException; 25 | 26 | public List getUserTokens(String siteUserId) throws SQLException; 27 | 28 | public int limitDeviceNum(String siteUserId, int limit) throws SQLException; 29 | 30 | boolean delDevice(String siteUserId)throws SQLException; 31 | } 32 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/api/IUserFriendDao.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.api; 2 | 3 | import java.sql.SQLException; 4 | import java.util.List; 5 | 6 | import com.akaxin.site.storage.bean.SimpleUserBean; 7 | import com.akaxin.site.storage.bean.UserFriendBean; 8 | 9 | public interface IUserFriendDao { 10 | 11 | public int getUserFriendNum(String siteUserId) throws SQLException; 12 | 13 | public List getUserFriends(String userId) throws SQLException; 14 | 15 | public List getUserFriendsByPage(String siteUserId, int pageNum, int pageSize) throws SQLException; 16 | 17 | boolean saveRelation(String siteUserId, String siteFriendId, int relation) throws SQLException; 18 | 19 | int queryRelation(String siteUserId, String siteFriendId) throws SQLException; 20 | 21 | boolean queryIsFriendRelation(String siteUserId, String siteFriendId, boolean isMaster) throws SQLException; 22 | 23 | boolean deleteRelation(String siteUserId, String siteFriendId) throws SQLException; 24 | 25 | boolean updateRelation(String siteUserId, String siteFriendId, int relation) throws SQLException; 26 | 27 | public UserFriendBean getFriendSetting(String siteUserId, String siteFriendId) throws SQLException; 28 | 29 | public boolean updateFriendSetting(String siteUserId, UserFriendBean bean) throws SQLException; 30 | 31 | public boolean isMute(String siteUserId, String siteFriendId) throws SQLException; 32 | 33 | public boolean updateMute(String siteUserId, String siteFriendId, boolean mute) throws SQLException; 34 | 35 | public boolean remarkFriend(String siteUserId, String siteFriendId, String aliasName, String aliasInLatin) 36 | throws SQLException; 37 | 38 | public int friendNum(long now, int day) throws SQLException; 39 | 40 | boolean delUserFriend(String siteUserId) throws SQLException; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/api/IUserGroupDao.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.api; 2 | 3 | import java.sql.SQLException; 4 | import java.util.List; 5 | 6 | import com.akaxin.site.storage.bean.UserGroupBean; 7 | 8 | public interface IUserGroupDao { 9 | 10 | List checkGroupMember(String siteGroupId, List userIds) throws SQLException; 11 | 12 | UserGroupBean getUserGroupSetting(String siteUserId, String siteGroupId) throws SQLException; 13 | 14 | boolean updateUserGroupSetting(String siteUserId, UserGroupBean bean) throws SQLException; 15 | 16 | public boolean isMute(String siteUserId, String siteGroupId) throws SQLException; 17 | 18 | public boolean updateMute(String siteUserId, String siteGroupId, boolean mute) throws SQLException; 19 | 20 | public int queryGroupMessagePerDay(long now, int day) throws SQLException; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/api/IUserSessionDao.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.api; 2 | 3 | import java.sql.SQLException; 4 | import java.util.List; 5 | 6 | import com.akaxin.site.storage.bean.SimpleAuthBean; 7 | import com.akaxin.site.storage.bean.UserSessionBean; 8 | 9 | public interface IUserSessionDao { 10 | public boolean saveUserSession(UserSessionBean bean) throws SQLException; 11 | 12 | public boolean onlineSession(String siteUserId, String deviceId) throws SQLException; 13 | 14 | public boolean offlineSession(String siteUserId, String deviceId) throws SQLException; 15 | 16 | public SimpleAuthBean getUserSession(String sessionId) throws SQLException; 17 | 18 | public List getSessionDeivceIds(String userId) throws SQLException; 19 | 20 | public boolean deleteUserSession(String siteUserId, String deviceId) throws SQLException; 21 | } 22 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/ApplyFriendBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | import com.akaxin.common.utils.GsonUtils; 4 | 5 | public class ApplyFriendBean { 6 | private String siteUserId; 7 | private String siteFriendId; 8 | private String applyInfo; 9 | private long applyTime; 10 | 11 | public String getSiteUserId() { 12 | return siteUserId; 13 | } 14 | 15 | public void setSiteUserId(String siteUserId) { 16 | this.siteUserId = siteUserId; 17 | } 18 | 19 | public String getSiteFriendId() { 20 | return siteFriendId; 21 | } 22 | 23 | public void setSiteFriendId(String siteFriendId) { 24 | this.siteFriendId = siteFriendId; 25 | } 26 | 27 | public String getApplyInfo() { 28 | return applyInfo; 29 | } 30 | 31 | public void setApplyInfo(String applyInfo) { 32 | this.applyInfo = applyInfo; 33 | } 34 | 35 | public long getApplyTime() { 36 | return applyTime; 37 | } 38 | 39 | public void setApplyTime(long applyTime) { 40 | this.applyTime = applyTime; 41 | } 42 | 43 | public String toString() { 44 | return GsonUtils.toJson(this); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/ApplyUserBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | public class ApplyUserBean extends SimpleUserBean { 4 | 5 | private String applyReason; 6 | private long applyTime; 7 | 8 | public String getApplyReason() { 9 | return applyReason; 10 | } 11 | 12 | public void setApplyReason(String applyReason) { 13 | this.applyReason = applyReason; 14 | } 15 | 16 | public long getApplyTime() { 17 | return applyTime; 18 | } 19 | 20 | public void setApplyTime(long applyTime) { 21 | this.applyTime = applyTime; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/GroupMemberBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | /** 4 | * 群成员bean 5 | * 6 | * @author Sam 7 | * @since 2017.10.25 8 | * 9 | */ 10 | public class GroupMemberBean extends SimpleUserBean { 11 | private int userRole; 12 | 13 | public int getUserRole() { 14 | return userRole; 15 | } 16 | 17 | public void setUserRole(int userRole) { 18 | this.userRole = userRole; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/GroupMessageBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | import com.akaxin.common.utils.GsonUtils; 4 | 5 | public class GroupMessageBean { 6 | private int id; 7 | private String siteGroupId; 8 | private String msgId; 9 | private String sendUserId; 10 | private String sendDeviceId; 11 | private int msgType; 12 | private String content; 13 | private long msgTime; 14 | 15 | public int getId() { 16 | return id; 17 | } 18 | 19 | public void setId(int id) { 20 | this.id = id; 21 | } 22 | 23 | public String getSiteGroupId() { 24 | return siteGroupId; 25 | } 26 | 27 | public void setSiteGroupId(String siteGroupId) { 28 | this.siteGroupId = siteGroupId; 29 | } 30 | 31 | public String getMsgId() { 32 | return msgId; 33 | } 34 | 35 | public void setMsgId(String msgId) { 36 | this.msgId = msgId; 37 | } 38 | 39 | public String getSendUserId() { 40 | return sendUserId; 41 | } 42 | 43 | public void setSendUserId(String sendUserId) { 44 | this.sendUserId = sendUserId; 45 | } 46 | 47 | public String getSendDeviceId() { 48 | return sendDeviceId; 49 | } 50 | 51 | public void setSendDeviceId(String sendDeviceId) { 52 | this.sendDeviceId = sendDeviceId; 53 | } 54 | 55 | public int getMsgType() { 56 | return msgType; 57 | } 58 | 59 | public void setMsgType(int msgType) { 60 | this.msgType = msgType; 61 | } 62 | 63 | public String getContent() { 64 | return content; 65 | } 66 | 67 | public void setContent(String content) { 68 | this.content = content; 69 | } 70 | 71 | public long getMsgTime() { 72 | return msgTime; 73 | } 74 | 75 | public void setMsgTime(long msgTime) { 76 | this.msgTime = msgTime; 77 | } 78 | 79 | public String toString() { 80 | return GsonUtils.toJson(this); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/MonitorBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | public class MonitorBean { 4 | private int registerNum; 5 | private int messageNum; 6 | private int groupMsgNum; 7 | private int u2MsgNum; 8 | private int userNum; 9 | private int groupNum; 10 | private int friendNum; 11 | 12 | public MonitorBean(int registerNum, int messageNum, int groupMsgNum, int u2MsgNum, int userNum, int groupNum, int friendNum) { 13 | this.registerNum = registerNum; 14 | this.messageNum = messageNum; 15 | this.groupMsgNum = groupMsgNum; 16 | this.u2MsgNum = u2MsgNum; 17 | this.userNum = userNum; 18 | this.groupNum = groupNum; 19 | this.friendNum = friendNum; 20 | } 21 | public MonitorBean() {} 22 | 23 | public int getRegisterNum() { 24 | return registerNum; 25 | } 26 | 27 | public void setRegisterNum(int registerNum) { 28 | this.registerNum = registerNum; 29 | } 30 | 31 | public int getMessageNum() { 32 | return messageNum; 33 | } 34 | 35 | public void setMessageNum(int messageNum) { 36 | this.messageNum = messageNum; 37 | } 38 | 39 | public int getGroupMsgNum() { 40 | return groupMsgNum; 41 | } 42 | 43 | public void setGroupMsgNum(int groupMsgNum) { 44 | this.groupMsgNum = groupMsgNum; 45 | } 46 | 47 | public int getU2MsgNum() { 48 | return u2MsgNum; 49 | } 50 | 51 | public void setU2MsgNum(int u2MsgNum) { 52 | this.u2MsgNum = u2MsgNum; 53 | } 54 | 55 | public int getUserNum() { 56 | return userNum; 57 | } 58 | 59 | public void setUserNum(int userNum) { 60 | this.userNum = userNum; 61 | } 62 | 63 | public int getGroupNum() { 64 | return groupNum; 65 | } 66 | 67 | public void setGroupNum(int groupNum) { 68 | this.groupNum = groupNum; 69 | } 70 | 71 | public int getFriendNum() { 72 | return friendNum; 73 | } 74 | 75 | public void setFriendNum(int friendNum) { 76 | this.friendNum = friendNum; 77 | } 78 | 79 | public MonitorBean(int registerNum) { 80 | 81 | this.registerNum = registerNum; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/SimpleAuthBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | import com.akaxin.common.utils.GsonUtils; 4 | 5 | public class SimpleAuthBean { 6 | private String siteUserId; 7 | private String deviceId; 8 | 9 | public String getSiteUserId() { 10 | return siteUserId; 11 | } 12 | 13 | public void setSiteUserId(String siteUserId) { 14 | this.siteUserId = siteUserId; 15 | } 16 | 17 | public String getDeviceId() { 18 | return deviceId; 19 | } 20 | 21 | public void setDeviceId(String deviceId) { 22 | this.deviceId = deviceId; 23 | } 24 | 25 | public String toString() { 26 | return GsonUtils.toJson(this); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/SimpleGroupBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | import com.akaxin.common.utils.GsonUtils; 4 | 5 | /** 6 | * 群对象简单bean 7 | * 8 | * @author Sam 9 | * @since 2017.10.25 10 | * 11 | */ 12 | public class SimpleGroupBean { 13 | 14 | private String groupId; 15 | private String groupName; 16 | private String groupPhoto; 17 | 18 | public String getGroupId() { 19 | return groupId; 20 | } 21 | 22 | public void setGroupId(String groupId) { 23 | this.groupId = groupId; 24 | } 25 | 26 | public String getGroupName() { 27 | return groupName; 28 | } 29 | 30 | public void setGroupName(String groupName) { 31 | this.groupName = groupName; 32 | } 33 | 34 | public String getGroupPhoto() { 35 | return groupPhoto; 36 | } 37 | 38 | public void setGroupPhoto(String groupPhoto) { 39 | this.groupPhoto = groupPhoto; 40 | } 41 | 42 | public String toString() { 43 | return GsonUtils.toJson(this); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/SimpleUserRelationBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | /** 4 | * 当前用户siteUserId,与继承的用户userId,之间的用户关系 5 | * 6 | * @author Sam{@link an.guoyue254@gmail.com} 7 | * @since 2017-12-27 15:18:45 8 | */ 9 | public class SimpleUserRelationBean extends SimpleUserBean { 10 | 11 | private String siteUserId; 12 | private int relation; 13 | 14 | public String getSiteUserId() { 15 | return siteUserId; 16 | } 17 | 18 | public void setSiteUserId(String siteUserId) { 19 | this.siteUserId = siteUserId; 20 | } 21 | 22 | public int getRelation() { 23 | return relation; 24 | } 25 | 26 | public void setRelation(int relation) { 27 | this.relation = relation; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/SiteConfigBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | public class SiteConfigBean { 4 | private String siteIp; 5 | private int sitePort; 6 | private String siteName; 7 | private String siteIcon; 8 | private String siteInstructions; 9 | 10 | public String getSiteIp() { 11 | return siteIp; 12 | } 13 | 14 | public void setSiteIp(String siteIp) { 15 | this.siteIp = siteIp; 16 | } 17 | 18 | public int getSitePort() { 19 | return sitePort; 20 | } 21 | 22 | public void setSitePort(int sitePort) { 23 | this.sitePort = sitePort; 24 | } 25 | 26 | public String getSiteName() { 27 | return siteName; 28 | } 29 | 30 | public void setSiteName(String siteName) { 31 | this.siteName = siteName; 32 | } 33 | 34 | public String getSiteIcon() { 35 | return siteIcon; 36 | } 37 | 38 | public void setSiteIcon(String siteIcon) { 39 | this.siteIcon = siteIcon; 40 | } 41 | 42 | public String getSiteInstructions() { 43 | return siteInstructions; 44 | } 45 | 46 | public void setSiteInstructions(String siteInstructions) { 47 | this.siteInstructions = siteInstructions; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/UicBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | import com.akaxin.common.utils.GsonUtils; 4 | 5 | /** 6 | * 用户注册/登陆站点,需要使用的邀请码 7 | * 8 | * @author Sam{@link an.guoyue254@gmail.com} 9 | * @since 2018-01-12 15:03:42 10 | */ 11 | public class UicBean { 12 | private int id; 13 | private String uic; 14 | private String siteUserId; 15 | private String userName; 16 | private int status; 17 | private long createTime; 18 | private long useTime; 19 | 20 | public int getId() { 21 | return id; 22 | } 23 | 24 | public void setId(int id) { 25 | this.id = id; 26 | } 27 | 28 | public String getUic() { 29 | return uic; 30 | } 31 | 32 | public void setUic(String uic) { 33 | this.uic = uic; 34 | } 35 | 36 | public String getSiteUserId() { 37 | return siteUserId; 38 | } 39 | 40 | public void setSiteUserId(String siteUserId) { 41 | this.siteUserId = siteUserId; 42 | } 43 | 44 | public int getStatus() { 45 | return status; 46 | } 47 | 48 | public void setStatus(int status) { 49 | this.status = status; 50 | } 51 | 52 | public String getUserName() { 53 | return userName; 54 | } 55 | 56 | public void setUserName(String userName) { 57 | this.userName = userName; 58 | } 59 | 60 | public long getCreateTime() { 61 | return createTime; 62 | } 63 | 64 | public void setCreateTime(long createTime) { 65 | this.createTime = createTime; 66 | } 67 | 68 | public long getUseTime() { 69 | return useTime; 70 | } 71 | 72 | public void setUseTime(long useTime) { 73 | this.useTime = useTime; 74 | } 75 | 76 | public String toString() { 77 | return GsonUtils.toJson(this); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/UserDeviceBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | import com.akaxin.common.utils.GsonUtils; 4 | 5 | /** 6 | * 用户设备信息 7 | * 8 | * @author Sam{@link an.guoyue254@gmail.com} 9 | * @since 2017.10.21 10 | */ 11 | public class UserDeviceBean { 12 | private String siteUserId; 13 | private String deviceId; 14 | private String userDevicePubk; 15 | private String deviceName; 16 | private String deviceIp; 17 | private String userToken; 18 | private long loginTime; 19 | private long activeTime; 20 | private long addTime; 21 | 22 | public String getSiteUserId() { 23 | return siteUserId; 24 | } 25 | 26 | public void setSiteUserId(String siteUserId) { 27 | this.siteUserId = siteUserId; 28 | } 29 | 30 | public String getDeviceId() { 31 | return deviceId; 32 | } 33 | 34 | public void setDeviceId(String deviceId) { 35 | this.deviceId = deviceId; 36 | } 37 | 38 | public String getUserDevicePubk() { 39 | return userDevicePubk; 40 | } 41 | 42 | public void setUserDevicePubk(String userDevicePubk) { 43 | this.userDevicePubk = userDevicePubk; 44 | } 45 | 46 | public String getDeviceName() { 47 | return deviceName; 48 | } 49 | 50 | public void setDeviceName(String deviceName) { 51 | this.deviceName = deviceName; 52 | } 53 | 54 | public long getLoginTime() { 55 | return loginTime; 56 | } 57 | 58 | public void setLoginTime(long loginTime) { 59 | this.loginTime = loginTime; 60 | } 61 | 62 | public String getDeviceIp() { 63 | return deviceIp; 64 | } 65 | 66 | public void setDeviceIp(String deviceIp) { 67 | this.deviceIp = deviceIp; 68 | } 69 | 70 | public String getUserToken() { 71 | return userToken; 72 | } 73 | 74 | public void setUserToken(String userToken) { 75 | this.userToken = userToken; 76 | } 77 | 78 | public long getActiveTime() { 79 | return activeTime; 80 | } 81 | 82 | public void setActiveTime(long activeTime) { 83 | this.activeTime = activeTime; 84 | } 85 | 86 | public long getAddTime() { 87 | return addTime; 88 | } 89 | 90 | public void setAddTime(long addTime) { 91 | this.addTime = addTime; 92 | } 93 | 94 | public String toString() { 95 | return GsonUtils.toJson(this); 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/UserFriendBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | import com.akaxin.common.utils.GsonUtils; 4 | 5 | public class UserFriendBean extends UserProfileBean { 6 | private boolean mute;// 是否对该用户设置消息免打扰 7 | 8 | public boolean isMute() { 9 | return mute; 10 | } 11 | 12 | public void setMute(boolean mute) { 13 | this.mute = mute; 14 | } 15 | 16 | public String toString() { 17 | return GsonUtils.toJson(this); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/UserGroupBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | import com.akaxin.common.utils.GsonUtils; 4 | 5 | /** 6 | * 用户对应群的bean 7 | * 8 | * @author anguoyue 9 | * 10 | */ 11 | public class UserGroupBean { 12 | private String id; 13 | private String siteUserId; 14 | private String siteGroupId; 15 | private String userRole; 16 | private String tsKey; 17 | private String deviceId; 18 | private boolean mute; 19 | private long addTime; 20 | 21 | public String getId() { 22 | return id; 23 | } 24 | 25 | public void setId(String id) { 26 | this.id = id; 27 | } 28 | 29 | public String getSiteUserId() { 30 | return siteUserId; 31 | } 32 | 33 | public void setSiteUserId(String siteUserId) { 34 | this.siteUserId = siteUserId; 35 | } 36 | 37 | public String getSiteGroupId() { 38 | return siteGroupId; 39 | } 40 | 41 | public void setSiteGroupId(String siteGroupId) { 42 | this.siteGroupId = siteGroupId; 43 | } 44 | 45 | public String getUserRole() { 46 | return userRole; 47 | } 48 | 49 | public void setUserRole(String userRole) { 50 | this.userRole = userRole; 51 | } 52 | 53 | public String getTsKey() { 54 | return tsKey; 55 | } 56 | 57 | public void setTsKey(String tsKey) { 58 | this.tsKey = tsKey; 59 | } 60 | 61 | public String getDeviceId() { 62 | return deviceId; 63 | } 64 | 65 | public void setDeviceId(String deviceId) { 66 | this.deviceId = deviceId; 67 | } 68 | 69 | public long getAddTime() { 70 | return addTime; 71 | } 72 | 73 | public void setAddTime(long addTime) { 74 | this.addTime = addTime; 75 | } 76 | 77 | public boolean isMute() { 78 | return mute; 79 | } 80 | 81 | public void setMute(boolean mute) { 82 | this.mute = mute; 83 | } 84 | 85 | public String toString() { 86 | return GsonUtils.toJson(this); 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/bean/UserSessionBean.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.bean; 2 | 3 | import com.akaxin.common.utils.GsonUtils; 4 | 5 | public class UserSessionBean { 6 | private String siteUserId; 7 | private String sessionId; 8 | private boolean online; 9 | private String deviceId; 10 | private long loginTime; 11 | 12 | public String getSiteUserId() { 13 | return siteUserId; 14 | } 15 | 16 | public void setSiteUserId(String siteUserId) { 17 | this.siteUserId = siteUserId; 18 | } 19 | 20 | public String getSessionId() { 21 | return sessionId; 22 | } 23 | 24 | public void setSessionId(String sessionId) { 25 | this.sessionId = sessionId; 26 | } 27 | 28 | public boolean isOnline() { 29 | return online; 30 | } 31 | 32 | public void setOnline(boolean online) { 33 | this.online = online; 34 | } 35 | 36 | public String getDeviceId() { 37 | return deviceId; 38 | } 39 | 40 | public void setDeviceId(String deviceId) { 41 | this.deviceId = deviceId; 42 | } 43 | 44 | public long getLoginTime() { 45 | return loginTime; 46 | } 47 | 48 | public void setLoginTime(long loginTime) { 49 | this.loginTime = loginTime; 50 | } 51 | 52 | public String toString() { 53 | return GsonUtils.toJson(this); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/dao/config/DBType.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.dao.config; 2 | 3 | public enum DBType { 4 | PERSONAL(1, "personal"), // sqlite 5 | TEAM(2, "team"); 6 | 7 | private int index; 8 | private String name; 9 | 10 | DBType(int index, String name) { 11 | this.index = index; 12 | this.name = name; 13 | } 14 | 15 | public String getName() { 16 | return this.name; 17 | } 18 | 19 | public static DBType getDBType(String name) { 20 | for (DBType db : DBType.values()) { 21 | if (db.getName().equalsIgnoreCase(name)) { 22 | return db; 23 | } 24 | } 25 | return PERSONAL; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/dao/config/JdbcConst.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.dao.config; 2 | 3 | /** 4 | * 数据库配置中的KEY 5 | * 6 | * @author Sam{@link an.guoyue254@gmail.com} 7 | * @since 2018-06-09 12:51:54 8 | */ 9 | public interface JdbcConst { 10 | 11 | String OPENZALY_EDITION = "openzaly.edition"; 12 | 13 | String SQLITE_URL = "openzaly.sqlite.url"; 14 | 15 | // ----------------------MASTER-------------------- 16 | String MYSQL_HOST = "openzaly.mysql.host"; 17 | String MYSQL_PORT = "openzaly.mysql.port"; 18 | String MYSQL_DB = "openzaly.mysql.database"; 19 | 20 | String MYSQL_USER_NAME = "openzaly.mysql.username"; 21 | String MYSQL_PASSWORD = "openzaly.mysql.password"; 22 | String MYSQL_INITIAL_SIZE = "openzaly.mysql.initial-size"; 23 | String MYSQL_MAX_SIZE = "openzaly.mysql.max-size"; 24 | String MYSQL_MAX_IDLE = "openzaly.mysql.max-idle"; 25 | 26 | String MYSQL_USE_UNICODE = "openzaly.mysql.useUnicode"; 27 | String MYSQL_CHARACTER_ENCODING = "openzaly.mysql.characterEncoding"; 28 | String MYSQL_VERIFY_SERVER_CERTIFICATE = "openzaly.mysql.verifyServerCertificate"; 29 | String MYSQL_USE_SSL = "openzaly.mysql.useSSL"; 30 | 31 | // ----------------------SLAVE-------------------- 32 | String MYSQL_SLAVE_HOST = "openzaly.mysql.slave.host"; 33 | String MYSQL_SLAVE_PORT = "openzaly.mysql.slave.port"; 34 | String MYSQL_SLAVE_DB = "openzaly.mysql.slave.database"; 35 | 36 | String MYSQL_SLAVE_USER_NAME = "openzaly.mysql.slave.username"; 37 | String MYSQL_SLAVE_PASSWORD = "openzaly.mysql.slave.password"; 38 | String MYSQL_SLAVE_INITIAL_SIZE = "openzaly.mysql.slave.initial-size"; 39 | String MYSQL_SLAVE_MAX_SIZE = "openzaly.mysql.slave.max-size"; 40 | String MYSQL_SLAVE_MAX_IDLE = "openzaly.mysql.slave.max-idle"; 41 | 42 | String MYSQL_SLAVE_USE_UNICODE = "openzaly.mysql.slave.useUnicode"; 43 | String MYSQL_SLAVE_CHARACTER_ENCODING = "openzaly.mysql.slave.characterEncoding"; 44 | String MYSQL_SLAVE_VERIFY_SERVER_CERTIFICATE = "openzaly.mysql.slave.verifyServerCertificate"; 45 | String MYSQL_SLAVE_USE_SSL = "openzaly.mysql.slave.useSSL"; 46 | } 47 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/dao/mysql/manager/C3P0PoolManager.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.dao.mysql.manager; 2 | 3 | import java.sql.SQLException; 4 | import java.util.Properties; 5 | 6 | import com.akaxin.site.storage.dao.config.JdbcConst; 7 | import com.akaxin.site.storage.util.SqlLog; 8 | import com.mchange.v2.c3p0.ComboPooledDataSource; 9 | 10 | /** 11 | * C3P0 主库配置管理 12 | * 13 | * @author Sam{@link an.guoyue254@gmail.com} 14 | * @since 2018-06-11 18:21:38 15 | */ 16 | public class C3P0PoolManager extends AbstractPoolManager { 17 | private static ComboPooledDataSource cpds; 18 | 19 | public static void initPool(Properties pro) throws Exception { 20 | String jdbcUrl = getJdbcUrl(pro); 21 | String userName = trimToNull(pro, JdbcConst.MYSQL_USER_NAME); 22 | String password = trimToNull(pro, JdbcConst.MYSQL_PASSWORD); 23 | 24 | cpds = new ComboPooledDataSource(); 25 | cpds.setDriverClass(MYSQL_JDBC_DRIVER); // loads the jdbc driver 26 | cpds.setJdbcUrl(jdbcUrl); 27 | cpds.setUser(userName); 28 | cpds.setPassword(password); 29 | int inititalSize = Integer.valueOf(trimToNull(pro, JdbcConst.MYSQL_INITIAL_SIZE, "10")); 30 | int maxSize = Integer.valueOf(trimToNull(pro, JdbcConst.MYSQL_MAX_SIZE, "100")); 31 | cpds.setInitialPoolSize(inititalSize);// 初始创建默认10个连接 32 | cpds.setMaxPoolSize(maxSize);// 最大默认100个 33 | int inc = (maxSize - inititalSize) / 5; 34 | cpds.setAcquireIncrement(Integer.max(1, inc));// 每次创建10个 35 | 36 | int maxIdle = Integer.valueOf(trimToNull(pro, JdbcConst.MYSQL_MAX_IDLE, "60")); 37 | cpds.setMaxIdleTime(maxIdle);// 最大空闲时间 38 | 39 | SqlLog.info("openzaly init mysql master connection pool cpds={}", cpds); 40 | } 41 | 42 | public static java.sql.Connection getConnection() throws SQLException { 43 | return cpds.getConnection(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/dao/mysql/manager/MysqlManager.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.dao.mysql.manager; 2 | 3 | import java.sql.Connection; 4 | import java.sql.SQLException; 5 | import java.util.Properties; 6 | 7 | import com.akaxin.site.storage.exception.InitDatabaseException; 8 | import com.akaxin.site.storage.exception.NeedInitMysqlException; 9 | 10 | /** 11 | * Mysql 连接器管理 12 | * 13 | * @author Sam{@link an.guoyue254@gmail.com} 14 | * @since 2018-06-11 19:05:56 15 | */ 16 | public class MysqlManager { 17 | 18 | // 初始化数据库异常,会导致程序终端启动 19 | public static void initMysqlDB(Properties pro) throws InitDatabaseException, NeedInitMysqlException { 20 | try { 21 | // init db && table 22 | InitDatabaseConnection.init(pro); 23 | 24 | // init c3p0 pool 25 | C3P0PoolManager.initPool(pro); 26 | C3P0PoolSlaveManager.initPool(pro); 27 | } catch (Exception e) { 28 | throw new InitDatabaseException("init mysql database error", e); 29 | } finally { 30 | InitDatabaseConnection.closeInitConnection(); 31 | } 32 | 33 | } 34 | 35 | // 获取主库连接 36 | public static Connection getConnection() throws SQLException { 37 | return C3P0PoolManager.getConnection(); 38 | } 39 | 40 | // 获取从库连接 41 | public static Connection getSalveConnection() throws SQLException { 42 | return C3P0PoolSlaveManager.getConnection(); 43 | } 44 | 45 | // 释放资源 46 | public static void returnConnection(Connection conn) { 47 | C3P0PoolManager.returnConnection(conn); 48 | } 49 | 50 | public static String trimToNull(Properties pro, String key) { 51 | return C3P0PoolManager.trimToNull(pro, key); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/dao/sql/SQLConst.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.dao.sql; 2 | 3 | /** 4 | * SQLite中的表以及建表的SQL语句 5 | * 6 | * @author Sam{@link an.guoyue254@gmail.com} 7 | * @since 2017-12-13 17:35:52 8 | */ 9 | public interface SQLConst { 10 | 11 | int SITE_DB_VERSION_9 = 9;// 0.9.5 12 | 13 | int SITE_DB_VERSION_10 = 10;// 0.10.6 14 | 15 | int SITE_DB_VERSION_11 = 11;// 1.0.7 16 | 17 | String SITE_CONFIG_INFO = "site_config_info"; 18 | String SITE_USER_PROFILE = "site_user_profile"; 19 | String SITE_USER_SESSION = "site_user_session"; 20 | String SITE_USER_FRIEND = "site_user_friend"; 21 | String SITE_FRIEND_APPLY = "site_friend_apply"; 22 | String SITE_USER_MESSAGE = "site_user_message"; 23 | String SITE_MESSAGE_POINTER = "site_message_pointer"; 24 | String SITE_USER_GROUP = "site_user_group"; 25 | String SITE_GROUP_PROFILE = "site_group_profile"; 26 | String SITE_GROUP_MESSAGE = "site_group_message"; 27 | String SITE_GROUP_MESSAGE_POINTER = "site_group_message_pointer"; 28 | String SITE_USER_DEVICE = "site_user_device"; 29 | String SITE_PLUGIN_MANAGER = "site_plugin_manager"; 30 | String SITE_USER_UIC = "site_user_uic";// 用户邀请码存放信息表名称 31 | 32 | String SITE_EXPIRE_TOKEN = "site_expire_token"; 33 | } 34 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/dao/sqlite/manager/PluginArgs.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.dao.sqlite.manager; 2 | 3 | public interface PluginArgs { 4 | public String SITE_ADMIN_NAME = "管理后台"; 5 | 6 | public String FRIEND_SQUARE = "friendSquare"; 7 | public String FRIEND_SQUARE_NAME = "用户广场"; 8 | public String FRIEND_SQUARE_API = "/akaxin/userSquare/index"; 9 | } 10 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/exception/InitDatabaseException.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.exception; 2 | 3 | public class InitDatabaseException extends Throwable { 4 | 5 | /** 6 | * 7 | */ 8 | private static final long serialVersionUID = -893476933526596823L; 9 | 10 | public InitDatabaseException(String message) { 11 | super(message); 12 | } 13 | 14 | public InitDatabaseException(String message, Throwable t) { 15 | super(message, t); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/exception/MigrateDatabaseException.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.exception; 2 | 3 | import com.akaxin.common.utils.StringHelper; 4 | 5 | public class MigrateDatabaseException extends Throwable { 6 | 7 | /** 8 | * 9 | */ 10 | private static final long serialVersionUID = -893476933526596823L; 11 | 12 | public MigrateDatabaseException(String message) { 13 | super(message); 14 | } 15 | 16 | public MigrateDatabaseException(String message, Throwable t) { 17 | super(message, t); 18 | } 19 | 20 | public MigrateDatabaseException(Throwable t) { 21 | super(t); 22 | } 23 | 24 | public MigrateDatabaseException(String messagePattern, Object... objects) { 25 | this(StringHelper.format(messagePattern, objects)); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/exception/NeedInitMysqlException.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.exception; 2 | 3 | public class NeedInitMysqlException extends Throwable { 4 | 5 | /** 6 | * 7 | */ 8 | private static final long serialVersionUID = -893476933526596823L; 9 | 10 | public NeedInitMysqlException(String message) { 11 | super(message); 12 | } 13 | 14 | public NeedInitMysqlException(String message, Throwable t) { 15 | super(message, t); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/exception/UpgradeDatabaseException.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.exception; 2 | 3 | import com.akaxin.common.utils.StringHelper; 4 | 5 | /** 6 | * 迁移数据库错误会抛出此异常 7 | * 8 | * @author Sam{@link an.guoyue254@gmail.com} 9 | * @since 2018-06-14 19:06:40 10 | */ 11 | public class UpgradeDatabaseException extends Throwable { 12 | 13 | /** 14 | * 15 | */ 16 | private static final long serialVersionUID = -893476933526596823L; 17 | 18 | public UpgradeDatabaseException(String message) { 19 | super(message); 20 | } 21 | 22 | public UpgradeDatabaseException(String message, Throwable t) { 23 | super(message, t); 24 | } 25 | 26 | public UpgradeDatabaseException(String messagePattern, Object... objects) { 27 | this(StringHelper.format(messagePattern, objects)); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/service/SiteConfigDaoService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.storage.service; 17 | 18 | import java.sql.SQLException; 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | import com.akaxin.site.storage.api.ISiteConfigDao; 23 | import com.akaxin.site.storage.dao.SiteConfigDao; 24 | 25 | /** 26 | * @author Sam{@link an.guoyue254@gmail.com} 27 | * @since 2018-01-31 12:11:22 28 | */ 29 | public class SiteConfigDaoService implements ISiteConfigDao { 30 | 31 | @Override 32 | public Map getSiteConfig() throws SQLException { 33 | return SiteConfigDao.getInstance().queryConfig(); 34 | } 35 | 36 | @Override 37 | public String getSiteConfigValue(int key) throws SQLException { 38 | return SiteConfigDao.getInstance().queryConfigValue(key); 39 | } 40 | 41 | @Override 42 | public int updateSiteConfig(Map configMap, boolean isAdmin) throws SQLException { 43 | return SiteConfigDao.getInstance().updateConfig(configMap, isAdmin); 44 | } 45 | 46 | @Override 47 | public int updateSiteConfig(int key, String value) throws SQLException { 48 | return SiteConfigDao.getInstance().updateConfig(key, value); 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/service/SiteUsersDaoService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.storage.service; 17 | 18 | import java.sql.SQLException; 19 | import java.util.List; 20 | 21 | import com.akaxin.site.storage.api.ISiteUsersDao; 22 | import com.akaxin.site.storage.dao.SiteUsersDao; 23 | 24 | /** 25 | * 26 | * @author Sam{@link an.guoyue254@gmail.com} 27 | * @since 2018-01-31 12:11:03 28 | */ 29 | public class SiteUsersDaoService implements ISiteUsersDao { 30 | 31 | @Override 32 | public List getSiteUserByPage(int pageNum, int pageSize) throws SQLException { 33 | return SiteUsersDao.getInstance().querySiteUserId(pageNum, pageSize); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/service/TokenDaoService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.storage.service; 17 | 18 | import java.sql.SQLException; 19 | 20 | import com.akaxin.site.storage.api.ITokenDao; 21 | import com.akaxin.site.storage.bean.ExpireToken; 22 | import com.akaxin.site.storage.dao.SiteTokenDao; 23 | 24 | /** 25 | * 26 | * @author Sam{@link an.guoyue254@gmail.com} 27 | * @since 2018-06-28 16:42:43 28 | */ 29 | public class TokenDaoService implements ITokenDao { 30 | 31 | @Override 32 | public boolean addToken(ExpireToken bean) throws SQLException { 33 | return SiteTokenDao.getInstance().addToken(bean); 34 | } 35 | 36 | @Override 37 | public ExpireToken getExpireToken(String token) throws SQLException { 38 | return SiteTokenDao.getInstance().queryExpireToken(token); 39 | } 40 | 41 | @Override 42 | public ExpireToken getExpireTokenByBid(String bid, long time) throws SQLException { 43 | return SiteTokenDao.getInstance().queryExpireTokenByBid(bid, time); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/service/UicDaoService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018-2028 Akaxin Group 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.akaxin.site.storage.service; 17 | 18 | import java.sql.SQLException; 19 | import java.util.List; 20 | 21 | import com.akaxin.site.storage.api.IUicDao; 22 | import com.akaxin.site.storage.bean.UicBean; 23 | import com.akaxin.site.storage.dao.SiteUICDao; 24 | 25 | /** 26 | * 27 | * @author Sam{@link an.guoyue254@gmail.com} 28 | * @since 2018-01-31 12:11:17 29 | */ 30 | public class UicDaoService implements IUicDao { 31 | 32 | @Override 33 | public boolean addUic(UicBean bean) throws SQLException { 34 | return SiteUICDao.getInstance().addUIC(bean); 35 | } 36 | 37 | @Override 38 | public boolean batchAddUic(UicBean bean, int num, int length) throws SQLException { 39 | return SiteUICDao.getInstance().batchAddUIC(bean, num, length); 40 | } 41 | 42 | @Override 43 | public boolean updateUic(UicBean bean) throws SQLException { 44 | return SiteUICDao.getInstance().updateUIC(bean); 45 | } 46 | 47 | @Override 48 | public UicBean getUicInfo(String uic) throws SQLException { 49 | return SiteUICDao.getInstance().queryUIC(uic); 50 | } 51 | 52 | @Override 53 | public List getUicPageList(int pageNum, int pageSize, int status) throws SQLException { 54 | return SiteUICDao.getInstance().queryUicList(pageNum, pageSize, status); 55 | } 56 | 57 | @Override 58 | public List getAllUicPageList(int pageNum, int pageSize) throws SQLException { 59 | return SiteUICDao.getInstance().queryAllUicList(pageNum, pageSize); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/util/FileUtils.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.util; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.File; 5 | import java.io.FileNotFoundException; 6 | import java.io.FileOutputStream; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | 10 | import com.akaxin.site.storage.dao.mysql.manager.MysqlManager; 11 | 12 | public class FileUtils { 13 | 14 | public static void writeResourceToFile(String resourceName, File file) throws FileNotFoundException, IOException { 15 | if (!file.exists()) { 16 | new FileOutputStream(file).close(); 17 | } 18 | InputStream is = MysqlManager.class.getResourceAsStream(resourceName); 19 | BufferedInputStream bis = new BufferedInputStream(is); 20 | FileOutputStream fos = new FileOutputStream(file); 21 | try { 22 | byte[] buffer = new byte[1024]; 23 | int bytesLen = 0; 24 | while ((bytesLen = bis.read(buffer)) != -1) { 25 | fos.write(buffer, 0, bytesLen); 26 | } 27 | } finally { 28 | if (bis != null) { 29 | bis.close(); 30 | } 31 | if (is != null) { 32 | is.close(); 33 | } 34 | if (fos != null) { 35 | fos.close(); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/util/SqlLog.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | public class SqlLog { 7 | private static final Logger logger = LoggerFactory.getLogger(SqlLog.class); 8 | 9 | public static void info(String msg) { 10 | logger.info(msg); 11 | } 12 | 13 | public static void info(String messagePattern, Object... objs) { 14 | logger.info(messagePattern, objs); 15 | } 16 | 17 | public static void warn(String msg) { 18 | logger.warn(msg); 19 | } 20 | 21 | public static void warn(String messagePattern, Object... objs) { 22 | logger.warn(messagePattern, objs); 23 | } 24 | 25 | public static void error(String msg) { 26 | logger.error(msg); 27 | } 28 | 29 | public static void error(String msg, Throwable t) { 30 | logger.error(msg, t); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/java/com/akaxin/site/storage/util/SqlUtils.java: -------------------------------------------------------------------------------- 1 | package com.akaxin.site.storage.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.apache.commons.lang3.StringUtils; 7 | 8 | /** 9 | * 10 | * @author Sam{@link an.guoyue254@gmail.com} 11 | * @since 2018-05-26 11:42:47 12 | */ 13 | public class SqlUtils { 14 | 15 | public static SqlBean buildUpdateSql(String sql, Map sqlMap) { 16 | SqlUtils.SqlBean bean = new SqlBean(); 17 | bean.setSql(sql); 18 | Map res = new HashMap(); 19 | StringBuilder sqlTag = new StringBuilder("SET "); 20 | if (sqlMap != null) { 21 | int index = 0; 22 | for (String key : sqlMap.keySet()) { 23 | if (StringUtils.isNotEmpty(sqlMap.get(key))) { 24 | if (index++ > 0) { 25 | sqlTag.append(","); 26 | } 27 | sqlTag.append(key + "=?"); 28 | res.put(index, sqlMap.get(key)); 29 | } 30 | 31 | } 32 | } 33 | bean.setSqlSupple(sqlTag.toString()); 34 | bean.setParams(res); 35 | return bean; 36 | } 37 | 38 | public static class SqlBean { 39 | private String sql; 40 | private String sqlSupple; 41 | private Map params; 42 | 43 | public String getSql() { 44 | if (sqlSupple != null) { 45 | return sql.replace("{}", sqlSupple); 46 | } 47 | return sql; 48 | } 49 | 50 | public void setSql(String sql) { 51 | this.sql = sql; 52 | } 53 | 54 | public String getSqlSupple() { 55 | return sqlSupple; 56 | } 57 | 58 | public void setSqlSupple(String sqlSupple) { 59 | this.sqlSupple = sqlSupple; 60 | } 61 | 62 | public Map getParams() { 63 | return params; 64 | } 65 | 66 | public void setParams(Map params) { 67 | this.params = params; 68 | } 69 | 70 | } 71 | 72 | public static void main(String[] args) { 73 | Map hello = new HashMap(); 74 | hello.put("vk_na", null); 75 | hello.put("vk_he", "nihao"); 76 | hello.put("vk_he2", "nihao2"); 77 | 78 | String sql = "update site_user_profile {} where site_user_id=?;"; 79 | SqlBean bean = buildUpdateSql(sql, hello); 80 | 81 | System.out.println(bean.getSql()); 82 | System.out.println(bean.getParams()); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /openzaly-storage/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # log4j 2 | log4j.rootLogger=INFO,console,info-out,warn-out,error-out 3 | 4 | log4j.appender.console=org.apache.log4j.ConsoleAppender 5 | log4j.appender.console.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.console.layout.ConversionPattern=%d %p [%c] \r\n\t%m%n 7 | 8 | log4j.appender.debug-out=org.apache.log4j.RollingFileAppender 9 | log4j.appender.debug-out.File=debug.log 10 | log4j.appender.debug-out.MaxFileSize=102400KB 11 | log4j.appender.debug-out.MaxBackupIndex=1 12 | log4j.appender.debug-out.Threshold=DEBUG 13 | log4j.appender.debug-out.layout=org.apache.log4j.PatternLayout 14 | log4j.appender.debug-out.layout.ConversionPattern=%d %p [%c] \r\n\t%m%n 15 | 16 | log4j.appender.info-out=org.apache.log4j.RollingFileAppender 17 | log4j.appender.info-out.File=info.log 18 | log4j.appender.info-out.MaxFileSize=102400KB 19 | log4j.appender.info-out.MaxBackupIndex=1 20 | log4j.appender.info-out.Threshold=INFO 21 | log4j.appender.info-out.layout=org.apache.log4j.PatternLayout 22 | log4j.appender.info-out.layout.ConversionPattern=%d %p [%c] \r\n\t%m%n 23 | 24 | log4j.appender.warn-out=org.apache.log4j.RollingFileAppender 25 | log4j.appender.warn-out.File=warn.log 26 | log4j.appender.warn-out.MaxFileSize=102400KB 27 | log4j.appender.warn-out.MaxBackupIndex=1 28 | log4j.appender.warn-out.Threshold=WARN 29 | log4j.appender.warn-out.layout=org.apache.log4j.PatternLayout 30 | log4j.appender.warn-out.layout.ConversionPattern=%d %p [%c] \r\n\t%m%n 31 | 32 | log4j.appender.error-out=org.apache.log4j.RollingFileAppender 33 | log4j.appender.error-out.File=error.log 34 | log4j.appender.error-out.MaxFileSize=102400KB 35 | log4j.appender.error-out.MaxBackupIndex=1 36 | log4j.appender.error-out.Threshold=ERROR 37 | log4j.appender.error-out.layout=org.apache.log4j.PatternLayout 38 | log4j.appender.error-out.layout.ConversionPattern=%d %p [%c] \r\n\t%m%n 39 | 40 | 41 | -------------------------------------------------------------------------------- /restart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PORT=$1 3 | PORT2=$2 4 | 5 | #### echo akaxin logo and desc 6 | echo " 7 | 8 | / \ 9 | / . \ 10 | \ . \ 11 | / \ \ / _ _ __ _ __ __ ___ _ _ 12 | / . \ | / / \ / \ | |/ / / \ \ \/ / |_ _| | \ | | 13 | / . _ \ / / . \ / _ \ | ' / / _ \ \ / | | | \| | 14 | \ / / \ - . / / ___ \ | . \ / ___ \ / \ | | | |\ | 15 | \ / / | \ / /_/ \_\ |_|\_\ /_/ \_\ /_/\_\ |___| |_| \_| 16 | / . \ \ / 17 | \ . \ 18 | \ / 19 | \ / 20 | 21 | Akaxin is an open source and free proprietary IM software,you can build private openzaly-server for everyone in any server. 22 | 23 | " 24 | 25 | ##set tcp port 26 | if [ -n $PORT ]; then 27 | PORT=2021 28 | fi 29 | 30 | ##set http port 31 | if [ -n $PORT2 ]; then 32 | PORT2=8280 33 | fi 34 | 35 | sh stop.sh $PORT 1 36 | sh start.sh $PORT $PORT2 1 -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PORT=$1 4 | PORT2=$2 5 | IS_RESTART=$3 6 | 7 | if [ -z $IS_RESTART ];then 8 | #### echo akaxin logo and desc 9 | echo " 10 | 11 | / \ 12 | / . \ 13 | \ . \ 14 | / \ \ / _ _ __ _ __ __ ___ _ _ 15 | / . \ | / / \ / \ | |/ / / \ \ \/ / |_ _| | \ | | 16 | / . _ \ / / . \ / _ \ | ' / / _ \ \ / | | | \| | 17 | \ / / \ - . / / ___ \ | . \ / ___ \ / \ | | | |\ | 18 | \ / / | \ / /_/ \_\ |_|\_\ /_/ \_\ /_/\_\ |___| |_| \_| 19 | / . \ \ / 20 | \ . \ 21 | \ / 22 | \ / 23 | 24 | Akaxin is an open source and free proprietary IM software,you can build private openzaly-server for everyone in any server. 25 | 26 | " 27 | fi 28 | 29 | 30 | ##set tcp port 31 | if [ -n $PORT ]; then 32 | PORT=2021 33 | fi 34 | 35 | ##set http port 36 | if [ -n $PORT2 ]; then 37 | PORT2=8280 38 | fi 39 | 40 | #### echo server is starting 41 | echo "[OK] openzaly-server is starting [tcp-port:"$PORT" http-port:"$PORT2"]" 42 | 43 | JAVA_JAR="openzaly-server" 44 | PID=$(ps -ef|grep $JAVA_JAR|grep $PORT |head -1| awk '{printf $2}') 45 | 46 | ###if server is running, exit and echo error 47 | if [ $PID > 0 ]; then 48 | echo "[ERROR] openzaly-server is running [PID:"$PID"]" 49 | echo "[ERROR] openzaly-server start failure" 50 | echo "" 51 | exit 52 | fi 53 | 54 | java -Dsite.port=$PORT -Dhttp.port=$PORT2 -jar openzaly-server.jar >>stdout.log 2>&1 & 55 | 56 | PID=$(ps -ef|grep $JAVA_JAR|grep $PORT |head -1| awk '{printf $2}') 57 | 58 | if [ $? -eq 0 ]; then 59 | echo "[OK] openzaly-server tcp-port:"$PORT",http-port:$PORT2,PID:$PID" 60 | echo "[OK] openzaly-server is started successfully [PID:"$PID"]" 61 | else 62 | echo "[ERROR] openzaly-server is started failed" 63 | echo "exit..." 64 | echo "" 65 | exit 66 | fi 67 | 68 | echo "" 69 | echo "" -------------------------------------------------------------------------------- /stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PORT=$1 4 | IS_RESTART=$2 5 | JAVA_JAR="openzaly-server" 6 | 7 | ## IS_RESTART not exist ,echo info 8 | if [ -z $IS_RESTART ]; then 9 | #### echo akaxin logo and desc 10 | echo " 11 | 12 | / \ 13 | / . \ 14 | \ . \ 15 | / \ \ / _ _ __ _ __ __ ___ _ _ 16 | / . \ | / / \ / \ | |/ / / \ \ \/ / |_ _| | \ | | 17 | / . _ \ / / . \ / _ \ | ' / / _ \ \ / | | | \| | 18 | \ / / \ - . / / ___ \ | . \ / ___ \ / \ | | | |\ | 19 | \ / / | \ / /_/ \_\ |_|\_\ /_/ \_\ /_/\_\ |___| |_| \_| 20 | / . \ \ / 21 | \ . \ 22 | \ / 23 | \ / 24 | 25 | Akaxin is an open source and free proprietary IM software,you can build private openzaly-server for everyone in any server. 26 | 27 | " 28 | fi 29 | 30 | 31 | ##set tcp port 32 | if [ -n $PORT ]; then 33 | PORT=2021 34 | fi 35 | 36 | echo "[OK] openzaly-server is closing [PORT:"$PORT"]" 37 | 38 | PID=$(ps -ef|grep $JAVA_JAR|grep $PORT |head -1| awk '{printf $2}') 39 | 40 | #if [ $? -eq 0 ]; then 41 | if [ $PID ]; then 42 | echo "[OK] openzaly-server is running on [PID:"$PID"]" 43 | else 44 | echo "[ERROR] openzaly-server stop failure, as it's not running." 45 | echo "" 46 | exit 47 | fi 48 | 49 | 50 | kill -9 ${PID} 51 | 52 | if [ $? -eq 0 ];then 53 | echo "[OK] openzaly-server is stoped [PORT:"$PORT" PID:"$PID"]" 54 | else 55 | echo "[ERROR] openzaly-server stop failure." 56 | fi 57 | 58 | echo "" --------------------------------------------------------------------------------