diff --git a/0 b/0 new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index 59455b2..537f7bb 100755 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ 简介 ---- -WindChat 是一款开源免费私有IM聊天软件,原身是Akaxin即时通讯开源软件,由原开发者SAM2O2O个人维护,主要面向企业定制IM,全端开源,免费。 +WindChat 是一款开源免费私有IM聊天软件,由核心开发者SAM2O2O等维护,主要面向企业定制IM,开源、免费。 特性: @@ -85,13 +85,10 @@ WindChat Team版本 命令: **2. 下载客户端** Android 客户端: -> * [Android 源码地址GitHub](https://github.com/WindChat/wind-android.git) -> * GitHube地址 : https://github.com/WindChat/wind-android.git -> * [Android 源码地址Gitee](https://gitee.com/wind-chat/wind-android.git) -> * Gitee地址 :(https://gitee.com/wind-chat/wind-android.git) +> Android 端暂未开源,敬请期待 iOS 客户端: -> iOS 暂未开源,预计2020-06-14 开源 +> iOS 端暂未开源,敬请期待 **3. 访问站点** @@ -120,6 +117,7 @@ iOS 客户端: WindChat 具有灵活、强大的扩展机制 `(“管理平台” 就是一个扩展)`。通过嵌入WEB页面,与后端的扩展API进行交互, 可以很轻松的构建丰富的业务功能,如: * 附近交友 +* 线上打卡 * 店铺点评 * 在线游戏 * 等等等等 diff --git a/pom.xml b/pom.xml index 284d1fe..b8d769f 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 2.8.2 1.2.31 1.7.25 - 23.6-jre + 29.0-jre 3.21.0.1 8.0.16 diff --git a/windchat-admin/src/main/java/com/windchat/im/web/OpenzalyAdminApplication.java b/windchat-admin/src/main/java/com/windchat/im/web/OpenzalyAdminApplication.java index 659d005..b716c79 100755 --- a/windchat-admin/src/main/java/com/windchat/im/web/OpenzalyAdminApplication.java +++ b/windchat-admin/src/main/java/com/windchat/im/web/OpenzalyAdminApplication.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/AbstractController.java b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/AbstractController.java index d059d84..e9331f0 100755 --- a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/AbstractController.java +++ b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/AbstractController.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/CommomController.java b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/CommomController.java index 0adccd6..e683992 100755 --- a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/CommomController.java +++ b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/CommomController.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/ConfigManageController.java b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/ConfigManageController.java index 95ca925..8b80261 100755 --- a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/ConfigManageController.java +++ b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/ConfigManageController.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/GroupManageController.java b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/GroupManageController.java index adc5b69..d3d2844 100755 --- a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/GroupManageController.java +++ b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/GroupManageController.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/PluginManageController.java b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/PluginManageController.java index 0b2291b..83c4a93 100755 --- a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/PluginManageController.java +++ b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/PluginManageController.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/UICManageController.java b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/UICManageController.java index b6eafe0..fd5a8d8 100755 --- a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/UICManageController.java +++ b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/UICManageController.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/UserManageController.java b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/UserManageController.java index 6afc4c4..0e60cb0 100755 --- a/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/UserManageController.java +++ b/windchat-admin/src/main/java/com/windchat/im/web/admin/controller/UserManageController.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/ConfigManageService.java b/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/ConfigManageService.java index 4e6a077..4e15710 100755 --- a/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/ConfigManageService.java +++ b/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/ConfigManageService.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/GroupManageService.java b/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/GroupManageService.java index d82754b..bc3f561 100755 --- a/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/GroupManageService.java +++ b/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/GroupManageService.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/PluginManageService.java b/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/PluginManageService.java index f5b16e3..9863cb9 100755 --- a/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/PluginManageService.java +++ b/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/PluginManageService.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/UICManageService.java b/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/UICManageService.java index f899ab8..5fad33d 100755 --- a/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/UICManageService.java +++ b/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/UICManageService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/UserManageService.java b/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/UserManageService.java index 16a8782..713adce 100755 --- a/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/UserManageService.java +++ b/windchat-admin/src/main/java/com/windchat/im/web/admin/service/impl/UserManageService.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-boot/openzaly-server.config b/windchat-boot/openzaly-server.config deleted file mode 100755 index f11bfcf..0000000 --- a/windchat-boot/openzaly-server.config +++ /dev/null @@ -1,82 +0,0 @@ -# -# Copyright 2018-2028 Akaxin Group -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -######################################################## -### ***************Akaxin *************** -### openzaly-server -######################################################## - - - -## personal/PERSONAL edition : use sqlite database -## team/TEAM edition : use mysql database,support one master with several slaves -## enterprise/ENTERPRISE edition : use mysql + redis database ,support im server distribution -## ultimate edition : team or enterprise customization -openzaly.edition=PERSONAL - - -# openzaly version -openzaly.version=1.0.7 - -##### site tcp address,clients connect to site.address -site.address=0.0.0.0 -# site tcp port default 2021 -site.port=2021 - -# pluginapi server address -pluginapi.address=0.0.0.0 -# pluginapi server port -pluginapi.port=8280 - -# default back-stage management address -site.admin.address=127.0.0.1 -# default back-stage management port -site.admin.port=8288 - -# first user login site,use this user invite code(UIC) -site.uic=000000 - -# deposit pictures,audio,db default current path -# site.baseDir=${pwd} -# goup max members count = 100 -# group.members.count=100 - -## if openzaly.edition = personal/PERSONAL -openzaly.sqlite.url=openzalyDB.sqlite3 - - -## if openzaly.edition = team/TEAM -openzaly.mysql.host=localhost -openzaly.mysql.port=3306 -openzaly.mysql.database=openzaly - -openzaly.mysql.username=root -openzaly.mysql.password=1234567890 -openzaly.mysql.initial-size=10 -openzaly.mysql.max-size=100 -openzaly.mysql.max-idle=60 - -openzaly.mysql.useUnicode=true -openzaly.mysql.characterEncoding=utf-8 -openzaly.mysql.verifyServerCertificate=false -openzaly.mysql.useSSL=true - - -## if openzaly.edition = enterprise/ENTERPRISE -#### support support im server distribution - -## if openzaly.edition = ultimate edition -#### openzaly support customed for team or enterprise \ No newline at end of file diff --git a/windchat-boot/src/main/java/com/windchat/im/boot/config/ConfigHelper.java b/windchat-boot/src/main/java/com/windchat/im/boot/config/ConfigHelper.java index b595e1f..e5447d9 100755 --- a/windchat-boot/src/main/java/com/windchat/im/boot/config/ConfigHelper.java +++ b/windchat-boot/src/main/java/com/windchat/im/boot/config/ConfigHelper.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-boot/src/main/java/com/windchat/im/boot/config/ConfigKey.java b/windchat-boot/src/main/java/com/windchat/im/boot/config/ConfigKey.java index f752682..669d152 100755 --- a/windchat-boot/src/main/java/com/windchat/im/boot/config/ConfigKey.java +++ b/windchat-boot/src/main/java/com/windchat/im/boot/config/ConfigKey.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-boot/src/main/java/com/windchat/im/boot/config/SiteDefaultIcon.java b/windchat-boot/src/main/java/com/windchat/im/boot/config/SiteDefaultIcon.java index 13217a1..b0f06ca 100755 --- a/windchat-boot/src/main/java/com/windchat/im/boot/config/SiteDefaultIcon.java +++ b/windchat-boot/src/main/java/com/windchat/im/boot/config/SiteDefaultIcon.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-boot/src/main/java/com/windchat/im/boot/main/Bootstrap.java b/windchat-boot/src/main/java/com/windchat/im/boot/main/Bootstrap.java index d4e8384..c262ea6 100755 --- a/windchat-boot/src/main/java/com/windchat/im/boot/main/Bootstrap.java +++ b/windchat-boot/src/main/java/com/windchat/im/boot/main/Bootstrap.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-boot/src/main/java/com/windchat/im/boot/utils/PropertiesUtils.java b/windchat-boot/src/main/java/com/windchat/im/boot/utils/PropertiesUtils.java index e744f69..42c21d6 100755 --- a/windchat-boot/src/main/java/com/windchat/im/boot/utils/PropertiesUtils.java +++ b/windchat-boot/src/main/java/com/windchat/im/boot/utils/PropertiesUtils.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-boot/src/main/resources/openzaly-server.config b/windchat-boot/src/main/resources/openzaly-server.config index d17724f..2b309b7 100755 --- a/windchat-boot/src/main/resources/openzaly-server.config +++ b/windchat-boot/src/main/resources/openzaly-server.config @@ -1,5 +1,5 @@ # -# Copyright 2018-2028 Akaxin Group +# Copyright 2018-2028 WindChat Group # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/bean/ApiActions.java b/windchat-business/src/main/java/com/windchat/im/business/bean/ApiActions.java new file mode 100644 index 0000000..e2bf6ac --- /dev/null +++ b/windchat-business/src/main/java/com/windchat/im/business/bean/ApiActions.java @@ -0,0 +1,19 @@ +package com.windchat.im.business.bean; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * customized annotation + * + * @author Librena + * @since 2020-10-20 + */ +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ApiActions { + + String action(); + +} diff --git a/windchat-business/src/main/java/com/windchat/im/business/constant/NoticeText.java b/windchat-business/src/main/java/com/windchat/im/business/constant/NoticeText.java index 7ec52a7..d54d33e 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/constant/NoticeText.java +++ b/windchat-business/src/main/java/com/windchat/im/business/constant/NoticeText.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,9 @@ package com.windchat.im.business.constant; * @since 2017-12-28 14:38:15 */ public interface NoticeText { - public String USER_ADD_FRIEND = "我通过了你的好友验证,现在可以开始聊天了"; - public String USER_ADD_GROUP = " 加入了群聊"; + String USER_ADD_FRIEND = "我通过了你的好友验证,现在可以开始聊天了"; + String USER_ADD_GROUP = " 加入了群聊"; - public String USER_ADD_GROUP_QR_CODE = " 通过群组二维码加入群聊"; + String USER_ADD_GROUP_QR_CODE = " 通过群组二维码加入群聊"; } \ No newline at end of file diff --git a/windchat-business/src/main/java/com/windchat/im/business/dao/ExpireTokenDao.java b/windchat-business/src/main/java/com/windchat/im/business/dao/ExpireTokenDao.java index a9d1a3c..503b54e 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/dao/ExpireTokenDao.java +++ b/windchat-business/src/main/java/com/windchat/im/business/dao/ExpireTokenDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/dao/SiteConfigDao.java b/windchat-business/src/main/java/com/windchat/im/business/dao/SiteConfigDao.java index ef187ba..ae3c58e 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/dao/SiteConfigDao.java +++ b/windchat-business/src/main/java/com/windchat/im/business/dao/SiteConfigDao.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-business/src/main/java/com/windchat/im/business/dao/SiteLoginDao.java b/windchat-business/src/main/java/com/windchat/im/business/dao/SiteLoginDao.java index 3b14314..672519e 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/dao/SiteLoginDao.java +++ b/windchat-business/src/main/java/com/windchat/im/business/dao/SiteLoginDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/dao/SitePluginDao.java b/windchat-business/src/main/java/com/windchat/im/business/dao/SitePluginDao.java index f21bd09..db801f5 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/dao/SitePluginDao.java +++ b/windchat-business/src/main/java/com/windchat/im/business/dao/SitePluginDao.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-business/src/main/java/com/windchat/im/business/dao/SiteUicDao.java b/windchat-business/src/main/java/com/windchat/im/business/dao/SiteUicDao.java index 894d3f3..5ff4b18 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/dao/SiteUicDao.java +++ b/windchat-business/src/main/java/com/windchat/im/business/dao/SiteUicDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/dao/UserFriendDao.java b/windchat-business/src/main/java/com/windchat/im/business/dao/UserFriendDao.java index 9710d49..f780468 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/dao/UserFriendDao.java +++ b/windchat-business/src/main/java/com/windchat/im/business/dao/UserFriendDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/dao/UserProfileDao.java b/windchat-business/src/main/java/com/windchat/im/business/dao/UserProfileDao.java index 70d74c2..ed1b987 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/dao/UserProfileDao.java +++ b/windchat-business/src/main/java/com/windchat/im/business/dao/UserProfileDao.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-business/src/main/java/com/windchat/im/business/dao/UserSessionDao.java b/windchat-business/src/main/java/com/windchat/im/business/dao/UserSessionDao.java index c19af88..0929890 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/dao/UserSessionDao.java +++ b/windchat-business/src/main/java/com/windchat/im/business/dao/UserSessionDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/AbstractRequest.java b/windchat-business/src/main/java/com/windchat/im/business/impl/AbstractRequest.java index 6d27067..b8f668f 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/AbstractRequest.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/AbstractRequest.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,10 +15,14 @@ */ package com.windchat.im.business.impl; -import java.lang.reflect.Method; - -import com.windchat.im.business.dao.UserGroupDao; -import com.windchat.im.business.dao.UserProfileDao; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.windchat.common.command.Command; +import com.windchat.common.command.CommandResponse; +import com.windchat.common.constant.CommandConst; +import com.windchat.common.constant.ErrorCode2; +import com.windchat.common.logs.LogUtils; +import com.windchat.im.business.bean.ApiActions; import com.windchat.im.business.dao.UserGroupDao; import com.windchat.im.business.dao.UserProfileDao; import com.windchat.im.storage.bean.GroupProfileBean; @@ -27,62 +31,76 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.windchat.common.command.Command; -import com.windchat.common.command.CommandResponse; -import com.windchat.common.constant.CommandConst; -import com.windchat.common.constant.ErrorCode2; -import com.windchat.common.logs.LogUtils; +import java.lang.reflect.Method; +import java.util.concurrent.TimeUnit; /** - * * @author Sam{@link an.guoyue254@gmail.com} * @since 2018-01-31 12:20:14 */ public abstract class AbstractRequest implements IRequestService { - private static final Logger logger = LoggerFactory.getLogger(AbstractRequest.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractRequest.class); - public CommandResponse execute(Command command) { - return executeMethodByReflect(command); - } + Cache cache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(10, TimeUnit.MINUTES).build(); - private CommandResponse executeMethodByReflect(Command command) { - CommandResponse response = null; - ErrorCode2 errCode = ErrorCode2.ERROR; - try { - String methodName = command.getMethod(); - Method m = this.getClass().getDeclaredMethod(methodName, command.getClass()); - response = (CommandResponse) m.invoke(this, command); - } catch (Exception e) { - LogUtils.requestErrorLog(logger, command, e); - } + public CommandResponse execute(Command command) { + return executeMethodByReflect(command); + } - if (response == null) { - response = new CommandResponse().setVersion(CommandConst.PROTOCOL_VERSION) - .setAction(CommandConst.ACTION_RES).setErrCode2(errCode); - } - return response; - } + private CommandResponse executeMethodByReflect(Command command) { + CommandResponse response = null; + ErrorCode2 errCode = ErrorCode2.ERROR; + try { + Method actionMethod = cache.getIfPresent(command.getAction()); + if (actionMethod == null) { + Method[] allMethods = this.getClass().getDeclaredMethods(); + ApiActions serviceAction = this.getClass().getDeclaredAnnotation(ApiActions.class); + for (Method method : allMethods) { + ApiActions apiActions = method.getAnnotation(ApiActions.class); + if (apiActions == null) { + continue; + } + String action = serviceAction.action() + apiActions.action(); + if (action.equals(command.getAction())) { + response = (CommandResponse) method.invoke(this, command); + cache.put(action, method); + break; + } + } + } else { + response = (CommandResponse) actionMethod.invoke(this, command); + } + } catch (Exception e) { + LogUtils.requestErrorLog(logger, command, e); + } - //检查请求的参数中的siteUserId是否是存在的 - public boolean checkUserIdLegal(String siteUserId) { - if (StringUtils.isNotEmpty(siteUserId)) { - SimpleUserBean userProfile = UserProfileDao.getInstance().getSimpleProfileById(siteUserId); - if (userProfile != null && StringUtils.isNotEmpty(userProfile.getSiteUserId())) { - return true; - } - } - return false; - } + if (response == null) { + response = new CommandResponse().setVersion(CommandConst.PROTOCOL_VERSION) + .setAction(CommandConst.ACTION_RES).setErrCode2(errCode); + } + return response; + } - //检查请求的参数中的groupId是否是存在的 - public boolean checkGroupIdLegal(String groupId) { - if (StringUtils.isNotEmpty(groupId)) { - GroupProfileBean groupProfile = UserGroupDao.getInstance().getSimpleGroupBeanById(groupId); - if (groupProfile != null) { - return true; - } - } - return false; - } + //检查请求的参数中的siteUserId是否是存在的 + public boolean checkUserIdLegal(String siteUserId) { + if (StringUtils.isNotEmpty(siteUserId)) { + SimpleUserBean userProfile = UserProfileDao.getInstance().getSimpleProfileById(siteUserId); + if (userProfile != null && StringUtils.isNotEmpty(userProfile.getSiteUserId())) { + return true; + } + } + return false; + } + + //检查请求的参数中的groupId是否是存在的 + public boolean checkGroupIdLegal(String groupId) { + if (StringUtils.isNotEmpty(groupId)) { + GroupProfileBean groupProfile = UserGroupDao.getInstance().getSimpleGroupBeanById(groupId); + if (groupProfile != null) { + return true; + } + } + return false; + } } diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpFriendService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpFriendService.java index f876b45..43e69e1 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpFriendService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpFriendService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpGroupService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpGroupService.java index e6f15f7..ff42247 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpGroupService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpGroupService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpMessageService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpMessageService.java index b5d16b5..455473c 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpMessageService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpMessageService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpPushService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpPushService.java index 4b6eb16..7cd809d 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpPushService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpPushService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpSessionService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpSessionService.java index f5893cd..81bb159 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpSessionService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpSessionService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpSiteService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpSiteService.java index 8cee31b..d378b0e 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpSiteService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpSiteService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpUserService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpUserService.java index a058cf3..fa4814b 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpUserService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpUserService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/notice/GroupNotice.java b/windchat-business/src/main/java/com/windchat/im/business/impl/notice/GroupNotice.java index 9ccdd6a..276e80f 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/notice/GroupNotice.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/notice/GroupNotice.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/site/PlatformUserPhone.java b/windchat-business/src/main/java/com/windchat/im/business/impl/site/PlatformUserPhone.java index 4be1790..ae05660 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/site/PlatformUserPhone.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/site/PlatformUserPhone.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/site/SiteConfig.java b/windchat-business/src/main/java/com/windchat/im/business/impl/site/SiteConfig.java index db04aec..2bba695 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/site/SiteConfig.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/site/SiteConfig.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,23 +15,20 @@ */ package com.windchat.im.business.impl.site; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - +import com.akaxin.proto.core.ConfigProto; import com.windchat.im.business.constant.GroupConfig; import com.windchat.im.business.dao.SiteConfigDao; +import com.windchat.im.message.utils.SiteConfigHelper; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.akaxin.proto.core.ConfigProto; -import com.windchat.im.business.constant.GroupConfig; -import com.windchat.im.business.dao.SiteConfigDao; -import com.windchat.im.message.utils.SiteConfigHelper; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * 管理站点配置相关信息 diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/site/UserUic.java b/windchat-business/src/main/java/com/windchat/im/business/impl/site/UserUic.java index d8af7d5..0816d0e 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/site/UserUic.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/site/UserUic.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiDeviceService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiDeviceService.java index 9d548ba..57c26e4 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiDeviceService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiDeviceService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,25 +15,23 @@ */ package com.windchat.im.business.impl.tai; -import java.util.List; - -import com.windchat.im.business.dao.UserDeviceDao; -import com.windchat.im.business.impl.AbstractRequest; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.windchat.common.command.Command; -import com.windchat.common.command.CommandResponse; -import com.windchat.common.constant.ErrorCode2; -import com.windchat.common.logs.LogUtils; import com.akaxin.proto.core.DeviceProto; import com.akaxin.proto.site.ApiDeviceBoundListProto; import com.akaxin.proto.site.ApiDeviceListProto; import com.akaxin.proto.site.ApiDeviceProfileProto; +import com.windchat.common.command.Command; +import com.windchat.common.command.CommandResponse; +import com.windchat.common.constant.ErrorCode2; +import com.windchat.common.logs.LogUtils; +import com.windchat.im.business.bean.ApiActions; import com.windchat.im.business.dao.UserDeviceDao; import com.windchat.im.business.impl.AbstractRequest; import com.windchat.im.storage.bean.UserDeviceBean; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; /** * @@ -41,9 +39,11 @@ import com.windchat.im.storage.bean.UserDeviceBean; * @since 2017.10.20 * */ +@ApiActions(action = "api.device") public class ApiDeviceService extends AbstractRequest { private static final Logger logger = LoggerFactory.getLogger(ApiDeviceService.class); + @ApiActions(action = ".profile") public CommandResponse profile(Command command) { CommandResponse commandResponse = new CommandResponse(); ErrorCode2 errCode = ErrorCode2.ERROR; @@ -76,6 +76,7 @@ public class ApiDeviceService extends AbstractRequest { return commandResponse.setErrCode2(errCode); } + @ApiActions(action = ".list") public CommandResponse list(Command command) { CommandResponse commandResponse = new CommandResponse(); ErrorCode2 errCode = ErrorCode2.ERROR; @@ -116,6 +117,7 @@ public class ApiDeviceService extends AbstractRequest { * @param command * @return */ + @ApiActions(action = ".boundList") public CommandResponse boundList(Command command) { CommandResponse commandResponse = new CommandResponse(); ErrorCode2 errCode = ErrorCode2.ERROR; diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiFileService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiFileService.java index c35f4f0..f5834f9 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiFileService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiFileService.java @@ -15,23 +15,21 @@ */ package com.windchat.im.business.impl.tai; -import com.windchat.im.business.impl.AbstractRequest; -import com.windchat.im.business.utils.FilePathUtils; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import com.akaxin.proto.core.FileProto; +import com.akaxin.proto.site.ApiFileDownloadProto; +import com.akaxin.proto.site.ApiFileUploadProto; +import com.google.protobuf.ByteString; import com.windchat.common.command.Command; import com.windchat.common.command.CommandResponse; import com.windchat.common.constant.ErrorCode2; import com.windchat.common.logs.LogUtils; -import com.akaxin.proto.core.FileProto; -import com.akaxin.proto.site.ApiFileDownloadProto; -import com.akaxin.proto.site.ApiFileUploadProto; +import com.windchat.im.business.bean.ApiActions; import com.windchat.im.business.impl.AbstractRequest; import com.windchat.im.business.utils.FilePathUtils; import com.windchat.im.business.utils.FileServerUtils; -import com.google.protobuf.ByteString; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * 文件(图片,语音)上传下载 @@ -39,9 +37,11 @@ import com.google.protobuf.ByteString; * @author Sam{@link an.guoyue254@gmail.com} * @since 2018-01-25 17:52:08 */ +@ApiActions(action = "api.file") public class ApiFileService extends AbstractRequest { private static Logger logger = LoggerFactory.getLogger(ApiFileService.class); + @ApiActions(action = ".upload") public CommandResponse upload(Command command) { CommandResponse commandResponse = new CommandResponse(); ErrorCode2 errCode = ErrorCode2.ERROR; @@ -66,6 +66,7 @@ public class ApiFileService extends AbstractRequest { return commandResponse.setErrCode2(errCode); } + @ApiActions(action = ".download") public CommandResponse download(Command command) { CommandResponse commandResponse = new CommandResponse(); ErrorCode2 errCode = ErrorCode2.ERROR; diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiFriendService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiFriendService.java index 3345491..e90a795 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiFriendService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiFriendService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,23 +15,6 @@ */ package com.windchat.im.business.impl.tai; -import java.util.List; - -import com.windchat.im.business.dao.UserFriendDao; -import com.windchat.im.business.dao.UserProfileDao; -import com.windchat.im.business.impl.AbstractRequest; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.windchat.common.command.Command; -import com.windchat.common.command.CommandResponse; -import com.windchat.common.constant.CommandConst; -import com.windchat.common.constant.ErrorCode2; -import com.windchat.common.constant.IErrorCode; -import com.windchat.common.exceptions.ZalyException2; -import com.windchat.common.logs.LogUtils; -import com.windchat.common.utils.StringHelper; import com.akaxin.proto.core.UserProto; import com.akaxin.proto.site.ApiFriendApplyCountProto; import com.akaxin.proto.site.ApiFriendApplyListProto; @@ -45,6 +28,15 @@ import com.akaxin.proto.site.ApiFriendRemarkProto; import com.akaxin.proto.site.ApiFriendSettingProto; import com.akaxin.proto.site.ApiFriendUpdateMuteProto; import com.akaxin.proto.site.ApiFriendUpdateSettingProto; +import com.windchat.common.command.Command; +import com.windchat.common.command.CommandResponse; +import com.windchat.common.constant.CommandConst; +import com.windchat.common.constant.ErrorCode2; +import com.windchat.common.constant.IErrorCode; +import com.windchat.common.exceptions.ZalyException2; +import com.windchat.common.logs.LogUtils; +import com.windchat.common.utils.StringHelper; +import com.windchat.im.business.bean.ApiActions; import com.windchat.im.business.dao.UserFriendDao; import com.windchat.im.business.dao.UserProfileDao; import com.windchat.im.business.impl.AbstractRequest; @@ -55,6 +47,11 @@ import com.windchat.im.storage.bean.ApplyFriendBean; import com.windchat.im.storage.bean.ApplyUserBean; import com.windchat.im.storage.bean.SimpleUserBean; import com.windchat.im.storage.bean.UserFriendBean; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; /** *

@@ -73,6 +70,7 @@ import com.windchat.im.storage.bean.UserFriendBean;
  * @author Sam{@link an.guoyue254@gmail.com}
  * @since 2017.11.24 18:36:59
  */
+@ApiActions(action = "api.friend")
 public class ApiFriendService extends AbstractRequest {
 	private static final Logger logger = LoggerFactory.getLogger(ApiFriendService.class);
 
@@ -82,6 +80,7 @@ public class ApiFriendService extends AbstractRequest {
 	 * @param command
 	 * @return
 	 */
+	@ApiActions(action = ".profile")
 	public CommandResponse profile(Command command) {
 		CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
 		ErrorCode2 errCode = ErrorCode2.ERROR;
@@ -156,6 +155,7 @@ public class ApiFriendService extends AbstractRequest {
 	 * @param command
 	 * @return
 	 */
+	@ApiActions(action = ".list")
 	public CommandResponse list(Command command) {
 		CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
 		ErrorCode2 errCode = ErrorCode2.ERROR;
@@ -210,6 +210,7 @@ public class ApiFriendService extends AbstractRequest {
 	 * @param command
 	 * @return
 	 */
+	@ApiActions(action = ".apply")
 	public CommandResponse apply(Command command) {
 		CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
 		IErrorCode errCode = ErrorCode2.ERROR;
@@ -270,6 +271,7 @@ public class ApiFriendService extends AbstractRequest {
 	 * @param command
 	 * @return
 	 */
+	@ApiActions(action = ".applyList")
 	public CommandResponse applyList(Command command) {
 		CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
 		ErrorCode2 errCode = ErrorCode2.ERROR;
@@ -309,6 +311,7 @@ public class ApiFriendService extends AbstractRequest {
 	 * @param command
 	 * @return
 	 */
+	@ApiActions(action = ".applyCount")
 	public CommandResponse applyCount(Command command) {
 		CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
 		ErrorCode2 errCode = ErrorCode2.ERROR;
@@ -336,6 +339,7 @@ public class ApiFriendService extends AbstractRequest {
 	 * @param command
 	 * @return
 	 */
+	@ApiActions(action = ".applyResult")
 	public CommandResponse applyResult(Command command) {
 		CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
 		ErrorCode2 errCode = ErrorCode2.ERROR;
@@ -382,6 +386,7 @@ public class ApiFriendService extends AbstractRequest {
 	 * @param command
 	 * @return
 	 */
+	@ApiActions(action = ".delete")
 	public CommandResponse delete(Command command) {
 		CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
 		ErrorCode2 errCode = ErrorCode2.ERROR;
@@ -413,6 +418,7 @@ public class ApiFriendService extends AbstractRequest {
 	 * @param command
 	 * @return
 	 */
+	@ApiActions(action = ".setting")
 	public CommandResponse setting(Command command) {
 		CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
 		ErrorCode2 errCode = ErrorCode2.ERROR;
@@ -451,6 +457,7 @@ public class ApiFriendService extends AbstractRequest {
 	 * @param command
 	 * @return
 	 */
+	@ApiActions(action = ".updateSetting")
 	public CommandResponse updateSetting(Command command) {
 		CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
 		ErrorCode2 errCode = ErrorCode2.ERROR;
@@ -488,6 +495,7 @@ public class ApiFriendService extends AbstractRequest {
 	 * @param command
 	 * @return
 	 */
+	@ApiActions(action = ".mute")
 	public CommandResponse mute(Command command) {
 		CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
 		ErrorCode2 errCode = ErrorCode2.ERROR;
@@ -520,6 +528,7 @@ public class ApiFriendService extends AbstractRequest {
 	 * @param command
 	 * @return
 	 */
+	@ApiActions(action = ".updateMute")
 	public CommandResponse updateMute(Command command) {
 		CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
 		ErrorCode2 errCode = ErrorCode2.ERROR;
@@ -548,6 +557,13 @@ public class ApiFriendService extends AbstractRequest {
 		return commandResponse.setErrCode2(errCode);
 	}
 
+	/**
+	 * 设置好友备注
+	 *
+	 * @param command
+	 * @return
+	 */
+	@ApiActions(action =".remark")
 	public CommandResponse remark(Command command) {
 		CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
 		IErrorCode errCode = ErrorCode2.ERROR;
diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiGroupService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiGroupService.java
index f107277..d66978e 100755
--- a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiGroupService.java
+++ b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiGroupService.java
@@ -1,5 +1,5 @@
 /**
- * Copyright 2018-2028 Akaxin Group
+ * Copyright 2018-2028 WindChat Group
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,26 +15,6 @@
  */
 package com.windchat.im.business.impl.tai;
 
-import java.util.List;
-import java.util.UUID;
-
-import com.windchat.im.business.constant.GroupConfig;
-import com.windchat.im.business.dao.ExpireTokenDao;
-import com.windchat.im.business.dao.UserGroupDao;
-import com.windchat.im.business.dao.UserProfileDao;
-import com.windchat.im.business.impl.AbstractRequest;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.windchat.common.command.Command;
-import com.windchat.common.command.CommandResponse;
-import com.windchat.common.constant.CommandConst;
-import com.windchat.common.constant.ErrorCode2;
-import com.windchat.common.constant.IErrorCode;
-import com.windchat.common.exceptions.ZalyException;
-import com.windchat.common.exceptions.ZalyException2;
-import com.windchat.common.logs.LogUtils;
 import com.akaxin.proto.core.GroupProto;
 import com.akaxin.proto.core.TokenProto;
 import com.akaxin.proto.core.UserProto;
@@ -53,6 +33,18 @@ import com.akaxin.proto.site.ApiGroupRemoveMemberProto;
 import com.akaxin.proto.site.ApiGroupSettingProto;
 import com.akaxin.proto.site.ApiGroupUpdateProfileProto;
 import com.akaxin.proto.site.ApiGroupUpdateSettingProto;
+import com.google.common.collect.Lists;
+import com.google.protobuf.ProtocolStringList;
+import com.windchat.common.command.Command;
+import com.windchat.common.command.CommandResponse;
+import com.windchat.common.constant.CommandConst;
+import com.windchat.common.constant.ErrorCode2;
+import com.windchat.common.constant.IErrorCode;
+import com.windchat.common.exceptions.ZalyException;
+import com.windchat.common.exceptions.ZalyException2;
+import com.windchat.common.exceptions.ZalyWarning;
+import com.windchat.common.logs.LogUtils;
+import com.windchat.im.business.bean.ApiActions;
 import com.windchat.im.business.constant.GroupConfig;
 import com.windchat.im.business.dao.ExpireTokenDao;
 import com.windchat.im.business.dao.UserGroupDao;
@@ -65,8 +57,12 @@ import com.windchat.im.storage.bean.GroupProfileBean;
 import com.windchat.im.storage.bean.SimpleGroupBean;
 import com.windchat.im.storage.bean.SimpleUserBean;
 import com.windchat.im.storage.bean.UserGroupBean;
-import com.google.common.collect.Lists;
-import com.google.protobuf.ProtocolStringList;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.UUID;
 
 /**
  * 扩展服务器与站点之间通过hai接口,管理群组功能
@@ -74,884 +70,918 @@ import com.google.protobuf.ProtocolStringList;
  * @author Sam{@link an.guoyue254@gmail.com}
  * @since 2018-01-13 21:48:35
  */
+@ApiActions(action = "api.group")
 public class ApiGroupService extends AbstractRequest {
-	private static final Logger logger = LoggerFactory.getLogger(ApiGroupService.class);
-
-	/**
-	 * 获取用户群列表 
- * 无权限限制 - * - * @param command - * @return - */ - public CommandResponse list(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupListProto.ApiGroupListRequest request = ApiGroupListProto.ApiGroupListRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isNotBlank(siteUserId) && siteUserId.equals(siteUserId)) { - List groupBeanList = UserGroupDao.getInstance().getUserGroupList(siteUserId); - ApiGroupListProto.ApiGroupListResponse.Builder responseBuilder = ApiGroupListProto.ApiGroupListResponse - .newBuilder(); - for (SimpleGroupBean groupBean : groupBeanList) { - GroupProto.SimpleGroupProfile.Builder groupProfileBuilder = GroupProto.SimpleGroupProfile - .newBuilder(); - groupProfileBuilder.setGroupId(groupBean.getGroupId()); - if (StringUtils.isNotEmpty(groupBean.getGroupName())) { - groupProfileBuilder.setGroupName(groupBean.getGroupName()); - } - if (StringUtils.isNotEmpty(groupBean.getGroupPhoto())) { - groupProfileBuilder.setGroupIcon(groupBean.getGroupPhoto()); - } - responseBuilder.addList(groupProfileBuilder.build()); - } - ApiGroupListProto.ApiGroupListResponse response = responseBuilder.build(); - commandResponse.setParams(response.toByteArray()); - errCode = ErrorCode2.SUCCESS; - } else { - errCode = ErrorCode2.ERROR_PARAMETER; - } - } catch (Exception e) { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - /** - * 用户创建群,并添加初始群成员
- * 无权限限制 - * - * @param command - * @return - */ - public CommandResponse create(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupCreateProto.ApiGroupCreateRequest request = ApiGroupCreateProto.ApiGroupCreateRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId();// group owner - String groupName = request.getGroupName(); - ProtocolStringList groupMembers = request.getSiteUserIdsList(); - List groupMemberIds = Lists.newArrayList(groupMembers);// copy a new list - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isAnyEmpty(siteUserId, groupName) || groupMemberIds == null) { - throw new ZalyException(ErrorCode2.ERROR_PARAMETER); - } - - if (!SiteConfig.allowCreateGroups(siteUserId)) { - throw new ZalyException(ErrorCode2.ERROR2_GROUP_NOTALLOW); - } - // 检查用户是否被封禁,或者不存在 - for (String groupMemberId : groupMemberIds) { - SimpleUserBean bean = UserProfileDao.getInstance().getSimpleProfileById(groupMemberId); - if (bean == null || bean.getUserStatus() == 1) { - groupMemberIds.remove(groupMemberId); - } - } - - if (!groupMemberIds.contains(siteUserId)) { - groupMemberIds.add(siteUserId); - } - - if (groupMemberIds.size() < 3) { - throw new ZalyException(ErrorCode2.ERROR_GROUP_MEMBERLESS3); - } - - GroupProfileBean groupBean = UserGroupDao.getInstance().createGroup(siteUserId, groupName, groupMemberIds); - if (groupBean != null && StringUtils.isNotEmpty(groupBean.getGroupId())) { - GroupProto.GroupProfile.Builder groupProfileBuilder = GroupProto.GroupProfile.newBuilder(); - groupProfileBuilder.setId(groupBean.getGroupId()); - if (StringUtils.isNotEmpty(groupBean.getGroupName())) { - groupProfileBuilder.setName(groupBean.getGroupName()); - } - if (StringUtils.isNotEmpty(groupBean.getGroupPhoto())) { - groupProfileBuilder.setIcon(String.valueOf(groupBean.getGroupPhoto())); - } - - ApiGroupCreateProto.ApiGroupCreateResponse response = ApiGroupCreateProto.ApiGroupCreateResponse - .newBuilder().setProfile(groupProfileBuilder.build()).build(); - commandResponse.setParams(response.toByteArray()); - errCode = ErrorCode2.SUCCESS; - } else { - errCode = ErrorCode2.ERROR_GROUP_WHEN_CREATE; - } - - } catch (Exception e) { - if (e instanceof ZalyException) { - errCode = ((ZalyException) e).getErrCode(); - } else { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - } - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - /** - *
-	 * 用户删除群,此时需要验证用户是否具有权限 
- * 目前:具有权限的仅为群的创建者 (群主) - *
- * - * @param command - * @return - */ - public CommandResponse delete(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupDeleteProto.ApiGroupDeleteRequest request = ApiGroupDeleteProto.ApiGroupDeleteRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String groupId = request.getGroupId(); - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isNoneEmpty(siteUserId, groupId)) { - - if (!checkGroupStatus(groupId)) { - throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); - } - - String groupMasterId = UserGroupDao.getInstance().getGroupMaster(groupId); - if (siteUserId.equals(groupMasterId)) { - if (UserGroupDao.getInstance().deleteGroup(groupId)) { - errCode = ErrorCode2.SUCCESS; - } - } else { - errCode = ErrorCode2.ERROR_NOPERMISSION; - } - } else { - errCode = ErrorCode2.ERROR_PARAMETER; - } - } catch (Exception e) { - if (e instanceof ZalyException) { - errCode = ((ZalyException) e).getErrCode(); - } else { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - } - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - /** - * 获取群资料信息,一般由以下几部分组成
- * 1.群资料GroupProfile
- * 2.群主基本资料GroupMaster,群主通过GroupProfile获取
- * 3.群成员人数以及排在最前列的四位用户
- * 4.无权限限制 - * - * @param command - * @return - */ - public CommandResponse profile(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupProfileProto.ApiGroupProfileRequest request = ApiGroupProfileProto.ApiGroupProfileRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String groupId = request.getGroupId(); - int pageNum = 1; - int pageSize = GroupConfig.GROUP_MIN_MEMBER_COUNT; - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isAnyEmpty(siteUserId, groupId)) { - throw new ZalyException(ErrorCode2.ERROR_PARAMETER); - } - - if (!checkGroupStatus(groupId)) { - throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); - } - - GroupProfileBean groupBean = UserGroupDao.getInstance().getGroupProfile(groupId); - if (groupBean == null || StringUtils.isEmpty(groupBean.getGroupId())) { - throw new ZalyException(ErrorCode2.ERROR_GROUP_QUERY_PROFILE); - } - - SimpleUserBean ownerProfileBean = UserProfileDao.getInstance() - .getSimpleProfileById(groupBean.getCreateUserId()); - logger.debug("get groupId={},groupOwner={}", groupId, ownerProfileBean.toString()); - - int groupMembersCount = UserGroupDao.getInstance().getGroupMemberCount(groupId); - logger.debug("get groupId={},groupMembers={}", groupId, groupMembersCount); - - List groupMemberList = UserGroupDao.getInstance().getGroupMemberList(groupId, pageNum, - pageSize); - - UserProto.UserProfile ownerProfile = UserProto.UserProfile.newBuilder() - .setSiteUserId(String.valueOf(ownerProfileBean.getUserId())) - .setUserPhoto(String.valueOf(ownerProfileBean.getUserPhoto())) - .setUserName(String.valueOf(ownerProfileBean.getUserName())).build(); - GroupProto.GroupProfile groupProfile = GroupProto.GroupProfile.newBuilder().setId(groupBean.getGroupId()) - .setName(String.valueOf(groupBean.getGroupName())) - .setIcon(String.valueOf(groupBean.getGroupPhoto())).build(); - - ApiGroupProfileProto.ApiGroupProfileResponse.Builder responseBuilder = ApiGroupProfileProto.ApiGroupProfileResponse - .newBuilder(); - responseBuilder.setOwner(ownerProfile); - responseBuilder.setProfile(groupProfile); - responseBuilder.setGroupMemberCount(groupMembersCount); - - for (GroupMemberBean memberBean : groupMemberList) { - UserProto.UserProfile memberProfile = UserProto.UserProfile.newBuilder() - .setSiteUserId(String.valueOf(memberBean.getUserId())) - .setUserPhoto(String.valueOf(memberBean.getUserPhoto())) - .setUserName(String.valueOf(memberBean.getUserName())).build(); - GroupProto.GroupMemberProfile groupMemberProfile = GroupProto.GroupMemberProfile.newBuilder() - .setProfile(memberProfile).build(); - responseBuilder.addGroupLastestMember(groupMemberProfile); - } - // 是否可以邀请群聊(除了群主以外) - responseBuilder.setCloseInviteGroupChat(groupBean.isCloseInviteGroupChat()); - ApiGroupProfileProto.ApiGroupProfileResponse response = responseBuilder.build(); - - commandResponse.setParams(response.toByteArray()); - errCode = ErrorCode2.SUCCESS; - } catch (Exception e) { - if (e instanceof ZalyException) { - errCode = ((ZalyException) e).getErrCode(); - } else { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - } - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - /** - * 用户更新群资料
- * 群主/管理员权限限制 - * - * @param command - * @return - */ - public CommandResponse updateProfile(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupUpdateProfileProto.ApiGroupUpdateProfileRequest request = ApiGroupUpdateProfileProto.ApiGroupUpdateProfileRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String groupId = request.getProfile().getId(); - String photoId = request.getProfile().getIcon(); - String groupName = request.getProfile().getName(); - String groupNotice = request.getProfile().getGroupNotice(); - // 新的群群主 - String newGroupOwner = request.getNewGroupOwner(); - // 是否可以邀请群聊(除了群主以外的其他群成员) - boolean closeInviteGroupChat = request.getCloseInviteGroupChat(); - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isAnyEmpty(siteUserId, groupId)) { - throw new ZalyException(ErrorCode2.ERROR_PARAMETER); - } - - if (!checkGroupStatus(groupId)) { - throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); - } - - // 判断是否具有权限,群主拥有权限 - String groupMasterId = UserGroupDao.getInstance().getGroupMaster(groupId); - if (siteUserId.equals(groupMasterId)) { - GroupProfileBean gprofileBean = new GroupProfileBean(); - gprofileBean.setGroupId(groupId); - gprofileBean.setGroupName(groupName); - gprofileBean.setGroupPhoto(photoId); - gprofileBean.setGroupNotice(groupNotice); - gprofileBean.setCreateUserId(newGroupOwner); - gprofileBean.setCloseInviteGroupChat(closeInviteGroupChat); - - if (StringUtils.isNotEmpty(groupName)) { - if (UserGroupDao.getInstance().updateGroupProfile(gprofileBean)) { - errCode = ErrorCode2.SUCCESS; - } - } else { - if (UserGroupDao.getInstance().updateGroupIGC(gprofileBean)) { - errCode = ErrorCode2.SUCCESS; - } - } - } else { - errCode = ErrorCode2.ERROR_NOPERMISSION; - } - - } catch (Exception e) { - if (e instanceof ZalyException) { - errCode = ((ZalyException) e).getErrCode(); - } else { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - } - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - /** - * 添加群成员,支持群成员拉取好友进群,因此无群主权限限制
- * 无管理员权限限制 -> 添加群资料中是否允许添加成员 - * - * @param command - * @return - */ - public CommandResponse addMember(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupAddMemberProto.ApiGroupAddMemberRequest request = ApiGroupAddMemberProto.ApiGroupAddMemberRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String groupId = request.getGroupId(); - ProtocolStringList memberList = request.getUserListList(); - List addMemberList = Lists.newArrayList(memberList);// copy a new list - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isAnyEmpty(siteUserId, groupId) || addMemberList == null) { - throw new ZalyException(ErrorCode2.ERROR_PARAMETER); - } - // 群是否存在 - if (!checkGroupStatus(groupId)) { - throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); - } - - // 校验用户,删除禁封的用户 - for (String groupMemberId : addMemberList) { - SimpleUserBean bean = UserProfileDao.getInstance().getSimpleProfileById(groupMemberId); - if (bean == null || bean.getUserStatus() == 1) { - addMemberList.remove(groupMemberId); - } - } - - GroupProfileBean bean = UserGroupDao.getInstance().getGroupProfile(groupId); - // 校验权限 - if (checkAddMemberPermission(siteUserId, bean)) { - int currentSize = UserGroupDao.getInstance().getGroupMemberCount(groupId); - int maxSize = SiteConfig.getMaxGroupMemberSize(); - if (currentSize + addMemberList.size() <= maxSize) { - if (UserGroupDao.getInstance().addGroupMember(siteUserId, groupId, addMemberList)) { - errCode = ErrorCode2.SUCCESS; - } - } else { - errCode = ErrorCode2.ERROR_GROUP_MAXMEMBERCOUNT; - } - } else { - errCode = ErrorCode2.ERROR_GROUP_INVITE_CHAT_CLOSE; - } - - } catch (Exception e) { - if (e instanceof ZalyException) { - errCode = ((ZalyException) e).getErrCode(); - } else { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - } - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - /** - *
-	 * 添加群成员权限:
-	 * 		1.关闭的开关是打开的
-	 * 		2.是管理员操作
-	 * 
- * - * @param siteUserId - * @param bean - * @return - */ - private boolean checkAddMemberPermission(String siteUserId, GroupProfileBean bean) { - if (bean != null) { - if (!bean.isCloseInviteGroupChat() || siteUserId.equals(bean.getCreateUserId())) { - return true; - } - } - return false; - } - - public CommandResponse removeMember(Command command) { - return deleteMember(command); - } - - /** - * 群主以及管理员删除群成员
- * 群主/管理员权限限制 - * - * @param command - * @return - */ - public CommandResponse deleteMember(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupRemoveMemberProto.ApiGroupRemoveMemberRequest request = ApiGroupRemoveMemberProto.ApiGroupRemoveMemberRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String groupId = request.getGroupId(); - ProtocolStringList deleteMemberIds = request.getSiteUserIdList(); - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isAnyBlank(siteUserId, groupId) || deleteMemberIds == null) { - throw new ZalyException(ErrorCode2.ERROR_PARAMETER); - } - - if (!checkGroupStatus(groupId)) { - throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); - } - - String groupMasterId = UserGroupDao.getInstance().getGroupMaster(groupId); - if (siteUserId.equals(groupMasterId)) { - if (UserGroupDao.getInstance().deleteGroupMember(groupId, deleteMemberIds)) { - errCode = ErrorCode2.SUCCESS; - } - } else { - errCode = ErrorCode2.ERROR_NOPERMISSION; - } - - } catch (Exception e) { - if (e instanceof ZalyException) { - errCode = ((ZalyException) e).getErrCode(); - } else { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - } - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - /** - * 用户退群
- * 无权限限制 - * - * @param command - * @return - */ - public CommandResponse quit(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupQuitProto.ApiGroupQuitRequest request = ApiGroupQuitProto.ApiGroupQuitRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String groupId = request.getGroupId(); - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isNoneEmpty(siteUserId, groupId)) { - if (UserGroupDao.getInstance().quitGroup(groupId, siteUserId)) { - errCode = ErrorCode2.SUCCESS; - } - } else { - errCode = ErrorCode2.ERROR_PARAMETER; - } - } catch (Exception e) { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - /** - * 获取群成员
- * 无权限控制 - * - * @param command - * @return - */ - public CommandResponse members(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupMembersProto.ApiGroupMembersRequest request = ApiGroupMembersProto.ApiGroupMembersRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String siteGroupId = request.getGroupId(); - int pageNum = 1; - int pageSize = GroupConfig.GROUP_MAX_MEMBER_COUNT; - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isAnyEmpty(siteUserId, siteGroupId)) { - throw new ZalyException(ErrorCode2.ERROR_PARAMETER); - } - - if (!checkGroupStatus(siteGroupId)) { - throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); - } - - List memberList = UserGroupDao.getInstance().getGroupMemberList(siteGroupId, pageNum, - pageSize); - ApiGroupMembersProto.ApiGroupMembersResponse.Builder responseBuilder = ApiGroupMembersProto.ApiGroupMembersResponse - .newBuilder(); - for (GroupMemberBean member : memberList) { - GroupProto.GroupMemberRole memberRole = GroupProto.GroupMemberRole.forNumber(member.getUserRole()); - UserProto.UserProfile memberProfile = UserProto.UserProfile.newBuilder() - .setSiteUserId(member.getUserId()).setUserName(String.valueOf(member.getUserName())) - .setUserPhoto(String.valueOf(member.getUserPhoto())).build(); - GroupProto.GroupMemberProfile groupMember = GroupProto.GroupMemberProfile.newBuilder() - .setRole(memberRole).setProfile(memberProfile).build(); - responseBuilder.addList(groupMember); - } - commandResponse.setParams(responseBuilder.build().toByteArray()); - errCode = ErrorCode2.SUCCESS; - - } catch (Exception e) { - if (e instanceof ZalyException) { - errCode = ((ZalyException) e).getErrCode(); - } else { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - } - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - /** - * 获取用户群组中,不存在的好友用户 - * - * @param command - * @return - */ - public CommandResponse nonMembers(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupNonMembersProto.ApiGroupNonMembersRequest request = ApiGroupNonMembersProto.ApiGroupNonMembersRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String groupId = request.getGroupId(); - int pageNum = request.getPageNumber(); - int pageSize = request.getPageSize(); - if (pageNum == 0 && pageSize == 0) { - pageNum = 1; - pageSize = 100; - } - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isAnyEmpty(siteUserId, groupId)) { - throw new ZalyException(ErrorCode2.ERROR_PARAMETER); - } - - if (!checkGroupStatus(groupId)) { - throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); - } - - List userFriendList = UserGroupDao.getInstance().getUserFriendNonGroupMemberList(siteUserId, - groupId, pageNum, pageSize); - ApiGroupNonMembersProto.ApiGroupNonMembersResponse.Builder responseBuilder = ApiGroupNonMembersProto.ApiGroupNonMembersResponse - .newBuilder(); - for (SimpleUserBean friendBean : userFriendList) { - UserProto.SimpleUserProfile friendProfile = UserProto.SimpleUserProfile.newBuilder() - .setSiteUserId(friendBean.getUserId()).setUserName(String.valueOf(friendBean.getUserName())) - .setUserPhoto(String.valueOf(friendBean.getUserPhoto())).build(); - responseBuilder.addProfile(friendProfile); - } - commandResponse.setParams(responseBuilder.build().toByteArray()); - errCode = ErrorCode2.SUCCESS; - - } catch (Exception e) { - if (e instanceof ZalyException) { - errCode = ((ZalyException) e).getErrCode(); - } else { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - } - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - /** - * 获取个人对群的设置 - * - * @param command - * @return - */ - @Deprecated - public CommandResponse setting(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupSettingProto.ApiGroupSettingRequest request = ApiGroupSettingProto.ApiGroupSettingRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String groupId = request.getGroupId(); - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isNoneEmpty(siteUserId, groupId)) { - UserGroupBean bean = UserGroupDao.getInstance().getUserGroupSetting(siteUserId, groupId); - if (bean != null) { - ApiGroupSettingProto.ApiGroupSettingResponse response = ApiGroupSettingProto.ApiGroupSettingResponse - .newBuilder().setMessageMute(bean.isMute()).build(); - commandResponse.setParams(response.toByteArray()); - errCode = ErrorCode2.SUCCESS; - } else { - errCode = ErrorCode2.ERROR_DATABASE_EXECUTE; - } - } else { - errCode = ErrorCode2.ERROR_PARAMETER; - } - - } catch (Exception e) { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - /** - * 个人更新群设置信息 - * - * @param command - * @return - */ - @Deprecated - public CommandResponse updateSetting(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest request = ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String groupId = request.getGroupId(); - boolean isMute = request.getMessageMute(); - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isNoneEmpty(siteUserId, groupId)) { - UserGroupBean bean = new UserGroupBean(); - bean.setSiteGroupId(groupId); - bean.setMute(isMute); - if (UserGroupDao.getInstance().updateUserGroupSetting(siteUserId, bean)) { - errCode = ErrorCode2.SUCCESS; - } else { - errCode = ErrorCode2.ERROR_DATABASE_EXECUTE; - } - } else { - errCode = ErrorCode2.ERROR_PARAMETER; - } - - } catch (Exception e) { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - public CommandResponse mute(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupMuteProto.ApiGroupMuteRequest request = ApiGroupMuteProto.ApiGroupMuteRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String siteGroupId = request.getSiteGroupId(); - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isAnyEmpty(siteUserId, siteGroupId)) { - throw new ZalyException(ErrorCode2.ERROR_PARAMETER); - } - - if (!checkGroupStatus(siteGroupId)) { - throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); - } - - UserGroupBean bean = UserGroupDao.getInstance().getUserGroupSetting(siteUserId, siteGroupId); - if (bean != null) { - ApiGroupSettingProto.ApiGroupSettingResponse response = ApiGroupSettingProto.ApiGroupSettingResponse - .newBuilder().setMessageMute(bean.isMute()).build(); - commandResponse.setParams(response.toByteArray()); - errCode = ErrorCode2.SUCCESS; - } else { - errCode = ErrorCode2.ERROR_DATABASE_EXECUTE; - } - - } catch (Exception e) { - if (e instanceof ZalyException) { - errCode = ((ZalyException) e).getErrCode(); - } else { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - } - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - /** - * 个人更新群设置信息 - * - * @param command - * @return - */ - public CommandResponse updateMute(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest request = ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String groupId = request.getGroupId(); - boolean isMute = request.getMessageMute(); - LogUtils.requestDebugLog(logger, command, request.toString()); - - if (StringUtils.isAnyEmpty(siteUserId, groupId)) { - throw new ZalyException2(ErrorCode2.ERROR_PARAMETER); - } - - if (!checkGroupStatus(groupId)) { - throw new ZalyException2(ErrorCode2.ERROR_GROUP_DELETED); - } - - UserGroupBean bean = new UserGroupBean(); - bean.setSiteGroupId(groupId); - bean.setMute(isMute); - if (UserGroupDao.getInstance().updateUserGroupSetting(siteUserId, bean)) { - errCode = ErrorCode2.SUCCESS; - } else { - errCode = ErrorCode2.ERROR_DATABASE_EXECUTE; - } - - } catch (Exception e) { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - LogUtils.requestErrorLog(logger, command, e); - } catch (ZalyException2 e) { - errCode = e.getErrCode(); - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } - - // 检测群主是否存在 - private boolean checkGroupStatus(String groupId) { - int status = UserGroupDao.getInstance().getGroupStatus(groupId); - return status == 1; - } - - /** - * api.group.qrcode 获取群的二维码 - * - * @param command - * @return - */ - public CommandResponse applyToken(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupApplyTokenProto.ApiGroupApplyTokenRequest request = ApiGroupApplyTokenProto.ApiGroupApplyTokenRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String siteGroupId = request.getSiteGroupId(); - - if (StringUtils.isAnyEmpty(siteUserId, siteGroupId)) { - throw new ZalyException2(ErrorCode2.ERROR_PARAMETER); - } - - String groupToken = null; - long expireTime = 0; - - // 查找一天之内的是否存在token - long time = System.currentTimeMillis() - 24 * 60 * 60 * 1000l; - ExpireToken existsToken = ExpireTokenDao.getInstance().getExpireTokenByBid(siteGroupId, time); - - if (existsToken != null && StringUtils.isNotEmpty(existsToken.getToken())) { - int status = existsToken.getStatus(); - expireTime = existsToken.getExpireTime(); - } else { - int day = SiteConfig.getGroupQRExpireDay(); - - ExpireToken tokenBean = new ExpireToken(); - tokenBean.setBid(siteGroupId); - tokenBean.setBtype(TokenProto.TokenType.GROUP_TOKEN_VALUE); - tokenBean.setStatus(TokenProto.GroupTokenStatus.GROUP_TOKEN_AVAILABLE_VALUE); - String nToken = TokenProto.TokenType.GROUP_TOKEN_VALUE + UUID.randomUUID().toString().replace("-", ""); - tokenBean.setToken(nToken); - long nowTime = System.currentTimeMillis(); - tokenBean.setCreateTime(nowTime); - tokenBean.setExpireTime(nowTime + day * 24 * 60 * 60 * 1000l); - if (ExpireTokenDao.getInstance().addToken(tokenBean)) { - groupToken = tokenBean.getToken(); - expireTime = tokenBean.getExpireTime(); - } - } - - if (StringUtils.isNotEmpty(groupToken) && expireTime > 0) { - ApiGroupApplyTokenProto.ApiGroupApplyTokenResponse response = ApiGroupApplyTokenProto.ApiGroupApplyTokenResponse - .newBuilder().setExpireTime(expireTime).setToken(groupToken).build(); - commandResponse.setParams(response.toByteArray()); - errCode = ErrorCode2.SUCCESS; - } - } catch (ZalyException2 e) { - errCode = e.getErrCode(); - LogUtils.requestErrorLog(logger, command, e); - } catch (Exception e) { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - LogUtils.requestErrorLog(logger, command, e); - } - - return commandResponse.setErrCode(errCode); - } - - public CommandResponse joinByToken(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiGroupJoinByTokenProto.ApiGroupJoinByTokenRequest request = ApiGroupJoinByTokenProto.ApiGroupJoinByTokenRequest - .parseFrom(command.getParams()); - String siteUserId = command.getSiteUserId(); - String siteGroupId = request.getSiteGroupId(); - String token = request.getToken(); - - if (StringUtils.isAnyEmpty(siteGroupId, token)) { - throw new ZalyException2(ErrorCode2.ERROR_PARAMETER); - } - - // 群是否存在 - if (!checkGroupStatus(siteGroupId)) { - throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); - } - - ExpireToken expireToken = ExpireTokenDao.getInstance().getExpireToken(token); - - if (expireToken == null || StringUtils.isEmpty(expireToken.getToken())) { - throw new ZalyException2(ErrorCode2.ERROR2_GROUP_TOKEN_INVALID); - } - - if (System.currentTimeMillis() > expireToken.getExpireTime()) { - throw new ZalyException2(ErrorCode2.ERROR2_GROUP_TOKEN_EXPIRED); - } - - GroupProfileBean bean = UserGroupDao.getInstance().getGroupProfile(siteGroupId); - - // 校验权限 - if (!checkAddMemberPermission(siteUserId, bean)) { - throw new ZalyException2(ErrorCode2.ERROR_GROUP_INVITE_CHAT_CLOSE); - } - - if (UserGroupDao.getInstance().isGroupMember(siteUserId, siteGroupId)) { - throw new ZalyException2(ErrorCode2.ERROR2_GROUP_ISMEMBER); - } - - // 加人入群 - int currentSize = UserGroupDao.getInstance().getGroupMemberCount(siteGroupId); - int maxSize = SiteConfig.getMaxGroupMemberSize(); - if (currentSize < maxSize) { - if (UserGroupDao.getInstance().addGroupMemberByToken(siteGroupId, siteUserId)) { - errCode = ErrorCode2.SUCCESS; - } - } else { - errCode = ErrorCode2.ERROR_GROUP_MAXMEMBERCOUNT; - } - - } catch (ZalyException2 e) { - errCode = e.getErrCode(); - LogUtils.requestErrorLog(logger, command, e); - } catch (Exception e) { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - LogUtils.requestErrorLog(logger, command, e); - } - - return commandResponse.setErrCode(errCode); - } + private static final Logger logger = LoggerFactory.getLogger(ApiGroupService.class); + + /** + * 获取用户群列表
+ * 无权限限制 + * + * @param command + * @return + */ + @ApiActions(action = ".list") + public CommandResponse list(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupListProto.ApiGroupListRequest request = ApiGroupListProto.ApiGroupListRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isNotBlank(siteUserId) && siteUserId.equals(siteUserId)) { + List groupBeanList = UserGroupDao.getInstance().getUserGroupList(siteUserId); + ApiGroupListProto.ApiGroupListResponse.Builder responseBuilder = ApiGroupListProto.ApiGroupListResponse + .newBuilder(); + for (SimpleGroupBean groupBean : groupBeanList) { + GroupProto.SimpleGroupProfile.Builder groupProfileBuilder = GroupProto.SimpleGroupProfile + .newBuilder(); + groupProfileBuilder.setGroupId(groupBean.getGroupId()); + if (StringUtils.isNotEmpty(groupBean.getGroupName())) { + groupProfileBuilder.setGroupName(groupBean.getGroupName()); + } + if (StringUtils.isNotEmpty(groupBean.getGroupPhoto())) { + groupProfileBuilder.setGroupIcon(groupBean.getGroupPhoto()); + } + responseBuilder.addList(groupProfileBuilder.build()); + } + ApiGroupListProto.ApiGroupListResponse response = responseBuilder.build(); + commandResponse.setParams(response.toByteArray()); + errCode = ErrorCode2.SUCCESS; + } else { + errCode = ErrorCode2.ERROR_PARAMETER; + } + } catch (Exception e) { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } + + /** + * 用户创建群,并添加初始群成员
+ * 无权限限制 + * + * @param command + * @return + */ + @ApiActions(action = ".create") + public CommandResponse create(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupCreateProto.ApiGroupCreateRequest request = ApiGroupCreateProto.ApiGroupCreateRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId();// group owner + String groupName = request.getGroupName(); + ProtocolStringList groupMembers = request.getSiteUserIdsList(); + List groupMemberIds = Lists.newArrayList(groupMembers);// copy a new list + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isAnyEmpty(siteUserId, groupName) || groupMemberIds == null) { + throw new ZalyException(ErrorCode2.ERROR_PARAMETER); + } + + if (!SiteConfig.allowCreateGroups(siteUserId)) { + throw new ZalyException(ErrorCode2.ERROR2_GROUP_NOTALLOW); + } + // 检查用户是否被封禁,或者不存在 + for (String groupMemberId : groupMemberIds) { + SimpleUserBean bean = UserProfileDao.getInstance().getSimpleProfileById(groupMemberId); + if (bean == null || bean.getUserStatus() == 1) { + groupMemberIds.remove(groupMemberId); + } + } + + if (!groupMemberIds.contains(siteUserId)) { + groupMemberIds.add(siteUserId); + } + + if (groupMemberIds.size() < 3) { + throw new ZalyWarning(ErrorCode2.ERROR_GROUP_MEMBERLESS3); + } + + GroupProfileBean groupBean = UserGroupDao.getInstance().createGroup(siteUserId, groupName, groupMemberIds); + if (groupBean != null && StringUtils.isNotEmpty(groupBean.getGroupId())) { + GroupProto.GroupProfile.Builder groupProfileBuilder = GroupProto.GroupProfile.newBuilder(); + groupProfileBuilder.setId(groupBean.getGroupId()); + if (StringUtils.isNotEmpty(groupBean.getGroupName())) { + groupProfileBuilder.setName(groupBean.getGroupName()); + } + if (StringUtils.isNotEmpty(groupBean.getGroupPhoto())) { + groupProfileBuilder.setIcon(String.valueOf(groupBean.getGroupPhoto())); + } + + ApiGroupCreateProto.ApiGroupCreateResponse response = ApiGroupCreateProto.ApiGroupCreateResponse + .newBuilder().setProfile(groupProfileBuilder.build()).build(); + commandResponse.setParams(response.toByteArray()); + errCode = ErrorCode2.SUCCESS; + } else { + errCode = ErrorCode2.ERROR_GROUP_WHEN_CREATE; + } + + } catch (Exception e) { + if (e instanceof ZalyWarning) { + errCode = ((ZalyWarning) e).getErrCode(); + LogUtils.requestWarnLog(logger, command, errCode.getInfo()); + } else if (e instanceof ZalyException) { + errCode = ((ZalyException) e).getErrCode(); + LogUtils.requestErrorLog(logger, command, e); + } else { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + LogUtils.requestErrorLog(logger, command, e); + } + } + return commandResponse.setErrCode(errCode); + } + + /** + *
+     * 用户删除群,此时需要验证用户是否具有权限 
+ * 目前:具有权限的仅为群的创建者 (群主) + *
+ * + * @param command + * @return + */ + @ApiActions(action = ".delete") + public CommandResponse delete(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupDeleteProto.ApiGroupDeleteRequest request = ApiGroupDeleteProto.ApiGroupDeleteRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String groupId = request.getGroupId(); + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isNoneEmpty(siteUserId, groupId)) { + + if (!checkGroupStatus(groupId)) { + throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); + } + + String groupMasterId = UserGroupDao.getInstance().getGroupMaster(groupId); + if (siteUserId.equals(groupMasterId)) { + if (UserGroupDao.getInstance().deleteGroup(groupId)) { + errCode = ErrorCode2.SUCCESS; + } + } else { + errCode = ErrorCode2.ERROR_NOPERMISSION; + } + } else { + errCode = ErrorCode2.ERROR_PARAMETER; + } + } catch (Exception e) { + if (e instanceof ZalyException) { + errCode = ((ZalyException) e).getErrCode(); + } else { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + } + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } + + /** + * 获取群资料信息,一般由以下几部分组成
+ * 1.群资料GroupProfile
+ * 2.群主基本资料GroupMaster,群主通过GroupProfile获取
+ * 3.群成员人数以及排在最前列的四位用户
+ * 4.无权限限制 + * + * @param command + * @return + */ + @ApiActions(action = ".profile") + public CommandResponse profile(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupProfileProto.ApiGroupProfileRequest request = ApiGroupProfileProto.ApiGroupProfileRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String groupId = request.getGroupId(); + int pageNum = 1; + int pageSize = GroupConfig.GROUP_MIN_MEMBER_COUNT; + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isAnyEmpty(siteUserId, groupId)) { + throw new ZalyException(ErrorCode2.ERROR_PARAMETER); + } + + if (!checkGroupStatus(groupId)) { + throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); + } + + GroupProfileBean groupBean = UserGroupDao.getInstance().getGroupProfile(groupId); + if (groupBean == null || StringUtils.isEmpty(groupBean.getGroupId())) { + throw new ZalyException(ErrorCode2.ERROR_GROUP_QUERY_PROFILE); + } + + SimpleUserBean ownerProfileBean = UserProfileDao.getInstance() + .getSimpleProfileById(groupBean.getCreateUserId()); + logger.debug("get groupId={},groupOwner={}", groupId, ownerProfileBean.toString()); + + int groupMembersCount = UserGroupDao.getInstance().getGroupMemberCount(groupId); + logger.debug("get groupId={},groupMembers={}", groupId, groupMembersCount); + + List groupMemberList = UserGroupDao.getInstance().getGroupMemberList(groupId, pageNum, + pageSize); + + UserProto.UserProfile ownerProfile = UserProto.UserProfile.newBuilder() + .setSiteUserId(String.valueOf(ownerProfileBean.getUserId())) + .setUserPhoto(String.valueOf(ownerProfileBean.getUserPhoto())) + .setUserName(String.valueOf(ownerProfileBean.getUserName())).build(); + GroupProto.GroupProfile groupProfile = GroupProto.GroupProfile.newBuilder().setId(groupBean.getGroupId()) + .setName(String.valueOf(groupBean.getGroupName())) + .setIcon(String.valueOf(groupBean.getGroupPhoto())).build(); + + ApiGroupProfileProto.ApiGroupProfileResponse.Builder responseBuilder = ApiGroupProfileProto.ApiGroupProfileResponse + .newBuilder(); + responseBuilder.setOwner(ownerProfile); + responseBuilder.setProfile(groupProfile); + responseBuilder.setGroupMemberCount(groupMembersCount); + + for (GroupMemberBean memberBean : groupMemberList) { + UserProto.UserProfile memberProfile = UserProto.UserProfile.newBuilder() + .setSiteUserId(String.valueOf(memberBean.getUserId())) + .setUserPhoto(String.valueOf(memberBean.getUserPhoto())) + .setUserName(String.valueOf(memberBean.getUserName())).build(); + GroupProto.GroupMemberProfile groupMemberProfile = GroupProto.GroupMemberProfile.newBuilder() + .setProfile(memberProfile).build(); + responseBuilder.addGroupLastestMember(groupMemberProfile); + } + // 是否可以邀请群聊(除了群主以外) + responseBuilder.setCloseInviteGroupChat(groupBean.isCloseInviteGroupChat()); + ApiGroupProfileProto.ApiGroupProfileResponse response = responseBuilder.build(); + + commandResponse.setParams(response.toByteArray()); + errCode = ErrorCode2.SUCCESS; + } catch (Exception e) { + if (e instanceof ZalyException) { + errCode = ((ZalyException) e).getErrCode(); + } else { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + } + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } + + /** + * 用户更新群资料
+ * 群主/管理员权限限制 + * + * @param command + * @return + */ + @ApiActions(action = ".updateProfile") + public CommandResponse updateProfile(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupUpdateProfileProto.ApiGroupUpdateProfileRequest request = ApiGroupUpdateProfileProto.ApiGroupUpdateProfileRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String groupId = request.getProfile().getId(); + String photoId = request.getProfile().getIcon(); + String groupName = request.getProfile().getName(); + String groupNotice = request.getProfile().getGroupNotice(); + // 新的群群主 + String newGroupOwner = request.getNewGroupOwner(); + // 是否可以邀请群聊(除了群主以外的其他群成员) + boolean closeInviteGroupChat = request.getCloseInviteGroupChat(); + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isAnyEmpty(siteUserId, groupId)) { + throw new ZalyException(ErrorCode2.ERROR_PARAMETER); + } + + if (!checkGroupStatus(groupId)) { + throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); + } + + // 判断是否具有权限,群主拥有权限 + String groupMasterId = UserGroupDao.getInstance().getGroupMaster(groupId); + if (siteUserId.equals(groupMasterId)) { + GroupProfileBean gprofileBean = new GroupProfileBean(); + gprofileBean.setGroupId(groupId); + gprofileBean.setGroupName(groupName); + gprofileBean.setGroupPhoto(photoId); + gprofileBean.setGroupNotice(groupNotice); + gprofileBean.setCreateUserId(newGroupOwner); + gprofileBean.setCloseInviteGroupChat(closeInviteGroupChat); + + if (StringUtils.isNotEmpty(groupName)) { + if (UserGroupDao.getInstance().updateGroupProfile(gprofileBean)) { + errCode = ErrorCode2.SUCCESS; + } + } else { + if (UserGroupDao.getInstance().updateGroupIGC(gprofileBean)) { + errCode = ErrorCode2.SUCCESS; + } + } + } else { + errCode = ErrorCode2.ERROR_NOPERMISSION; + } + + } catch (Exception e) { + if (e instanceof ZalyException) { + errCode = ((ZalyException) e).getErrCode(); + } else { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + } + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } + + /** + * 添加群成员,支持群成员拉取好友进群,因此无群主权限限制
+ * 无管理员权限限制 -> 添加群资料中是否允许添加成员 + * + * @param command + * @return + */ + @ApiActions(action = ".addMember") + public CommandResponse addMember(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupAddMemberProto.ApiGroupAddMemberRequest request = ApiGroupAddMemberProto.ApiGroupAddMemberRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String groupId = request.getGroupId(); + ProtocolStringList memberList = request.getUserListList(); + List addMemberList = Lists.newArrayList(memberList);// copy a new list + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isAnyEmpty(siteUserId, groupId) || addMemberList == null) { + throw new ZalyException(ErrorCode2.ERROR_PARAMETER); + } + // 群是否存在 + if (!checkGroupStatus(groupId)) { + throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); + } + + // 校验用户,删除禁封的用户 + for (String groupMemberId : addMemberList) { + SimpleUserBean bean = UserProfileDao.getInstance().getSimpleProfileById(groupMemberId); + if (bean == null || bean.getUserStatus() == 1) { + addMemberList.remove(groupMemberId); + } + } + + GroupProfileBean bean = UserGroupDao.getInstance().getGroupProfile(groupId); + // 校验权限 + if (checkAddMemberPermission(siteUserId, bean)) { + int currentSize = UserGroupDao.getInstance().getGroupMemberCount(groupId); + int maxSize = SiteConfig.getMaxGroupMemberSize(); + if (currentSize + addMemberList.size() <= maxSize) { + if (UserGroupDao.getInstance().addGroupMember(siteUserId, groupId, addMemberList)) { + errCode = ErrorCode2.SUCCESS; + } + } else { + errCode = ErrorCode2.ERROR_GROUP_MAXMEMBERCOUNT; + } + } else { + errCode = ErrorCode2.ERROR_GROUP_INVITE_CHAT_CLOSE; + } + + } catch (Exception e) { + if (e instanceof ZalyException) { + errCode = ((ZalyException) e).getErrCode(); + } else { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + } + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } + + /** + *
+     * 添加群成员权限:
+     * 		1.关闭的开关是打开的
+     * 		2.是管理员操作
+     * 
+ * + * @param siteUserId + * @param bean + * @return + */ + private boolean checkAddMemberPermission(String siteUserId, GroupProfileBean bean) { + if (bean != null) { + if (!bean.isCloseInviteGroupChat() || siteUserId.equals(bean.getCreateUserId())) { + return true; + } + } + return false; + } + + @ApiActions(action = ".removeMember") + public CommandResponse removeMember(Command command) { + return deleteMember(command); + } + + /** + * 群主以及管理员删除群成员
+ * 群主/管理员权限限制 + * + * @param command + * @return + */ + @ApiActions(action = ".deleteMember") + public CommandResponse deleteMember(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupRemoveMemberProto.ApiGroupRemoveMemberRequest request = ApiGroupRemoveMemberProto.ApiGroupRemoveMemberRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String groupId = request.getGroupId(); + ProtocolStringList deleteMemberIds = request.getSiteUserIdList(); + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isAnyBlank(siteUserId, groupId) || deleteMemberIds == null) { + throw new ZalyException(ErrorCode2.ERROR_PARAMETER); + } + + if (!checkGroupStatus(groupId)) { + throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); + } + + String groupMasterId = UserGroupDao.getInstance().getGroupMaster(groupId); + if (siteUserId.equals(groupMasterId)) { + if (UserGroupDao.getInstance().deleteGroupMember(groupId, deleteMemberIds)) { + errCode = ErrorCode2.SUCCESS; + } + } else { + errCode = ErrorCode2.ERROR_NOPERMISSION; + } + + } catch (Exception e) { + if (e instanceof ZalyException) { + errCode = ((ZalyException) e).getErrCode(); + } else { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + } + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } + + /** + * 用户退群
+ * 无权限限制 + * + * @param command + * @return + */ + @ApiActions(action = ".quit") + public CommandResponse quit(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupQuitProto.ApiGroupQuitRequest request = ApiGroupQuitProto.ApiGroupQuitRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String groupId = request.getGroupId(); + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isNoneEmpty(siteUserId, groupId)) { + if (UserGroupDao.getInstance().quitGroup(groupId, siteUserId)) { + errCode = ErrorCode2.SUCCESS; + } + } else { + errCode = ErrorCode2.ERROR_PARAMETER; + } + } catch (Exception e) { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } + + /** + * 获取群成员
+ * 无权限控制 + * + * @param command + * @return + */ + @ApiActions(action = ".members") + public CommandResponse members(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupMembersProto.ApiGroupMembersRequest request = ApiGroupMembersProto.ApiGroupMembersRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String siteGroupId = request.getGroupId(); + int pageNum = 1; + int pageSize = GroupConfig.GROUP_MAX_MEMBER_COUNT; + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isAnyEmpty(siteUserId, siteGroupId)) { + throw new ZalyException(ErrorCode2.ERROR_PARAMETER); + } + + if (!checkGroupStatus(siteGroupId)) { + throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); + } + + List memberList = UserGroupDao.getInstance().getGroupMemberList(siteGroupId, pageNum, + pageSize); + ApiGroupMembersProto.ApiGroupMembersResponse.Builder responseBuilder = ApiGroupMembersProto.ApiGroupMembersResponse + .newBuilder(); + for (GroupMemberBean member : memberList) { + GroupProto.GroupMemberRole memberRole = GroupProto.GroupMemberRole.forNumber(member.getUserRole()); + UserProto.UserProfile memberProfile = UserProto.UserProfile.newBuilder() + .setSiteUserId(member.getUserId()).setUserName(String.valueOf(member.getUserName())) + .setUserPhoto(String.valueOf(member.getUserPhoto())).build(); + GroupProto.GroupMemberProfile groupMember = GroupProto.GroupMemberProfile.newBuilder() + .setRole(memberRole).setProfile(memberProfile).build(); + responseBuilder.addList(groupMember); + } + commandResponse.setParams(responseBuilder.build().toByteArray()); + errCode = ErrorCode2.SUCCESS; + + } catch (Exception e) { + if (e instanceof ZalyException) { + errCode = ((ZalyException) e).getErrCode(); + } else { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + } + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } + + /** + * 获取用户群组中,不存在的好友用户 + * + * @param command + * @return + */ + @ApiActions(action = ".nonMembers") + public CommandResponse nonMembers(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupNonMembersProto.ApiGroupNonMembersRequest request = ApiGroupNonMembersProto.ApiGroupNonMembersRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String groupId = request.getGroupId(); + int pageNum = request.getPageNumber(); + int pageSize = request.getPageSize(); + if (pageNum == 0 && pageSize == 0) { + pageNum = 1; + pageSize = 100; + } + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isAnyEmpty(siteUserId, groupId)) { + throw new ZalyException(ErrorCode2.ERROR_PARAMETER); + } + + if (!checkGroupStatus(groupId)) { + throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); + } + + List userFriendList = UserGroupDao.getInstance().getUserFriendNonGroupMemberList(siteUserId, + groupId, pageNum, pageSize); + ApiGroupNonMembersProto.ApiGroupNonMembersResponse.Builder responseBuilder = ApiGroupNonMembersProto.ApiGroupNonMembersResponse + .newBuilder(); + for (SimpleUserBean friendBean : userFriendList) { + UserProto.SimpleUserProfile friendProfile = UserProto.SimpleUserProfile.newBuilder() + .setSiteUserId(friendBean.getUserId()).setUserName(String.valueOf(friendBean.getUserName())) + .setUserPhoto(String.valueOf(friendBean.getUserPhoto())).build(); + responseBuilder.addProfile(friendProfile); + } + commandResponse.setParams(responseBuilder.build().toByteArray()); + errCode = ErrorCode2.SUCCESS; + + } catch (Exception e) { + if (e instanceof ZalyException) { + errCode = ((ZalyException) e).getErrCode(); + } else { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + } + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } + + /** + * 获取个人对群的设置 + * + * @param command + * @return + */ + @Deprecated + @ApiActions(action = ".setting") + public CommandResponse setting(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupSettingProto.ApiGroupSettingRequest request = ApiGroupSettingProto.ApiGroupSettingRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String groupId = request.getGroupId(); + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isNoneEmpty(siteUserId, groupId)) { + UserGroupBean bean = UserGroupDao.getInstance().getUserGroupSetting(siteUserId, groupId); + if (bean != null) { + ApiGroupSettingProto.ApiGroupSettingResponse response = ApiGroupSettingProto.ApiGroupSettingResponse + .newBuilder().setMessageMute(bean.isMute()).build(); + commandResponse.setParams(response.toByteArray()); + errCode = ErrorCode2.SUCCESS; + } else { + errCode = ErrorCode2.ERROR_DATABASE_EXECUTE; + } + } else { + errCode = ErrorCode2.ERROR_PARAMETER; + } + + } catch (Exception e) { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } + + /** + * 个人更新群设置信息 + * + * @param command + * @return + */ + @Deprecated + @ApiActions(action = ".updateSetting") + public CommandResponse updateSetting(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest request = ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String groupId = request.getGroupId(); + boolean isMute = request.getMessageMute(); + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isNoneEmpty(siteUserId, groupId)) { + UserGroupBean bean = new UserGroupBean(); + bean.setSiteGroupId(groupId); + bean.setMute(isMute); + if (UserGroupDao.getInstance().updateUserGroupSetting(siteUserId, bean)) { + errCode = ErrorCode2.SUCCESS; + } else { + errCode = ErrorCode2.ERROR_DATABASE_EXECUTE; + } + } else { + errCode = ErrorCode2.ERROR_PARAMETER; + } + + } catch (Exception e) { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } + + /** + * 获取群静音状态 + * + * @param command + * @return + */ + @ApiActions(action = ".mute") + public CommandResponse mute(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupMuteProto.ApiGroupMuteRequest request = ApiGroupMuteProto.ApiGroupMuteRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String siteGroupId = request.getSiteGroupId(); + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isAnyEmpty(siteUserId, siteGroupId)) { + throw new ZalyException(ErrorCode2.ERROR_PARAMETER); + } + + if (!checkGroupStatus(siteGroupId)) { + throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); + } + + UserGroupBean bean = UserGroupDao.getInstance().getUserGroupSetting(siteUserId, siteGroupId); + if (bean != null) { + ApiGroupSettingProto.ApiGroupSettingResponse response = ApiGroupSettingProto.ApiGroupSettingResponse + .newBuilder().setMessageMute(bean.isMute()).build(); + commandResponse.setParams(response.toByteArray()); + errCode = ErrorCode2.SUCCESS; + } else { + errCode = ErrorCode2.ERROR_DATABASE_EXECUTE; + } + + } catch (Exception e) { + if (e instanceof ZalyException) { + errCode = ((ZalyException) e).getErrCode(); + } else { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + } + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } + + /** + * 设置群静音状态 + * + * @param command + * @return + */ + @ApiActions(action = ".updateMute") + public CommandResponse updateMute(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest request = ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String groupId = request.getGroupId(); + boolean isMute = request.getMessageMute(); + LogUtils.requestDebugLog(logger, command, request.toString()); + + if (StringUtils.isAnyEmpty(siteUserId, groupId)) { + throw new ZalyException2(ErrorCode2.ERROR_PARAMETER); + } + + if (!checkGroupStatus(groupId)) { + throw new ZalyException2(ErrorCode2.ERROR_GROUP_DELETED); + } + + UserGroupBean bean = new UserGroupBean(); + bean.setSiteGroupId(groupId); + bean.setMute(isMute); + if (UserGroupDao.getInstance().updateUserGroupSetting(siteUserId, bean)) { + errCode = ErrorCode2.SUCCESS; + } else { + errCode = ErrorCode2.ERROR_DATABASE_EXECUTE; + } + + } catch (Exception e) { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + LogUtils.requestErrorLog(logger, command, e); + } catch (ZalyException2 e) { + errCode = e.getErrCode(); + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } + + // 检测群主是否存在 + private boolean checkGroupStatus(String groupId) { + int status = UserGroupDao.getInstance().getGroupStatus(groupId); + return status == 1; + } + + /** + * api.group.qrcode 获取群的二维码 + * + * @param command + * @return + */ + @ApiActions(action = ".applyToken") + public CommandResponse applyToken(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupApplyTokenProto.ApiGroupApplyTokenRequest request = ApiGroupApplyTokenProto.ApiGroupApplyTokenRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String siteGroupId = request.getSiteGroupId(); + + if (StringUtils.isAnyEmpty(siteUserId, siteGroupId)) { + throw new ZalyException2(ErrorCode2.ERROR_PARAMETER); + } + + String groupToken = null; + long expireTime = 0; + + // 查找一天之内的是否存在token + long time = System.currentTimeMillis() - 24 * 60 * 60 * 1000l; + ExpireToken existsToken = ExpireTokenDao.getInstance().getExpireTokenByBid(siteGroupId, time); + + if (existsToken != null && StringUtils.isNotEmpty(existsToken.getToken())) { + int status = existsToken.getStatus(); + expireTime = existsToken.getExpireTime(); + } else { + int day = SiteConfig.getGroupQRExpireDay(); + + ExpireToken tokenBean = new ExpireToken(); + tokenBean.setBid(siteGroupId); + tokenBean.setBtype(TokenProto.TokenType.GROUP_TOKEN_VALUE); + tokenBean.setStatus(TokenProto.GroupTokenStatus.GROUP_TOKEN_AVAILABLE_VALUE); + String nToken = TokenProto.TokenType.GROUP_TOKEN_VALUE + UUID.randomUUID().toString().replace("-", ""); + tokenBean.setToken(nToken); + long nowTime = System.currentTimeMillis(); + tokenBean.setCreateTime(nowTime); + tokenBean.setExpireTime(nowTime + day * 24 * 60 * 60 * 1000l); + if (ExpireTokenDao.getInstance().addToken(tokenBean)) { + groupToken = tokenBean.getToken(); + expireTime = tokenBean.getExpireTime(); + } + } + + if (StringUtils.isNotEmpty(groupToken) && expireTime > 0) { + ApiGroupApplyTokenProto.ApiGroupApplyTokenResponse response = ApiGroupApplyTokenProto.ApiGroupApplyTokenResponse + .newBuilder().setExpireTime(expireTime).setToken(groupToken).build(); + commandResponse.setParams(response.toByteArray()); + errCode = ErrorCode2.SUCCESS; + } + } catch (ZalyException2 e) { + errCode = e.getErrCode(); + LogUtils.requestErrorLog(logger, command, e); + } catch (Exception e) { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + LogUtils.requestErrorLog(logger, command, e); + } + + return commandResponse.setErrCode(errCode); + } + + /** + * 通过扫二维码入群 + * + * @param command + * @return + */ + @ApiActions(action = ".joinByToken") + public CommandResponse joinByToken(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiGroupJoinByTokenProto.ApiGroupJoinByTokenRequest request = ApiGroupJoinByTokenProto.ApiGroupJoinByTokenRequest + .parseFrom(command.getParams()); + String siteUserId = command.getSiteUserId(); + String siteGroupId = request.getSiteGroupId(); + String token = request.getToken(); + + if (StringUtils.isAnyEmpty(siteGroupId, token)) { + throw new ZalyException2(ErrorCode2.ERROR_PARAMETER); + } + + // 群是否存在 + if (!checkGroupStatus(siteGroupId)) { + throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); + } + + ExpireToken expireToken = ExpireTokenDao.getInstance().getExpireToken(token); + + if (expireToken == null || StringUtils.isEmpty(expireToken.getToken())) { + throw new ZalyException2(ErrorCode2.ERROR2_GROUP_TOKEN_INVALID); + } + + if (System.currentTimeMillis() > expireToken.getExpireTime()) { + throw new ZalyException2(ErrorCode2.ERROR2_GROUP_TOKEN_EXPIRED); + } + + GroupProfileBean bean = UserGroupDao.getInstance().getGroupProfile(siteGroupId); + + // 校验权限 + if (!checkAddMemberPermission(siteUserId, bean)) { + throw new ZalyException2(ErrorCode2.ERROR_GROUP_INVITE_CHAT_CLOSE); + } + + if (UserGroupDao.getInstance().isGroupMember(siteUserId, siteGroupId)) { + throw new ZalyException2(ErrorCode2.ERROR2_GROUP_ISMEMBER); + } + + // 加人入群 + int currentSize = UserGroupDao.getInstance().getGroupMemberCount(siteGroupId); + int maxSize = SiteConfig.getMaxGroupMemberSize(); + if (currentSize < maxSize) { + if (UserGroupDao.getInstance().addGroupMemberByToken(siteGroupId, siteUserId)) { + errCode = ErrorCode2.SUCCESS; + } + } else { + errCode = ErrorCode2.ERROR_GROUP_MAXMEMBERCOUNT; + } + + } catch (ZalyException2 e) { + errCode = e.getErrCode(); + LogUtils.requestErrorLog(logger, command, e); + } catch (Exception e) { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + LogUtils.requestErrorLog(logger, command, e); + } + + return commandResponse.setErrCode(errCode); + } } diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiPluginService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiPluginService.java index 9a008ed..b94893a 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiPluginService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiPluginService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,18 +15,12 @@ */ package com.windchat.im.business.impl.tai; -import java.util.Base64; -import java.util.List; -import java.util.Map; - -//import org.apache.commons.codec.binary.Base64; -import com.windchat.im.business.dao.SitePluginDao; -import com.windchat.im.business.impl.AbstractRequest; -import com.windchat.im.business.impl.site.SiteConfig; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import com.akaxin.proto.core.CoreProto; +import com.akaxin.proto.core.PluginProto; +import com.akaxin.proto.site.ApiPluginListProto; +import com.akaxin.proto.site.ApiPluginPageProto; +import com.akaxin.proto.site.ApiPluginProxyProto; +import com.google.protobuf.ByteString; import com.windchat.common.command.Command; import com.windchat.common.command.CommandResponse; import com.windchat.common.constant.CharsetCoding; @@ -37,16 +31,18 @@ import com.windchat.common.crypto.AESCrypto; import com.windchat.common.exceptions.ZalyException2; import com.windchat.common.http.ZalyHttpClient; import com.windchat.common.logs.LogUtils; -import com.akaxin.proto.core.CoreProto; -import com.akaxin.proto.core.PluginProto; -import com.akaxin.proto.site.ApiPluginListProto; -import com.akaxin.proto.site.ApiPluginPageProto; -import com.akaxin.proto.site.ApiPluginProxyProto; +import com.windchat.im.business.bean.ApiActions; import com.windchat.im.business.dao.SitePluginDao; import com.windchat.im.business.impl.AbstractRequest; import com.windchat.im.business.impl.site.SiteConfig; import com.windchat.im.storage.bean.PluginBean; -import com.google.protobuf.ByteString; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Base64; +import java.util.List; +import java.util.Map; /** * 处理客户端与服务点扩展之间功能 @@ -54,6 +50,7 @@ import com.google.protobuf.ByteString; * @author Sam{@link an.guoyue254@gmail.com} * @since 2017-12-11 14:46:28 */ +@ApiActions(action = "api.plugin") public class ApiPluginService extends AbstractRequest { private static Logger logger = LoggerFactory.getLogger(ApiPluginService.class); private static final String HTTP_PREFFIX = "http://"; @@ -65,6 +62,7 @@ public class ApiPluginService extends AbstractRequest { * @param command * @return */ + @ApiActions(action = ".list") public CommandResponse list(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); IErrorCode errCode = ErrorCode2.ERROR; @@ -134,6 +132,7 @@ public class ApiPluginService extends AbstractRequest { * @param command * @return */ + @ApiActions(action = ".page") public CommandResponse page(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); ErrorCode2 errCode = ErrorCode2.ERROR; @@ -209,6 +208,7 @@ public class ApiPluginService extends AbstractRequest { * @param command * @return */ + @ApiActions(action = ".proxy") public CommandResponse proxy(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); ErrorCode2 errCode = ErrorCode2.ERROR; diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiSecretChatService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiSecretChatService.java index f5ef4a6..98ef4f0 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiSecretChatService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiSecretChatService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,24 +15,23 @@ */ package com.windchat.im.business.impl.tai; -import com.windchat.im.business.impl.AbstractRequest; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import com.akaxin.proto.core.ConfigProto; +import com.akaxin.proto.core.DeviceProto; +import com.akaxin.proto.site.ApiSecretChatApplyU2Proto; import com.windchat.common.command.Command; import com.windchat.common.command.CommandResponse; import com.windchat.common.constant.CommandConst; import com.windchat.common.constant.ErrorCode2; import com.windchat.common.logs.LogUtils; -import com.akaxin.proto.core.ConfigProto; -import com.akaxin.proto.core.DeviceProto; -import com.akaxin.proto.site.ApiSecretChatApplyU2Proto; +import com.windchat.im.business.bean.ApiActions; import com.windchat.im.business.impl.AbstractRequest; import com.windchat.im.business.impl.site.SiteConfig; import com.windchat.im.storage.api.IUserDeviceDao; import com.windchat.im.storage.bean.UserDeviceBean; import com.windchat.im.storage.service.DeviceDaoService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * 用户开启二人/群聊 绝密聊天 @@ -40,6 +39,7 @@ import com.windchat.im.storage.service.DeviceDaoService; * @author Sam{@link an.guoyue254@gmail.com} * @since 2017.10.20 */ +@ApiActions(action = "api.secretChat") public class ApiSecretChatService extends AbstractRequest { private static final Logger logger = LoggerFactory.getLogger(ApiSecretChatService.class); private IUserDeviceDao userDeviceDao = new DeviceDaoService(); @@ -50,6 +50,7 @@ public class ApiSecretChatService extends AbstractRequest { * @param command * @return */ + @ApiActions(action = ".applyU2") public CommandResponse applyU2(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); ErrorCode2 errCode = ErrorCode2.ERROR; diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiSiteService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiSiteService.java index d4d98dc..ca169b2 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiSiteService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiSiteService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,20 +15,12 @@ */ package com.windchat.im.business.impl.tai; -import java.security.PublicKey; -import java.security.Signature; -import java.util.Base64; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -import com.windchat.im.business.bean.PlatformPhoneBean; -import com.windchat.im.business.dao.*; -import com.windchat.im.business.impl.AbstractRequest; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import com.akaxin.proto.core.ConfigProto; +import com.akaxin.proto.core.CoreProto; +import com.akaxin.proto.core.UserProto; +import com.akaxin.proto.site.ApiSiteConfigProto; +import com.akaxin.proto.site.ApiSiteLoginProto; +import com.akaxin.proto.site.ApiSiteRegisterProto; import com.windchat.common.command.Command; import com.windchat.common.command.CommandResponse; import com.windchat.common.constant.CommandConst; @@ -40,12 +32,7 @@ import com.windchat.common.exceptions.ZalyException2; import com.windchat.common.logs.LogUtils; import com.windchat.common.utils.StringHelper; import com.windchat.common.utils.UserIdUtils; -import com.akaxin.proto.core.ConfigProto; -import com.akaxin.proto.core.CoreProto; -import com.akaxin.proto.core.UserProto; -import com.akaxin.proto.site.ApiSiteConfigProto; -import com.akaxin.proto.site.ApiSiteLoginProto; -import com.akaxin.proto.site.ApiSiteRegisterProto; +import com.windchat.im.business.bean.ApiActions; import com.windchat.im.business.bean.PlatformPhoneBean; import com.windchat.im.business.dao.SiteConfigDao; import com.windchat.im.business.dao.SiteLoginDao; @@ -64,422 +51,439 @@ import com.windchat.im.storage.bean.UserDeviceBean; import com.windchat.im.storage.bean.UserProfileBean; import com.windchat.im.storage.bean.UserSessionBean; import com.windchat.im.storage.service.DeviceDaoService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.security.PublicKey; +import java.security.Signature; +import java.util.Base64; +import java.util.Map; +import java.util.Set; +import java.util.UUID; /** - * 获取站点信息
+ * 获取站点信息 * 执行注册&&登陆 * * @author Sam{@link an.guoyue254@gmail.com} * @since 2017-10-17 18:14:10 */ +@ApiActions(action = "api.site") public class ApiSiteService extends AbstractRequest { - private static final Logger logger = LoggerFactory.getLogger(ApiSiteService.class); - private static final int DEFAULT_PORT = 2021; - private IUserDeviceDao userDeviceDao = new DeviceDaoService(); + private static final Logger logger = LoggerFactory.getLogger(ApiSiteService.class); + private static final int DEFAULT_PORT = 2021; + private IUserDeviceDao userDeviceDao = new DeviceDaoService(); - /** - *

-	 * 		api.site.config
-	 * 		获取站点配置信息
-	 * 
- * - * @param command - * @return - */ - public CommandResponse config(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - ErrorCode2 errCode = ErrorCode2.ERROR; - try { - Map configMap = SiteConfig.getConfigMap(); - LogUtils.requestDebugLog(logger, command, ""); + /** + * 获取站点配置信息 + * + * @param command + * @return + */ + @ApiActions(action = ".config") + public CommandResponse config(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + ErrorCode2 errCode = ErrorCode2.ERROR; + try { + Map configMap = SiteConfig.getConfigMap(); + LogUtils.requestDebugLog(logger, command, ""); - if (configMap != null) { - ConfigProto.SiteConfig.Builder configBuilder = ConfigProto.SiteConfig.newBuilder(); - if (StringUtils.isNotBlank(configMap.get(ConfigProto.ConfigKey.SITE_ADDRESS_VALUE))) { - configBuilder.setSiteAddress(configMap.get(ConfigProto.ConfigKey.SITE_ADDRESS_VALUE)); - } - if (StringUtils.isNumeric(configMap.get(ConfigProto.ConfigKey.SITE_PORT_VALUE))) { - configBuilder.setSitePort(Integer.valueOf(configMap.get(ConfigProto.ConfigKey.SITE_PORT_VALUE))); - } - if (StringUtils.isNotBlank(configMap.get(ConfigProto.ConfigKey.SITE_NAME_VALUE))) { - configBuilder.setSiteName(configMap.get(ConfigProto.ConfigKey.SITE_NAME_VALUE)); - } - if (StringUtils.isNotBlank(configMap.get(ConfigProto.ConfigKey.SITE_LOGO_VALUE))) { - configBuilder.setSiteLogo(configMap.get(ConfigProto.ConfigKey.SITE_LOGO_VALUE)); - } - if (StringUtils.isNotBlank(configMap.get(ConfigProto.ConfigKey.SITE_VERSION_VALUE))) { - configBuilder.setSiteVersion(configMap.get(ConfigProto.ConfigKey.SITE_VERSION_VALUE)); - } - if (StringUtils.isNotBlank(configMap.get(ConfigProto.ConfigKey.SITE_INTRODUCTION_VALUE))) { - configBuilder.setSiteIntroduction(configMap.get(ConfigProto.ConfigKey.SITE_INTRODUCTION_VALUE)); - } - if (StringUtils.isNotBlank(configMap.get(ConfigProto.ConfigKey.PIC_SIZE_VALUE))) { - configBuilder.setPicSize(configMap.get(ConfigProto.ConfigKey.PIC_SIZE_VALUE)); - } - if (StringUtils.isNumeric(configMap.get(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE))) { - configBuilder.setRealNameConfigValue( - Integer.valueOf(configMap.get(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE))); - } - if (StringUtils.isNumeric(configMap.get(ConfigProto.ConfigKey.INVITE_CODE_STATUS_VALUE))) { - configBuilder.setInviteCodeConfigValue( - Integer.valueOf(configMap.get(ConfigProto.ConfigKey.INVITE_CODE_STATUS_VALUE))); - } - ApiSiteConfigProto.ApiSiteConfigResponse response = ApiSiteConfigProto.ApiSiteConfigResponse - .newBuilder().setSiteConfig(configBuilder.build()).build(); - commandResponse.setParams(response.toByteArray()); - errCode = ErrorCode2.SUCCESS; - } + if (configMap != null) { + ConfigProto.SiteConfig.Builder configBuilder = ConfigProto.SiteConfig.newBuilder(); + if (StringUtils.isNotBlank(configMap.get(ConfigProto.ConfigKey.SITE_ADDRESS_VALUE))) { + configBuilder.setSiteAddress(configMap.get(ConfigProto.ConfigKey.SITE_ADDRESS_VALUE)); + } + if (StringUtils.isNumeric(configMap.get(ConfigProto.ConfigKey.SITE_PORT_VALUE))) { + configBuilder.setSitePort(Integer.valueOf(configMap.get(ConfigProto.ConfigKey.SITE_PORT_VALUE))); + } + if (StringUtils.isNotBlank(configMap.get(ConfigProto.ConfigKey.SITE_NAME_VALUE))) { + configBuilder.setSiteName(configMap.get(ConfigProto.ConfigKey.SITE_NAME_VALUE)); + } + if (StringUtils.isNotBlank(configMap.get(ConfigProto.ConfigKey.SITE_LOGO_VALUE))) { + configBuilder.setSiteLogo(configMap.get(ConfigProto.ConfigKey.SITE_LOGO_VALUE)); + } + if (StringUtils.isNotBlank(configMap.get(ConfigProto.ConfigKey.SITE_VERSION_VALUE))) { + configBuilder.setSiteVersion(configMap.get(ConfigProto.ConfigKey.SITE_VERSION_VALUE)); + } + if (StringUtils.isNotBlank(configMap.get(ConfigProto.ConfigKey.SITE_INTRODUCTION_VALUE))) { + configBuilder.setSiteIntroduction(configMap.get(ConfigProto.ConfigKey.SITE_INTRODUCTION_VALUE)); + } + if (StringUtils.isNotBlank(configMap.get(ConfigProto.ConfigKey.PIC_SIZE_VALUE))) { + configBuilder.setPicSize(configMap.get(ConfigProto.ConfigKey.PIC_SIZE_VALUE)); + } + if (StringUtils.isNumeric(configMap.get(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE))) { + configBuilder.setRealNameConfigValue( + Integer.valueOf(configMap.get(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE))); + } + if (StringUtils.isNumeric(configMap.get(ConfigProto.ConfigKey.INVITE_CODE_STATUS_VALUE))) { + configBuilder.setInviteCodeConfigValue( + Integer.valueOf(configMap.get(ConfigProto.ConfigKey.INVITE_CODE_STATUS_VALUE))); + } + ApiSiteConfigProto.ApiSiteConfigResponse response = ApiSiteConfigProto.ApiSiteConfigResponse + .newBuilder().setSiteConfig(configBuilder.build()).build(); + commandResponse.setParams(response.toByteArray()); + errCode = ErrorCode2.SUCCESS; + } - } catch (Exception e) { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode2(errCode); - } + } catch (Exception e) { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode2(errCode); + } - public CommandResponse register(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiSiteRegisterProto.ApiSiteRegisterRequest request = ApiSiteRegisterProto.ApiSiteRegisterRequest - .parseFrom(command.getParams()); - String userIdPubk = request.getUserIdPubk(); - String userName = request.getUserName(); - String userPhoto = request.getUserPhoto(); - String userUic = request.getUserUic(); - String applyInfo = request.getApplyInfo(); - String phoneToken = request.getPhoneToken(); - String fullPhoneId = null;// 通过phoneToken 查询的 counrtyCode:phoneId - String siteUserId = UUID.randomUUID().toString();// siteUserId保证各站不同 - String siteLoginId = request.getSiteLoginId();// 站点账号 + /** + * 注册站点账户 + * + * @param command + * @return + */ + @ApiActions(action = ".register") + public CommandResponse register(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiSiteRegisterProto.ApiSiteRegisterRequest request = ApiSiteRegisterProto.ApiSiteRegisterRequest + .parseFrom(command.getParams()); + String userIdPubk = request.getUserIdPubk(); + String userName = request.getUserName(); + String userPhoto = request.getUserPhoto(); + String userUic = request.getUserUic(); + String applyInfo = request.getApplyInfo(); + String phoneToken = request.getPhoneToken(); + String fullPhoneId = null;// 通过phoneToken 查询的 counrtyCode:phoneId + String siteUserId = UUID.randomUUID().toString();// siteUserId保证各站不同 + String siteLoginId = request.getSiteLoginId();// 站点账号 - LogUtils.requestDebugLog(logger, command, request.toString()); + LogUtils.requestDebugLog(logger, command, request.toString()); - if (StringUtils.isAnyEmpty(userIdPubk, userName)) { - throw new ZalyException2(ErrorCode2.ERROR_PARAMETER); - } + if (StringUtils.isAnyEmpty(userIdPubk, userName)) { + throw new ZalyException2(ErrorCode2.ERROR_PARAMETER); + } - if (userName.length() > 16) { - throw new ZalyException2(ErrorCode2.ERROR_PARAMETER_NICKNAME); - } + if (userName.length() > 16) { + throw new ZalyException2(ErrorCode2.ERROR_PARAMETER_NICKNAME); + } - // 是否开启实名 - ConfigProto.RealNameConfig realNameConfig = SiteConfig.getRealNameConfig(); - switch (realNameConfig) { - case REALNAME_YES: - if (StringUtils.isNotBlank(phoneToken)) { - PlatformPhoneBean bean = PlatformUserPhone.getInstance().getPhoneIdFromPlatform(phoneToken); - fullPhoneId = bean.getFullPhoneId(); - logger.debug("user realname register,get phoneid from platform:{}", fullPhoneId); + // 是否开启实名 + ConfigProto.RealNameConfig realNameConfig = SiteConfig.getRealNameConfig(); + switch (realNameConfig) { + case REALNAME_YES: + if (StringUtils.isNotBlank(phoneToken)) { + PlatformPhoneBean bean = PlatformUserPhone.getInstance().getPhoneIdFromPlatform(phoneToken); + fullPhoneId = bean.getFullPhoneId(); + logger.debug("user realname register,get phoneid from platform:{}", fullPhoneId); - if (StringUtils.isEmpty(fullPhoneId)) { - throw new ZalyException2(ErrorCode2.ERROR_REGISTER_PHONEID); - } - } else { - throw new ZalyException2(ErrorCode2.ERROR_REGISTER_PHONETOKEN); - } - break; - default: - break; - } + if (StringUtils.isEmpty(fullPhoneId)) { + throw new ZalyException2(ErrorCode2.ERROR_REGISTER_PHONEID); + } + } else { + throw new ZalyException2(ErrorCode2.ERROR_REGISTER_PHONETOKEN); + } + break; + default: + break; + } - // 是否开启邀请码 - ConfigProto.InviteCodeConfig uicConfig = SiteConfig.getUICConfig(); - switch (uicConfig) { - case UIC_YES: - logger.debug("注册方式:邀请码注册"); - if (!UserUic.getInstance().checkUic(userUic, siteUserId)) { - throw new ZalyException2(ErrorCode2.ERROR_REGISTER_UIC); - } - break; - default: - break; - } + // 是否开启邀请码 + ConfigProto.InviteCodeConfig uicConfig = SiteConfig.getUICConfig(); + switch (uicConfig) { + case UIC_YES: + logger.debug("注册方式:邀请码注册"); + if (!UserUic.getInstance().checkUic(userUic, siteUserId)) { + throw new ZalyException2(ErrorCode2.ERROR_REGISTER_UIC); + } + break; + default: + break; + } - UserProfileBean regBean = new UserProfileBean(); - regBean.setSiteUserId(siteUserId); - regBean.setUserIdPubk(userIdPubk); - regBean.setUserName(userName); - regBean.setUserNameInLatin(StringHelper.toLatinPinYin(userName)); - regBean.setApplyInfo(applyInfo); - regBean.setUserPhoto(userPhoto); - regBean.setPhoneId(fullPhoneId); - regBean.setUserStatus(UserProto.UserStatus.NORMAL_VALUE); - regBean.setRegisterTime(System.currentTimeMillis()); + UserProfileBean regBean = new UserProfileBean(); + regBean.setSiteUserId(siteUserId); + regBean.setUserIdPubk(userIdPubk); + regBean.setUserName(userName); + regBean.setUserNameInLatin(StringHelper.toLatinPinYin(userName)); + regBean.setApplyInfo(applyInfo); + regBean.setUserPhoto(userPhoto); + regBean.setPhoneId(fullPhoneId); + regBean.setUserStatus(UserProto.UserStatus.NORMAL_VALUE); + regBean.setRegisterTime(System.currentTimeMillis()); - if (SiteLoginDao.getInstance().registerUser(regBean)) { - ApiSiteRegisterProto.ApiSiteRegisterResponse response = ApiSiteRegisterProto.ApiSiteRegisterResponse - .newBuilder().setSiteUserId(siteUserId).build(); - commandResponse.setParams(response.toByteArray()); - errCode = ErrorCode2.SUCCESS; - } else { - errCode = ErrorCode2.ERROR_REGISTER_USERID_UNIQUE; - } + if (SiteLoginDao.getInstance().registerUser(regBean)) { + ApiSiteRegisterProto.ApiSiteRegisterResponse response = ApiSiteRegisterProto.ApiSiteRegisterResponse + .newBuilder().setSiteUserId(siteUserId).build(); + commandResponse.setParams(response.toByteArray()); + errCode = ErrorCode2.SUCCESS; + } else { + errCode = ErrorCode2.ERROR_REGISTER_USERID_UNIQUE; + } - if (ErrorCode2.SUCCESS == errCode) { - addUserDefaultFriendsAndGroups(siteUserId); - // 注册成功,需要做一个管理员身份验证 - justForAdminUser(siteUserId, command.getHeader()); - } - } catch (Exception e) { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - LogUtils.requestErrorLog(logger, command, e); - } catch (ZalyException2 e) { - errCode = e.getErrCode(); - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } + if (ErrorCode2.SUCCESS == errCode) { + addUserDefaultFriendsAndGroups(siteUserId); + // 注册成功,需要做一个管理员身份验证 + justForAdminUser(siteUserId, command.getHeader()); + } + } catch (Exception e) { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + LogUtils.requestErrorLog(logger, command, e); + } catch (ZalyException2 e) { + errCode = e.getErrCode(); + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } - // 增加默认好友以及群组 - private void addUserDefaultFriendsAndGroups(String siteUserId) { - try { - Set defaultFriends = SiteConfig.getUserDefaultFriends(); - if (defaultFriends != null && defaultFriends.size() > 0) { - for (String siteFriendId : defaultFriends) { - UserFriendDao.getInstance().saveFriendApply(siteFriendId, siteUserId, "我已成为你的好友,给我发消息试试吧"); - UserFriendDao.getInstance().agreeApply(siteUserId, siteFriendId, true); - ApplyFriendBean applyBean = UserFriendDao.getInstance().agreeApplyWithClear(siteUserId, - siteFriendId, true); - new User2Notice().addFriendTextMessage(applyBean); - } - } - logger.debug("{} add default friends={}", siteUserId, defaultFriends); - } catch (Exception e) { - logger.error("add default friends error", e); - } + // 增加默认好友以及群组 + private void addUserDefaultFriendsAndGroups(String siteUserId) { + try { + Set defaultFriends = SiteConfig.getUserDefaultFriends(); + if (defaultFriends != null && defaultFriends.size() > 0) { + for (String siteFriendId : defaultFriends) { + UserFriendDao.getInstance().saveFriendApply(siteFriendId, siteUserId, "我已成为你的好友,给我发消息试试吧"); + UserFriendDao.getInstance().agreeApply(siteUserId, siteFriendId, true); + ApplyFriendBean applyBean = UserFriendDao.getInstance().agreeApplyWithClear(siteUserId, + siteFriendId, true); + new User2Notice().addFriendTextMessage(applyBean); + } + } + logger.debug("{} add default friends={}", siteUserId, defaultFriends); + } catch (Exception e) { + logger.error("add default friends error", e); + } - try { - Set defaultGroups = SiteConfig.getUserDefaultGroups(); - if (defaultGroups != null && defaultGroups.size() > 0) { - for (String groupId : defaultGroups) { - UserGroupDao.getInstance().addDefaultGroupMember(groupId, siteUserId); - } - } - logger.debug("{} add default groups={}", siteUserId, defaultGroups); - } catch (Exception e) { - logger.error("add user default groups error", e); - } + try { + Set defaultGroups = SiteConfig.getUserDefaultGroups(); + if (defaultGroups != null && defaultGroups.size() > 0) { + for (String groupId : defaultGroups) { + UserGroupDao.getInstance().addDefaultGroupMember(groupId, siteUserId); + } + } + logger.debug("{} add default groups={}", siteUserId, defaultGroups); + } catch (Exception e) { + logger.error("add user default groups error", e); + } - } + } - private void justForAdminUser(String siteUserId, Map header) { - try { - // 如果站点没有管理员 - if (SiteConfig.hasNoAdminUser()) { - logger.debug("user first time to register site server ,set it as admin:{} map:{}", siteUserId, header); - SiteConfigDao.getInstance().updateSiteConfig(ConfigProto.ConfigKey.SITE_ADMIN_VALUE, siteUserId); - if (header != null) { - String host = header.get(CoreProto.HeaderKey.CLIENT_REQUEST_SERVER_HOST_VALUE); - if (StringUtils.isNotEmpty(host)) { - SiteConfigDao.getInstance().updateSiteConfig(ConfigProto.ConfigKey.SITE_ADDRESS_VALUE, host); - SiteConfigDao.getInstance().updateSiteConfig(ConfigProto.ConfigKey.SITE_NAME_VALUE, host); - } - String port = header.get(CoreProto.HeaderKey.CLIENT_REQUEST_SERVER_HOST_VALUE); - if (StringUtils.isNotBlank(port)) { - port = "" + DEFAULT_PORT; - SiteConfigDao.getInstance().updateSiteConfig(ConfigProto.ConfigKey.SITE_PORT_VALUE, port); - } - // 修改邀请码注册方式 - SiteConfigDao.getInstance().updateSiteConfig(ConfigProto.ConfigKey.INVITE_CODE_STATUS_VALUE, - ConfigProto.InviteCodeConfig.UIC_NO_VALUE + ""); - } - SiteConfig.updateConfig(); - } - } catch (Exception e) { - logger.error("set site admin error", e); - } - } + private void justForAdminUser(String siteUserId, Map header) { + try { + // 如果站点没有管理员 + if (SiteConfig.hasNoAdminUser()) { + logger.debug("user first time to register site server ,set it as admin:{} map:{}", siteUserId, header); + SiteConfigDao.getInstance().updateSiteConfig(ConfigProto.ConfigKey.SITE_ADMIN_VALUE, siteUserId); + if (header != null) { + String host = header.get(CoreProto.HeaderKey.CLIENT_REQUEST_SERVER_HOST_VALUE); + if (StringUtils.isNotEmpty(host)) { + SiteConfigDao.getInstance().updateSiteConfig(ConfigProto.ConfigKey.SITE_ADDRESS_VALUE, host); + SiteConfigDao.getInstance().updateSiteConfig(ConfigProto.ConfigKey.SITE_NAME_VALUE, host); + } + String port = header.get(CoreProto.HeaderKey.CLIENT_REQUEST_SERVER_HOST_VALUE); + if (StringUtils.isNotBlank(port)) { + port = "" + DEFAULT_PORT; + SiteConfigDao.getInstance().updateSiteConfig(ConfigProto.ConfigKey.SITE_PORT_VALUE, port); + } + // 修改邀请码注册方式 + SiteConfigDao.getInstance().updateSiteConfig(ConfigProto.ConfigKey.INVITE_CODE_STATUS_VALUE, + ConfigProto.InviteCodeConfig.UIC_NO_VALUE + ""); + } + SiteConfig.updateConfig(); + } + } catch (Exception e) { + logger.error("set site admin error", e); + } + } - /** - * 执行用户登陆站点行为 - * - * @param command - * @return - */ - public CommandResponse login(Command command) { - CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); - IErrorCode errCode = ErrorCode2.ERROR; - try { - ApiSiteLoginProto.ApiSiteLoginRequest loginRequest = ApiSiteLoginProto.ApiSiteLoginRequest - .parseFrom(command.getParams()); - String userIdPubk = loginRequest.getUserIdPubk(); - String userIdSignBase64 = loginRequest.getUserIdSignBase64(); - String userDeviceIdPubk = loginRequest.getUserDeviceIdPubk(); - String userDeviceIdSignBase64 = loginRequest.getUserDeviceIdSignBase64(); - String userDeviceName = loginRequest.getUserDeviceName(); - String userToken = loginRequest.getUserToken(); - String phoneToken = loginRequest.getPhoneToken(); - LogUtils.requestDebugLog(logger, command, loginRequest.toString()); + /** + * 执行用户登录站点行为 + * + * @param command + * @return + */ + @ApiActions(action = ".login") + public CommandResponse login(Command command) { + CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); + IErrorCode errCode = ErrorCode2.ERROR; + try { + ApiSiteLoginProto.ApiSiteLoginRequest loginRequest = ApiSiteLoginProto.ApiSiteLoginRequest + .parseFrom(command.getParams()); + String userIdPubk = loginRequest.getUserIdPubk(); + String userIdSignBase64 = loginRequest.getUserIdSignBase64(); + String userDeviceIdPubk = loginRequest.getUserDeviceIdPubk(); + String userDeviceIdSignBase64 = loginRequest.getUserDeviceIdSignBase64(); + String userDeviceName = loginRequest.getUserDeviceName(); + String userToken = loginRequest.getUserToken(); + String phoneToken = loginRequest.getPhoneToken(); + LogUtils.requestDebugLog(logger, command, loginRequest.toString()); - if (StringUtils.isAnyEmpty(userIdPubk, userIdSignBase64)) { - throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_USERID_EMPTY); - } + if (StringUtils.isAnyEmpty(userIdPubk, userIdSignBase64)) { + throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_USERID_EMPTY); + } - if (StringUtils.isAnyEmpty(userDeviceIdPubk, userDeviceIdSignBase64)) { - throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_DEVICEID_EMPTY); - } + if (StringUtils.isAnyEmpty(userDeviceIdPubk, userDeviceIdSignBase64)) { + throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_DEVICEID_EMPTY); + } - // if (StringUtils.isEmpty(userToken)) { - // throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_USERTOKEN_EMPTY); - // } + // if (StringUtils.isEmpty(userToken)) { + // throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_USERTOKEN_EMPTY); + // } - PublicKey userPubKey = RSACrypto.getRSAPubKeyFromPem(userIdPubk);// 个人身份公钥,解密Sign签名,解密Key - Signature userSign = Signature.getInstance("SHA512withRSA"); - userSign.initVerify(userPubKey); - userSign.update(userIdPubk.getBytes());// 原文 - boolean userSignResult = userSign.verify(Base64.getDecoder().decode(userIdSignBase64)); - logger.debug("userSignResult={}", userSignResult); + PublicKey userPubKey = RSACrypto.getRSAPubKeyFromPem(userIdPubk);// 个人身份公钥,解密Sign签名,解密Key + Signature userSign = Signature.getInstance("SHA512withRSA"); + userSign.initVerify(userPubKey); + userSign.update(userIdPubk.getBytes());// 原文 + boolean userSignResult = userSign.verify(Base64.getDecoder().decode(userIdSignBase64)); + logger.debug("userSignResult={}", userSignResult); - if (userSignResult) { - Signature userDeviceSign = Signature.getInstance("SHA512withRSA"); - userDeviceSign.initVerify(userPubKey); - userDeviceSign.update(userDeviceIdPubk.getBytes());// 原文 - userSignResult = userDeviceSign.verify(Base64.getDecoder().decode(userDeviceIdSignBase64)); - } - logger.debug("deviceSignResult={}", userSignResult); + if (userSignResult) { + Signature userDeviceSign = Signature.getInstance("SHA512withRSA"); + userDeviceSign.initVerify(userPubKey); + userDeviceSign.update(userDeviceIdPubk.getBytes());// 原文 + userSignResult = userDeviceSign.verify(Base64.getDecoder().decode(userDeviceIdSignBase64)); + } + logger.debug("deviceSignResult={}", userSignResult); - // 用户身份校验成功,方可执行登陆操作 - if (!userSignResult) { - throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_ERRORSIGN); - } + // 用户身份校验成功,方可执行登陆操作 + if (!userSignResult) { + throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_ERRORSIGN); + } - // 登陆去平台实名机制校验 - String globalUserId = verifyPlatformPhoneAndGetGlobalUserId(userIdPubk, phoneToken); + // 登陆去平台实名机制校验 + String globalUserId = verifyPlatformPhoneAndGetGlobalUserId(userIdPubk, phoneToken); - // 判断用户,是否已经注册,从主库中查找 - SimpleUserBean subean = UserProfileDao.getInstance().getSimpleProfileByGlobalUserId(globalUserId, true); - if (subean == null || StringUtils.isEmpty(subean.getUserId())) { - logger.info("login site: new user need to register before login site"); - errCode = ErrorCode2.ERROR2_LOGGIN_NOREGISTER;// 未注册,告知用户执行注册行为 - return commandResponse.setErrCode(errCode); - } + // 判断用户,是否已经注册,从主库中查找 + SimpleUserBean subean = UserProfileDao.getInstance().getSimpleProfileByGlobalUserId(globalUserId, true); + if (subean == null || StringUtils.isEmpty(subean.getUserId())) { + logger.info("login site: new user need to register before login site"); + errCode = ErrorCode2.ERROR2_LOGGIN_NOREGISTER;// 未注册,告知用户执行注册行为 + return commandResponse.setErrCode(errCode); + } - if (subean.getUserStatus() == UserProto.UserStatus.SEALUP_VALUE) { - logger.info("login site: user no permision as sealed up"); - errCode = ErrorCode2.ERROR2_LOGGIN_SEALUPUSER;// 禁封用户禁止登陆 - return commandResponse.setErrCode(errCode); - } + if (subean.getUserStatus() == UserProto.UserStatus.SEALUP_VALUE) { + logger.info("login site: user no permision as sealed up"); + errCode = ErrorCode2.ERROR2_LOGGIN_SEALUPUSER;// 禁封用户禁止登陆 + return commandResponse.setErrCode(errCode); + } - String siteUserId = subean.getUserId(); - String deviceId = HashCrypto.MD5(userDeviceIdPubk); + String siteUserId = subean.getUserId(); + String deviceId = HashCrypto.MD5(userDeviceIdPubk); - // 保存设备信息 - UserDeviceBean deviceBean = new UserDeviceBean(); - deviceBean.setDeviceId(deviceId); - deviceBean.setDeviceName(userDeviceName); - deviceBean.setSiteUserId(siteUserId); - deviceBean.setUserDevicePubk(userDeviceIdPubk); - deviceBean.setUserToken(userToken); - deviceBean.setActiveTime(System.currentTimeMillis()); - deviceBean.setAddTime(System.currentTimeMillis()); + // 保存设备信息 + UserDeviceBean deviceBean = new UserDeviceBean(); + deviceBean.setDeviceId(deviceId); + deviceBean.setDeviceName(userDeviceName); + deviceBean.setSiteUserId(siteUserId); + deviceBean.setUserDevicePubk(userDeviceIdPubk); + deviceBean.setUserToken(userToken); + deviceBean.setActiveTime(System.currentTimeMillis()); + deviceBean.setAddTime(System.currentTimeMillis()); - boolean loginResult = SiteLoginDao.getInstance().updateUserDevice(deviceBean); + boolean loginResult = SiteLoginDao.getInstance().updateUserDevice(deviceBean); - if (!loginResult) {// 更新失败,则重新保存数据 - loginResult = SiteLoginDao.getInstance().saveUserDevice(deviceBean); - // 在新增设备情况下,控制设备数量 - limitUserDevice(siteUserId); - } + if (!loginResult) {// 更新失败,则重新保存数据 + loginResult = SiteLoginDao.getInstance().saveUserDevice(deviceBean); + // 在新增设备情况下,控制设备数量 + limitUserDevice(siteUserId); + } - logger.debug("login site: save device result={} deviceBean={}", loginResult, deviceBean.toString()); + logger.debug("login site: save device result={} deviceBean={}", loginResult, deviceBean.toString()); - if (!loginResult) { - // 身份校验失败 - throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_UPDATE_DEVICE); - } + if (!loginResult) { + // 身份校验失败 + throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_UPDATE_DEVICE); + } - // 生成session - String sessionId = UUID.randomUUID().toString(); + // 生成session + String sessionId = UUID.randomUUID().toString(); - UserSessionBean sessionBean = new UserSessionBean(); - sessionBean.setLoginTime(System.currentTimeMillis()); - sessionBean.setSiteUserId(siteUserId); - sessionBean.setOnline(true); - sessionBean.setSessionId(sessionId); - sessionBean.setDeviceId(deviceId); - sessionBean.setLoginTime(System.currentTimeMillis());// 上次登陆(auth)时间 + UserSessionBean sessionBean = new UserSessionBean(); + sessionBean.setLoginTime(System.currentTimeMillis()); + sessionBean.setSiteUserId(siteUserId); + sessionBean.setOnline(true); + sessionBean.setSessionId(sessionId); + sessionBean.setDeviceId(deviceId); + sessionBean.setLoginTime(System.currentTimeMillis());// 上次登陆(auth)时间 - loginResult = loginResult && SiteLoginDao.getInstance().saveUserSession(sessionBean); + loginResult = loginResult && SiteLoginDao.getInstance().saveUserSession(sessionBean); - if (loginResult) { - ApiSiteLoginProto.ApiSiteLoginResponse response = ApiSiteLoginProto.ApiSiteLoginResponse.newBuilder() - .setSiteUserId(siteUserId).setUserSessionId(sessionId).build(); - commandResponse.setParams(response.toByteArray()); - errCode = ErrorCode2.SUCCESS; - } else { - errCode = ErrorCode2.ERROR2_LOGGIN_UPDATE_SESSION; - } - } catch (ZalyException2 e) { - errCode = e.getErrCode(); - LogUtils.requestErrorLog(logger, command, e); - } catch (Exception e) { - errCode = ErrorCode2.ERROR_SYSTEMERROR; - LogUtils.requestErrorLog(logger, command, e); - } - return commandResponse.setErrCode(errCode); - } + if (loginResult) { + ApiSiteLoginProto.ApiSiteLoginResponse response = ApiSiteLoginProto.ApiSiteLoginResponse.newBuilder() + .setSiteUserId(siteUserId).setUserSessionId(sessionId).build(); + commandResponse.setParams(response.toByteArray()); + errCode = ErrorCode2.SUCCESS; + } else { + errCode = ErrorCode2.ERROR2_LOGGIN_UPDATE_SESSION; + } + } catch (ZalyException2 e) { + errCode = e.getErrCode(); + LogUtils.requestErrorLog(logger, command, e); + } catch (Exception e) { + errCode = ErrorCode2.ERROR_SYSTEMERROR; + LogUtils.requestErrorLog(logger, command, e); + } + return commandResponse.setErrCode(errCode); + } - private String verifyPlatformPhoneAndGetGlobalUserId(String userIdPubk, String phoneToken) throws ZalyException2 { - phoneToken = null; - if (StringUtils.isEmpty(phoneToken)) { - logger.debug("api.site.login with phoneToken={}", phoneToken); - return UserIdUtils.getV1GlobalUserId(userIdPubk); - } + private String verifyPlatformPhoneAndGetGlobalUserId(String userIdPubk, String phoneToken) throws ZalyException2 { + phoneToken = null; + if (StringUtils.isEmpty(phoneToken)) { + logger.debug("api.site.login with phoneToken={}", phoneToken); + return UserIdUtils.getV1GlobalUserId(userIdPubk); + } - // 登陆去平台校验实名机制 - ConfigProto.RealNameConfig realNameConfig = SiteConfig.getRealNameConfig(); + // 登陆去平台校验实名机制 + ConfigProto.RealNameConfig realNameConfig = SiteConfig.getRealNameConfig(); - if (ConfigProto.RealNameConfig.REALNAME_YES == realNameConfig) { - PlatformPhoneBean bean = PlatformUserPhone.getInstance().getPhoneIdFromPlatform(phoneToken); - String fullPhoneId = bean.getFullPhoneId(); - String platformUserIdPubk = bean.getUserIdPubk(); - logger.debug("get platform realname phone info bean={}", bean); + if (ConfigProto.RealNameConfig.REALNAME_YES == realNameConfig) { + PlatformPhoneBean bean = PlatformUserPhone.getInstance().getPhoneIdFromPlatform(phoneToken); + String fullPhoneId = bean.getFullPhoneId(); + String platformUserIdPubk = bean.getUserIdPubk(); + logger.debug("get platform realname phone info bean={}", bean); - if (StringUtils.isEmpty(fullPhoneId)) { - return UserIdUtils.getV1GlobalUserId(userIdPubk); - } + if (StringUtils.isEmpty(fullPhoneId)) { + return UserIdUtils.getV1GlobalUserId(userIdPubk); + } - if (!userIdPubk.equals(platformUserIdPubk)) { - logger.error("api.site.login equals={} userIdPubk={} platformUserIdPubk={}", false, userIdPubk, - platformUserIdPubk); - return UserIdUtils.getV1GlobalUserId(userIdPubk); - } + if (!userIdPubk.equals(platformUserIdPubk)) { + logger.error("api.site.login equals={} userIdPubk={} platformUserIdPubk={}", false, userIdPubk, + platformUserIdPubk); + return UserIdUtils.getV1GlobalUserId(userIdPubk); + } - // 手机号查询用户身份 - UserProfileBean profile = UserProfileDao.getInstance().getUserProfileByFullPhoneId(fullPhoneId); + // 手机号查询用户身份 + UserProfileBean profile = UserProfileDao.getInstance().getUserProfileByFullPhoneId(fullPhoneId); - if (profile != null && StringUtils.isNoneEmpty(platformUserIdPubk, profile.getUserIdPubk())) { + if (profile != null && StringUtils.isNoneEmpty(platformUserIdPubk, profile.getUserIdPubk())) { - if (platformUserIdPubk.equals(profile.getUserIdPubk())) { - logger.debug("new site realname login verifyPlatformPhone success"); - return UserIdUtils.getV1GlobalUserId(platformUserIdPubk); - } else { - // 更新数据 - String globalUserId = UserIdUtils.getV1GlobalUserId(platformUserIdPubk); - boolean updateRes = UserProfileDao.getInstance().updateUserIdPubk(profile.getSiteUserId(), - globalUserId, userIdPubk); + if (platformUserIdPubk.equals(profile.getUserIdPubk())) { + logger.debug("new site realname login verifyPlatformPhone success"); + return UserIdUtils.getV1GlobalUserId(platformUserIdPubk); + } else { + // 更新数据 + String globalUserId = UserIdUtils.getV1GlobalUserId(platformUserIdPubk); + boolean updateRes = UserProfileDao.getInstance().updateUserIdPubk(profile.getSiteUserId(), + globalUserId, userIdPubk); - if (!updateRes) { - throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_UPDATENEWPUBK); - } - } + if (!updateRes) { + throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_UPDATENEWPUBK); + } + } - } + } - } + } - return UserIdUtils.getV1GlobalUserId(userIdPubk); - } + return UserIdUtils.getV1GlobalUserId(userIdPubk); + } - // 控制用户的设备数量 - private void limitUserDevice(String siteUserId) { - try { - int limitNumber = 4; - userDeviceDao.limitDeviceNum(siteUserId, limitNumber); - } catch (Exception e) { - logger.error(StringHelper.format("limit siteUserId={} device num error", siteUserId), e); - } - } + // 控制用户的设备数量 + private void limitUserDevice(String siteUserId) { + try { + int limitNumber = 4; + userDeviceDao.limitDeviceNum(siteUserId, limitNumber); + } catch (Exception e) { + logger.error(StringHelper.format("limit siteUserId={} device num error", siteUserId), e); + } + } } diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiUserService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiUserService.java index 85f916e..2cb9818 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiUserService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiUserService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,16 +15,12 @@ */ package com.windchat.im.business.impl.tai; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.windchat.im.business.dao.UserFriendDao; -import com.windchat.im.business.dao.UserProfileDao; -import com.windchat.im.business.impl.AbstractRequest; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import com.akaxin.proto.core.UserProto; +import com.akaxin.proto.site.ApiUserMuteProto; +import com.akaxin.proto.site.ApiUserProfileProto; +import com.akaxin.proto.site.ApiUserSearchProto; +import com.akaxin.proto.site.ApiUserUpdateMuteProto; +import com.akaxin.proto.site.ApiUserUpdateProfileProto; import com.windchat.common.command.Command; import com.windchat.common.command.CommandResponse; import com.windchat.common.constant.CommandConst; @@ -34,17 +30,18 @@ import com.windchat.common.exceptions.ZalyException2; import com.windchat.common.logs.LogUtils; import com.windchat.common.utils.StringHelper; import com.windchat.common.utils.ValidatorPattern; -import com.akaxin.proto.core.UserProto; -import com.akaxin.proto.site.ApiUserMuteProto; -import com.akaxin.proto.site.ApiUserProfileProto; -import com.akaxin.proto.site.ApiUserSearchProto; -import com.akaxin.proto.site.ApiUserUpdateMuteProto; -import com.akaxin.proto.site.ApiUserUpdateProfileProto; +import com.windchat.im.business.bean.ApiActions; import com.windchat.im.business.dao.UserFriendDao; import com.windchat.im.business.dao.UserProfileDao; import com.windchat.im.business.impl.AbstractRequest; import com.windchat.im.storage.bean.UserFriendBean; import com.windchat.im.storage.bean.UserProfileBean; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * 用户个人自身资料相关功能 @@ -52,6 +49,7 @@ import com.windchat.im.storage.bean.UserProfileBean; * @author Sam{@link an.guoyue254@gmail.com} * @since 2017.11.25 15:10:36 */ +@ApiActions(action = "api.user") public class ApiUserService extends AbstractRequest { private static final Logger logger = LoggerFactory.getLogger(ApiUserService.class); @@ -61,6 +59,7 @@ public class ApiUserService extends AbstractRequest { * @param command * @return */ + @ApiActions(action = ".search") public CommandResponse search(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); IErrorCode errCode = ErrorCode2.ERROR; @@ -150,6 +149,7 @@ public class ApiUserService extends AbstractRequest { * @param command * @return */ + @ApiActions(action = ".profile") public CommandResponse profile(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); ErrorCode2 errorCode = ErrorCode2.ERROR; @@ -206,6 +206,7 @@ public class ApiUserService extends AbstractRequest { * @param command * @return */ + @ApiActions(action = ".updateProfile") public CommandResponse updateProfile(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); IErrorCode errCode = ErrorCode2.ERROR; @@ -271,6 +272,13 @@ public class ApiUserService extends AbstractRequest { return commandResponse.setErrCode(errCode); } + /** + * 获取消息免打扰状态 + * + * @param command + * @return + */ + @ApiActions(action = ".mute") public CommandResponse mute(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); ErrorCode2 errCode = ErrorCode2.ERROR; @@ -290,6 +298,13 @@ public class ApiUserService extends AbstractRequest { return commandResponse.setErrCode2(errCode); } + /** + * 设置消息免打扰状态 + * + * @param command + * @return + */ + @ApiActions(action = ".updateMute") public CommandResponse updateMute(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); ErrorCode2 errCode = ErrorCode2.ERROR; diff --git a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiWebService.java b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiWebService.java index 4922ff0..e64c420 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiWebService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/impl/tai/ApiWebService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,11 +15,7 @@ */ package com.windchat.im.business.impl.tai; -import com.windchat.im.business.impl.AbstractRequest; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import com.akaxin.proto.site.ApiWebAuthProto; import com.windchat.common.command.Command; import com.windchat.common.command.CommandResponse; import com.windchat.common.constant.CommandConst; @@ -27,9 +23,12 @@ import com.windchat.common.constant.ErrorCode2; import com.windchat.common.constant.IErrorCode; import com.windchat.common.exceptions.ZalyException; import com.windchat.common.logs.LogUtils; -import com.akaxin.proto.site.ApiWebAuthProto; +import com.windchat.im.business.bean.ApiActions; import com.windchat.im.business.cache.WebSessionCache; import com.windchat.im.business.impl.AbstractRequest; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * webim服务 @@ -37,9 +36,11 @@ import com.windchat.im.business.impl.AbstractRequest; * @author Sam{@link an.guoyue254@gmail.com} * @since 2017.11.25 15:10:36 */ +@ApiActions(action = "api.web") public class ApiWebService extends AbstractRequest { private static final Logger logger = LoggerFactory.getLogger(ApiWebService.class); + @ApiActions(action = ".auth") public CommandResponse auth(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); IErrorCode errCode = ErrorCode2.ERROR; diff --git a/windchat-business/src/main/java/com/windchat/im/business/service/ApiRequestService.java b/windchat-business/src/main/java/com/windchat/im/business/service/ApiRequestService.java index d41cb47..25dd42a 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/service/ApiRequestService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/service/ApiRequestService.java @@ -1,5 +1,5 @@ -/** - * Copyright 2018-2028 Akaxin Group +/** + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -11,39 +11,37 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License. + * limitations under the License. */ package com.windchat.im.business.service; -import com.windchat.im.business.api.IRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.windchat.common.command.Command; import com.windchat.common.command.CommandResponse; import com.windchat.common.constant.CommandConst; import com.windchat.common.constant.ErrorCode2; import com.windchat.common.utils.StringHelper; import com.windchat.im.business.api.IRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * API处理业务逻辑 - * + * * @author Sam{@link an.guoyue254@gmail.com} * @since 2017.10.16 - * */ public class ApiRequestService implements IRequest { - private static final Logger logger = LoggerFactory.getLogger(ApiRequestService.class); + private static final Logger logger = LoggerFactory.getLogger(ApiRequestService.class); - public CommandResponse process(Command command) { - try { - return ApiServiceFactory.getService(command.getService()).execute(command); - } catch (Exception e) { - logger.error(StringHelper.format("api request service error.command={}", command), e); - } - return new CommandResponse().setVersion(CommandConst.PROTOCOL_VERSION).setAction(CommandConst.ACTION_RES) - .setErrCode2(ErrorCode2.ERROR); - } + public CommandResponse process(Command command) { + try { + String action = command.getRety() + "." + command.getService(); + return ApiServiceFactory.getService(action).execute(command); + } catch (Exception e) { + logger.error(StringHelper.format("api request service error.command={}", command), e); + } + return new CommandResponse().setVersion(CommandConst.PROTOCOL_VERSION).setAction(CommandConst.ACTION_RES) + .setErrCode2(ErrorCode2.ERROR); + } } diff --git a/windchat-business/src/main/java/com/windchat/im/business/service/ApiServiceFactory.java b/windchat-business/src/main/java/com/windchat/im/business/service/ApiServiceFactory.java index a2f9acd..5ee22f5 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/service/ApiServiceFactory.java +++ b/windchat-business/src/main/java/com/windchat/im/business/service/ApiServiceFactory.java @@ -1,5 +1,5 @@ -/** - * Copyright 2018-2028 Akaxin Group +/** + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -11,14 +11,11 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License. + * limitations under the License. */ package com.windchat.im.business.service; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.windchat.common.constant.RequestAction; +import com.windchat.im.business.bean.ApiActions; import com.windchat.im.business.impl.IRequestService; import com.windchat.im.business.impl.tai.ApiDeviceService; import com.windchat.im.business.impl.tai.ApiFileService; @@ -28,40 +25,50 @@ import com.windchat.im.business.impl.tai.ApiPluginService; import com.windchat.im.business.impl.tai.ApiSecretChatService; import com.windchat.im.business.impl.tai.ApiSiteService; import com.windchat.im.business.impl.tai.ApiUserService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; /** * API业务请求,分发工厂 - * + * * @author Sam{@link an.guoyue254@gmail.com} * @since 2017.10.24 18:25:31 */ public class ApiServiceFactory { - private static final Logger logger = LoggerFactory.getLogger(ApiServiceFactory.class); + private static final Logger logger = LoggerFactory.getLogger(ApiServiceFactory.class); - public static IRequestService getService(String serviceName) { - RequestAction nameEnum = RequestAction.getAction(serviceName); - switch (nameEnum) { - case SITE: - return new ApiSiteService(); - case API_USER: - return new ApiUserService(); - case API_FRIEND: - return new ApiFriendService(); - case API_GROUP: - return new ApiGroupService(); - case API_SECRETCHAT: - return new ApiSecretChatService(); - case API_FILE: - return new ApiFileService(); - case API_DEVICE: - return new ApiDeviceService(); - case API_PLUGIN: - return new ApiPluginService(); - default: - logger.error("api business service error.service={}", nameEnum.getName()); - break; - } - return null; - } + private static Map serviceMap = new LinkedHashMap(); + private static List serviceList = new LinkedList(); + + static { + serviceList.add(new ApiSiteService()); + serviceList.add(new ApiUserService()); + serviceList.add(new ApiFriendService()); + serviceList.add(new ApiGroupService()); + serviceList.add(new ApiSecretChatService()); + serviceList.add(new ApiFileService()); + serviceList.add(new ApiDeviceService()); + serviceList.add(new ApiPluginService()); + + init(); + } + + private static void init() { + for (IRequestService requestService : serviceList) { + ApiActions serviceApiAction = requestService.getClass().getDeclaredAnnotation(ApiActions.class); + if (serviceApiAction != null) { + serviceMap.put(serviceApiAction.action(), requestService); + } + } + } + + public static IRequestService getService(String serviceAction) { + return serviceMap.get(serviceAction); + } } diff --git a/windchat-business/src/main/java/com/windchat/im/business/service/HttpRequestService.java b/windchat-business/src/main/java/com/windchat/im/business/service/HttpRequestService.java index bef10a0..bfe5c39 100755 --- a/windchat-business/src/main/java/com/windchat/im/business/service/HttpRequestService.java +++ b/windchat-business/src/main/java/com/windchat/im/business/service/HttpRequestService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,10 +15,6 @@ */ package com.windchat.im.business.service; -import com.windchat.im.business.api.IRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.windchat.common.command.Command; import com.windchat.common.command.CommandResponse; import com.windchat.common.constant.CommandConst; @@ -32,6 +28,8 @@ import com.windchat.im.business.impl.hai.HttpPushService; import com.windchat.im.business.impl.hai.HttpSessionService; import com.windchat.im.business.impl.hai.HttpSiteService; import com.windchat.im.business.impl.hai.HttpUserService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Http请求服务分发 diff --git a/windchat-common/src/main/java/com/windchat/common/channel/ChannelManager.java b/windchat-common/src/main/java/com/windchat/common/channel/ChannelManager.java index 73222fe..dca292c 100755 --- a/windchat-common/src/main/java/com/windchat/common/channel/ChannelManager.java +++ b/windchat-common/src/main/java/com/windchat/common/channel/ChannelManager.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/channel/ChannelSession.java b/windchat-common/src/main/java/com/windchat/common/channel/ChannelSession.java index 2fe992c..f0655f1 100755 --- a/windchat-common/src/main/java/com/windchat/common/channel/ChannelSession.java +++ b/windchat-common/src/main/java/com/windchat/common/channel/ChannelSession.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/channel/ChannelWriter.java b/windchat-common/src/main/java/com/windchat/common/channel/ChannelWriter.java index 2da4de6..27c38e7 100755 --- a/windchat-common/src/main/java/com/windchat/common/channel/ChannelWriter.java +++ b/windchat-common/src/main/java/com/windchat/common/channel/ChannelWriter.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/command/Command.java b/windchat-common/src/main/java/com/windchat/common/command/Command.java index 87028bf..8661c51 100755 --- a/windchat-common/src/main/java/com/windchat/common/command/Command.java +++ b/windchat-common/src/main/java/com/windchat/common/command/Command.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,18 +15,14 @@ */ package com.windchat.common.command; -import java.util.HashMap; -import java.util.Map; - -import com.windchat.common.channel.ChannelSession; -import com.windchat.common.utils.StringHelper; -import org.apache.commons.lang3.StringUtils; - import com.windchat.common.channel.ChannelSession; import com.windchat.common.constant.CommandConst; import com.windchat.common.utils.StringHelper; - import io.netty.channel.ChannelHandlerContext; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.Map; /** * 处理完成后的消息载体 diff --git a/windchat-common/src/main/java/com/windchat/common/command/CommandResponse.java b/windchat-common/src/main/java/com/windchat/common/command/CommandResponse.java index a40ac1b..6022a0d 100755 --- a/windchat-common/src/main/java/com/windchat/common/command/CommandResponse.java +++ b/windchat-common/src/main/java/com/windchat/common/command/CommandResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/command/RedisCommand.java b/windchat-common/src/main/java/com/windchat/common/command/RedisCommand.java index f5aba45..c664163 100755 --- a/windchat-common/src/main/java/com/windchat/common/command/RedisCommand.java +++ b/windchat-common/src/main/java/com/windchat/common/command/RedisCommand.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/constant/IErrorCode.java b/windchat-common/src/main/java/com/windchat/common/constant/IErrorCode.java index ee60502..eb02e12 100755 --- a/windchat-common/src/main/java/com/windchat/common/constant/IErrorCode.java +++ b/windchat-common/src/main/java/com/windchat/common/constant/IErrorCode.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,11 @@ package com.windchat.common.constant; public interface IErrorCode { - public String getCode(); + String getCode(); - public String getInfo(); + String getInfo(); - public boolean isSuccess(); + boolean isSuccess(); - public String toString(); + String toString(); } diff --git a/windchat-common/src/main/java/com/windchat/common/crypto/HashCrypto.java b/windchat-common/src/main/java/com/windchat/common/crypto/HashCrypto.java index 23500cc..3d90c31 100755 --- a/windchat-common/src/main/java/com/windchat/common/crypto/HashCrypto.java +++ b/windchat-common/src/main/java/com/windchat/common/crypto/HashCrypto.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/crypto/RSACrypto.java b/windchat-common/src/main/java/com/windchat/common/crypto/RSACrypto.java index 043efec..6b0a74b 100755 --- a/windchat-common/src/main/java/com/windchat/common/crypto/RSACrypto.java +++ b/windchat-common/src/main/java/com/windchat/common/crypto/RSACrypto.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/exceptions/ZalyWarning.java b/windchat-common/src/main/java/com/windchat/common/exceptions/ZalyWarning.java new file mode 100755 index 0000000..08859cd --- /dev/null +++ b/windchat-common/src/main/java/com/windchat/common/exceptions/ZalyWarning.java @@ -0,0 +1,41 @@ +/** + * Copyright 2018-2028 WindChat Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.windchat.common.exceptions; + +import com.windchat.common.constant.IErrorCode; + +/** + * 自定义API请求过程中产生的特殊异常 + * + * @author Sam{@link an.guoyue254@gmail.com} + * @since 2018-04-09 12:32:08 + */ +public class ZalyWarning extends Exception { + /** + * + */ + private static final long serialVersionUID = 1L; + private IErrorCode errCode; + + public ZalyWarning(IErrorCode errCode) { + super(errCode.toString()); + this.errCode = errCode; + } + + public IErrorCode getErrCode() { + return this.errCode; + } +} diff --git a/windchat-common/src/main/java/com/windchat/common/executor/chain/handler/MethodReflectHandler.java b/windchat-common/src/main/java/com/windchat/common/executor/chain/handler/MethodReflectHandler.java index 3f9f0b9..9355695 100755 --- a/windchat-common/src/main/java/com/windchat/common/executor/chain/handler/MethodReflectHandler.java +++ b/windchat-common/src/main/java/com/windchat/common/executor/chain/handler/MethodReflectHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/http/ZalyHttpClient.java b/windchat-common/src/main/java/com/windchat/common/http/ZalyHttpClient.java index 4989c72..c2ddfbe 100755 --- a/windchat-common/src/main/java/com/windchat/common/http/ZalyHttpClient.java +++ b/windchat-common/src/main/java/com/windchat/common/http/ZalyHttpClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/logs/AkxLog4jManager.java b/windchat-common/src/main/java/com/windchat/common/logs/AkxLog4jManager.java index 1eaea5e..11d588c 100755 --- a/windchat-common/src/main/java/com/windchat/common/logs/AkxLog4jManager.java +++ b/windchat-common/src/main/java/com/windchat/common/logs/AkxLog4jManager.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/logs/LogUtils.java b/windchat-common/src/main/java/com/windchat/common/logs/LogUtils.java index b949739..92b8bb6 100755 --- a/windchat-common/src/main/java/com/windchat/common/logs/LogUtils.java +++ b/windchat-common/src/main/java/com/windchat/common/logs/LogUtils.java @@ -1,5 +1,5 @@ -/** - * Copyright 2018-2028 Akaxin Group +/** + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -11,7 +11,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License. + * limitations under the License. */ package com.windchat.common.logs; @@ -22,65 +22,68 @@ import org.slf4j.Logger; import org.slf4j.helpers.FormattingTuple; import org.slf4j.helpers.MessageFormatter; -import com.windchat.common.command.Command; -import com.windchat.common.command.CommandResponse; -import com.windchat.common.utils.StringHelper; - /** * 封装log,针对网络日志以及数据库操作日志 - * + * * @author Sam{@link an.guoyue254@gmail.com} * @since 2018-01-25 16:13:00 */ public class LogUtils extends LogCreater { - public static void requestInfoLog(Logger logger, Command command, String messagePattern, Object... objects) { - FormattingTuple format = MessageFormatter.arrayFormat(messagePattern, objects); - logger.info("client={} siteUserId={} action={} msg={}", command.getClientIp(), command.getSiteUserId(), - command.getAction(), command.toString(), format.getMessage()); - return; - } + public static void requestInfoLog(Logger logger, Command command, String messagePattern, Object... objects) { + FormattingTuple format = MessageFormatter.arrayFormat(messagePattern, objects); + logger.info("client={} siteUserId={} action={} msg={}", command.getClientIp(), command.getSiteUserId(), + command.getAction(), command.toString(), format.getMessage()); + return; + } - public static void requestDebugLog(Logger logger, Command command, String requestStr) { - logger.debug("client={} siteUserId={} action={} command={} request={}", command.getClientIp(), - command.getSiteUserId(), command.getAction(), command.toString(), requestStr); - } + public static void requestWarnLog(Logger logger, Command command, String messagePattern, Object... objects) { + FormattingTuple format = MessageFormatter.arrayFormat(messagePattern, objects); + logger.warn("client={} siteUserId={} action={} msg={}", command.getClientIp(), command.getSiteUserId(), + command.getAction(), command.toString(), format.getMessage()); + return; + } - public static void requestErrorLog(Logger logger, Command command, Throwable t) { - logger.error(StringHelper.format("client={} siteUserId={} action={} uri={} error", command.getClientIp(), - command.getSiteUserId(), command.getAction(), command.getUri()), t); - } + public static void requestDebugLog(Logger logger, Command command, String requestStr) { + logger.debug("client={} siteUserId={} action={} command={} request={}", command.getClientIp(), + command.getSiteUserId(), command.getAction(), command.toString(), requestStr); + } - public static void requestErrorLog(Logger logger, Command command, Class clazz, Throwable t) { - logger.error(StringHelper.format("client={} siteUserId={} action={} uri={} {} error", command.getClientIp(), - command.getSiteUserId(), command.getAction(), command.getUri(), clazz.getClass().getName()), t); - } + public static void requestErrorLog(Logger logger, Command command, Throwable t) { + logger.error(StringHelper.format("client={} siteUserId={} action={} uri={} error", command.getClientIp(), + command.getSiteUserId(), command.getAction(), command.getUri()), t); + } - public static void requestResultLog(Logger logger, Command command, CommandResponse response) { - try { - logger.info("client={} clientVersion={} siteUserId={} action={} uri={} cost={}ms result=[{}]", - command.getClientIp(), command.getClientVersion(), command.getSiteUserId(), command.getAction(), - command.getUri(), System.currentTimeMillis() - command.getStartTime(), response.getErrorCodeInfo()); - } catch (Exception e) { - logger.error(StringHelper.format("request result log error command={} response={}", command, response), e); - } - } + public static void requestErrorLog(Logger logger, Command command, Class clazz, Throwable t) { + logger.error(StringHelper.format("client={} siteUserId={} action={} uri={} {} error", command.getClientIp(), + command.getSiteUserId(), command.getAction(), command.getUri(), clazz.getClass().getName()), t); + } - public static void dbDebugLog(Logger logger, long startTime, Object result, String sql, Object... objects) { - String messagePattern = sql.replace("?", "{}"); - FormattingTuple format = MessageFormatter.arrayFormat(messagePattern, objects); - logger.debug("[windchat-db] cost:{}ms result:{} sql:{}", System.currentTimeMillis() - startTime, result, - format.getMessage()); - } + public static void requestResultLog(Logger logger, Command command, CommandResponse response) { + try { + logger.info("client={} clientVersion={} siteUserId={} action={} uri={} cost={}ms result=[{}]", + command.getClientIp(), command.getClientVersion(), command.getSiteUserId(), command.getAction(), + command.getUri(), System.currentTimeMillis() - command.getStartTime(), response.getErrorCodeInfo()); + } catch (Exception e) { + logger.error(StringHelper.format("request result log error command={} response={}", command, response), e); + } + } - public static void info(org.apache.log4j.Logger logger, String messagePattern, Object object) { - FormattingTuple format = MessageFormatter.format(messagePattern, object); - logger.info(format.getMessage()); - } + public static void dbDebugLog(Logger logger, long startTime, Object result, String sql, Object... objects) { + String messagePattern = sql.replace("?", "{}"); + FormattingTuple format = MessageFormatter.arrayFormat(messagePattern, objects); + logger.debug("[windchat-db] cost:{}ms result:{} sql:{}", System.currentTimeMillis() - startTime, result, + format.getMessage()); + } - public static void info(org.apache.log4j.Logger logger, String messagePattern, Object... objects) { - FormattingTuple format = MessageFormatter.arrayFormat(messagePattern, objects); - logger.info(format.getMessage()); - } + public static void info(org.apache.log4j.Logger logger, String messagePattern, Object object) { + FormattingTuple format = MessageFormatter.format(messagePattern, object); + logger.info(format.getMessage()); + } + + public static void info(org.apache.log4j.Logger logger, String messagePattern, Object... objects) { + FormattingTuple format = MessageFormatter.arrayFormat(messagePattern, objects); + logger.info(format.getMessage()); + } } diff --git a/windchat-common/src/main/java/com/windchat/common/netty/IRedisCommandResponse.java b/windchat-common/src/main/java/com/windchat/common/netty/IRedisCommandResponse.java index 00dbb7a..5c881c1 100755 --- a/windchat-common/src/main/java/com/windchat/common/netty/IRedisCommandResponse.java +++ b/windchat-common/src/main/java/com/windchat/common/netty/IRedisCommandResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,6 @@ */ package com.windchat.common.netty; -import com.windchat.common.command.RedisCommand; import com.windchat.common.command.RedisCommand; /** @@ -26,10 +25,10 @@ import com.windchat.common.command.RedisCommand; */ public interface IRedisCommandResponse { - public RedisCommand getRedisCommand(); + RedisCommand getRedisCommand(); - public boolean isSuccess(); + boolean isSuccess(); - public String getErrInfo(); + String getErrInfo(); } diff --git a/windchat-common/src/main/java/com/windchat/common/netty/NettyClient2.java b/windchat-common/src/main/java/com/windchat/common/netty/NettyClient2.java index 3655865..774b3b2 100755 --- a/windchat-common/src/main/java/com/windchat/common/netty/NettyClient2.java +++ b/windchat-common/src/main/java/com/windchat/common/netty/NettyClient2.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,17 +15,9 @@ */ package com.windchat.common.netty; -import java.util.concurrent.TimeUnit; - -import com.windchat.common.command.RedisCommand; -import com.windchat.common.netty.codec.MessageDecoder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.windchat.common.command.RedisCommand; import com.windchat.common.netty.codec.MessageDecoder; import com.windchat.common.netty.codec.MessageEncoder; - import io.netty.bootstrap.Bootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; @@ -44,6 +36,10 @@ import io.netty.util.concurrent.GenericFutureListener; import io.netty.util.concurrent.GlobalEventExecutor; import io.netty.util.concurrent.Promise; import io.netty.util.concurrent.SucceededFuture; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; /** * @author Sam{@link an.guoyue254@gmail.com} @@ -93,7 +89,7 @@ public class NettyClient2 { this.channelPromise = connectFuture.channel().newPromise(); } catch (Exception e) { - logger.error("connect to akaxin platform error.", e); + logger.error("connect to WindChat platform error.", e); } } diff --git a/windchat-common/src/main/java/com/windchat/common/netty/NettyClientHandler.java b/windchat-common/src/main/java/com/windchat/common/netty/NettyClientHandler.java index 9f920ec..bd5c61c 100755 --- a/windchat-common/src/main/java/com/windchat/common/netty/NettyClientHandler.java +++ b/windchat-common/src/main/java/com/windchat/common/netty/NettyClientHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,17 +15,13 @@ */ package com.windchat.common.netty; -import com.windchat.common.command.Command; -import com.windchat.common.command.RedisCommand; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.windchat.common.command.Command; -import com.windchat.common.command.RedisCommand; import com.akaxin.proto.core.CoreProto; - +import com.windchat.common.command.Command; +import com.windchat.common.command.RedisCommand; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Sam{@link an.guoyue254@gmail.com} diff --git a/windchat-common/src/main/java/com/windchat/common/netty/PlatformClientHandler.java b/windchat-common/src/main/java/com/windchat/common/netty/PlatformClientHandler.java index 2ce65f0..04547e1 100755 --- a/windchat-common/src/main/java/com/windchat/common/netty/PlatformClientHandler.java +++ b/windchat-common/src/main/java/com/windchat/common/netty/PlatformClientHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,17 +15,13 @@ */ package com.windchat.common.netty; -import com.windchat.common.command.Command; -import com.windchat.common.command.RedisCommand; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.windchat.common.command.Command; -import com.windchat.common.command.RedisCommand; import com.akaxin.proto.core.CoreProto; - +import com.windchat.common.command.Command; +import com.windchat.common.command.RedisCommand; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Sam{@link an.guoyue254@gmail.com} diff --git a/windchat-common/src/main/java/com/windchat/common/netty/PlatformSSLClient.java b/windchat-common/src/main/java/com/windchat/common/netty/PlatformSSLClient.java index 90e2b26..f419deb 100755 --- a/windchat-common/src/main/java/com/windchat/common/netty/PlatformSSLClient.java +++ b/windchat-common/src/main/java/com/windchat/common/netty/PlatformSSLClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,21 +15,10 @@ */ package com.windchat.common.netty; -import java.util.concurrent.TimeUnit; - -import javax.net.ssl.SSLEngine; - -import com.windchat.common.command.RedisCommand; -import com.windchat.common.netty.codec.MessageDecoder; -import com.windchat.common.ssl.ZalySSLContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.windchat.common.command.RedisCommand; import com.windchat.common.netty.codec.MessageDecoder; import com.windchat.common.netty.codec.MessageEncoder; import com.windchat.common.ssl.ZalySSLContext; - import io.netty.bootstrap.Bootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; @@ -50,6 +39,11 @@ import io.netty.util.concurrent.GenericFutureListener; import io.netty.util.concurrent.GlobalEventExecutor; import io.netty.util.concurrent.Promise; import io.netty.util.concurrent.SucceededFuture; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.net.ssl.SSLEngine; +import java.util.concurrent.TimeUnit; /** * @author Sam{@link an.guoyue254@gmail.com} @@ -110,7 +104,7 @@ public class PlatformSSLClient { this.channelPromise = connectFuture.channel().newPromise(); } catch (Exception e) { - logger.error("connect to akaxin platform error.", e); + logger.error("connect to WindChat platform error.", e); } } diff --git a/windchat-common/src/main/java/com/windchat/common/netty/codec/MessageDecoder.java b/windchat-common/src/main/java/com/windchat/common/netty/codec/MessageDecoder.java index b2b4d3c..e1cd95a 100755 --- a/windchat-common/src/main/java/com/windchat/common/netty/codec/MessageDecoder.java +++ b/windchat-common/src/main/java/com/windchat/common/netty/codec/MessageDecoder.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/netty/codec/MessageEncoder.java b/windchat-common/src/main/java/com/windchat/common/netty/codec/MessageEncoder.java index b839f71..be7a9c4 100755 --- a/windchat-common/src/main/java/com/windchat/common/netty/codec/MessageEncoder.java +++ b/windchat-common/src/main/java/com/windchat/common/netty/codec/MessageEncoder.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,20 +15,17 @@ */ package com.windchat.common.netty.codec; -import java.nio.ByteBuffer; - import com.windchat.common.command.RedisCommand; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.windchat.common.command.RedisCommand; - import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPromise; import io.netty.handler.codec.MessageToByteEncoder; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GenericFutureListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.nio.ByteBuffer; /** * 编码器 diff --git a/windchat-common/src/main/java/com/windchat/common/netty/codec/ProtocolParser.java b/windchat-common/src/main/java/com/windchat/common/netty/codec/ProtocolParser.java index 47f0f72..907d4c0 100755 --- a/windchat-common/src/main/java/com/windchat/common/netty/codec/ProtocolParser.java +++ b/windchat-common/src/main/java/com/windchat/common/netty/codec/ProtocolParser.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/netty/codec/ReplaySignal.java b/windchat-common/src/main/java/com/windchat/common/netty/codec/ReplaySignal.java index 79b6c3e..991a74a 100755 --- a/windchat-common/src/main/java/com/windchat/common/netty/codec/ReplaySignal.java +++ b/windchat-common/src/main/java/com/windchat/common/netty/codec/ReplaySignal.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/utils/ServerAddress.java b/windchat-common/src/main/java/com/windchat/common/utils/ServerAddress.java index ddf9d6d..3bf26b9 100755 --- a/windchat-common/src/main/java/com/windchat/common/utils/ServerAddress.java +++ b/windchat-common/src/main/java/com/windchat/common/utils/ServerAddress.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/utils/ServerAddressUtils.java b/windchat-common/src/main/java/com/windchat/common/utils/ServerAddressUtils.java index ea2e678..6ed8012 100755 --- a/windchat-common/src/main/java/com/windchat/common/utils/ServerAddressUtils.java +++ b/windchat-common/src/main/java/com/windchat/common/utils/ServerAddressUtils.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/utils/TimeFormats.java b/windchat-common/src/main/java/com/windchat/common/utils/TimeFormats.java index 67139f1..f7bf85c 100755 --- a/windchat-common/src/main/java/com/windchat/common/utils/TimeFormats.java +++ b/windchat-common/src/main/java/com/windchat/common/utils/TimeFormats.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-common/src/main/java/com/windchat/common/utils/URLRegexUtils.java b/windchat-common/src/main/java/com/windchat/common/utils/URLRegexUtils.java index 43a0db1..65e44b1 100755 --- a/windchat-common/src/main/java/com/windchat/common/utils/URLRegexUtils.java +++ b/windchat-common/src/main/java/com/windchat/common/utils/URLRegexUtils.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-common/src/main/java/com/windchat/common/utils/UserIdUtils.java b/windchat-common/src/main/java/com/windchat/common/utils/UserIdUtils.java index d2fe2d7..fdeda3f 100755 --- a/windchat-common/src/main/java/com/windchat/common/utils/UserIdUtils.java +++ b/windchat-common/src/main/java/com/windchat/common/utils/UserIdUtils.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/codec/parser/IProtocolParser.java b/windchat-connector/src/main/java/com/windchat/im/connector/codec/parser/IProtocolParser.java index 4e32d98..cc3dce7 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/codec/parser/IProtocolParser.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/codec/parser/IProtocolParser.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,6 @@ import io.netty.channel.Channel; */ public interface IProtocolParser { - public void readAndOut(Channel ch, ByteBuf inByte, List out, MessageDecoder decoder) throws Exception; + void readAndOut(Channel ch, ByteBuf inByte, List out, MessageDecoder decoder) throws Exception; } diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/codec/parser/ProtocolParser.java b/windchat-connector/src/main/java/com/windchat/im/connector/codec/parser/ProtocolParser.java index 3a0e987..fcbde80 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/codec/parser/ProtocolParser.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/codec/parser/ProtocolParser.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/codec/protocol/MessageDecoder.java b/windchat-connector/src/main/java/com/windchat/im/connector/codec/protocol/MessageDecoder.java index 7392801..aba8bdf 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/codec/protocol/MessageDecoder.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/codec/protocol/MessageDecoder.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/codec/protocol/ReplaySignal.java b/windchat-connector/src/main/java/com/windchat/im/connector/codec/protocol/ReplaySignal.java index 72654e8..2e71f46 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/codec/protocol/ReplaySignal.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/codec/protocol/ReplaySignal.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/handler/ApiRequestHandler.java b/windchat-connector/src/main/java/com/windchat/im/connector/handler/ApiRequestHandler.java index 9660b65..39a08b7 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/handler/ApiRequestHandler.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/handler/ApiRequestHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/handler/HttpRequestHandler.java b/windchat-connector/src/main/java/com/windchat/im/connector/handler/HttpRequestHandler.java index d70cf6e..06b4998 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/handler/HttpRequestHandler.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/handler/HttpRequestHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/handler/ImMessageHandler.java b/windchat-connector/src/main/java/com/windchat/im/connector/handler/ImMessageHandler.java index ddec5b0..c0be996 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/handler/ImMessageHandler.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/handler/ImMessageHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/handler/ImSiteAuthHandler.java b/windchat-connector/src/main/java/com/windchat/im/connector/handler/ImSiteAuthHandler.java index caf99ef..d7e4eec 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/handler/ImSiteAuthHandler.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/handler/ImSiteAuthHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/handler/WSRequestHandler.java b/windchat-connector/src/main/java/com/windchat/im/connector/handler/WSRequestHandler.java index 1726c73..c8c3141 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/handler/WSRequestHandler.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/handler/WSRequestHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,8 +32,6 @@ import io.netty.util.concurrent.GenericFutureListener; * * @author Sam * @since 2017.10.19 - * - * @param */ public class WSRequestHandler extends AbstractCommonHandler { private static final Logger logger = LoggerFactory.getLogger(WSRequestHandler.class); diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/http/HttpServer.java b/windchat-connector/src/main/java/com/windchat/im/connector/http/HttpServer.java index d60eb9c..cae8033 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/http/HttpServer.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/http/HttpServer.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/http/handler/HttpServerHandler.java b/windchat-connector/src/main/java/com/windchat/im/connector/http/handler/HttpServerHandler.java index faa76e0..f97499f 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/http/handler/HttpServerHandler.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/http/handler/HttpServerHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/netty/NettyServer.java b/windchat-connector/src/main/java/com/windchat/im/connector/netty/NettyServer.java index 89ec940..5d9d856 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/netty/NettyServer.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/netty/NettyServer.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/netty/PrefixThreadFactory.java b/windchat-connector/src/main/java/com/windchat/im/connector/netty/PrefixThreadFactory.java index 19797bf..3a3ec18 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/netty/PrefixThreadFactory.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/netty/PrefixThreadFactory.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/netty/handler/NettyServerHandler.java b/windchat-connector/src/main/java/com/windchat/im/connector/netty/handler/NettyServerHandler.java index 552d92c..3f4e41c 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/netty/handler/NettyServerHandler.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/netty/handler/NettyServerHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-connector/src/main/java/com/windchat/im/connector/ssl/NettySocketSslContext.java b/windchat-connector/src/main/java/com/windchat/im/connector/ssl/NettySocketSslContext.java index b854189..975d225 100755 --- a/windchat-connector/src/main/java/com/windchat/im/connector/ssl/NettySocketSslContext.java +++ b/windchat-connector/src/main/java/com/windchat/im/connector/ssl/NettySocketSslContext.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserFriendDao.java b/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserFriendDao.java index 21608e0..7e2cd50 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserFriendDao.java +++ b/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserFriendDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserGroupDao.java b/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserGroupDao.java index 2a9a039..73c984a 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserGroupDao.java +++ b/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserGroupDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserProfileDao.java b/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserProfileDao.java index 311bf12..913ea74 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserProfileDao.java +++ b/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserProfileDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserSessionDao.java b/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserSessionDao.java index 4d09bd5..bc1bf53 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserSessionDao.java +++ b/windchat-message/src/main/java/com/windchat/im/message/dao/ImUserSessionDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/dao/SessionDeviceDao.java b/windchat-message/src/main/java/com/windchat/im/message/dao/SessionDeviceDao.java index 72140e4..b91cae0 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/dao/SessionDeviceDao.java +++ b/windchat-message/src/main/java/com/windchat/im/message/dao/SessionDeviceDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/dao/SiteConfigDao.java b/windchat-message/src/main/java/com/windchat/im/message/dao/SiteConfigDao.java index fb878e3..bf91d53 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/dao/SiteConfigDao.java +++ b/windchat-message/src/main/java/com/windchat/im/message/dao/SiteConfigDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/group/handler/GroupMessageTextSecretHandler.java b/windchat-message/src/main/java/com/windchat/im/message/group/handler/GroupMessageTextSecretHandler.java index c6f18e4..b528eb1 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/group/handler/GroupMessageTextSecretHandler.java +++ b/windchat-message/src/main/java/com/windchat/im/message/group/handler/GroupMessageTextSecretHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/notice/handler/AbstractNoticeHandler.java b/windchat-message/src/main/java/com/windchat/im/message/notice/handler/AbstractNoticeHandler.java index 982e0d7..89cfef9 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/notice/handler/AbstractNoticeHandler.java +++ b/windchat-message/src/main/java/com/windchat/im/message/notice/handler/AbstractNoticeHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/notice/handler/NoticeHandler.java b/windchat-message/src/main/java/com/windchat/im/message/notice/handler/NoticeHandler.java index b5eabed..136b2ed 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/notice/handler/NoticeHandler.java +++ b/windchat-message/src/main/java/com/windchat/im/message/notice/handler/NoticeHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/sync/handler/SyncGroupMessageHandler.java b/windchat-message/src/main/java/com/windchat/im/message/sync/handler/SyncGroupMessageHandler.java index 5cd5b1c..df6d67e 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/sync/handler/SyncGroupMessageHandler.java +++ b/windchat-message/src/main/java/com/windchat/im/message/sync/handler/SyncGroupMessageHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,15 +15,11 @@ */ package com.windchat.im.message.sync.handler; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.windchat.im.message.bean.WebBean; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import com.akaxin.proto.client.ImStcMessageProto; +import com.akaxin.proto.core.CoreProto; +import com.akaxin.proto.core.CoreProto.MsgType; +import com.akaxin.proto.site.ImSyncMessageProto; +import com.google.protobuf.ByteString; import com.windchat.common.channel.ChannelSession; import com.windchat.common.command.Command; import com.windchat.common.command.RedisCommand; @@ -31,10 +27,6 @@ import com.windchat.common.constant.CommandConst; import com.windchat.common.logs.LogUtils; import com.windchat.common.utils.GsonUtils; import com.windchat.common.utils.StringHelper; -import com.akaxin.proto.client.ImStcMessageProto; -import com.akaxin.proto.core.CoreProto; -import com.akaxin.proto.core.CoreProto.MsgType; -import com.akaxin.proto.site.ImSyncMessageProto; import com.windchat.im.message.bean.WebBean; import com.windchat.im.message.utils.NumUtils; import com.windchat.im.storage.api.IGroupDao; @@ -42,9 +34,14 @@ import com.windchat.im.storage.api.IMessageDao; import com.windchat.im.storage.bean.GroupMessageBean; import com.windchat.im.storage.service.GroupDaoService; import com.windchat.im.storage.service.MessageDaoService; -import com.google.protobuf.ByteString; - import io.netty.channel.Channel; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * 同步群组消息 diff --git a/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageTextHandler.java b/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageTextHandler.java index 74ddead..33cac36 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageTextHandler.java +++ b/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageTextHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageTextSecretHandler.java b/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageTextSecretHandler.java index 090ef46..6bc0937 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageTextSecretHandler.java +++ b/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageTextSecretHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageWebHandler.java b/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageWebHandler.java index c31e40a..9635e4e 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageWebHandler.java +++ b/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageWebHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,18 +15,16 @@ */ package com.windchat.im.message.user2.handler; -import com.windchat.im.message.bean.WebBean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.windchat.common.command.Command; -import com.windchat.common.logs.LogUtils; import com.akaxin.proto.core.CoreProto; import com.akaxin.proto.site.ImCtsMessageProto; +import com.windchat.common.command.Command; +import com.windchat.common.logs.LogUtils; import com.windchat.im.message.bean.WebBean; import com.windchat.im.storage.api.IMessageDao; import com.windchat.im.storage.bean.U2MessageBean; import com.windchat.im.storage.service.MessageDaoService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class U2MessageWebHandler extends AbstractU2Handler { private static final Logger logger = LoggerFactory.getLogger(U2MessageWebHandler.class); diff --git a/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageWebNoticeHandler.java b/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageWebNoticeHandler.java index ed43c49..0930c9b 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageWebNoticeHandler.java +++ b/windchat-message/src/main/java/com/windchat/im/message/user2/handler/U2MessageWebNoticeHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,18 +15,16 @@ */ package com.windchat.im.message.user2.handler; -import com.windchat.im.message.bean.WebBean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.windchat.common.command.Command; -import com.windchat.common.logs.LogUtils; import com.akaxin.proto.core.CoreProto; import com.akaxin.proto.site.ImCtsMessageProto; +import com.windchat.common.command.Command; +import com.windchat.common.logs.LogUtils; import com.windchat.im.message.bean.WebBean; import com.windchat.im.storage.api.IMessageDao; import com.windchat.im.storage.bean.U2MessageBean; import com.windchat.im.storage.service.MessageDaoService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class U2MessageWebNoticeHandler extends AbstractU2Handler { private static final Logger logger = LoggerFactory.getLogger(U2MessageWebNoticeHandler.class); diff --git a/windchat-message/src/main/java/com/windchat/im/message/user2/handler/UserDetectionHandler.java b/windchat-message/src/main/java/com/windchat/im/message/user2/handler/UserDetectionHandler.java index ccd8080..53e6036 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/user2/handler/UserDetectionHandler.java +++ b/windchat-message/src/main/java/com/windchat/im/message/user2/handler/UserDetectionHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/user2/handler/UserPsnHandler.java b/windchat-message/src/main/java/com/windchat/im/message/user2/handler/UserPsnHandler.java index 569dd16..e7c6c5a 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/user2/handler/UserPsnHandler.java +++ b/windchat-message/src/main/java/com/windchat/im/message/user2/handler/UserPsnHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,20 +15,18 @@ */ package com.windchat.im.message.user2.handler; -import java.util.List; - -import com.windchat.im.message.dao.ImUserSessionDao; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import com.akaxin.proto.client.ImStcPsnProto; import com.windchat.common.channel.ChannelWriter; import com.windchat.common.command.Command; import com.windchat.common.command.CommandResponse; import com.windchat.common.constant.CommandConst; import com.windchat.common.constant.ErrorCode2; import com.windchat.common.logs.LogUtils; -import com.akaxin.proto.client.ImStcPsnProto; import com.windchat.im.message.dao.ImUserSessionDao; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; public class UserPsnHandler extends AbstractU2Handler { private static final Logger logger = LoggerFactory.getLogger(UserPsnHandler.class); diff --git a/windchat-message/src/main/java/com/windchat/im/message/utils/HexUtils.java b/windchat-message/src/main/java/com/windchat/im/message/utils/HexUtils.java index 0eaeb77..4b9e5b9 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/utils/HexUtils.java +++ b/windchat-message/src/main/java/com/windchat/im/message/utils/HexUtils.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/web/chat/WebChatReceiveMessageHandler.java b/windchat-message/src/main/java/com/windchat/im/message/web/chat/WebChatReceiveMessageHandler.java index 68f06a0..2ce2eb2 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/web/chat/WebChatReceiveMessageHandler.java +++ b/windchat-message/src/main/java/com/windchat/im/message/web/chat/WebChatReceiveMessageHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-message/src/main/java/com/windchat/im/message/web/chat/WebChatSendMessageHandler.java b/windchat-message/src/main/java/com/windchat/im/message/web/chat/WebChatSendMessageHandler.java index 5545d1b..873d9cf 100755 --- a/windchat-message/src/main/java/com/windchat/im/message/web/chat/WebChatSendMessageHandler.java +++ b/windchat-message/src/main/java/com/windchat/im/message/web/chat/WebChatSendMessageHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,20 +15,17 @@ */ package com.windchat.im.message.web.chat; -import com.windchat.im.message.dao.ImUserFriendDao; -import com.windchat.im.message.dao.ImUserProfileDao; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.windchat.common.command.Command; -import com.windchat.common.logs.LogUtils; -import com.windchat.common.utils.StringHelper; import com.akaxin.proto.core.CoreProto; import com.akaxin.proto.core.UserProto; import com.akaxin.proto.site.ImCtsMessageProto; +import com.windchat.common.command.Command; +import com.windchat.common.logs.LogUtils; +import com.windchat.common.utils.StringHelper; import com.windchat.im.message.dao.ImUserFriendDao; import com.windchat.im.message.dao.ImUserProfileDao; import com.windchat.im.storage.bean.SimpleUserBean; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * web消息检测 diff --git a/windchat-storage/src/main/java/com/windchat/im/storage/DataSourceManager.java b/windchat-storage/src/main/java/com/windchat/im/storage/DataSourceManager.java index 7935e50..4b1f450 100755 --- a/windchat-storage/src/main/java/com/windchat/im/storage/DataSourceManager.java +++ b/windchat-storage/src/main/java/com/windchat/im/storage/DataSourceManager.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteGroupMessageDao.java b/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteGroupMessageDao.java index 56ec326..8628eed 100755 --- a/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteGroupMessageDao.java +++ b/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteGroupMessageDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteU2MessageDao.java b/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteU2MessageDao.java index 3e855d8..48d3574 100755 --- a/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteU2MessageDao.java +++ b/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteU2MessageDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteUserDeviceDao.java b/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteUserDeviceDao.java index 64fb2c3..fb364b1 100755 --- a/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteUserDeviceDao.java +++ b/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteUserDeviceDao.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteUserFriendDao.java b/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteUserFriendDao.java index 31341c5..ffc46ab 100755 --- a/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteUserFriendDao.java +++ b/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteUserFriendDao.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteUsersDao.java b/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteUsersDao.java index 90b114f..ca76e92 100755 --- a/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteUsersDao.java +++ b/windchat-storage/src/main/java/com/windchat/im/storage/dao/SiteUsersDao.java @@ -1,12 +1,12 @@ /** - * Copyright 2018-2028 Akaxin Group - *

+ * Copyright 2018-2028 WindChat Group + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

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

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/windchat-storage/src/main/java/com/windchat/im/storage/dao/sqlite/manager/SQLiteJDBCManager.java b/windchat-storage/src/main/java/com/windchat/im/storage/dao/sqlite/manager/SQLiteJDBCManager.java index ac4fdab..4a3b7f8 100755 --- a/windchat-storage/src/main/java/com/windchat/im/storage/dao/sqlite/manager/SQLiteJDBCManager.java +++ b/windchat-storage/src/main/java/com/windchat/im/storage/dao/sqlite/manager/SQLiteJDBCManager.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-storage/src/main/java/com/windchat/im/storage/service/FriendApplyDaoService.java b/windchat-storage/src/main/java/com/windchat/im/storage/service/FriendApplyDaoService.java index 1a4eddd..07493ca 100755 --- a/windchat-storage/src/main/java/com/windchat/im/storage/service/FriendApplyDaoService.java +++ b/windchat-storage/src/main/java/com/windchat/im/storage/service/FriendApplyDaoService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-storage/src/main/java/com/windchat/im/storage/service/SiteUsersDaoService.java b/windchat-storage/src/main/java/com/windchat/im/storage/service/SiteUsersDaoService.java index fe6bbb0..91dbc80 100755 --- a/windchat-storage/src/main/java/com/windchat/im/storage/service/SiteUsersDaoService.java +++ b/windchat-storage/src/main/java/com/windchat/im/storage/service/SiteUsersDaoService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/windchat-storage/src/main/java/com/windchat/im/storage/service/UserFriendDaoService.java b/windchat-storage/src/main/java/com/windchat/im/storage/service/UserFriendDaoService.java index bd85247..ac80691 100755 --- a/windchat-storage/src/main/java/com/windchat/im/storage/service/UserFriendDaoService.java +++ b/windchat-storage/src/main/java/com/windchat/im/storage/service/UserFriendDaoService.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2028 Akaxin Group + * Copyright 2018-2028 WindChat Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.