add project

This commit is contained in:
SAM2O2O 2019-07-29 23:42:16 +08:00
commit c42515bf41
504 changed files with 236653 additions and 0 deletions

13
.gitignore vendored Executable file
View File

@ -0,0 +1,13 @@
*.classpath
*.project
*.settings/
.idea/
*.swp
*.iml
target/
.DS_Store
openzalyDB.sqlite3
stdout.log
openzaly-server.jar
site-file/
site-logs/

201
LICENSE Executable file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

170
NOTICE Executable file
View File

@ -0,0 +1,170 @@
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.
========================[Dependencies]===============================
Spring:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://www.springsource.org
Javassist:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://www.jboss.org/javassist
Netty:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://netty.io
Mina:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://mina.apache.org
Grizzly:
* LICENSE:
* http://www.gnu.org/licenses/gpl-2.0.html (General Public License 2.0)
* HOMEPAGE:
* http://grizzly.java.net
HttpClient:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://hc.apache.org
Hessian:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://hessian.caucho.com
XStream:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://xstream.codehaus.org
FastJson:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://code.alibabatech.com/wiki/fastjson
Zookeeper:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://zookeeper.apache.org
Jedis:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://code.google.com/p/jedis
XMemcached:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://code.google.com/p/xmemcached
Jetty:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://jetty.mortbay.org
Thrift:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://thrift.apache.org
CXF:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://cxf.apache.org
ZKClient:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* https://github.com/sgroschupf/zkclient
Curator
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* https://github.com/Netflix/curator
JFreeChart:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://www.jfree.org
HibernateValidator:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://www.hibernate.org/subprojects/validator.html
CommonsLogging:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://commons.apache.org/logging
SLF4J:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://www.slf4j.org
Log4j:
* LICENSE:
* http://www.apache.org/licenses/LICENSE-2.0 (Apache License 2.0)
* HOMEPAGE:
* http://log4j.apache.org

163
README.md Executable file
View File

@ -0,0 +1,163 @@
<p align="right">
<a href="https://www.akaxin.com/">
<img
alt="Akaxin"
src="https://avatars3.githubusercontent.com/u/32624098?s=200&v=4"
width="128"
/>
</a>
</p>
[Akaxin](https://www.akaxin.com)
====
[![License](https://img.shields.io/badge/license-apache2-blue.svg)](LICENSE)
**源码仓库**
> * **Github**: https://github.com/akaxincom/openzaly
> * `国内快` Gitee: https://gitee.com/akaxin/openzaly
_
**向我们提问**
> QQ群`655249600`
简介
----
Akaxin 是一款开源免费的私有聊天软件,可以部署在任意服务器上,搭建自己的聊天服务器,供自己与朋友、用户使用。
特性:
* 单聊、群聊(含文字、图片、语音等)
* 端到端的加密消息(服务端不可解密,服务器可通过配置关闭此特性)
* 匿名注册、实名注册,以及注册邀请码机制(只允许特定用户注册)
* 扩展机制
* 等
<p align="center">
<img align="center" src="https://is1-ssl.mzstatic.com/image/thumb/Purple118/v4/5f/56/82/5f56825f-5a1d-751a-76ee-e4af3337133c/pr_source.png/0x0ss.jpg" width="200" /> &nbsp; <img align="center" src="https://is1-ssl.mzstatic.com/image/thumb/Purple128/v4/0a/13/7f/0a137f45-a89e-57d6-3135-5c72b219b28d/pr_source.png/0x0ss.jpg" width="200" /> &nbsp; <img align="center" src="https://is1-ssl.mzstatic.com/image/thumb/Purple128/v4/45/ec/0a/45ec0a96-6683-049e-139b-f11aaea306c8/pr_source.png/0x0ss.jpg" width="200" /> &nbsp;
</p>
一、快速体验
----
**1. 启动服务器**
* **最新版本: openzaly 1.0.7**
* 国内镜像https://cdn-akaxin-1255552447.cos.ap-beijing.myqcloud.com/openzaly/openzaly-server.jar
* Github下载: https://github.com/akaxincom/openzaly/releases/
* **Changelog**
* openzaly发布team版本同时支持个人版与team版。
* team 版本支持使用mysql数据库并且可配置主从库。
* openzaly使用ssl与平台交互增加了信息传输的安全性。
openzlay 0.10.6开始支持personal个人版与team版默认状态下使用personal
支持的启动参数:`java -jar openzaly-server.jar -h`
openzaly Personal版本 命令:
* 版本升级:`java -jar openzaly-server.jar -upgrade` 此命令在服务与sqlite数据库版本不一致时执行正常情况无需执行
* 启动命令:`java -jar openzaly-server.jar`
openzaly Team版本 命令:
* 生成Team版本所需配置模版`java -jar openzaly-server.jar -team`
* 修改配置文件: 上一步会生成 openzaly-server.config 使用mysql数据库需在openzaly-server.config配置文件中配置mysql参数
主库数据库编码需要设置utf8mb4
openzaly.mysql.host=localhost //数据库的地址
openzaly.mysql.port=3306 //数据库端口
openzaly.mysql.database=openzaly //数据库名称
openzaly.mysql.username=root //mysql数据库访问用户
openzaly.mysql.password=1234567890 //mysql数据库密码
从库如果需要使用主从模式配置这里不需要从库则不需要配置数据库编码需要设置utf8mb4
openzaly.mysql.slave.host=localhost
openzaly.mysql.slave.port=3306
openzaly.mysql.slave.database=openzaly
openzaly.mysql.slave.username=root
openzaly.mysql.slave.password=1234567890
其他mysql参数为使用mysql连接池的配置参数如若涉及性能优化可开启配置项。
* 迁移数据库命令openzaly支持使用者把Personal版本的sqlite中的数据迁移到Team版本的mysql数据库
如果执行这一步需要在openzaly-server.config配置文件中配置
`openzaly.sqlite.url=openzalyDB.sqlite3` 这里指定sqlite数据库文件的位置
继续执行迁移命令:
`java -jar openzaly-server.jar -migrate`
* 启动命令:`java -jar openzaly-server.jar`
**2. 下载客户端**
> * [iOS](https://itunes.apple.com/cn/app/%E9%98%BF%E5%8D%A1%E4%BF%A1/id1346971087?mt=8)
> * [Android](https://www.akaxin.com)
**3. 访问站点**
> * 生成账号(手机账号与匿名均可)
> * 输入站点服务器
> * 首次登陆为管理员邀请码000000
> * 别的用户登陆后可以互加好友,开始聊天。
* 匿名账号,账号保存在设备本地,用户不会填写手机信息,任何地方都获取不到。
> **站点注册方式默认为匿名,进入站点后,请根据情况第一时间修改为 实名 或者 开启邀请码,防止恶意用户进入**
二、源码编译安装
----
需要本地有mvn直接使用mvn编译即可。
三、扩展开发
----
Akaxin 具有灵活、强大的扩展机制 `(“管理平台” 就是一个扩展)`。通过嵌入WEB页面与后端的扩展API进行交互 可以很轻松的构建丰富的业务功能,如:
* 附近交友
* 店铺点评
* 在线游戏
* 等等等等
你的聊天服务器,将摇身一变,成为一个强大的社交软件平台。
> 扩展机制处于技术预览阶段,如果你希望在自己的业务中开发自己的扩展,可以联系我们( mail: hi@akaxin.xyz ),我们将免费提供文档与技术答疑。
以下是我们开发的一个 “校园社交” 的扩展,截图如下:
<p align="center">
<img align="center" src="https://raw.githubusercontent.com/akaxincom/faq/master/app_pic/plugin.1.jpeg" width="200" /> &nbsp; <img align="center" src="https://raw.githubusercontent.com/akaxincom/faq/master/app_pic/plugin.2.jpeg" width="200" /> &nbsp; <img align="center" src="https://raw.githubusercontent.com/akaxincom/faq/master/app_pic/plugin.3.jpeg" width="200" /> &nbsp;
</p>
> 大家可以去 demo.akaxin.com 体验。
四、技术贡献者
----
> 以加入时间排序
* sisishiliu
* SAM2O2O
* childeYin
* yi.chao
* lei.yu
* cuikun
* alexfanchina
* Mino0885
* 505541778

27
build.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# ----------------------------------------------------------------------------
# Copyright 2018-2028 Akaxin Group
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
# ----------------------------------------------------------------------------
cd `dirname $0`
mvn -T 2C clean package
cp openzaly-boot/target/openzaly-boot-*-SNAPSHOT.jar openzaly-server.jar

68
openzaly-admin/pom.xml Executable file
View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.akaxin</groupId>
<artifactId>openzaly-parent</artifactId>
<version>0.0.1</version>
</parent>
<groupId>com.akaxin.site</groupId>
<artifactId>openzaly-admin</artifactId>
<version>0.0.1-RELEASE</version>
<packaging>jar</packaging>
<name>openzaly-admin</name>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.akaxin.site</groupId>
<artifactId>openzaly-business</artifactId>
<version>0.0.1-RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.2.RELEASE</version>
<!-- <configuration>
指定该Main Class为全局的唯一入口
<mainClass>com.akaxin.admin.OpenzalyAdminApplication</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions> -->
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,37 @@
/**
* 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.
*/
package com.akaxin.site.web;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* springboot的支持放在openzaly-boot中
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-06-05 19:31:16
*/
@Deprecated
@SpringBootApplication
public class OpenzalyAdminApplication {
public static void main(String[] args) {
SpringApplication application = new SpringApplication(OpenzalyAdminApplication.class);
application.setBannerMode(Banner.Mode.OFF);
application.run(args);
}
}

View File

@ -0,0 +1,92 @@
package com.akaxin.site.web.admin.bean;
import com.akaxin.common.utils.GsonUtils;
public class WebMessageBean {
private String siteUserId;
private String siteFriendId;
private String siteGroupId;
private String msgId;
private String webCode;
private int width;
private int height;
private String hrefUrl;
private long msgTime;
public String getSiteUserId() {
return siteUserId;
}
public void setSiteUserId(String siteUserId) {
this.siteUserId = siteUserId;
}
public String getSiteFriendId() {
return siteFriendId;
}
public void setSiteFriendId(String siteFriendId) {
this.siteFriendId = siteFriendId;
}
public String getWebCode() {
return webCode;
}
public void setWebCode(String webCode) {
this.webCode = webCode;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public String getMsgId() {
return msgId;
}
public void setMsgId(String msgId) {
this.msgId = msgId;
}
public long getMsgTime() {
return msgTime;
}
public void setMsgTime(long msgTime) {
this.msgTime = msgTime;
}
public String getSiteGroupId() {
return siteGroupId;
}
public void setSiteGroupId(String siteGroupId) {
this.siteGroupId = siteGroupId;
}
public String getHrefUrl() {
return hrefUrl;
}
public void setHrefUrl(String hrefUrl) {
this.hrefUrl = hrefUrl;
}
public String toString() {
return GsonUtils.toJson(this);
}
}

View File

@ -0,0 +1,22 @@
package com.akaxin.site.web.admin.common;
import org.apache.commons.lang3.StringUtils;
/**
* 消息工具类
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-04-25 11:49:21
*/
public class MsgUtils {
public static String buildU2MsgId(String siteUserid) {
StringBuilder sb = new StringBuilder("U2-");
if (StringUtils.isNotEmpty(siteUserid)) {
int len = siteUserid.length();
sb.append(siteUserid.substring(0, len >= 8 ? 8 : len));
sb.append("-");
}
sb.append(System.currentTimeMillis());
return sb.toString();
}
}

View File

@ -0,0 +1,16 @@
package com.akaxin.site.web.admin.common;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
public class Timeutils {
//返回前num天的日期
public static String getDate(Integer num) {
if (num != null && num >= 1) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
return simpleDateFormat.format(new Date(System.currentTimeMillis()-TimeUnit.DAYS.toMillis(num)));
}
return null;
}
}

View File

@ -0,0 +1,59 @@
/**
* 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.
*/
package com.akaxin.site.web.admin.controller;
import java.util.Map;
import com.akaxin.common.utils.GsonUtils;
import com.akaxin.proto.core.PluginProto;
import com.akaxin.site.business.impl.site.SiteConfig;
public class AbstractController {
protected final int PAGE_SIZE = 20;
protected final String SUCCESS = "success";
protected final String ERROR = "error";
protected final String NO_PERMISSION = "no-permission";
public boolean isManager(String siteUserId) {
return SiteConfig.isSiteManager(siteUserId);
}
public boolean isAdmin(String siteUserId) {
return SiteConfig.isSiteSuperAdmin(siteUserId);
}
public String getRequestSiteUserId(PluginProto.ProxyPluginPackage pluginPackage) {
Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap();
return headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE);
}
@SuppressWarnings("unchecked")
public Map<String, String> getRequestDataMap(PluginProto.ProxyPluginPackage pluginPackage) {
return GsonUtils.fromJson(pluginPackage.getData(), Map.class);
}
public String trim(String parameter) {
if (parameter == null) {
return parameter;
}
String trim = parameter.replaceAll("[  ]", "");
return trim;
}
}

View File

@ -0,0 +1,40 @@
/**
* 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.
*/
package com.akaxin.site.web.admin.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("common")
public class CommomController {
@RequestMapping("success")
public String toSuccessPage() {
return "success";
}
@RequestMapping("nopermission")
public String toNoPermissionPage() {
return "success";
}
@RequestMapping("error")
public String toErrorPage() {
return "error";
}
}

View File

@ -0,0 +1,282 @@
/**
* Copyright 2018-2028 Akaxin Group
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.akaxin.site.web.admin.controller;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.akaxin.common.logs.AkxLog4jManager;
import com.akaxin.common.utils.GsonUtils;
import com.akaxin.proto.core.ConfigProto;
import com.akaxin.proto.core.ConfigProto.ConfigKey;
import com.akaxin.proto.core.PluginProto;
import com.akaxin.site.business.impl.site.SiteConfig;
import com.akaxin.site.web.admin.exception.UserPermissionException;
import com.akaxin.site.web.admin.service.IConfigService;
import com.google.protobuf.InvalidProtocolBufferException;
/**
* 阿卡信 - 后台管理 - 站点设置
*
* akaxin 后台管理配置
*
* @author Sam{@link an.guoyue254@gmail.com} ,Mino
* @since 2018-05-28 14:10:05
*/
@Controller
@RequestMapping("manage")
public class ConfigManageController extends AbstractController {
private static final Logger logger = LoggerFactory.getLogger(UserManageController.class);
@Autowired
private IConfigService configManageService;
@RequestMapping("/index")
public String homePage(@RequestBody byte[] bodyParam) {
PluginProto.ProxyPluginPackage pluginPackage = null;
try {
pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
boolean isManager = SiteConfig.isSiteManager(siteUserId);
if (!isManager) {
throw new UserPermissionException("Current user is not a manager");
}
return "admin";
} catch (InvalidProtocolBufferException e) {
logger.error("to basic manage error", e);
} catch (UserPermissionException u) {
logger.error("to basic manage error : " + u.getMessage());
}
return "error";
}
// 获取站点配置信息
@RequestMapping("/basicConfig")
public ModelAndView toSiteConfigPage(@RequestBody byte[] bodyParam) {
ModelAndView modelAndView = new ModelAndView("basic/config");
Map<String, Object> model = modelAndView.getModel();
// 设置默认属性
PluginProto.ProxyPluginPackage pluginPackage = null;
try {
pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
if (isAdmin(siteUserId)) {
model.put("manager_type", "admin");
} else if (isManager(siteUserId)) {
model.put("manager_type", "site_manager");
}
// 设置默认值
model.put("uic_status", "0");
model.put("pic_size", "1");
model.put("pic_path", "/akaxin");
model.put("group_members_count", "100");
model.put("u2_encryption_status", "1");
model.put("push_client_status", "0");
model.put("log_level", "INFO");
model.put("add_friends_status", "0");// 0表示允许
model.put("create_groups_status", "0");// 0默认为允许
model.put("group_qrcode_expire_time", "14");// 群二维码默认两周
Map<Integer, String> map = configManageService.getSiteConfig();
Set<Integer> integers = map.keySet();
String site_prot = "";
String site_address = "";
String http_prot = "";
String http_address = "";
for (Integer integer : integers) {
String res = map.get(integer);
switch (integer) {
case ConfigKey.SITE_NAME_VALUE:
model.put("site_name", res);
break;
case ConfigKey.SITE_ADDRESS_VALUE:
site_address = res;
break;
case ConfigKey.SITE_PORT_VALUE:
site_prot = res;
break;
case ConfigKey.SITE_HTTP_ADDRESS_VALUE:
http_address = res;
break;
case ConfigKey.SITE_HTTP_PORT_VALUE:
http_prot = res;
break;
case ConfigKey.SITE_LOGO_VALUE:
model.put("site_logo", res);
break;
case ConfigKey.SITE_INTRODUCTION_VALUE:
model.put("site_desc", res);
break;
case ConfigKey.REALNAME_STATUS_VALUE:
model.put("realName_status", res);
break;
case ConfigKey.INVITE_CODE_STATUS_VALUE:
model.put("uic_status", res);
break;
case ConfigKey.PIC_SIZE_VALUE:
model.put("pic_size", res);
break;
case ConfigKey.PIC_PATH_VALUE:
model.put("pic_path", res);
break;
case ConfigKey.GROUP_MEMBERS_COUNT_VALUE:
model.put("group_members_count", res);
break;
case ConfigKey.U2_ENCRYPTION_STATUS_VALUE:
model.put("u2_encryption_status", res);
break;
case ConfigKey.PUSH_CLIENT_STATUS_VALUE:
model.put("push_client_status", res);
break;
case ConfigKey.LOG_LEVEL_VALUE:
model.put("log_level", res);
break;
case ConfigKey.SITE_MANAGER_VALUE:
model.put("subgenus_admin", res);
break;
case ConfigKey.CONFIG_FRIEND_REQUEST_VALUE:
model.put("add_friends_status", res);
break;
case ConfigKey.CONFIG_CREATE_GROUP_VALUE:
model.put("create_groups_status", res);
break;
case ConfigKey.GROUP_QR_EXPIRE_TIME_VALUE:
model.put("group_qrcode_expire_time", res);
break;
}
}
model.put("siteAddressAndPort", site_address + ":" + site_prot);
model.put("httpAddressAndPort", http_address + ":" + http_prot);
return modelAndView;
} catch (InvalidProtocolBufferException e) {
logger.error("to basic config page error", e);
} catch (UserPermissionException u) {
logger.error("to basic config page error : " + u.getMessage());
}
return new ModelAndView("error");
}
// 更新站点配置信息
@SuppressWarnings("unchecked")
@RequestMapping(method = RequestMethod.POST, value = "/updateConfig")
@ResponseBody
public String updateSiteConfig(HttpServletRequest request, @RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> dataMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class);
logger.info("siteUserId={} update config={}", siteUserId, dataMap);
Map<Integer, String> configMap = new HashMap<Integer, String>();
if (StringUtils.isNotEmpty(trim(dataMap.get("site_name")))) {
configMap.put(ConfigProto.ConfigKey.SITE_NAME_VALUE, trim(dataMap.get("site_name")));
}
if (StringUtils.isNotEmpty(trim(dataMap.get("site_address")))) {
configMap.put(ConfigProto.ConfigKey.SITE_ADDRESS_VALUE, trim(dataMap.get("site_address")));
}
if (StringUtils.isNotEmpty(trim(dataMap.get("site_port")))) {
configMap.put(ConfigProto.ConfigKey.SITE_PORT_VALUE, trim(dataMap.get("site_port")));
}
if (StringUtils.isNotEmpty(trim(dataMap.get("group_members_count")))) {
configMap.put(ConfigProto.ConfigKey.GROUP_MEMBERS_COUNT_VALUE,
trim(dataMap.get("group_members_count")));
}
if (StringUtils.isNotEmpty(trim(dataMap.get("pic_path")))) {
configMap.put(ConfigProto.ConfigKey.PIC_PATH_VALUE, trim(dataMap.get("pic_path")));
}
if (StringUtils.isNotEmpty(dataMap.get("site_logo"))) {
configMap.put(ConfigProto.ConfigKey.SITE_LOGO_VALUE, dataMap.get("site_logo"));
}
if (StringUtils.isNotEmpty(dataMap.get("uic_status"))) {
configMap.put(ConfigProto.ConfigKey.INVITE_CODE_STATUS_VALUE, dataMap.get("uic_status"));
}
if (StringUtils.isNotEmpty(dataMap.get("realName_status"))) {
configMap.put(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE, dataMap.get("realName_status"));
}
if (StringUtils.isNotEmpty(dataMap.get("u2_encryption_status"))) {
configMap.put(ConfigProto.ConfigKey.U2_ENCRYPTION_STATUS_VALUE, dataMap.get("u2_encryption_status"));
}
if (StringUtils.isNotEmpty(dataMap.get("add_friends_status"))) {
configMap.put(ConfigProto.ConfigKey.CONFIG_FRIEND_REQUEST_VALUE, dataMap.get("add_friends_status"));
}
if (StringUtils.isNotEmpty(dataMap.get("create_groups_status"))) {
configMap.put(ConfigProto.ConfigKey.CONFIG_CREATE_GROUP_VALUE, dataMap.get("create_groups_status"));
}
if (StringUtils.isNotEmpty(dataMap.get("group_qrcode_expire_time"))) {
configMap.put(ConfigProto.ConfigKey.GROUP_QR_EXPIRE_TIME_VALUE,
dataMap.get("group_qrcode_expire_time"));
}
if (StringUtils.isNotEmpty(dataMap.get("push_client_status"))) {
configMap.put(ConfigProto.ConfigKey.PUSH_CLIENT_STATUS_VALUE, dataMap.get("push_client_status"));
}
if (StringUtils.isNotEmpty(dataMap.get("log_level"))) {
String logLevel = dataMap.get("log_level");
configMap.put(ConfigProto.ConfigKey.LOG_LEVEL_VALUE, logLevel);
Level level = Level.INFO;
if ("DEBUG".equalsIgnoreCase(logLevel)) {
level = Level.DEBUG;
} else if ("ERROR".equalsIgnoreCase(logLevel)) {
level = Level.ERROR;
}
// 更新日志级别
AkxLog4jManager.setLogLevel(level);
}
// 普通管理员无权限
if (isAdmin(siteUserId) && StringUtils.isNotEmpty(trim(dataMap.get("site_manager")))) {
configMap.put(ConfigProto.ConfigKey.SITE_MANAGER_VALUE, trim(dataMap.get("site_manager")));
}
if (configManageService.updateSiteConfig(siteUserId, configMap)) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("update site config error", e);
} catch (UserPermissionException u) {
logger.error("update site config error : " + u.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
}

View File

@ -0,0 +1,555 @@
/**
* Copyright 2018-2028 Akaxin Group
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.akaxin.site.web.admin.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.akaxin.common.utils.GsonUtils;
import com.akaxin.proto.core.PluginProto;
import com.akaxin.site.business.dao.UserProfileDao;
import com.akaxin.site.storage.bean.GroupMemberBean;
import com.akaxin.site.storage.bean.GroupProfileBean;
import com.akaxin.site.storage.bean.SimpleGroupBean;
import com.akaxin.site.storage.bean.UserProfileBean;
import com.akaxin.site.web.admin.exception.UserPermissionException;
import com.akaxin.site.web.admin.service.IConfigService;
import com.akaxin.site.web.admin.service.IGroupService;
import com.google.protobuf.InvalidProtocolBufferException;
/**
* 群组管理控制器
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-04-17 18:03:07
*/
@Controller
@RequestMapping("group")
public class GroupManageController extends AbstractController {
private static final Logger logger = LoggerFactory.getLogger(UserManageController.class);
@Resource(name = "groupManageService")
private IGroupService groupService;
@Autowired
private IConfigService configService;
// admin.html 为群列表页
@RequestMapping("/index")
public ModelAndView toGroupIndex(@RequestBody byte[] bodyParam) {
ModelAndView modelAndView = new ModelAndView("group/index");
PluginProto.ProxyPluginPackage pluginPackage = null;
try {
pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
List<String> defaultGroupList = configService.getUserDefaultGroupList();
ArrayList<GroupProfileBean> groupProfileBeans = new ArrayList<>();
modelAndView.addObject("groupDefaultSize", "0");
if (defaultGroupList != null && defaultGroupList.size() > 0) {
for (String s : defaultGroupList) {
GroupProfileBean groupProfile = groupService.getGroupProfile(s);
groupProfileBeans.add(groupProfile);
}
modelAndView.addObject("groupList", groupProfileBeans);
modelAndView.addObject("groupDefaultSize", String.valueOf(defaultGroupList.size()));
}
return modelAndView;
} catch (InvalidProtocolBufferException e) {
logger.error("to group index error", e);
} catch (UserPermissionException e) {
logger.error("to group index error : " + e.getMessage());
}
return new ModelAndView("error");
}
@SuppressWarnings("unchecked")
public Map<String, Object> getRequestDataMapObj(PluginProto.ProxyPluginPackage pluginPackage) {
return GsonUtils.fromJson(pluginPackage.getData(), Map.class);
}
// 跳转到manage界面
@RequestMapping("manage")
public ModelAndView toManage(@RequestBody byte[] bodyParams) {
ModelAndView modelAndView = new ModelAndView("group/manage");
Map<String, Object> model = modelAndView.getModel();
PluginProto.ProxyPluginPackage pluginPackage = null;
try {
pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String siteGroupId = reqMap.get("group_id");
GroupProfileBean groupProfile = groupService.getGroupProfile(siteGroupId);
model.put("group_id", siteGroupId);
model.put("defaultState", groupProfile.getDefaultState());
return modelAndView;
} catch (InvalidProtocolBufferException e) {
logger.error("to group manage error", e);
} catch (UserPermissionException e) {
logger.error("to group manage error : " + e.getMessage());
}
return new ModelAndView("error");
}
// 跳转到添加群成员界面
@RequestMapping("/siteUser")
public ModelAndView toAddMember(@RequestBody byte[] bodyParams) {
ModelAndView modelAndView = new ModelAndView("group/addMember");
Map<String, Object> model = modelAndView.getModel();
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String siteGroupId = reqMap.get("group_id");
model.put("siteGroupId", siteGroupId);
return modelAndView;
} catch (InvalidProtocolBufferException e) {
logger.error("to group add error", e);
} catch (UserPermissionException e) {
logger.error("to group add error : " + e.getMessage());
}
return new ModelAndView("error");
}
/**
* 设置用户的默认群组
*
* @param bodyParams
* @return
*/
@RequestMapping("/setUserDefaultGroup")
@ResponseBody
public String setUserDefaultGroup(@RequestBody byte[] bodyParams) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String requestSiteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(requestSiteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String siteGroupId = reqMap.get("group_id");
boolean flag = configService.setUserDefaultGroups(siteGroupId);
if (flag) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("to group add error", e);
} catch (UserPermissionException e) {
logger.error("to group add error : " + e.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
@RequestMapping("/deleteUserDefaultGroup")
@ResponseBody
public String deleteUserDefaultGroup(@RequestBody byte[] bodyParams) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String siteGroupId = reqMap.get("group_id");
boolean flag = configService.deleteUserDefaultGroup(siteGroupId);
if (flag) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("del group default error", e);
} catch (UserPermissionException e) {
logger.error("del group default error : " + e.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
@RequestMapping("toMemberList")
public ModelAndView toMemberList(@RequestBody byte[] bodyParams) {
ModelAndView modelAndView = new ModelAndView("group/memberList");
Map<String, Object> model = modelAndView.getModel();
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String siteUserId = getRequestSiteUserId(pluginPackage);
// 增加权限校验
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String siteGroupId = reqMap.get("group_id");
model.put("siteGroupId", siteGroupId);
return modelAndView;
} catch (InvalidProtocolBufferException e) {
logger.error("to group add error", e);
} catch (UserPermissionException e) {
logger.error("to group add error : " + e.getMessage());
}
return new ModelAndView("error");
}
// 跳转群组资料群信息页面修改群信息页面
@RequestMapping("/profile")
public ModelAndView toGroupProfile(HttpServletRequest request, @RequestBody byte[] bodyParams) {
ModelAndView modelAndView = new ModelAndView("group/profile");
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String siteGroupId = reqMap.get("group_id");
GroupProfileBean bean = groupService.getGroupProfile(siteGroupId);
modelAndView.addObject("siteGroupId", bean.getGroupId());
modelAndView.addObject("groupName", bean.getGroupName());
modelAndView.addObject("groupPhoto", bean.getGroupPhoto());
modelAndView.addObject("ownerUserId", bean.getCreateUserId());
modelAndView.addObject("groupNotice", bean.getGroupNotice());
modelAndView.addObject("groupStatus", bean.getGroupStatus());
modelAndView.addObject("createTime", bean.getCreateTime());
return modelAndView;
} catch (InvalidProtocolBufferException e) {
logger.error("to group profile error", e);
} catch (UserPermissionException e) {
logger.error("to group profile error : " + e.getMessage());
}
return new ModelAndView("error");
}
@RequestMapping("/refresh")
@ResponseBody
public Map<String, Object> refreshPage(@RequestBody byte[] bodyParams) {
HashMap<String, Object> dataMap = new HashMap<>();
PluginProto.ProxyPluginPackage pluginPackage = null;
try {
pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
List<String> defaultGroupList = configService.getUserDefaultGroupList();
if (defaultGroupList == null || defaultGroupList.size() <= 0) {
dataMap.put("size", 0);
return dataMap;
}
ArrayList<Map<String, Object>> data = new ArrayList<>();
for (String s : defaultGroupList) {
GroupProfileBean bean = groupService.getGroupProfile(s);
HashMap<String, Object> groupMap = new HashMap<>();
groupMap.put("siteGroupId", bean.getGroupId());
groupMap.put("groupName", bean.getGroupName());
groupMap.put("groupPhoto", bean.getGroupPhoto());
data.add(groupMap);
}
dataMap.put("size", data.size());
dataMap.put("data", data);
} catch (InvalidProtocolBufferException e) {
logger.error("refresh group list error", e);
} catch (UserPermissionException e) {
logger.error("refresh group list error : " + e.getMessage());
}
return dataMap;
}
@RequestMapping(method = RequestMethod.POST, value = "/list")
@ResponseBody
public Map<String, Object> getGroupList(HttpServletRequest request, @RequestBody byte[] bodyParams) {
Map<String, Object> results = new HashMap<String, Object>();
boolean nodata = true;
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
int pageNum = Integer.valueOf(reqMap.get("page"));
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
List<SimpleGroupBean> groupList = groupService.getGroupList(pageNum, PAGE_SIZE);
if (groupList != null && groupList.size() > 0) {
nodata = false;
List<String> defaultGroupList = configService.getUserDefaultGroupList();
for (SimpleGroupBean bean : groupList) {
if (defaultGroupList != null && defaultGroupList.size() > 0) {
boolean contains = defaultGroupList.contains(bean.getGroupId());
if (contains) {
continue;
}
}
Map<String, Object> groupMap = new HashMap<String, Object>();
groupMap.put("siteGroupId", bean.getGroupId());
groupMap.put("groupName", bean.getGroupName());
groupMap.put("groupPhoto", bean.getGroupPhoto());
data.add(groupMap);
}
}
results.put("groupData", data);
} catch (InvalidProtocolBufferException e) {
logger.error("get group list error", e);
} catch (UserPermissionException e) {
logger.error("get group list error : " + e.getMessage());
}
results.put("loading", nodata);
return results;
}
@RequestMapping(method = RequestMethod.POST, value = "/updateProfile")
@ResponseBody
public String updateGroupProfile(HttpServletRequest request, @RequestBody byte[] bodyParams) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
GroupProfileBean bean = new GroupProfileBean();
bean.setGroupId(trim(reqMap.get("siteGroupId")));
bean.setGroupName(trim(reqMap.get("groupName")));
bean.setGroupPhoto(trim(reqMap.get("groupPhoto")));
bean.setGroupNotice(trim(reqMap.get("groupNotice")));
if (groupService.updateGroupProfile(bean)) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("update group profile error", e);
} catch (UserPermissionException e) {
logger.error("update group profile error : " + e.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
@RequestMapping(method = RequestMethod.POST, value = "/groupMember")
@ResponseBody
public Map<String, Object> getGroupMembers(HttpServletRequest request, @RequestBody byte[] bodyParams) {
Map<String, Object> results = new HashMap<String, Object>();
boolean nodata = true;
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String siteGroupId = reqMap.get("group_id");
int pageNum = Integer.valueOf(reqMap.get("page"));
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
List<GroupMemberBean> memberList = groupService.getGroupMembers(siteGroupId, pageNum, PAGE_SIZE);
if (memberList != null && memberList.size() > 0) {
if (PAGE_SIZE == memberList.size()) {
nodata = false;
}
for (GroupMemberBean bean : memberList) {
Map<String, Object> memberMap = new HashMap<String, Object>();
memberMap.put("siteUserId", bean.getUserId());
memberMap.put("userName", bean.getUserName());
memberMap.put("userPhoto", bean.getUserPhoto());
memberMap.put("userStatus", bean.getUserStatus());
memberMap.put("userRole", bean.getUserRole());// 是否为群主
data.add(memberMap);
}
}
results.put("groupMemberData", data);
} catch (InvalidProtocolBufferException e) {
logger.error("get group members error", e);
} catch (UserPermissionException e) {
logger.error("get group members error : " + e.getMessage());
}
results.put("loading", nodata);
return results;
}
@RequestMapping(method = RequestMethod.POST, value = "/nonGroupMember")
@ResponseBody
public Map<String, Object> getNonGroupMembers(HttpServletRequest request, @RequestBody byte[] bodyParams) {
Map<String, Object> results = new HashMap<String, Object>();
boolean nodata = true;
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String siteGroupId = reqMap.get("group_id");
int pageNum = Integer.valueOf(reqMap.get("page"));
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
List<GroupMemberBean> noMemberList = groupService.getNonGroupMembers(siteGroupId, pageNum, PAGE_SIZE);
for (GroupMemberBean bean : noMemberList) {
if (bean.getUserStatus() == 1) {
noMemberList.remove(bean);
}
}
if (noMemberList != null && noMemberList.size() > 0) {
if (PAGE_SIZE == noMemberList.size()) {
nodata = false;
}
for (GroupMemberBean bean : noMemberList) {
Map<String, Object> nonMemberMap = new HashMap<String, Object>();
nonMemberMap.put("siteUserId", bean.getUserId());
nonMemberMap.put("userName", bean.getUserName());
nonMemberMap.put("userPhoto", bean.getUserPhoto());
nonMemberMap.put("userStatus", bean.getUserStatus());
nonMemberMap.put("userRole", bean.getUserRole());// 这里全部为非群成员
data.add(nonMemberMap);
}
}
results.put("nonGroupMemberData", data);
} catch (InvalidProtocolBufferException e) {
logger.error("get non group members error", e);
} catch (UserPermissionException e) {
logger.error("get non group members error : " + e.getMessage());
}
results.put("loading", nodata);
return results;
}
// 添加群组成员后台添加群聊不添加通知消息
@SuppressWarnings("unchecked")
@RequestMapping(method = RequestMethod.POST, value = "/addGroupMember")
@ResponseBody
public String addGroupMember(HttpServletRequest request, @RequestBody byte[] bodyParams) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, Object> reqMap = getRequestDataMapObj(pluginPackage);
String siteGroupId = (String) reqMap.get("siteGroupId");
List<String> memberList = (List<String>) reqMap.get("groupMembers");
for (String id : memberList) {
UserProfileBean bean = UserProfileDao.getInstance().getUserProfileById(id);
if (bean.getUserStatus() == 1) {
memberList.remove(id);
}
}
logger.info("siteUserId={} add group={} members={}", siteUserId, siteGroupId, memberList);
if (groupService.addGroupMembers(siteGroupId, memberList)) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("update group profile error", e);
} catch (UserPermissionException e) {
logger.error("update group profile error : " + e.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
// 添加群组成员后台添加群聊不添加通知消息
@SuppressWarnings("unchecked")
@RequestMapping(method = RequestMethod.POST, value = "/removeGroupMember")
@ResponseBody
public String removeGroupMember(HttpServletRequest request, @RequestBody byte[] bodyParams) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, Object> reqMap = getRequestDataMapObj(pluginPackage);
String siteGroupId = (String) reqMap.get("siteGroupId");
List<String> memberList = (List<String>) reqMap.get("groupMembers");
if (groupService.removeGroupMembers(siteGroupId, memberList)) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("update group profile error", e);
} catch (UserPermissionException e) {
logger.error("update group profile error : " + e.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
// 解散群聊逻辑删除
@RequestMapping(method = RequestMethod.POST, value = "/dissmiss")
@ResponseBody
public String dissmisGroup(HttpServletRequest request, @RequestBody byte[] bodyParams) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParams);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String siteGroupId = reqMap.get("group_id");
if (groupService.dismissGroup(siteGroupId)) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("update group profile error", e);
} catch (UserPermissionException e) {
logger.error("update group profile error : " + e.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
}

View File

@ -0,0 +1,99 @@
package com.akaxin.site.web.admin.controller;
import com.akaxin.common.utils.GsonUtils;
import com.akaxin.proto.core.PluginProto;
import com.akaxin.site.storage.bean.MonitorBean;
import com.akaxin.site.web.admin.common.Timeutils;
import com.akaxin.site.web.admin.exception.UserPermissionException;
import com.akaxin.site.web.admin.service.IMonitorService;
import com.google.protobuf.InvalidProtocolBufferException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import java.util.Map;
@Controller
@RequestMapping("monitor")
public class MonitorController extends AbstractController {
private static final Logger logger = LoggerFactory.getLogger(MonitorController.class);
@Autowired
private IMonitorService monitorService;
@RequestMapping("/index")
public ModelAndView toMonitor(@RequestBody byte[] bodyParam) {
ModelAndView modelAndView = new ModelAndView("monitor/index");
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
if (!isManager(getRequestSiteUserId(pluginPackage))) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, Object> model = modelAndView.getModel();
//转换可选时间
model.put("data_2", Timeutils.getDate(2));
model.put("data_3", Timeutils.getDate(3));
model.put("data_4", Timeutils.getDate(4));
model.put("data_5", Timeutils.getDate(5));
model.put("data_6", Timeutils.getDate(6));
model.put("flag", "success");
return modelAndView;
} catch (InvalidProtocolBufferException e) {
logger.error("to data report error", e);
} catch (UserPermissionException e) {
logger.error("to data report error : "+e.getMessage());
}
return new ModelAndView("error");
}
@RequestMapping("/refresh")
@ResponseBody
public MonitorBean refresh(@RequestBody byte[] bodyParam) {
PluginProto.ProxyPluginPackage pluginPackage = null;
int registerNum = 0;
int messageNum = 0;
int groupMsgNum = 0;
int u2MsgNum = 0;
int userNum = 0;
int groupNum = 0;
int friendNum = 0;
try {
pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
if (!isManager(getRequestSiteUserId(pluginPackage))) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> uicReqMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class);
Integer day = null;
if (uicReqMap != null) {
day = Integer.parseInt(uicReqMap.get("dayNum"));
}
if (day == null) {
day = 0;
}
long now = System.currentTimeMillis();
registerNum = monitorService.queryNumRegisterPerDay(now, day);
messageNum = monitorService.queryNumMessagePerDay(now, day);
groupMsgNum = monitorService.queryGroupMessagePerDay(now, day);
u2MsgNum = monitorService.queryU2MessagePerDay(now, day);
userNum = monitorService.getSiteUserNum(now, 0);
groupNum = monitorService.getGroupNum(now, 0);
friendNum = monitorService.friendNum(now, 0);
return new MonitorBean(registerNum, messageNum, groupMsgNum, u2MsgNum, userNum, groupNum, friendNum);
} catch (InvalidProtocolBufferException e) {
logger.error("data report refresh error", e);
} catch (UserPermissionException e) {
logger.error("data report refresh error : "+e.getMessage());
}
return new MonitorBean();
}
}

View File

@ -0,0 +1,324 @@
/**
* Copyright 2018-2028 Akaxin Group
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.akaxin.site.web.admin.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.akaxin.common.utils.StringHelper;
import com.akaxin.proto.core.PluginProto;
import com.akaxin.site.storage.bean.PluginBean;
import com.akaxin.site.web.admin.exception.UserPermissionException;
import com.akaxin.site.web.admin.service.IPluginService;
import com.google.protobuf.InvalidProtocolBufferException;
//插件扩展管理
@Controller
@RequestMapping("plugin")
public class PluginManageController extends AbstractController {
private static final Logger logger = LoggerFactory.getLogger(UserManageController.class);
@Autowired
private IPluginService pluginService;
@RequestMapping("/indexPage")
public ModelAndView toPluginIndex(@RequestBody byte[] bodyParam) {
ModelAndView modelAndView = new ModelAndView("plugin/index");
PluginProto.ProxyPluginPackage pluginPackage = null;
try {
pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
if (!isManager(getRequestSiteUserId(pluginPackage))) {
throw new UserPermissionException("Current user is not a manager");
}
return modelAndView;
} catch (InvalidProtocolBufferException e) {
logger.error("to plugin error", e);
} catch (UserPermissionException e) {
logger.error("to plugin error : " + e.getMessage());
}
return new ModelAndView("error");
}
@RequestMapping("/addPage")
public String toPluginAdd(@RequestBody byte[] bodyParam) {
PluginProto.ProxyPluginPackage pluginPackage = null;
try {
pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
if (!isManager(getRequestSiteUserId(pluginPackage))) {
throw new UserPermissionException("Current user is not a manager");
}
return "plugin/add";
} catch (InvalidProtocolBufferException e) {
logger.error("to plugin add page error", e);
} catch (UserPermissionException e) {
logger.error("to plugin add page error : " + e.getMessage());
}
return "error";
}
@RequestMapping("/listPage")
public String toPluginList(@RequestBody byte[] bodyParam) {
PluginProto.ProxyPluginPackage pluginPackage = null;
try {
pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
if (!isManager(getRequestSiteUserId(pluginPackage))) {
throw new UserPermissionException("Current user is not a manager");
}
return "plugin/list";
} catch (InvalidProtocolBufferException e) {
logger.error("to plugin list error", e);
} catch (UserPermissionException e) {
logger.error("to plugin list error : " + e.getMessage());
}
return "error";
}
@RequestMapping("/editPage")
public ModelAndView toEditPage(@RequestBody byte[] bodyParam) {
ModelAndView modelAndView = new ModelAndView("plugin/update");
Map<String, Object> model = modelAndView.getModel();
PluginProto.ProxyPluginPackage pluginPackage = null;
try {
pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
// 解析Plugin_id
int authKeyState = 1;
String data = pluginPackage.getData();
String[] split = data.split(":\"");
String res = split[1].replaceAll("\"}", "");
PluginBean plugin = pluginService.getPlugin(Integer.valueOf(res));
model.put("name", plugin.getName());
model.put("url_page", plugin.getUrlPage());
model.put("api_url", plugin.getApiUrl());
model.put("plugin_icon", plugin.getIcon());
model.put("order", plugin.getSort());
model.put("allow_ip", plugin.getAllowedIp());
model.put("position", plugin.getPosition());
model.put("per_status", plugin.getPermissionStatus());
model.put("display_mode", plugin.getDisplayMode());
model.put("plugin_id", plugin.getId());
model.put("auth_key", plugin.getAuthKey());
// 如果是默认添加的扩展则不提供修改authkey设置
if (plugin.getId() == 1 || plugin.getId() == 2) {
authKeyState = 0;
}
model.put("authKeyState", authKeyState);
return modelAndView;
} catch (InvalidProtocolBufferException e) {
logger.error("to plugin error", e);
} catch (UserPermissionException e) {
logger.error("to plugin error : " + e.getMessage());
}
return new ModelAndView("error");
}
// 增加新扩展
@RequestMapping(method = RequestMethod.POST, value = "/addPlugin")
@ResponseBody
public String addPlugin(HttpServletRequest request, @RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> pluginData = getRequestDataMap(pluginPackage);
PluginBean bean = new PluginBean();
bean.setName(trim(pluginData.get("name")));
bean.setIcon(pluginData.get("plugin_icon"));
bean.setUrlPage(trim(pluginData.get("url_page")));
bean.setApiUrl(trim(pluginData.get("api_url")));
bean.setAllowedIp(trim(pluginData.get("allow_ip")));
bean.setPosition(Integer.valueOf(pluginData.get("position")));
bean.setSort(Integer.valueOf(pluginData.get("order")));
bean.setDisplayMode(PluginProto.PluginDisplayMode.NEW_PAGE_VALUE);
bean.setPermissionStatus(Integer.valueOf(pluginData.get("per_status")));
bean.setDisplayMode(Integer.valueOf(pluginData.get("display_mode")));
bean.setAddTime(System.currentTimeMillis());
bean.setAuthKey(StringHelper.generateRandomString(16));// 随机生成
logger.info("siteUserId={} add new plugin bean={}", siteUserId, bean);
if (pluginService.addNewPlugin(bean)) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("add new plugin controller error", e);
} catch (UserPermissionException e) {
logger.error("add new plugin controller error : " + e.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
// 获取扩展列表
@RequestMapping(method = RequestMethod.POST, value = "/pluginList")
@ResponseBody
public Map<String, Object> getPluginList(HttpServletRequest request, @RequestBody byte[] bodyParam) {
Map<String, Object> result = new HashMap<String, Object>();
boolean nodata = true;// 是还有更多数据
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> dataMap = getRequestDataMap(pluginPackage);
int pageNum = Integer.valueOf(dataMap.get("page"));
List<PluginBean> pluginList = pluginService.getPluginList(pageNum, PAGE_SIZE);
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
if (pluginList != null) {
if (PAGE_SIZE == pluginList.size()) {
nodata = false;
}
for (PluginBean bean : pluginList) {
Map<String, Object> pluginMap = new HashMap<String, Object>();
pluginMap.put("plugin_id", bean.getId());
pluginMap.put("name", bean.getName());
pluginMap.put("plugin_icon", bean.getIcon());
pluginMap.put("url_page", bean.getUrlPage());
pluginMap.put("api_url", bean.getApiUrl());
pluginMap.put("position", bean.getPosition());
pluginMap.put("order", bean.getSort());
pluginMap.put("per_status", bean.getPermissionStatus());
pluginMap.put("allow_ip", bean.getAllowedIp());
// add to list
data.add(pluginMap);
}
}
result.put("pluginData", pluginList);
} catch (InvalidProtocolBufferException e) {
logger.error("get plugin list error", e);
} catch (UserPermissionException e) {
logger.error("get plugin list error : " + e.getMessage());
}
result.put("loading", nodata);
return result;
}
// 编辑扩展
@RequestMapping(method = RequestMethod.POST, value = "/editPlugin")
@ResponseBody
public String editPlugin(HttpServletRequest request, @RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> pluginData = getRequestDataMap(pluginPackage);
PluginBean bean = new PluginBean();
bean.setId(Integer.valueOf(trim(pluginData.get("plugin_id"))));
bean.setName(trim(pluginData.get("name")));
bean.setIcon(pluginData.get("plugin_icon"));
bean.setUrlPage(trim(pluginData.get("url_page")));
bean.setApiUrl(trim(pluginData.get("api_url")));
bean.setSort(Integer.valueOf(pluginData.get("order")));
bean.setPosition(Integer.valueOf(pluginData.get("position")));
bean.setDisplayMode(Integer.valueOf(pluginData.get("display_mode")));
bean.setPermissionStatus(Integer.valueOf(pluginData.get("per_status")));
bean.setAllowedIp(trim(pluginData.get("allow_ip")));
if (pluginService.updatePlugin(bean)) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("edit plugin error", e);
} catch (UserPermissionException e) {
logger.error("edit plugin error : " + e.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
@RequestMapping(method = RequestMethod.POST, value = "/delPlugin")
@ResponseBody
public String deletePlugin(HttpServletRequest request, @RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> dataMap = getRequestDataMap(pluginPackage);
int pluginId = Integer.valueOf(dataMap.get("plugin_id"));
if (pluginService.deletePlugin(pluginId)) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("edit plugin error", e);
} catch (UserPermissionException e) {
logger.error("edit plugin error : " + e.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
@RequestMapping(method = RequestMethod.POST, value = "/reSet")
@ResponseBody
public String reSetAuthKey(HttpServletRequest request, @RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> dataMap = getRequestDataMap(pluginPackage);
int pluginId = Integer.valueOf(dataMap.get("plugin_id"));
String authKey = pluginService.reSetAuthKey(pluginId);
return authKey;
} catch (InvalidProtocolBufferException e) {
logger.error("edit plugin error", e);
} catch (UserPermissionException e) {
logger.error("edit plugin error : " + e.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
}

View File

@ -0,0 +1,165 @@
/**
* 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.
*/
package com.akaxin.site.web.admin.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.akaxin.site.web.admin.exception.UserPermissionException;
import com.google.protobuf.InvalidProtocolBufferException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.akaxin.common.utils.GsonUtils;
import com.akaxin.proto.core.PluginProto;
import com.akaxin.site.business.impl.site.SiteConfig;
import com.akaxin.site.storage.bean.UicBean;
import com.akaxin.site.web.admin.service.IUICService;
//邀请码管理
@Controller
@RequestMapping("uic")
public class UICManageController extends AbstractController {
private static final Logger logger = LoggerFactory.getLogger(UserManageController.class);
private static final int UIC_PAGE_SIZE = 20;
@Autowired
private IUICService uicServer;
@RequestMapping("/index")
public ModelAndView toUICIndex(@RequestBody byte[] bodyParam) {
ModelAndView modelAndView = new ModelAndView("uic/index");
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
if (!isManager(getRequestSiteUserId(pluginPackage))) {
throw new UserPermissionException("Current user is not a manager");
}
return modelAndView;
} catch (InvalidProtocolBufferException e) {
logger.error("to Uic error", e);
} catch (UserPermissionException e) {
logger.error("to Uic error : "+e.getMessage());
}
return new ModelAndView("error");
}
@RequestMapping("/unused")
public String toUnUsed(@RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
if (!isManager(getRequestSiteUserId(pluginPackage))) {
throw new UserPermissionException("Current user is not a manager");
}
return "uic/unused_list";
} catch (InvalidProtocolBufferException e) {
logger.error("get unused list error", e);
} catch (UserPermissionException e) {
logger.error("get unused list error : "+e.getMessage());
}
return "error";
}
@RequestMapping("/used")
public String toused(@RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
if (!isManager(getRequestSiteUserId(pluginPackage))) {
throw new UserPermissionException("Current user is not a manager");
}
return "uic/used_list";
} catch (InvalidProtocolBufferException e) {
logger.error("get used list error",e);
} catch (UserPermissionException e) {
logger.error("get used list error : "+e.getMessage());
}
return "error";
}
@RequestMapping(method = RequestMethod.POST, value = "/addUic")
@ResponseBody
public String addNewUIC(HttpServletRequest request, @RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap();
String siteUserId = headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE);
boolean isManager = SiteConfig.isSiteManager(siteUserId);
if (!isManager) {
throw new UserPermissionException("Current user is not a manager");
}
return uicServer.addUIC(100, 16) ? SUCCESS : ERROR;
} catch (InvalidProtocolBufferException e) {
logger.error("add new uic error", e);
} catch (UserPermissionException e) {
logger.error("add new uic error : "+e.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
@SuppressWarnings("unchecked")
@RequestMapping(method = RequestMethod.POST, value = "/uicList")
@ResponseBody
public Map<String, Object> getUICList(HttpServletRequest request, @RequestBody byte[] bodyParam) {
Map<String, Object> results = new HashMap<String, Object>();
boolean nodata = true;
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap();
String siteUserId = headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE);
boolean isManager = SiteConfig.isSiteManager(siteUserId);
if (!isManager) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> uicReqMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class);
int pageNum = Integer.valueOf(uicReqMap.get("page"));
int status = Integer.valueOf(uicReqMap.get("code_status"));
List<UicBean> uicList = uicServer.getUsedUicList(pageNum, UIC_PAGE_SIZE, status);
List<Map<String, String>> data = new ArrayList<Map<String, String>>();
if (uicList != null && uicList.size() > 0) {
if (UIC_PAGE_SIZE == uicList.size()) {
nodata = false;
}
for (UicBean bean : uicList) {
Map<String, String> uicMap = new HashMap<String, String>();
uicMap.put("uic", bean.getUic());
uicMap.put("siteUserName", bean.getUserName());
data.add(uicMap);
}
}
results.put("uicData", data);
} catch (InvalidProtocolBufferException e) {
logger.error("get used uic list error", e);
} catch (UserPermissionException e) {
logger.error("get used uic list error : "+e.getMessage());
}
results.put("loading", nodata);
return results;
}
}

View File

@ -0,0 +1,465 @@
/**
* Copyright 2018-2028 Akaxin Group
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.akaxin.site.web.admin.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.akaxin.common.utils.StringHelper;
import com.akaxin.proto.core.PluginProto;
import com.akaxin.proto.core.UserProto.UserStatus;
import com.akaxin.site.storage.bean.SimpleUserBean;
import com.akaxin.site.storage.bean.UserProfileBean;
import com.akaxin.site.web.admin.exception.ManagerException;
import com.akaxin.site.web.admin.exception.UserPermissionException;
import com.akaxin.site.web.admin.service.IConfigService;
import com.akaxin.site.web.admin.service.IUserService;
import com.google.protobuf.InvalidProtocolBufferException;
/**
* 后台管理-用户管理
*/
@Controller
@RequestMapping("user")
public class UserManageController extends AbstractController {
private static final Logger logger = LoggerFactory.getLogger(UserManageController.class);
@Resource(name = "userManageService")
private IUserService userService;
@Autowired
private IConfigService configService;
// 进入用户管理首页
@RequestMapping("/index")
public ModelAndView toIndex(@RequestBody byte[] bodyParam) {
ModelAndView modelAndView = new ModelAndView("user/index");
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
if (!isManager(getRequestSiteUserId(pluginPackage))) {
throw new UserPermissionException("Current user is not a manager");
}
List<String> defaultFriendList = configService.getUserDefaultFriendList();
List<UserProfileBean> userProfileBeans = new ArrayList<>();
modelAndView.addObject("userDefaultSize", "0");
if (defaultFriendList != null && defaultFriendList.size() > 0) {
for (String siteUserId : defaultFriendList) {
UserProfileBean userProfile = userService.getUserProfile(siteUserId);
userProfileBeans.add(userProfile);
}
modelAndView.addObject("userList", userProfileBeans);
modelAndView.addObject("userDefaultSize", String.valueOf(defaultFriendList.size()));
}
return modelAndView;
} catch (InvalidProtocolBufferException e) {
logger.error("to User Manage error", e);
} catch (UserPermissionException e) {
logger.error("to User Manage error : " + e.getMessage());
}
return new ModelAndView("error");
}
/**
* 设置官方用户默认为所有新用户的好友
*
* @param bodyParam
* @return
*/
@RequestMapping("/setUserDefaultFriend")
@ResponseBody
public String setUserDefaultFriend(@RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
if (!isManager(getRequestSiteUserId(pluginPackage))) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String friendSiteUserId = reqMap.get("siteUserId");
boolean result = configService.setUserDefaultFriends(friendSiteUserId);
if (result) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("set user as default friend error", e);
} catch (UserPermissionException e) {
logger.error("set user as default friend error", e);
return NO_PERMISSION;
} catch (Exception e) {
logger.error("set user as default friend error", e);
}
return ERROR;
}
@RequestMapping("/deleteUserDefaultFriend")
@ResponseBody
public String deleteUserDefaultFriend(@RequestBody byte[] bodyParam) {
try {
logger.info("siteUserId={} deleteUserDefaultFriend userId={} ");
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String friendSiteUserId = reqMap.get("siteUserId");
boolean flag = configService.deleteUserDefaultFriends(friendSiteUserId);
logger.info("siteUserId={} deleteUserDefaultFriend userId={} ", siteUserId, friendSiteUserId);
if (flag) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("delete user as default friend error ", e);
} catch (UserPermissionException e) {
logger.error("delete user as default friend error : ", e);
return NO_PERMISSION;
} catch (Exception e) {
logger.error("delete user as default friend error", e);
}
return ERROR;
}
/**
* 设置用户为管理员
*
* @param bodyParam
* @return
*/
@RequestMapping("/setSiteManager")
@ResponseBody
public String setSiteManager(@RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
if (!isAdmin(getRequestSiteUserId(pluginPackage))) {
throw new UserPermissionException("Current user is not admin");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String managerUserId = reqMap.get("siteUserId");
boolean result = configService.addUserManager(managerUserId);
if (result) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("set site manager error : ", e.getMessage());
} catch (UserPermissionException e) {
logger.error("set site manager error : " + e.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
/**
* 删除用户管理员身份
*
* @param bodyParam
* @return
*/
@RequestMapping("/deleteSiteManager")
@ResponseBody
public String deleteSiteManager(@RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
if (!isAdmin(getRequestSiteUserId(pluginPackage))) {
throw new UserPermissionException("Current user is not admin");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String managerUserId = reqMap.get("siteUserId");
boolean result = configService.deleteUserManager(managerUserId);
if (result) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("delete site manager error : ", e.getMessage());
} catch (UserPermissionException e) {
logger.error("delete site manager error : " + e.getMessage());
return NO_PERMISSION;
}
return ERROR;
}
// 用户个人资料展示界面此界面编辑用户资料并执行更新
@RequestMapping("/profile")
public ModelAndView toUserProfile(HttpServletRequest request, @RequestBody byte[] bodyParam) {
ModelAndView modelAndView = new ModelAndView("user/profile");
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String currentUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(currentUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String siteUserId = reqMap.get("site_user_id");
UserProfileBean bean = userService.getUserProfile(siteUserId);
modelAndView.addObject("siteUserId", bean.getSiteUserId());
modelAndView.addObject("siteLoginId", bean.getSiteLoginId());
modelAndView.addObject("userName", bean.getUserName());
modelAndView.addObject("userPhoto", bean.getUserPhoto());
modelAndView.addObject("userIntroduce", bean.getSelfIntroduce());
modelAndView.addObject("userStatus", bean.getUserStatus());
modelAndView.addObject("regTime", bean.getRegisterTime());
modelAndView.addObject("defaultState", bean.getDefaultState());
boolean isManager = isManager(siteUserId);
modelAndView.addObject("managerState", isManager ? 1 : 0);
return modelAndView;
} catch (InvalidProtocolBufferException e) {
logger.error(StringHelper.format("siteUserId={} get user profile error"), e);
} catch (UserPermissionException e) {
logger.error("get user profile error : " + e.getMessage());
}
return new ModelAndView("error");
}
@RequestMapping("/refresh")
@ResponseBody
public Map<String, Object> refreshPage(@RequestBody byte[] bodyParam) {
HashMap<String, Object> dataMap = new HashMap<>();
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
if (!isManager(getRequestSiteUserId(pluginPackage))) {
throw new UserPermissionException("Current user is not a manager");
}
List<String> userDefault = configService.getUserDefaultFriendList();
if (userDefault == null || userDefault.size() <= 0) {
dataMap.put("size", 0);
return dataMap;
}
ArrayList<Map<String, Object>> data = new ArrayList<>();
for (String s : userDefault) {
UserProfileBean bean = userService.getUserProfile(s);
HashMap<String, Object> userMap = new HashMap<>();
userMap.put("siteUserId", bean.getSiteUserId());
userMap.put("userName", bean.getUserName());
userMap.put("userPhoto", bean.getUserPhoto());
userMap.put("userStatus", bean.getUserStatus());
data.add(userMap);
}
dataMap.put("size", data.size());
dataMap.put("data", data);
} catch (InvalidProtocolBufferException e) {
logger.error("refresh user list error", e);
} catch (UserPermissionException e) {
logger.error("refresh user list error : " + e.getMessage());
}
return dataMap;
}
@RequestMapping(method = RequestMethod.POST, value = "/userList")
@ResponseBody
public Map<String, Object> getSiteUsers(HttpServletRequest request, @RequestBody byte[] bodyParam) {
Map<String, Object> results = new HashMap<String, Object>();
boolean nodata = true;
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> dataMap = getRequestDataMap(pluginPackage);
int pageNum = Integer.valueOf(dataMap.get("page"));
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
List<SimpleUserBean> userList = userService.getUserList(pageNum, PAGE_SIZE);
if (userList != null && userList.size() > 0) {
nodata = false;
List<String> defaultFriendList = configService.getUserDefaultFriendList();
if (defaultFriendList != null && defaultFriendList.size() > 0) {
for (SimpleUserBean bean : userList) {
boolean contains = defaultFriendList.contains(bean.getUserId());
Map<String, Object> userMap = new HashMap<String, Object>();
if (contains) {
continue;
}
userMap.put("siteUserId", bean.getUserId());
userMap.put("siteLoginId", bean.getSiteLoginId());
userMap.put("userName", bean.getUserName());
userMap.put("userPhoto", bean.getUserPhoto());
userMap.put("userStatus", bean.getUserStatus());
data.add(userMap);
}
} else {
for (SimpleUserBean bean : userList) {
Map<String, Object> userMap = new HashMap<String, Object>();
userMap.put("siteUserId", bean.getUserId());
userMap.put("siteLoginId", bean.getSiteLoginId());
userMap.put("userName", bean.getUserName());
userMap.put("userPhoto", bean.getUserPhoto());
userMap.put("userStatus", bean.getUserStatus());
data.add(userMap);
}
}
}
results.put("userData", data);
} catch (InvalidProtocolBufferException e) {
logger.error("get site user list error", e);
} catch (UserPermissionException e) {
logger.error("get site user list error : " + e.getMessage());
}
results.put("loading", nodata);
return results;
}
@RequestMapping(method = RequestMethod.POST, value = "/updateProfile")
@ResponseBody
public String updateProfile(HttpServletRequest request, @RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
// 权限控制
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
// 参数校验
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String toUserId = reqMap.get("siteUserId");
String siteLoginId = reqMap.get("siteLoginId");
String userName = trim(reqMap.get("userName"));
if (StringUtils.isEmpty(toUserId)) {
throw new UserPermissionException("update user's siteUserId is null");
}
if (StringUtils.isNotEmpty(userName) && userName.length() > 16) {
throw new ManagerException("userName={} length={} longer than [1,16] error");
}
if (StringUtils.isNotEmpty(siteLoginId)) {
Matcher match = Pattern.compile("^[A-Za-z][A-Za-z0-9]{0,15}$").matcher(siteLoginId);
if (!match.matches()) {
throw new ManagerException("user's siteLoginId formatting error");
}
}
UserProfileBean originalBean = userService.getUserProfile(toUserId);
if (originalBean == null || StringUtils.isEmpty(originalBean.getSiteUserId())) {
throw new UserPermissionException("update user's profile is null from DB");
}
UserProfileBean bean = new UserProfileBean();
bean.setSiteUserId(toUserId);
bean.setSiteLoginId(siteLoginId);
bean.setUserName(userName);
bean.setUserPhoto(trim(reqMap.get("userPhoto")));
bean.setSelfIntroduce(trim(reqMap.get("userIntroduce")));
boolean result = userService.updateProfile(bean);
logger.info(
"siteUserId={} update user={} \n\t userName/nickName:{} -> {} \n\t siteLoginId:{} -> {} \n\t userPhoto:{} -> {}",
siteUserId, toUserId, originalBean.getUserName(), bean.getUserName(), originalBean.getSiteLoginId(),
bean.getSiteLoginId(), originalBean.getUserPhoto(), bean.getUserPhoto());
return result ? SUCCESS : ERROR;
} catch (InvalidProtocolBufferException e) {
logger.error("update profile error", e);
} catch (UserPermissionException e) {
logger.error("update profile error : " + e.getMessage());
return NO_PERMISSION;
} catch (ManagerException e) {
logger.error("update profile error:" + e.getMessage());
}
return ERROR;
}
@RequestMapping(method = RequestMethod.POST, value = "/sealup")
@ResponseBody
public String sealup(HttpServletRequest request, @RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (!isManager(siteUserId)) {
throw new UserPermissionException("Current user is not a manager");
}
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String reqUserId = reqMap.get("site_user_id");
String reqStatus = reqMap.get("user_status");
int status = UserStatus.NORMAL_VALUE;
if ("1".equals(reqStatus)) {
status = UserStatus.SEALUP_VALUE;
}
logger.info("siteUserId={} sealup siteUserId={} to status={}", siteUserId, reqUserId, status);
if (userService.sealUpUser(reqUserId, status)) {
return SUCCESS;
}
} catch (InvalidProtocolBufferException e) {
logger.error("sealup user error", e);
} catch (UserPermissionException e) {
logger.error("sealup user error : ", e);
return NO_PERMISSION;
} catch (Exception e) {
logger.error("sealup user error : ", e);
}
return ERROR;
}
@RequestMapping(method = RequestMethod.POST, value = "delUser")
@ResponseBody
public String deleteUser(HttpServletRequest request, @RequestBody byte[] bodyParam) {
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
String siteUserId = getRequestSiteUserId(pluginPackage);
if (isManager(siteUserId)) {
Map<String, String> reqMap = getRequestDataMap(pluginPackage);
String delUserID = reqMap.get("siteUserId");
if (userService.delUser(delUserID)) {
return SUCCESS;
}
} else {
return NO_PERMISSION;
}
} catch (Exception e) {
logger.error("del User error", e);
}
return ERROR;
}
}

View File

@ -0,0 +1,145 @@
package com.akaxin.site.web.admin.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.akaxin.common.utils.GsonUtils;
import com.akaxin.proto.core.PluginProto;
import com.akaxin.proto.core.UserProto;
import com.akaxin.site.business.dao.UserFriendDao;
import com.akaxin.site.business.impl.notice.User2Notice;
import com.akaxin.site.business.push.PushNotification;
import com.akaxin.site.storage.bean.SimpleUserBean;
import com.akaxin.site.storage.bean.UserProfileBean;
import com.akaxin.site.web.admin.service.IUserService;
import com.google.protobuf.InvalidProtocolBufferException;
/**
* 用户广场
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-06-12 18:24:29
*/
@Controller
@RequestMapping("userSquare")
public class UserSquareController extends AbstractController {
private static final Logger logger = LoggerFactory.getLogger(UserManageController.class);
@Resource(name = "userManageService")
private IUserService userService;
@RequestMapping("/index")
public ModelAndView toIndex(@RequestBody byte[] bodyParam) {
ModelAndView modelAndView = new ModelAndView("siteMember/siteMember");
Map<String, Object> model = modelAndView.getModel();
PluginProto.ProxyPluginPackage pluginPackage = null;
try {
pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap();
String siteUserId = headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE);
UserProfileBean userProfile = userService.getUserProfile(siteUserId);
model.put("site_user_id", siteUserId);
model.put("site_user_name", userProfile.getUserName());
} catch (InvalidProtocolBufferException e) {
logger.error("to user square error", e);
return new ModelAndView("siteMember/error");
}
return modelAndView;
}
@SuppressWarnings("unchecked")
@RequestMapping(method = RequestMethod.POST, value = "/pullMemberList")
@ResponseBody
public Map<String, Object> getMemberList(HttpServletRequest request, @RequestBody byte[] bodyParam) {
Map<String, Object> results = new HashMap<String, Object>();
boolean nodata = true;
int pageSize = 20;
try {
PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap();
String siteUserId = headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE);
Map<String, String> ReqMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class);
int pageNum = Integer.valueOf(ReqMap.get("pageNum"));
List<SimpleUserBean> userList = userService.getUserList(pageNum, pageSize);
List<Map<String, String>> data = new ArrayList<Map<String, String>>();
if (userList != null && userList.size() > 0) {
nodata = false;
for (SimpleUserBean bean : userList) {
Map<String, String> memberMap = new HashMap<String, String>();
if (siteUserId != bean.getUserId()) {
memberMap.put("site_user_id", bean.getUserId());
memberMap.put("site_user_name", bean.getUserName());
memberMap.put("site_user_photo", bean.getUserPhoto());
UserProto.UserRelation userRelation = UserFriendDao.getInstance().getUserRelation(siteUserId,
bean.getUserId());
memberMap.put("site_user_relation", String.valueOf(userRelation.getNumber()));
}
data.add(memberMap);
}
}
results.put("Data", data);
} catch (Exception e) {
logger.error("get Member list error", e);
}
results.put("loading", nodata);
return results;
}
@RequestMapping("/applyFriend")
@ResponseBody
public String[] applyFriend(@RequestBody byte[] bodyParam) {
PluginProto.ProxyPluginPackage pluginPackage = null;
try {
pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
Map<Integer, String> headerMap = pluginPackage.getPluginHeaderMap();
String siteUserId = headerMap.get(PluginProto.PluginHeaderKey.CLIENT_SITE_USER_ID_VALUE);
Map<String, String> ReqMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class);
String friendSiteUserId = ReqMap.get("site_user_id");
String apply_reason = ReqMap.get("apply_reason");
if (StringUtils.isBlank(siteUserId)) {
return new String[] { "添加失败", "0" };
} else if (siteUserId.equals(friendSiteUserId)) {
} else {
int applyTimes = UserFriendDao.getInstance().getApplyCount(friendSiteUserId, siteUserId);
if (applyTimes >= 5) {
return new String[] { "失败,次数过多", "0" };
} else {
if (UserFriendDao.getInstance().saveFriendApply(siteUserId, friendSiteUserId, apply_reason)) {
new User2Notice().applyFriendNotice(siteUserId, friendSiteUserId);
// 同时下发一条PUSH消息
if (applyTimes < 2) {
PushNotification.sendAddFriend(siteUserId, friendSiteUserId);
}
return new String[] { "成功", friendSiteUserId };
}
}
}
} catch (InvalidProtocolBufferException e) {
logger.error("Friend apply error.", e);
}
return new String[] { "添加失败", "0" };
}
}

View File

@ -0,0 +1,18 @@
package com.akaxin.site.web.admin.exception;
import com.akaxin.common.utils.StringHelper;
public class ManagerException extends Throwable {
/**
*
*/
private static final long serialVersionUID = -5303021403604515796L;
public ManagerException(String message) {
super(message);
}
public ManagerException(String messageParttern, Object... obs) {
this(StringHelper.format(messageParttern, obs));
}
}

View File

@ -0,0 +1,12 @@
package com.akaxin.site.web.admin.exception;
public class UserPermissionException extends Exception {
/**
*
*/
private static final long serialVersionUID = -5303021403604515796L;
public UserPermissionException(String message) {
super(message);
}
}

View File

@ -0,0 +1,27 @@
package com.akaxin.site.web.admin.service;
import java.util.List;
import java.util.Map;
public interface IConfigService {
Map<Integer, String> getSiteConfig();
boolean updateSiteConfig(String siteUserId, Map<Integer, String> config);
boolean addUserManager(String siteUserId);
boolean deleteUserManager(String siteUserId);
boolean setUserDefaultFriends(String siteUserId);
boolean deleteUserDefaultFriends(String siteUserId);
boolean setUserDefaultGroups(String siteGroupId);
boolean deleteUserDefaultGroup(String siteGroupId);
List<String> getUserDefaultFriendList();
List<String> getUserDefaultGroupList();
}

View File

@ -0,0 +1,32 @@
package com.akaxin.site.web.admin.service;
import java.util.List;
import com.akaxin.site.storage.bean.GroupMemberBean;
import com.akaxin.site.storage.bean.GroupProfileBean;
import com.akaxin.site.storage.bean.SimpleGroupBean;
/**
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-04-17 18:46:55
*/
public interface IGroupService {
GroupProfileBean getGroupProfile(String siteGroupId);
boolean updateGroupProfile(GroupProfileBean bean);
List<SimpleGroupBean> getGroupList(int pageNum, int pageSize);
List<GroupMemberBean> getGroupMembers(String siteGroupId, int pageNum, int pageSize);
List<GroupMemberBean> getNonGroupMembers(String siteGroupId, int pageNum, int pageSize);
boolean addGroupMembers(String siteGroupId, List<String> newMemberList);
boolean removeGroupMembers(String siteGroupId, List<String> groupMemberList);
boolean dismissGroup(String siteGroupId);
}

View File

@ -0,0 +1,20 @@
package com.akaxin.site.web.admin.service;
import com.akaxin.site.web.admin.bean.WebMessageBean;
/**
* 后台管理发送消息接口
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-04-25 11:11:10
*/
public interface IMessageManageService {
boolean sendU2WebMessage(WebMessageBean bean);
boolean sendU2WebNoticeMessage(WebMessageBean bean);
boolean sendGroupWebMessage(WebMessageBean bean);
boolean sendGroupWebNoticeMessage(WebMessageBean bean);
}

View File

@ -0,0 +1,17 @@
package com.akaxin.site.web.admin.service;
public interface IMonitorService {
int queryNumRegisterPerDay(long now, int day);
int queryNumMessagePerDay(long now, int day);
int queryGroupMessagePerDay(long now, int day);
int queryU2MessagePerDay(long now, int day);
int getSiteUserNum(long now,int day);
int getGroupNum(long now,int day);
int friendNum(long now,int day);
}

View File

@ -0,0 +1,19 @@
package com.akaxin.site.web.admin.service;
import java.util.List;
import com.akaxin.site.storage.bean.PluginBean;
public interface IPluginService {
boolean addNewPlugin(PluginBean bean);
boolean deletePlugin(int pluginId);
boolean updatePlugin(PluginBean bean);
PluginBean getPlugin(int pluginId);
List<PluginBean> getPluginList(int pageNum, int pageSize);
String reSetAuthKey(int pluginId);
}

View File

@ -0,0 +1,13 @@
package com.akaxin.site.web.admin.service;
import java.util.List;
import com.akaxin.site.storage.bean.UicBean;
public interface IUICService {
boolean addUIC(int num, int length);
List<UicBean> getUsedUicList(int pageNum, int pageSize, int status);
}

View File

@ -0,0 +1,23 @@
package com.akaxin.site.web.admin.service;
import java.util.List;
import com.akaxin.site.storage.bean.SimpleUserBean;
import com.akaxin.site.storage.bean.UserProfileBean;
public interface IUserService {
// 获取用户profile
UserProfileBean getUserProfile(String siteUserId);
// 更新用户profile
boolean updateProfile(UserProfileBean userProfileBean);
// 获取用户列表
List<SimpleUserBean> getUserList(int pageNum, int pageSize);
// 封禁用户
boolean sealUpUser(String siteUserId, int status);
// 删除用户
boolean delUser(String siteUserId);
}

View File

@ -0,0 +1,184 @@
/**
* Copyright 2018-2028 Akaxin Group
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.akaxin.site.web.admin.service.impl;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.akaxin.site.business.dao.SiteConfigDao;
import com.akaxin.site.business.impl.site.SiteConfig;
import com.akaxin.site.web.admin.service.IConfigService;
import com.akaxin.site.web.utils.ArraysUtils;
@Service
public class ConfigManageService implements IConfigService {
private static final Logger logger = LoggerFactory.getLogger(ConfigManageService.class);
@Override
public Map<Integer, String> getSiteConfig() {
Map<Integer, String> configMap = SiteConfig.getConfigMap();
return configMap;
}
@Override
public boolean updateSiteConfig(String siteUserId, Map<Integer, String> config) {
boolean isAdmin = SiteConfig.isSiteSuperAdmin(siteUserId);
boolean result = SiteConfigDao.getInstance().updateSiteConfig(config, isAdmin);
SiteConfig.updateConfig();
logger.info("siteUserId={} isAdmin={} update configMap={} result={}", siteUserId, isAdmin, config, result);
return result;
}
@Override
public boolean addUserManager(String siteUserId) {
boolean result = false;
String siteManagers = SiteConfigDao.getInstance().getSiteManagers();
if (StringUtils.isNotEmpty(siteManagers)) {
if (!siteManagers.contains(siteUserId)) {
siteManagers = siteManagers + "," + siteUserId;
}
} else {
siteManagers = siteUserId;
}
result = SiteConfigDao.getInstance().updateSiteManagers(siteManagers);
SiteConfig.updateConfig();
return result;
}
@Override
public boolean deleteUserManager(String siteUserId) {
boolean result = false;
String siteManagers = SiteConfigDao.getInstance().getSiteManagers();
if (StringUtils.isNotEmpty(siteManagers)) {
String[] managers = siteManagers.split(",");
List<String> managerList = ArraysUtils.asList(managers);
if (managerList.contains(siteUserId)) {
managerList.remove(siteUserId);
String newManagers = listToString(null, ",");
result = SiteConfigDao.getInstance().updateSiteManagers(newManagers);
SiteConfig.updateConfig();
}
}
return result;
}
@Override
public boolean setUserDefaultFriends(String siteUserId) {
boolean result = false;
String defaultFriends = SiteConfigDao.getInstance().getDefaultUserFriends();
if (StringUtils.isNotEmpty(defaultFriends)) {
if (!defaultFriends.contains(siteUserId)) {
defaultFriends = defaultFriends + "," + siteUserId;
}
} else {
defaultFriends = siteUserId;
}
result = SiteConfigDao.getInstance().updateDefaultUserFriends(defaultFriends);
SiteConfig.updateConfig();
return result;
}
@Override
public boolean deleteUserDefaultFriends(String siteUserId) {
boolean result = false;
String defaultFriends = SiteConfigDao.getInstance().getDefaultUserFriends();
if (StringUtils.isNotEmpty(defaultFriends)) {
String[] friends = defaultFriends.split(",");
List<String> friendList = ArraysUtils.asList(friends);
if (friendList.contains(siteUserId)) {
friendList.remove(siteUserId);
String newFriends = listToString(friendList, ",");
result = SiteConfigDao.getInstance().updateDefaultUserFriends(newFriends);
SiteConfig.updateConfig();
}
}
return result;
}
@Override
public boolean setUserDefaultGroups(String siteGroupId) {
boolean result = false;
String defaultGroups = SiteConfigDao.getInstance().getDefaultUserGroups();
if (StringUtils.isNotEmpty(defaultGroups)) {
if (!defaultGroups.contains(siteGroupId)) {
defaultGroups = defaultGroups + "," + siteGroupId;
}
} else {
defaultGroups = siteGroupId;
}
result = SiteConfigDao.getInstance().updateDefaultUserGroups(defaultGroups);
SiteConfig.updateConfig();
return result;
}
@Override
public boolean deleteUserDefaultGroup(String siteGroupId) {
boolean result = false;
String defaultGroups = SiteConfigDao.getInstance().getDefaultUserGroups();
if (StringUtils.isNotEmpty(defaultGroups)) {
String[] groups = defaultGroups.split(",");
List<String> groupList = ArraysUtils.asList(groups);
if (groupList.contains(siteGroupId)) {
groupList.remove(siteGroupId);
String newGroups = listToString(groupList, ",");
result = SiteConfigDao.getInstance().updateDefaultUserGroups(newGroups);
}
}
return result;
}
private static String listToString(Collection<? extends String> colls, String split) {
if (colls == null || colls.size() == 0) {
return null;
}
StringBuilder sb = new StringBuilder();
int i = 0;
for (String str : colls) {
sb.append(str);
if (++i < colls.size()) {
sb.append(split);
}
}
return sb.toString();
}
@Override
public List<String> getUserDefaultFriendList() {
String defaultFriends = SiteConfigDao.getInstance().getDefaultUserFriends();
if (StringUtils.isNotEmpty(defaultFriends)) {
String[] friends = defaultFriends.split(",");
return ArraysUtils.asList(friends);
}
return null;
}
@Override
public List<String> getUserDefaultGroupList() {
String defaultGroups = SiteConfigDao.getInstance().getDefaultUserGroups();
if (StringUtils.isNotEmpty(defaultGroups)) {
String[] groups = defaultGroups.split(",");
return ArraysUtils.asList(groups);
}
return null;
}
}

View File

@ -0,0 +1,87 @@
/**
* Copyright 2018-2028 Akaxin Group
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.akaxin.site.web.admin.service.impl;
import java.util.List;
import java.util.Set;
import org.springframework.stereotype.Service;
import com.akaxin.site.business.dao.UserGroupDao;
import com.akaxin.site.business.impl.site.SiteConfig;
import com.akaxin.site.storage.bean.GroupMemberBean;
import com.akaxin.site.storage.bean.GroupProfileBean;
import com.akaxin.site.storage.bean.SimpleGroupBean;
import com.akaxin.site.web.admin.service.IGroupService;
/**
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-04-17 18:59:24
*/
@Service("groupManageService")
public class GroupManageService implements IGroupService {
@Override
public GroupProfileBean getGroupProfile(String siteGroupId) {
GroupProfileBean groupProfile = UserGroupDao.getInstance().getGroupProfile(siteGroupId);
groupProfile.setDefaultState(isUserDefaultGroup(groupProfile.getGroupId()) ? 1 : 0);
return groupProfile;
}
private boolean isUserDefaultGroup(String siteGroupId) {
Set<String> defaultGroups = SiteConfig.getUserDefaultGroups();
if (defaultGroups != null && defaultGroups.size() > 0) {
return defaultGroups.contains(siteGroupId);
}
return false;
}
@Override
public boolean updateGroupProfile(GroupProfileBean bean) {
return UserGroupDao.getInstance().updateGroupProfile(bean);
}
@Override
public List<SimpleGroupBean> getGroupList(int pageNum, int pageSize) {
return UserGroupDao.getInstance().getGroupList(pageNum, pageSize);
}
@Override
public List<GroupMemberBean> getGroupMembers(String siteGroupId, int pageNum, int pageSize) {
return UserGroupDao.getInstance().getGroupMemberList(siteGroupId, pageNum, pageSize);
}
@Override
public List<GroupMemberBean> getNonGroupMembers(String siteGroupId, int pageNum, int pageSize) {
return UserGroupDao.getInstance().getNonGroupMemberList(siteGroupId, pageNum, pageSize);
}
@Override
public boolean addGroupMembers(String siteGroupId, List<String> newMemberList) {
return UserGroupDao.getInstance().addGroupMember(null, siteGroupId, newMemberList);
}
@Override
public boolean removeGroupMembers(String siteGroupId, List<String> groupMemberList) {
return UserGroupDao.getInstance().deleteGroupMember(siteGroupId, groupMemberList);
}
@Override
public boolean dismissGroup(String siteGroupId) {
return UserGroupDao.getInstance().deleteGroup(siteGroupId);
}
}

View File

@ -0,0 +1,105 @@
package com.akaxin.site.web.admin.service.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.akaxin.common.command.Command;
import com.akaxin.common.constant.RequestAction;
import com.akaxin.proto.core.CoreProto;
import com.akaxin.proto.core.CoreProto.MsgType;
import com.akaxin.proto.site.ImCtsMessageProto;
import com.akaxin.site.message.api.IMessageService;
import com.akaxin.site.message.service.ImMessageService;
import com.akaxin.site.web.admin.bean.WebMessageBean;
import com.akaxin.site.web.admin.service.IMessageManageService;
/**
* 后台管理发送消息实现
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-04-25 11:14:05
*/
@Service("messageManageService")
public class MessageManageService implements IMessageManageService {
private static final Logger logger = LoggerFactory.getLogger(MessageManageService.class);
private IMessageService imService = new ImMessageService();
@Override
public boolean sendU2WebMessage(WebMessageBean bean) {
CoreProto.U2Web u2Web = CoreProto.U2Web.newBuilder().setMsgId(bean.getMsgId())
.setSiteUserId(bean.getSiteUserId()).setSiteFriendId(bean.getSiteFriendId())
.setWebCode(bean.getWebCode()).setHeight(bean.getHeight()).setWidth(bean.getWidth())
.setTime(System.currentTimeMillis()).setHrefUrl(bean.getHrefUrl()).build();
ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.newBuilder()
.setType(MsgType.U2_WEB).setU2Web(u2Web).build();
Command command = new Command();
command.setSiteUserId(bean.getSiteUserId());
command.setSiteFriendId(bean.getSiteFriendId());
command.setAction(RequestAction.IM_CTS_MESSAGE.getName());
command.setParams(request.toByteArray());
boolean result = imService.execute(command);
logger.info("send u2 web message result={} bean={}", result, bean.toString());
return result;
}
@Override
public boolean sendU2WebNoticeMessage(WebMessageBean bean) {
CoreProto.U2WebNotice u2WebNotice = CoreProto.U2WebNotice.newBuilder().setMsgId(bean.getMsgId())
.setSiteUserId(bean.getSiteUserId()).setSiteFriendId(bean.getSiteFriendId())
.setWebCode(bean.getWebCode()).setHrefUrl(bean.getHrefUrl()).setTime(System.currentTimeMillis())
.build();
ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.newBuilder()
.setType(MsgType.U2_WEB_NOTICE).setU2WebNotice(u2WebNotice).build();
Command command = new Command();
command.setAction(RequestAction.IM_CTS_MESSAGE.getName());
command.setSiteUserId(bean.getSiteUserId());
command.setSiteFriendId(bean.getSiteFriendId());
command.setParams(request.toByteArray());
boolean result = imService.execute(command);
logger.info("send u2 web notice message result={} bean={}", result, bean.toString());
return result;
}
@Override
public boolean sendGroupWebMessage(WebMessageBean bean) {
CoreProto.GroupWeb groupWeb = CoreProto.GroupWeb.newBuilder().setMsgId(bean.getMsgId())
.setSiteUserId(bean.getSiteUserId()).setSiteGroupId(bean.getSiteGroupId()).setWebCode(bean.getWebCode())
.setHeight(bean.getHeight()).setHrefUrl(bean.getHrefUrl()).setWidth(bean.getWidth())
.setTime(System.currentTimeMillis()).build();
ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.newBuilder()
.setType(MsgType.GROUP_WEB).setGroupWeb(groupWeb).build();
Command command = new Command();
command.setSiteUserId(bean.getSiteUserId());
command.setAction(RequestAction.IM_CTS_MESSAGE.getName());
command.setParams(request.toByteArray());
boolean result = imService.execute(command);
logger.info("send group web message result={} bean={}", result, bean.toString());
return result;
}
@Override
public boolean sendGroupWebNoticeMessage(WebMessageBean bean) {
CoreProto.GroupWebNotice groupWebNotice = CoreProto.GroupWebNotice.newBuilder().setMsgId(bean.getMsgId())
.setSiteUserId(bean.getSiteUserId()).setSiteGroupId(bean.getSiteGroupId()).setWebCode(bean.getWebCode())
.setTime(System.currentTimeMillis()).setHrefUrl(bean.getHrefUrl()).build();
ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.newBuilder()
.setType(MsgType.GROUP_WEB_NOTICE).setGroupWebNotice(groupWebNotice).build();
Command command = new Command();
command.setSiteUserId(bean.getSiteUserId());
command.setAction(RequestAction.IM_CTS_MESSAGE.getName());
command.setParams(request.toByteArray());
boolean result = imService.execute(command);
logger.info("send group web message result={} bean={}", result, bean.toString());
return result;
}
}

View File

@ -0,0 +1,47 @@
package com.akaxin.site.web.admin.service.impl;
import com.akaxin.site.business.dao.MonitorDao;
import com.akaxin.site.web.admin.service.IMonitorService;
import org.springframework.stereotype.Service;
@Service
public class MonitorService implements IMonitorService {
private MonitorDao monitorDao = MonitorDao.getInstance();
@Override
public int queryNumRegisterPerDay(long now, int day) {
return monitorDao.queryNumRegisterPerDay(now, day);
}
@Override
public int queryNumMessagePerDay(long now, int day) {
return monitorDao.queryNumMessagePerDay(now, day);
}
@Override
public int queryGroupMessagePerDay(long now, int day) {
return monitorDao.queryGroupMessagePerDay(now, day);
}
@Override
public int queryU2MessagePerDay(long now, int day) {
return monitorDao.queryU2MessagePerDay(now, day);
}
@Override
public int getSiteUserNum(long now, int day) {
return monitorDao.getSiteUserNum(now, day);
}
@Override
public int getGroupNum(long now, int day) {
return monitorDao.getGroupNum(now, day);
}
@Override
public int friendNum(long now, int day) {
return monitorDao.friendNum(now, day);
}
}

View File

@ -0,0 +1,66 @@
/**
* Copyright 2018-2028 Akaxin Group
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.akaxin.site.web.admin.service.impl;
import java.util.List;
import org.springframework.stereotype.Service;
import com.akaxin.site.business.dao.SitePluginDao;
import com.akaxin.site.storage.bean.PluginBean;
import com.akaxin.site.web.admin.service.IPluginService;
/**
* 扩展管理Service
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-04-17 11:57:26
*/
@Service("pluginManageService")
public class PluginManageService implements IPluginService {
@Override
public boolean addNewPlugin(PluginBean bean) {
return SitePluginDao.getInstance().addPlugin(bean);
}
@Override
public boolean deletePlugin(int pluginId) {
return SitePluginDao.getInstance().deletePlugin(pluginId);
}
@Override
public boolean updatePlugin(PluginBean bean) {
return SitePluginDao.getInstance().updatePlugin(bean);
}
@Override
public PluginBean getPlugin(int pluginId) {
return SitePluginDao.getInstance().getPluginProfile(pluginId);
}
@Override
public List<PluginBean> getPluginList(int pageNum, int pageSize) {
return SitePluginDao.getInstance().getAllPluginList(pageNum, pageSize);
}
@Override
public String reSetAuthKey(int pluginId) {
return SitePluginDao.getInstance().reSetAuthKey(pluginId);
}
}

View File

@ -0,0 +1,54 @@
/**
* 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.
*/
package com.akaxin.site.web.admin.service.impl;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.akaxin.proto.core.UicProto.UicStatus;
import com.akaxin.site.business.dao.SiteUicDao;
import com.akaxin.site.storage.bean.UicBean;
import com.akaxin.site.web.admin.service.IUICService;
@Service
public class UICManageService implements IUICService {
private static final Logger logger = LoggerFactory.getLogger(UICManageService.class);
@Override
public boolean addUIC(int num, int length) {
try {
UicBean bean = new UicBean();
bean.setStatus(UicStatus.UNUSED_VALUE);
bean.setCreateTime(System.currentTimeMillis());
if (SiteUicDao.getInstance().batchAddUic(bean, num, length)) {
return true;
}
} catch (Exception e) {
logger.error("add uic error", e);
}
return false;
}
@Override
public List<UicBean> getUsedUicList(int pageNum, int pageSize, int status) {
List<UicBean> uicList = SiteUicDao.getInstance().getUicList(pageNum, pageSize, status);
return uicList;
}
}

View File

@ -0,0 +1,152 @@
/**
* Copyright 2018-2028 Akaxin Group
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.akaxin.site.web.admin.service.impl;
import java.io.File;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.akaxin.site.business.dao.UserGroupDao;
import com.akaxin.site.business.dao.UserProfileDao;
import com.akaxin.site.business.impl.site.SiteConfig;
import com.akaxin.site.business.utils.FilePathUtils;
import com.akaxin.site.storage.api.IGroupDao;
import com.akaxin.site.storage.api.IMessageDao;
import com.akaxin.site.storage.api.IUserDeviceDao;
import com.akaxin.site.storage.api.IUserFriendDao;
import com.akaxin.site.storage.api.IUserProfileDao;
import com.akaxin.site.storage.api.IUserSessionDao;
import com.akaxin.site.storage.bean.SimpleGroupBean;
import com.akaxin.site.storage.bean.SimpleUserBean;
import com.akaxin.site.storage.bean.UserDeviceBean;
import com.akaxin.site.storage.bean.UserProfileBean;
import com.akaxin.site.storage.service.DeviceDaoService;
import com.akaxin.site.storage.service.GroupDaoService;
import com.akaxin.site.storage.service.MessageDaoService;
import com.akaxin.site.storage.service.UserFriendDaoService;
import com.akaxin.site.storage.service.UserProfileDaoService;
import com.akaxin.site.storage.service.UserSessionDaoService;
import com.akaxin.site.web.admin.service.IUserService;
@Service("userManageService")
public class UserManageService implements IUserService {
private IMessageDao messageDao = new MessageDaoService();
private IUserFriendDao friendDao = new UserFriendDaoService();
private IGroupDao groupDao = new GroupDaoService();
private IUserProfileDao profileDao = new UserProfileDaoService();
private IUserDeviceDao deviceDao = new DeviceDaoService();
private IUserSessionDao sessionDao = new UserSessionDaoService();
private static final Logger logger = LoggerFactory.getLogger(UserManageService.class);
@Override
public UserProfileBean getUserProfile(String siteUserId) {
UserProfileBean bean = UserProfileDao.getInstance().getUserProfileById(siteUserId);
bean.setDefaultState(isUserDefaultFriend(bean.getSiteUserId()) ? 1 : 0);
return bean;
}
private boolean isUserDefaultFriend(String siteUserId) {
Set<String> defaultFriends = SiteConfig.getUserDefaultFriends();
if (defaultFriends != null && defaultFriends.size() > 0) {
return defaultFriends.contains(siteUserId);
}
return false;
}
@Override
public boolean updateProfile(UserProfileBean userProfileBean) {
return UserProfileDao.getInstance().updateUserProfile(userProfileBean);
}
@Override
public List<SimpleUserBean> getUserList(int pageNum, int pageSize) {
return UserProfileDao.getInstance().getUserPageList(pageNum, pageSize);
}
@Override
public boolean sealUpUser(String siteUserId, int status) {
return UserProfileDao.getInstance().updateUserStatus(siteUserId, status);
}
@Override
public boolean delUser(String siteUserId) {
boolean delProfile = false;
ArrayList<String> userFileIds = new ArrayList<>();
try {
List<UserDeviceBean> userDeviceList = deviceDao.getUserDeviceList(siteUserId);
for (UserDeviceBean userDeviceBean : userDeviceList) {
sessionDao.deleteUserSession(siteUserId, userDeviceBean.getDeviceId());
}
UserProfileBean userProfileById = profileDao.getUserProfileById(siteUserId);
String userPhoto = userProfileById.getUserPhoto();
userFileIds.add(userPhoto);
delProfile = profileDao.delUser(siteUserId) && deviceDao.delDevice(siteUserId);
} catch (SQLException e) {
logger.error("del user profile error", e);
}
try {
List<String> msgList = messageDao.queryMessageFile(siteUserId);
for (String fileId : msgList) {
userFileIds.add(fileId);
}
messageDao.delUserMessage(siteUserId);
} catch (SQLException e) {
logger.error("del user Message error", e);
}
try {
friendDao.delUserFriend(siteUserId);
} catch (SQLException e) {
logger.error("del user friend error", e);
}
try {
List<SimpleGroupBean> userGroups = groupDao.getUserGroupList(siteUserId);
for (SimpleGroupBean userGroup : userGroups) {
String groupMasterId = UserGroupDao.getInstance().getGroupMaster(userGroup.getGroupId());
if (groupMasterId.equals(siteUserId)) {
userFileIds.add(userGroup.getGroupPhoto());
groupDao.rmGroupProfile(userGroup.getGroupId());
} else {
ArrayList<String> delList = new ArrayList<>();
delList.add(siteUserId);
groupDao.deleteGroupMember(userGroup.getGroupId(), delList);
}
}
} catch (SQLException e) {
logger.error("del user group error", e);
}
for (String userFilePath : userFileIds) {
if (StringUtils.isNotBlank(userFilePath) && !"null".equals(userFilePath)) {
if (userFilePath.startsWith("AKX-") || userFilePath.startsWith("akx-")) {
userFilePath = userFilePath.substring(4, userFilePath.length());
}
File delFile = new File(FilePathUtils.getFilePathByFileId(userFilePath));
if (delFile.exists()) {
delFile.delete();
}
}
}
return delProfile;
}
}

View File

@ -0,0 +1,18 @@
package com.akaxin.site.web.utils;
import java.util.ArrayList;
import java.util.List;
public class ArraysUtils {
public static List<String> asList(String[] objs) {
if (objs == null)
return null;
List<String> list = new ArrayList<String>();
for (String obj : objs) {
list.add(obj);
}
return list;
}
}

View File

@ -0,0 +1,10 @@
#配置管理平台启动端口
#server.port=80
#设置输出日志
#logging.file=admin.log
#设置日志的输出级别
#logging.level.root=info
#配置mvc前缀界面位置
#spring.thymeleaf.prefix=classpath:/webapp/views/
#静态资源
#spring.resources.static-locations=classpath:/webapp/static/

View File

@ -0,0 +1,91 @@
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.basic-title {
text-align: center;
font-weight: 400;
color: #1E88E5;
margin: 0 15%;
}
.basic-sub-title {
text-align: center;
color: #1E88E5;
}
.basic-header {
padding: 35px 0;
}css
.basic-content-padded {
padding: 15px;
}
.margin_top_30px {
margin-top: 30px;
}
.basic-second-title {
text-align: center;
color: #1E88E5;
font-weight: 400;
margin: 0 15%;
}
.basic-weui-grid {
position: relative;
float: left;
padding: 5px;
width: 60px;
height: 60px;
}
.basic-color {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn_primary {
background-color: #1E88E5;
}
.basic-weui-btn {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:hover {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:active {
background-color: #1E88E5!important;
color: #FFFFFF;
}
.basic-weui-btn_mini {
display: inline-block;
padding: 0 1.32em;
line-height: 2.3;
}
.weui-dialog__btn {
color: #1E88E5;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.basic-color_bg {
background-color: #f4f4f4;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,622 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>站点设置</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.basic-color {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:hover {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:active {
background-color: #1E88E5 !important;
color: #FFFFFF;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="weui-cells__title weui-cell" style="margin-top: 0px;">
站点基本设置<a href="https://github.com/akaxincom/faq/blob/master/basic_config.md" class="weui-cell_link">-设置说明</a>
</div>
<div class="weui-cells weui-cells_form">
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">站点名称</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input site-name" name='site_name' type="text" th:value="${site_name}"
placeholder="请输入站点名称" pattern="[^'\x22]+" style="text-align: right;">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">站点地址</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input site-addr site_address_info" type="text"
th:value="${siteAddressAndPort}" placeholder="请输入站点地址" autocapitalize="off"
pattern="[a-zA-Z0-9:]*" style="text-align: right;">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">扩展API地址</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input site-port" type="text"
th:value="${httpAddressAndPort}" placeholder="InnerAPI服务器地址"
style="text-align: right;" disabled>
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">群成员限制</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input site-group-maxnum" type="number" th:value="${group_members_count}"
pattern="[0-9]*" placeholder="请输入群成员总量限制" style="text-align: right;">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">站点根目录</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input site-img-addr" type="text" name='pic_path' th:value="${pic_path}"
placeholder="请输入站点根目录" style="text-align: right;" disabled>
</div>
</div>
<div class="weui-gallery" id="gallery">
<span class="weui-gallery__img" id="galleryImg"></span>
<div class="weui-gallery__opr">
<a href="javascript:" class="weui-gallery__del">
<i class="weui-icon-delete weui-icon_gallery-delete"></i>
</a>
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<div class="weui-uploader">
<div class="weui-uploader__hd">
<p class="weui-uploader__title">站点Logo上传</p>
<div class="weui-uploader__info pic_num" th:if="${site_logo}==null">0/1</div>
<div class="weui-uploader__info pic_num" th:unless="${site_logo}==null">1/1</div>
</div>
<div class="weui-uploader__bd">
<ul class="weui-uploader__files uploaderFiles" id="uploaderFiles">
<li class="weui-uploader__file site_logo imgage_id"
th:attr="image-id=${site_logo},site-logo=${site_logo}" id="site_logo"
th:if="${site_logo}!=null"></li>
</ul>
<div class="weui-uploader__input-box">
<input id="uploaderInput" class="weui-uploader__input uploaderInput" type="file"
accept="image/*" multiple="">
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 登陆站点权限设置 -->
<div class="weui-cells">
<div class="weui-cell weui-cell_switch">
<div class="weui-cell__bd">是否开启绝密功能</div>
<div class="weui-cell__ft" th:switch="${u2_encryption_status}">
<input class="weui-switch open_secret" key-data='U2_ENCRYPTION_STATUS' type="checkbox"
checked="checked" th:case="1">
<input class="weui-switch open_secret" key-data='U2_ENCRYPTION_STATUS' type="checkbox" th:case="0">
</div>
</div>
<div class="weui-cell weui-cell_switch">
<div class="weui-cell__bd">是否要求实名认证</div>
<div class="weui-cell__ft" th:switch="${realName_status}">
<input class="weui-switch realName_status" key-data='REALNAME_STATUS_VALUE' type="checkbox"
checked="checked" th:case="1">
<input class="weui-switch realName_status" key-data='REALNAME_STATUS_VALUE' type="checkbox" th:case="0">
</div>
</div>
<div class="weui-cell weui-cell_switch">
<div class="weui-cell__bd">是否要求邀请码</div>
<div class="weui-cell__ft" th:switch="${uic_status}">
<input class="weui-switch uic_status" key-data='INVITE_CODE_STATUS_VALUE' type="checkbox"
checked="checked" th:case="1">
<input class="weui-switch uic_status" key-data='INVITE_CODE_STATUS_VALUE' type="checkbox" th:case="0">
</div>
</div>
</div>
<div class="weui-cells">
<div class="weui-cell weui-cell_switch">
<div class="weui-cell__bd">是否允许用户添加好友</div>
<div class="weui-cell__ft" th:switch="${add_friends_status}">
<input class="weui-switch add_friends_status" key-data='ADD_FRIENDS_STATUS' type="checkbox" value="0" checked="checked" th:case="0">
<input class="weui-switch add_friends_status" key-data='ADD_FRIENDS_STATUS' type="checkbox" value="1" th:case="1">
</div>
</div>
<div class="weui-cell weui-cell_switch">
<div class="weui-cell__bd">是否允许用户创建群组</div>
<div class="weui-cell__ft" th:switch="${create_groups_status}">
<input class="weui-switch create_groups_status" key-data='CREATE_GROUPS_STATUS' type="checkbox" value="0" checked="checked" th:case="0">
<input class="weui-switch create_groups_status" key-data='CREATE_GROUPS_STATUS' type="checkbox" value="1" th:case="1">
</div>
</div>
</div>
<!-- 登陆站点权限设置 -->
<div class="weui-cells">
<a class="weui-cell weui-cell_access group_qrcode_expire_time" th:attr="data=${group_qrcode_expire_time}" href="javascript:;">
<div class="weui-cell__bd">
<p>群二维码过期时间</p>
</div>
<div th:switch="${group_qrcode_expire_time}">
<div class="weui-cell__ft group_qrcode_expire_time—txt" th:case="1">
1天
</div>
<div class="weui-cell__ft group_qrcode_expire_time—txt" th:case="7">
1周
</div>
<div class="weui-cell__ft group_qrcode_expire_time—txt" th:case="14">
2周
</div>
</div>
</a>
<a class="weui-cell weui-cell_access site_push" th:attr="data=${push_client_status}" href="javascript:;">
<div class="weui-cell__bd">
<p>消息通知</p>
</div>
<div th:switch="${push_client_status}">
<div class="weui-cell__ft site_push—txt" th:case="0">
关闭通知
</div>
<div class="weui-cell__ft site_push—txt" th:case="1">
不显示文本内容
</div>
<div class="weui-cell__ft site_push—txt" th:case="2">
显示文本内容
</div>
</div>
</a>
<a class="weui-cell weui-cell_access log_level" th:attr="data=${log_level}" href="javascript:;">
<div class="weui-cell__bd">
<p>日志级别</p>
</div>
<div th:switch="${log_level}">
<div class="weui-cell__ft log_level—txt" th:case="DEBUG">
DEBUG
</div>
<div class="weui-cell__ft log_level—txt" th:case="*">
INFO
</div>
<div class="weui-cell__ft log_level—txt" th:case="ERROR">
ERROR
</div>
</div>
</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/updateConfig"
id="setBasicConfigButton">确定</a>
</div>
<div class="weui-gallery" id="gallery">
<span class="weui-gallery__img" id="galleryImg"></span>
<div class="weui-gallery__opr">
<a href="javascript:" class="weui-gallery__del">
<i class="weui-icon-delete weui-icon_gallery-delete"></i>
</a>
</div>
</div>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageUpload(callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageUpload(callback);
} else if (type == 'IOS') {
ios_imageUpload(callback);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageDownload(imageid, callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageDownload(imageid, callback);
} else if (type == 'IOS') {
ios_imageDownload(imageid, callback);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
function isDomain(siteAddress) {
siteAddress=siteAddress.replace(/\s/g,"");
if (siteAddress.indexOf("://") > -1) {
hostname = siteAddress.split('/')[2];
} else {
hostname = siteAddress.split('/')[0];
}
var domain = hostname.split(':')[0];
domain = domain.split('?')[0];
if (domain) {
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(domain)) {
return true;
}
var re2 = /^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/;
if (re2.test(domain)) {
return true;
}
}
return false;
}
$(document).on("click", "#setBasicConfigButton", function () {
var siteName = $('.site-name').val();
var siteGroupMaxnum = $('.site-group-maxnum').val();
var siteImgAddr = $('.site-img-addr').val();
var uic_status = $(".uic_status").prop('checked');
var realName_status = $(".realName_status").prop('checked');
var pushClientStatus = $(".site_push").attr("data");
var logLevel = $(".log_level").attr("data");
var siteAddressInfo = $('.site_address_info').val();
var openSecret = $('.open_secret').prop('checked');
var addFriends = $('.add_friends_status').prop('checked');
var createGroups = $('.create_groups_status').prop('checked');//创建群组
//二维码过期时间
var groupQrcodeExpireTime = $(".group_qrcode_expire_time").attr("data");
if(addFriends){
addFriends = '0';//表示允许
} else {
addFriends = '1';
}
if(createGroups){
createGroups = '0';//表示允许
} else {
createGroups = '1';
}
if (openSecret) {
openSecret = '1';
} else {
openSecret = '0';
}
if (uic_status) {
uic_status = '1';
} else {
uic_status = '0';
}
if (realName_status) {
realName_status = '1';
} else {
realName_status = '0';
}
var blobImgUrl = $('.blob_img_url').attr('data');
if (siteName.length < 1) {
$.toptip('站点名称不能为空', 'error');
return false;
}
var siteAddres = '';
var sitePort = '';
var siteAddressInfos = siteAddressInfo.replace('', ':').split(':');
if (siteAddressInfos.length > 2) {
$.toptip('请填写正确的站点地址', 'error');
return false;
} else if (siteAddressInfos.length == 2) {
var siteAddress = siteAddressInfos[0];
var sitePort = siteAddressInfos[1];
} else {
var siteAddress = siteAddressInfos[0];
}
var siteAddressFlag = false;
siteAddressFlag = isDomain(siteAddress);
if (!siteAddressFlag) {
$.toptip('请填写正确的站点地址', 'error');
return false;
}
if (siteGroupMaxnum.length < 1) {
$.toptip('群组最大的成员数量不能为空', 'error');
return false;
}
if (siteImgAddr.length < 1) {
$.toptip('图片存储地址不能为空', 'error');
return false;
}
var imageId = $('.imgage_id').attr('image-id');
var data = {
'site_name': siteName,
'site_address': siteAddress,
'site_port': sitePort,
'group_members_count': siteGroupMaxnum,
'pic_path': siteImgAddr,
'site_logo': imageId,
'realName_status': realName_status,
'uic_status': uic_status,
'u2_encryption_status': openSecret,
'push_client_status': pushClientStatus,
'log_level': logLevel,
'add_friends_status':addFriends,
'create_groups_status':createGroups,//create group
'group_qrcode_expire_time':groupQrcodeExpireTime
};
var reqUri = $(this).attr('url-data');
$.confirm({
title: '修改基本设置',
text: '确定要修改基本设置?',
onOK: function () {
reqUrl(reqUri, JSON.stringify(data), "siteBasic");
$.closeModal();
},
onCancel: function () {
console.log('cancle');
toast('取消操作');
$.closeModal();
}
});
});
function siteBasic(result) {
if (result == 'success') {
$.toast("修改成功");
} else if (result == 'no-permission') {
$.toast("没有权限,请稍后再试", "forbidden");
} else {
$.toast("修改失败,请稍后再试", "forbidden");
}
}
$(document).on("click", '.uploaderInput', function () {
reqImageUpload("jsimageUpload");
});
function jsimageUpload(result, imageId, imageLocalPath) {
var type = getOsType();
if (result == 1) {
if (type == 'Android') {
var img = '<li class="weui-uploader__file imgage_id" image-id="' + imageId + '"><img src="http://akaxin/img' + imageLocalPath + '" style="height:75px; width:75px;" /></li>';
} else {
var img = '<li class="weui-uploader__file imgage_id" image-id="' + imageId + '"><img src="' + imageLocalPath + '" style="height:75px; width:75px;" /></li>';
}
$('#uploaderFiles').html(img);
$('.pic_num').html('1/1');
} else {
$.toast('图片上传失败', 'forbidden');
}
}
$(document).on("click", '.log_level', function () {
$.actions({
title: "",
onClose: function () {
console.log("close");
},
actions: [{
text: "DEBUG",
className: "color-primary weui-dialog__btn",
onClick: function () {
$(".log_level—txt").html("DEBUG");
$(".log_level").attr("data", "DEBUG");
}
},
{
text: "INFO",
className: "color-warning weui-dialog__btn",
onClick: function () {
$(".log_level—txt").html("INFO");
$(".log_level").attr("data", "INFO");
}
},
{
text: "ERROR",
className: 'color-danger weui-dialog__btn',
onClick: function () {
$(".log_level—txt").html("ERROR");
$(".log_level").attr("data", "ERROR");
}
}
]
});
});
$(document).on("click", '.site_push', function () {
$.actions({
title: "",
onClose: function () {
console.log("close");
},
actions: [{
text: "禁用通知",
className: "color-primary weui-dialog__btn ",
onClick: function () {
$(".site_push—txt").html("禁用通知");
$(".site_push").attr("data", "0");
}
},
{
text: "显示文本内容",
className: 'color-danger weui-dialog__btn',
onClick: function () {
$(".site_push—txt").html("显示文本内容");
$(".site_push").attr("data", "2");
}
},
{
text: "不显示文本内容",
className: "color-warning weui-dialog__btn",
onClick: function () {
$(".site_push—txt").html("不显示文本内容");
$(".site_push").attr("data", "1");
}
}
]
});
});
//group qrcode expire time
$(document).on("click", '.group_qrcode_expire_time', function () {
$.actions({
title: "修改群二维码过期时间",
onClose: function () {
console.log("close");
},
actions: [{
text: "1天",
className: "color-primary weui-dialog__btn",
onClick: function () {
$(".group_qrcode_expire_time—txt").html("1天");
$(".group_qrcode_expire_time").attr("data", "1");
}
},
{
text: "1周",
className: 'color-primary weui-dialog__btn',
onClick: function () {
$(".group_qrcode_expire_time—txt").html("1周");
$(".group_qrcode_expire_time").attr("data", "7");
}
},
{
text: "2周",
className: "color-primary weui-dialog__btn",
onClick: function () {
$(".group_qrcode_expire_time—txt").html("2周");
$(".group_qrcode_expire_time").attr("data", "14");
}
}
]
});
});
$(window).load(function () {
var imageid = $('.site_logo').attr('site-logo');
reqImageDownload(imageid, "jsimageDownload");
});
function jsimageDownload(result, imageid, imageLocalPath) {
var type = getOsType();
if (type == 'Android') {
var html = '<img src="http://akaxin/img' + imageLocalPath + '" style="height:75px; width:75px;" />';
} else {
var html = '<img src="' + imageLocalPath + '" style="height:75px; width:75px;" />';
}
$('#site_logo').html(html);
}
</script>
</body>
</html>

View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>用户管理后台</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
.icon-box {
margin-bottom: 25px;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center
}
.icon-box i {
margin-right: 18px
}
.icon-box__ctn {
-webkit-flex-shrink: 100;
flex-shrink: 100
}
.icon-box__title {
font-weight: 400
}
.icon-box__desc {
margin-top: 6px;
font-size: 12px;
color: #888
}
.icon_sp_area {
margin-top: 10px;
text-align: left
}
.icon_sp_area i:before {
margin-bottom: 5px
}
</style>
</head>
<body ontouchstart="">
<header class='basic-header'>
<h1 class="basic-title">站点管理后台</h1>
</header>
<div class='basic-content-padded'>
<div class="icon-box">
<i class="weui-icon-warn weui-icon_msg"></i>
<div class="icon-box__ctn">
<h3 class="icon-box__title">无操作权限</h3>
<p class="icon-box__desc">您不是当前站点的管理员,不能进行该操作!</p>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,223 @@
<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<title>添加群成员</title>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.basic-color {
background-color: #1E88E5;
color: #FFFFFF;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart>
<div class="weui-cells__title weui-cell" style="margin: auto;">
<div class="weui-cell__hd"><img src=""></div>
<div class="weui-cell__bd">
<p></p>
</div>
<div class="weui-cell__ft">
<a class="weui-btn weui-btn-basic weui-btn_mini weui-btn_primary add-user-to-group basic-color"
style="background-color: #1E88E5;" th:attr="group-id=${siteGroupId}" url-data="/group/addGroupMember"
href="javascript:">添加入群</a>
</div>
</div>
<div class="weui-cells weui-cells_checkbox" id='user-lists'>
</div>
<div class="weui-loadmore weui-loadmore_line loadmore_site_user">
<span class="weui-loadmore__tips"></span>
</div>
<div id="groupID" th:attr="groupId=${siteGroupId}"></div>
<input type='hidden' id='init_url' url-data="/group/nonGroupMember"/>
<input type="hidden" id="add_group_user" site-user-id="">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
$(function () {
nonList();
});
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageDownload(imageid, callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageDownload(imageid, callback);
} else if (type == 'IOS') {
ios_imageDownload(imageid, callback);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(document).on("click", ".add-user-to-group", function () {
var reqUri = $(this).attr('url-data');
var groupId = $(this).attr('group-id');
var userIds = [];
$('input[name=select_user]').each(function () {
var checkedFlag = $(this).prop('checked');
var siteUserId = $(this).attr('id');
if (checkedFlag) {
userIds.push(siteUserId);
}
});
if (userIds.length < 1) {
$.toptip('添加成员不能为空', 'error');
return false;
}
$('#add_group_user').attr('site-user-id', JSON.stringify(userIds));
$.confirm({
title: '添加用户',
text: '确定要添加选中用户到当前群?',
onOK: function () {
var params = {
"groupMembers": userIds,
"siteGroupId": groupId
};
reqUrl(reqUri, JSON.stringify(params), "addGroupUser");
$.closeModal();
},
onCancel: function () {
console.log('cancle');
toast('取消操作');
$.closeModal();
}
});
});
function addGroupUser(result) {
if (result == 'success') {
var siteUserIds = $('#add_group_user').attr('site-user-id');
siteUserIds = JSON.parse(siteUserIds);
$.each(siteUserIds, function (index, siteUserId) {
console.log(index);
$("[for=" + siteUserId + "]").remove();
});
$.toast('添加成功');
} else {
$.toast('添加失败', 'forbidden');
}
}
var page = 0;
var loading = false;
function nonList() {
if (loading) {
$('.loadmore_site_user').addClass('weui-loadmore_line');
$('.loadmore_site_user span').html('暂无数据');
$('.loadmore_site_user i').remove();
return
}
page = page + 1;
var reqUri = $('#init_url').attr('url-data');
var groupId = $('#groupID').attr('groupId');
var params = {
'page': page.toString(),
'group_id': groupId
};
reqUrl(reqUri, JSON.stringify(params), 'addUserToList');
loading = true;
}
$(document.body).infinite().on("infinite", function () {
nonList();
});
function addUserToList(results) {
results = eval("(" + results + ")");
console.log(results);
var data = results.nonGroupMemberData;
var html = '';
$.each(data, function (index, user) {
var html = '<label class="weui-cell weui-check__label" for="' + user.siteUserId + '"> <div class="weui-cell__hd"> <input type="checkbox" class="weui-check" name="select_user" id="' + user.siteUserId + '" > <i class="weui-icon-checked"></i> </div><div name="user_image" class="weui-cell__hd user_image ' + user.userPhoto + ' " user-image="' + user.userPhoto + '" ></div> <div class="weui-cell__bd"> <p>' + user.userName + '</p> </div> </label>';
$('#user-lists').append(html);
});
loading = results.loading;
if (loading == true) {
$(".weui-loadmore__tips").html("到底啦");
} else {
$(".weui-loadmore__tips").html("加载更多");
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,240 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>群组管理</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="weui-pull-to-refresh__layer">
<div class='weui-pull-to-refresh__arrow'></div>
<div class='weui-pull-to-refresh__preloader'></div>
<div class="down">下拉刷新</div>
<div class="up">释放刷新</div>
<div class="refresh">正在刷新</div>
</div>
<div class="defaultGroup">
<div class="weui-cells__title weui-cell default_group_lists" th:unless="${groupDefaultSize} == 0">
默认群列表
</div>
<div class="weui-cells demos-content-padded default_group_lists" id='default_group_lists'
th:unless="${groupDefaultSize} == 0">
<a class="weui-cell weui-cell_access group-info" th:each="group:${groupList}"
th:attr="id=${group.groupId},group-id=${group.groupId},group-name=${group.groupName}"
href="javascript:;" url-data="/group/manage">
<div class="weui-cell__bd"><p th:text="${group.groupName}"></p></div>
<div class="weui-cell__ft"></div>
</a>
</div>
</div>
<div class="weui-cells__title weui-cell ">
群列表
</div>
<div class="weui-cells" id="group-lists">
</div>
<div class="weui-loadmore weui-loadmore_line loadmore_group">
<span class="weui-loadmore__tips"></span>
</div>
<input type='hidden' id='init_url' url-data="/group/list"/>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<!-- <script type="text/javascript" src="<?php echo $host_name;?>/public/js/manage-group-list.js<?php echo $static_version?>"> </script> -->
<script type="text/javascript">
//页面加载,执行
$(function () {
$('#group-lists').html("");
loadGroupList();
});
//定义全局变量
var page = 0;//
var loading = false;
//定义选择器,滚动使用
$(document.body).infinite().on("infinite", function () {
if(page == 0){
$('#group-lists').html("");
}
loadGroupList()
});
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 || u.indexOf('Windows Phone') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageUpload(callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageUpload(callback);
} else if (type == 'IOS') {
ios_imageUpload(callback);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageDownload(imageid, callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageDownload(imageid, callback);
} else if (type == 'IOS') {
ios_imageDownload(imageid, callback);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(document).on("click", ".group-info", function () {
var groupId = $(this).attr('group-id');
var groupName = $(this).attr('group-name');
console.log(groupId);
var reqUri = $(this).attr('url-data');
var params = {
"group_id": groupId,
"group_name": groupName,
};
reqHtml(reqUri, JSON.stringify(params));
});
//加载群聊列表
function loadGroupList() {
if (loading) {
$('.loadmore_group').addClass('weui-loadmore_line');
$('.loadmore_group span').html('到底啦');
return;
}
page = page + 1;
var reqUri = $('#init_url').attr('url-data');
var params = {
"page": page.toString()
};
reqUrl(reqUri, JSON.stringify(params), 'addGroupToList');
}
function addGroupToList(results) {
results = eval("(" + results + ")");
var data = results.groupData;
var html = '';
$.each(data, function (index, group) {
var html = '<a class="weui-cell weui-cell_access group-info" id="' + group.siteGroupId + '" group-id="' + group.siteGroupId + '" href="javascript:;" group-name="' + group.groupName + '" url-data="/group/manage"> <div class="weui-cell__bd"> <p>' + group.groupName + '</p> </div> <div class="weui-cell__ft"> </div> </a>';
$('#group-lists').append(html);
});
loading = results.loading;
if (loading == true) {
$(".weui-loadmore__tips").html("没有更多数据了");
} else {
$(".weui-loadmore__tips").html("加载更多");
}
}
$(document.body).pullToRefresh(function () {
reqUrl("/group/refresh", null, "doRefresh");
$('#group-lists').html("");
page = 0;
loading = false;
loadGroupList();
$(document.body).pullToRefreshDone();
});
function doRefresh(results) {
results = eval("(" + results + ")");
var size = results.size;
if (size <= 0) {
$('.defaultGroup').html("");
} else {
$('.defaultGroup').html("");
var defHtml = '<div class="weui-cells__title weui-cell default_group_lists" th:unless="${groupDefaultSize} == 0">\n' +
' 默认群列表\n' +
' </div>\n' +
' <div class="weui-cells demos-content-padded default_group_lists" id=\'default_group_lists\'\n' +
' th:unless="${groupDefaultSize} == 0"></div>';
$('.defaultGroup').append(defHtml);
var data = results.data;
var html = '';
$.each(data, function (index, group) {
var html = '<a class="weui-cell weui-cell_access group-info" group-id="' + group.siteGroupId + '" href="javascript:;" group-name="' + group.groupName + '" url-data="/group/manage"> <div class="weui-cell__bd"> <p>' + group.groupName + '</p> </div> <div class="weui-cell__ft"> </div> </a>';
$('#' + group.siteGroupId).remove();
$('#default_group_lists').append(html);
});
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,251 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>群管理</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.margin_top_30px {
margin-top: 30px;
}
.basic-color {
background-color: #1E88E5;
color: #FFFFFF;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="bd margin_top_30px">
<div class="page__bd">
<div class="weui-cells__title"></div>
<div class="weui-cells">
<a class="weui-cell weui-cell_access update-group-info-html" th:attr="group-id=${group_id}"
url-data="/group/profile" href="javascript:;">
<div class="weui-cell__bd">
<p>修改群信息</p>
</div>
<div class="weui-cell__ft">
</div>
</a>
<a class="weui-cell weui-cell_access group-add-member" th:attr="group-id=${group_id}"
url-data="/group/siteUser" href="javascript:;">
<div class="weui-cell__bd">
<p>添加群成员</p>
</div>
<div class="weui-cell__ft">
</div>
</a>
<a class="weui-cell weui-cell_access manage-group-member-html" url-data="/group/toMemberList"
th:attr="group-id=${group_id}" href="javascript:;">
<div class="weui-cell__bd">
<p>群成员管理</p>
</div>
<div class="weui-cell__ft">
</div>
</a>
<div class="weui-cell weui-cell_access"></div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn basic-color weui-btn_warn group_default"
url-data="/group/setUserDefaultGroup" href="javascript:" id="group_default"
th:if="${defaultState}==0" th:attr="defaultState=${defaultState},group-id=${group_id}">设为默认添加群</a>
<a class="weui-btn basic-weui-btn basic-color weui-btn_warn group_default"
url-data="/group/deleteUserDefaultGroup" href="javascript:" id="group_default"
th:if="${defaultState}==1" th:attr="defaultState=${defaultState},group-id=${group_id}">取消默认添加群</a>
<a href="javascript:;" url-data="/group/dissmiss"
class="weui-btn basic-weui-btn weui-btn_warn disband-group"
th:attr="group-id=${group_id}">解散群</a>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 || u.indexOf('Windows Phone') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageUpload(callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageUpload(callback);
} else if (type == 'IOS') {
ios_imageUpload(callback);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageDownload(imageid, callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageDownload(imageid, callback);
} else if (type == 'IOS') {
ios_imageDownload(imageid, callback);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(document).on("click", ".update-group-info-html", function () {
var groupId = $(this).attr('group-id');
var reqUri = $(this).attr('url-data');
var params = {
"group_id": groupId,
};
reqHtml(reqUri, JSON.stringify(params));
});
$(document).on("click", ".manage-group-member-html", function () {
var groupId = $(this).attr('group-id');
var reqUri = $(this).attr('url-data');
var params = {
"group_id": groupId
};
reqHtml(reqUri, JSON.stringify(params));
});
$(document).on("click", ".disband-group", function () {
var groupId = $(this).attr('group-id');
var reqUri = $(this).attr('url-data');
$.confirm({
title: '解散群',
text: '确定要解散该群?',
onOK: function () {
var params = {
"group_id": groupId,
};
reqUrl(reqUri, JSON.stringify(params), "disbandGroup");
$.closeModal();
},
onCancel: function () {
console.log('cancle');
toast('取消操作');
$.closeModal();
}
});
});
$(document).on("click", ".group-add-member", function () {
var groupId = $(this).attr('group-id');
var reqUri = $(this).attr('url-data');
var params = {
"group_id": groupId,
};
reqHtml(reqUri, JSON.stringify(params));
});
function disbandGroup(result) {
if (result == 'success') {
$.toast("解散群成功");
} else {
$.toast("解散群失败", "forbidden");
}
}
$(document).on("click", ".group_default", function () {
var groupId = $(this).attr('group-id');
var reqUri = $(this).attr('url-data');
var params = {
"group_id": groupId,
};
reqUrl(reqUri, JSON.stringify(params), 'groupDefault');
});
function groupDefault(results) {
if (results == 'success') {
$.toast("操作成功");
var attr = $('.group_default').attr('defaultState');
if (attr == '0') {
$('.group_default').attr('defaultState', '1');
$('.group_default').attr('url-data', '/group/deleteUserDefaultGroup');
$('.group_default').html('取消默认添加群');
} else {
$('.group_default').attr('defaultState', '0');
$('.group_default').attr('url-data', '/group/setUserDefaultGroup');
$('.group_default').html('设为默认添加群');
}
} else {
$.toast("操作失败", "forbidden");
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,236 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>群成员管理</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="weui-cells__title weui-cell" style="margin: auto;">
<div class="weui-cell__bd">
<p>群成员列表</p>
</div>
<div class="weui-cell__ft">
<a class="weui-btn weui-btn_mini weui-btn_warn remove-group-user"
th:attr="group-id=${siteGroupId}"
url-data="/group/removeGroupMember" href="javascript:">移除用户</a>
</div>
</div>
<div class="weui-cells group-member-lists weui-cells_checkbox" id='group-member-lists'>
</div>
<div class="weui-loadmore weui-loadmore_line loadmore_group_member">
<span class="weui-loadmore__tips"></span>
</div>
<input type="hidden" id="remove_group_user" site-user-id="">
<input type="hidden" id="init_url" th:attr="group-id=${siteGroupId}" url-data="/group/groupMember">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<!-- <script type="text/javascript" src="<?php echo $host_name;?>/public/js/manage-group-admin.js<?php echo $static_version?>"> </script> -->
<script type="text/javascript">
$(function () {
memberList();
});
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageUpload(callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageUpload(callback);
} else if (type == 'IOS') {
ios_imageUpload(callback);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageDownload(imageid, callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageDownload(imageid, callback);
} else if (type == 'IOS') {
ios_imageDownload(imageid, callback);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(document).on("click", ".remove-group-user", function () {
var groupId = $(this).attr('group-id');
var reqUri = $(this).attr('url-data');
var removeSiteUserIds = [];
$('input[name=remove_user]').each(function () {
var checkedFlag = $(this).prop('checked');
var siteUserId = $(this).attr('id');
if (checkedFlag) {
removeSiteUserIds.push(siteUserId);
}
});
if (removeSiteUserIds.length < 1) {
$.toptip('移除成员不能为空', 'error');
return false;
}
$('#remove_group_user').attr('site-user-id', JSON.stringify(removeSiteUserIds));
var params = {
"siteGroupId": groupId,
"groupMembers": removeSiteUserIds,
};
$.confirm({
title: '移除群成员',
text: '确定移除群成员?',
onOK: function () {
reqUrl(reqUri, JSON.stringify(params), "removeGroupUser");
$.closeModal();
},
onCancel: function () {
console.log('cancle');
toast('取消操作');
$.closeModal();
}
});
});
function removeGroupUser(result) {
if (result == 'success') {
var siteUserIds = $('#remove_group_user').attr('site-user-id');
siteUserIds = JSON.parse(siteUserIds);
$.each(siteUserIds, function (index, siteUserId) {
console.log(index);
$("[for=" + siteUserId + "]").remove();
});
$.toast('操作成功');
} else {
$.toast('操作失败', "forbidden");
}
}
function disbandGroup(result) {
if (result == 'success') {
$.toast("解散群成功");
} else {
$.toast("解散群失败", "forbidden");
}
}
var page = 0;
var loading = false;
$(document.body).infinite().on("infinite", function () {
memberList();
});
function memberList() {
if (loading) {
$('.loadmore_group_member').addClass('weui-loadmore_line');
$('.loadmore_group_member span').html('暂无数据');
$('.loadmore_group_member i').remove();
return false;
}
page = page + 1;
var groupId = $('#init_url').attr('group-id');
var reqUri = $('#init_url').attr('url-data');
var params = {
"page": page.toString(),
"group_id": groupId
};
reqUrl(reqUri, JSON.stringify(params), 'addMemberToList');
loading = true;
}
function addMemberToList(results) {
results = eval("(" + results + ")");
var data = results.groupMemberData;
var html = '';
$.each(data, function (index, groupMember) {
var html = '<label class="weui-cell weui-check__label" for="' + groupMember.siteUserId + '"> <div class="weui-cell__hd"> <input type="checkbox" class="weui-check" name="remove_user" id="' + groupMember.siteUserId + '" > <i class="weui-icon-checked"></i> </div> <div name="user_image" class="weui-cell__hd user_image ' + groupMember.userPhoto + '" user-image="' + groupMember.userPhoto + '"></div> <div class="weui-cell__bd"> <p>' + groupMember.userName + '</p> </div> </label>';
console.log(html);
$('#group-member-lists').append(html);
});
loading = results.loading;
if (loading == true) {
$(".weui-loadmore__tips").html("到底啦");
} else {
$(".weui-loadmore__tips").html("加载更多");
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,242 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>修改群信息</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.margin_top_30px {
margin-top: 30px;
}
.basic-color {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:hover {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:active {
background-color: #1E88E5 !important;
color: #FFFFFF;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="weui-cells weui-cells_form margin_top_30px">
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">群名称</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input group_name" type="text" pattern="[^'\x22]+" th:value="${groupName}"
placeholder="请输入群名称">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<div class="weui-uploader">
<div class="weui-uploader__hd">
<p class="weui-uploader__title">图片上传</p>
<div class="weui-uploader__info" th:if="${groupPhoto}!=null">1/1</div>
<div class="weui-uploader__info" th:unless="${groupPhoto}!=null">0/1</div>
</div>
<div class="weui-uploader__bd">
<ul class="weui-uploader__files" id="uploaderFiles">
<li class="weui-uploader__file group_icon" id="group_icon"
th:attr="group-icon=${groupPhoto}"></li>
</ul>
<div class="weui-uploader__input-box">
<input id="uploaderInput" class="weui-uploader__input uploaderInput" type="file"
accept="image/*" multiple="">
</div>
</div>
</div>
</div>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color setGroupInfoButton" href="javascript:"
th:attr="group-id=${siteGroupId}" url-data="/group/updateProfile" id="setGroupInfoButton">确定</a>
</div>
</div>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 || u.indexOf('Windows Phone') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageUpload(callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageUpload(callback);
} else if (type == 'IOS') {
ios_imageUpload(callback);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageDownload(imageid, callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageDownload(imageid, callback);
} else if (type == 'IOS') {
ios_imageDownload(imageid, callback);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(document).on("click", "#setGroupInfoButton", function () {
var groupId = $(this).attr('group-id');
var reqUri = $(this).attr('url-data');
var groupNotice = $('.group_notice').val();
var groupName = $('.group_name').val();
var groupIcon = $('.group_icon').attr('group-icon');
$('#group_info_id').attr('group-id', groupId);
$('#group_info_id').attr('group-name', groupName);
$.confirm({
title: '修改群信息',
text: '确定修改群信息?',
onOK: function () {
var params = {
"siteGroupId": groupId,
"groupName": groupName,
"groupNotice": groupNotice,
"groupPhoto": groupIcon
};
reqUrl(reqUri, JSON.stringify(params), "setGroupInfo");
$.closeModal();
},
onCancel: function () {
console.log('cancle');
toast('取消操作');
$.closeModal();
}
});
});
$(document).on("click", '.uploaderInput', function () {
reqImageUpload("jsimageUpload");
});
function jsimageUpload(result, imageId, imageLocalPath) {
var type = getOsType();
if (result == 1) {
if (type == 'Android') {
var img = '<li class="weui-uploader__file group_icon" group-icon="' + imageId + '"><img src="http://akaxin/img' + imageLocalPath + '" style="height:75px; width:75px;" /></li>';
} else {
var img = '<li class="weui-uploader__file group_icon" group-icon="' + imageId + '"><img src="' + imageLocalPath + '" style="height:75px; width:75px;" /></li>';
}
$('#uploaderFiles').html(img);
$('.pic_num').html('1/1');
} else {
$.toast('上传图片失败', 'forbidden');
}
}
$(window).load(function () {
var imageid = $('.group_icon').attr('group-icon');
reqImageDownload(imageid, "jsimageDownload");
});
function jsimageDownload(result, imageid, imageLocalPath) {
var type = getOsType();
if (type == 'Android') {
var html = '<img src="http://akaxin/img' + imageLocalPath + '" style="height:75px; width:75px;" />';
} else {
var html = '<img src="' + imageLocalPath + '" style="height:75px; width:75px;" />';
}
$('.group_icon').html(html);
}
function setGroupInfo(result) {
if (result == 'success') {
$.toast("修改成功");
} else {
$.toast("修改失败", "forbidden");
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,356 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>测试jump跳转</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.basic-color {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:hover {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:active {
background-color: #1E88E5 !important;
color: #FFFFFF;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="weui-cells__title">测试jump跳转</div>
<div class="weui-cells weui-cells_form">
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpGithub">跳转浏览器 github</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpMsg">跳转消息帧</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpContacts">跳转通讯录</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpPersonal">跳转个人帧</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpFriendApply">跳转好友申请列表</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpAddFriend">添加张君为好友 无申请信息</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpAddFriends">添加张君为好友 申请信息:你好么</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpAdminManager">管理后台</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpUserSquer">用户广场</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpNonePlugin">扩展不存在</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpU2msg">张君 u2_msg</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpU2msg_fanzhen">范臻 u2_msg</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpu2Msg_none">人不存在 u2_msg</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpProfile">张君 profile</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpProfile_fanzhen">范臻 profile</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpProfile_none">人不存在 profile</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpGroupmsg">创世开源</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpGroupmsg_100032">100032 huanhang</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpGroupmsg_none">none group</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpGroupProfile">创世开源 profile</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpGroupProfile_100032">100032 huanhang profile</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color" href="javascript:" url-data="/manage/setBasic"
id="jumpGroupProfile_none">none group profile</a>
</div>
<div class="weui-gallery" id="gallery">
<span class="weui-gallery__img" id="galleryImg"></span>
<div class="weui-gallery__opr">
<a href="javascript:" class="weui-gallery__del">
<i class="weui-icon-delete weui-icon_gallery-delete"></i>
</a>
</div>
</div>
</div>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
function jump(msg) {
var type = getOsType();
if (type == 'Android') {
Android.gotoPage(msg);
} else if (type == 'IOS') {
ios_gotoPage(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(document).on("click", "#jumpGithub", function () {
jump("zaly://im.akaxin.com/goto?page=os_browser&page_url=github.com");
});
$(document).on("click", "#jumpContacts", function () {
jump("zaly://im.akaxin.com/goto?page=contacts");
});
$(document).on("click", "#jumpMsg", function () {
jump("zaly://im.akaxin.com/goto?page=message");
});
$(document).on("click", "#jumpPersonal", function () {
jump("zaly://im.akaxin.com/goto?page=personal");
});
$(document).on("click", "#jumpFriendApply", function () {
jump("zaly://im.akaxin.com/goto?page=friend_apply");
});
$(document).on("click", "#jumpAddFriend", function () {
jump("zaly://im.akaxin.com/goto?page=request_friend&site_user_id=186542bb-644d-4aa2-a28c-d774c9cab1af");
});
$(document).on("click", "#jumpAddFriends", function () {
jump("zaly://im.akaxin.com/goto?page=request_friend&site_user_id=186542bb-644d-4aa2-a28c-d774c9cab1af&request_message=你好么");
});
$(document).on("click", "#jumpAdminManager", function () {
jump("zaly://im.akaxin.com/goto?page=plugin&plugin_id=1");
});
$(document).on("click", "#jumpUserSquer", function () {
jump("zaly://im.akaxin.com/goto?page=plugin&plugin_id=2");
});
$(document).on("click", "#jumpNonePlugin", function () {
jump("zaly://im.akaxin.com/goto?page=plugin&plugin_id=200000");
});
$(document).on("click", "#jumpU2msg", function () {
jump("zaly://im.akaxin.com/goto?page=u2_msg&site_user_id=186542bb-644d-4aa2-a28c-d774c9cab1af");
});
$(document).on("click", "#jumpU2msg_fanzhen", function () {
jump("zaly://im.akaxin.com/goto?page=u2_msg&site_user_id=f2aa5de3-ffb6-492b-ba04-64581201b40c");
});
$(document).on("click", "#jumpu2Msg_none", function () {
jump("zaly://im.akaxin.com/goto?page=u2_msg&site_user_id=f2aa5de3-ffb6-492b-ba04-64581201b40cfjdosalfa");
});
$(document).on("click", "#jumpProfile", function () {
jump("zaly://im.akaxin.com/goto?page=user_profile&site_user_id=186542bb-644d-4aa2-a28c-d774c9cab1af");
});
$(document).on("click", "#jumpProfile_fanzhen", function () {
jump("zaly://im.akaxin.com/goto?page=user_profile&site_user_id=f2aa5de3-ffb6-492b-ba04-64581201b40c");
});
$(document).on("click", "#jumpProfile_none", function () {
jump("zaly://im.akaxin.com/goto?page=user_profile&site_user_id=f2aa5de3-ffb6-492b-ba04-64581201b40cfjdosalfa");
});
$(document).on("click", "#jumpGroupmsg", function () {
jump("zaly://im.akaxin.com/goto?page=group_msg&site_group_id=10001");
});
$(document).on("click", "#jumpGroupmsg_100032", function () {
jump("zaly://im.akaxin.com/goto?page=group_msg&site_group_id=100032");
});
$(document).on("click", "#jumpGroupmsg_none", function () {
jump("zaly://im.akaxin.com/goto?page=group_msg&site_group_id=10000032");
});
$(document).on("click", "#jumpGroupProfile", function () {
jump("zaly://im.akaxin.com/goto?page=group_profile&site_group_id=10001");
});
$(document).on("click", "#jumpGroupProfile_100032", function () {
jump("zaly://im.akaxin.com/goto?page=group_profile&site_group_id=100032");
});
$(document).on("click", "#jumpGroupProfile_none", function () {
jump("zaly://im.akaxin.com/goto?page=group_profile&site_group_id=10000032");
});
</script>
</body>
</html>

View File

@ -0,0 +1,173 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>数据报表</title>
</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style>
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.basic-color {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:hover {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:active {
background-color: #1E88E5 !important;
color: #FFFFFF;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="weui-cells__title weui-cell" style="margin: auto;">
<div class="weui-cell__hd"><img src=""></div>
<div class="weui-cell__bd" align="center">
<select id="dayNum" onchange="change(this.options[this.options.selectedIndex].value)">
<option value="6" th:text="${data_6}"></option>
<option value="5" th:text="${data_5}"></option>
<option value="4" th:text="${data_4}"></option>
<option value="3" th:text="${data_3}"></option>
<option value="2" th:text="${data_2}"></option>
<option value="1">昨天数据</option>
<option value="0" selected>当天数据</option>
</select>
<div id="dayNum1"></div>
</div>
</div>
<div class="weui-cells" id="monitor-lists">
</div>
</div>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
$(function () {
sendReq(0);
});
function change(val) {
sendReq(val);
}
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 || u.indexOf('Windows Phone') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(document).on("click", ".OtherDay", function () {
sendReq();
});
function sendReq(dayNum) {
var url = '/monitor/refresh';
var params = {
"dayNum": dayNum.toString(),
};
reqUrl(url, JSON.stringify(params), 'doRefresh');
}
function doRefresh(results) {
$("#monitor-lists").html("");
var res = eval("(" + results + ")");
var htmlTip1 = '<div class="weui-loadmore weui-loadmore_line"><span class="weui-loadmore__tips">当日数据</span></div>';
var html1 = '<div class="weui-cell"><div class="weui-cell__bd"><p>当日注册用户数:</p></div><div class="weui-cell__ft">' + res.registerNum + '</div></div>';
var html2 = '<div class="weui-cell"><div class="weui-cell__bd"><p>当日消息总量(个人+群组):</p></div><div class="weui-cell__ft">' + res.messageNum + '</div></div>';
var html3 = '<div class="weui-cell"><div class="weui-cell__bd"><p>当日群组消息总量:</p></div><div class="weui-cell__ft">' + res.groupMsgNum + '</div></div>';
var html4 = '<div class="weui-cell"><div class="weui-cell__bd"><p>当日个人消息总量:</p></div><div class="weui-cell__ft">' + res.u2MsgNum + '</div></div>';
var htmlTip2 = '<div class="weui-loadmore weui-loadmore_line"><span class="weui-loadmore__tips">全部数据</span></div>';
var html5 = '<div class="weui-cell"><div class="weui-cell__bd"><p>全部用户数量:</p></div><div class="weui-cell__ft">' + res.userNum + '</div></div>';
var html6 = '<div class="weui-cell"><div class="weui-cell__bd"><p>全部群组数量:</p></div><div class="weui-cell__ft">' + res.groupNum + '</div></div>';
var html7 = '<div class="weui-cell"><div class="weui-cell__bd"><p>全部好友对数(互为好友):</p></div><div class="weui-cell__ft">' + res.friendNum + '</div></div>';
$("#monitor-lists").append(htmlTip1);
$("#monitor-lists").append(html1);
$("#monitor-lists").append(html2);
$("#monitor-lists").append(html3);
$("#monitor-lists").append(html4);
$("#monitor-lists").append(htmlTip2);
$("#monitor-lists").append(html5);
$("#monitor-lists").append(html6);
$("#monitor-lists").append(html7);
}
</script>
</body>
</html>

View File

@ -0,0 +1,413 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>添加小程序</title>
</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style>
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.basic-color {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:hover {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:active {
background-color: #1E88E5 !important;
color: #FFFFFF;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="weui-cells__title weui-cell">
基本信息
</div>
<div class="weui-cells ">
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">名称</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input plugin_name" type="text" placeholder="显示给用户看的名字" style="text-align: right;">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">ApiServer地址</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input plugin_api_url" type="text" pattern="[a-z\/0-9]*"
placeholder="纯网页小程序可以不填" style="text-align: right;">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">落地页URL</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input plugin_url_page" type="text" pattern="[a-z0-9]*" placeholder="纯网页小程序请填写页面完整URL" style="text-align: right;">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<div class="weui-uploader">
<div class="weui-uploader__hd">
<p class="weui-uploader__title">Logo</p>
<div class="weui-uploader__info">0/1</div>
</div>
<div class="weui-uploader__bd">
<ul class="weui-uploader__files" id="uploaderFiles">
</ul>
<div class="weui-uploader__input-box">
<input id="uploaderInput" class="weui-uploader__input uploaderInput" type="file"
accept="image/*" multiple="">
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<div class="weui-cells__title weui-cell">
基本设置
</div>
<div class="weui-cells">
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">排序序号</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input order" type="text" pattern="[0-9]*" placeholder="输入序号" style="text-align: right;">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">允许访问的IP</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input allow_ip" type="text" pattern="(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)" placeholder="输入允许访问的IP地址, 用逗号隔开" style="text-align: right;">
</div>
</div>
<a class="weui-cell weui-cell_access position" href="javascript:;">
<div class="weui-cell__bd">
<p>小程序位置</p>
</div>
<div class="weui-cell__ft position-txt">
</div>
</a>
<a class="weui-cell weui-cell_access per_status" href="javascript:;">
<div class="weui-cell__bd">
<p>小程序状态</p>
</div>
<div class="weui-cell__ft per_status-txt">
</div>
</a>
<a class="weui-cell weui-cell_access display_mode" href="javascript:;">
<div class="weui-cell__bd">
<p>展现方式</p>
</div>
<div class="weui-cell__ft display_mode-txt">
</div>
</a>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color addPluginButton" url-data="/plugin/addPlugin"
href="javascript:" id="addPluginButton">确定</a>
</div>
</div>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageUpload(callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageUpload(callback);
} else if (type == 'IOS') {
ios_imageUpload(callback);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageDownload(imageid, callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageDownload(imageid, callback);
} else if (type == 'IOS') {
ios_imageDownload(imageid, callback);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
console.log(msg);
}
}
function isDomain(siteAddress) {
siteAddress=siteAddress.replace(/\s/g,"");
if (siteAddress.indexOf("://") > -1) {
hostname = siteAddress.split('/')[2];
} else {
hostname = siteAddress.split('/')[0];
}
var domain = hostname.split(':')[0];
domain = domain.split('?')[0];
if (domain) {
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(domain)) {
return true;
}
var re2 = /^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/;
if (re2.test(domain)) {
return true;
}
}
return false;
}
$(document).on("click", '.position', function () {
$.actions({
title: "",
onClose: function () {
console.log("close");
},
actions: [{
text: "首页位置",
className: "color-primary weui-dialog__btn ",
onClick: function () {
$(".position-txt").html("首页位置");
$(".position").attr("data", "0");
}
},
{
text: "聊天界面",
className: "color-warning weui-dialog__btn",
onClick: function () {
$(".position-txt").html("聊天界面");
$(".position").attr("data", "1");
}
}
]
});
});
$(document).on("click", '.per_status', function () {
$.actions({
title: "",
onClose: function () {
console.log("close");
},
actions: [{
text: "仅管理员",
className: "color-primary weui-dialog__btn ",
onClick: function () {
$(".per_status-txt").html("仅管理员");
$(".per_status").attr("data", "0");
}
},
{
text: "全员展示",
className: "color-warning weui-dialog__btn",
onClick: function () {
$(".per_status-txt").html("全员展示");
$(".per_status").attr("data", "1");
}
}
]
});
});
$(document).on("click", '.display_mode', function () {
$.actions({
title: "",
onClose: function () {
console.log("close");
},
actions: [{
text: "新页面展示",
className: "color-primary weui-dialog__btn ",
onClick: function () {
$(".display_mode-txt").html("新页面展示");
$(".display_mode").attr("data", "0");
}
},
{
text: "浮屏(聊天界面专用)",
className: "color-warning weui-dialog__btn",
onClick: function () {
$(".display_mode-txt").html("浮屏(聊天界面专用)");
$(".display_mode").attr("data", "1");
}
}
]
});
});
$(document).on("click", ".addPluginButton", function () {
var reqUri = $(this).attr('url-data');
var apiUrl = $('.plugin_api_url').val();
var urlPage = $('.plugin_url_page').val();
var name = $('.plugin_name').val();
var pluginIcon = $('.plugin_icon').attr('plugin-icon');
var position = $(".position").attr("data");
var order = $(".order").val();
var allowIp = $(".allow_ip").val();
var perStatus = $(".per_status").attr("data");
var displayMode = $(".display_mode").attr("data");
if (name.length < 1) {
$.toptip('名称不能为空', 'error');
return false;
}
if (!position || position.length < 1) {
$.toptip('请选择小程序位置', 'error');
return false;
}
if (!perStatus || perStatus.length < 1) {
$.toptip('请选择状态', 'error');
return false;
}
var params = {
'api_url': apiUrl,
'url_page': urlPage,
'name': name,
'plugin_icon': pluginIcon,
'position': position,
'per_status': perStatus,
'order': order,
'allow_ip': allowIp,
'display_mode':displayMode
};
reqUrl(reqUri, JSON.stringify(params), 'addPlugin');
$('.addPluginButton').removeClass('weui-btn_primary');
$('.addPluginButton').removeClass('basic-color');
$('.addPluginButton').removeClass('basic-weui-btn');
$('.addPluginButton').addClass('weui-btn_disabled');
$('.addPluginButton').addClass('weui-btn_default');
$('.addPluginButton').prop('disabled', true);
});
function addPlugin(result) {
$('.addPluginButton').addClass('weui-btn_primary');
$('.addPluginButton').addClass('basic-color');
$('.addPluginButton').addClass('basic-weui-btn');
$('.addPluginButton').removeClass('weui-btn_disabled');
$('.addPluginButton').removeClass('weui-btn_default');
$('.addPluginButton').prop('disabled', false);
if (result == 'success') {
$('input').val('');
$('#uploaderFiles').html('');
$.toast('添加成功');
} else {
$.toast('添加失败', 'forbidden');
}
}
$(document).on("click", '.uploaderInput', function () {
reqImageUpload("jsimageUpload");
});
function jsimageUpload(result, imageId, imageLocalPath) {
var type = getOsType();
if (result == 1) {
if (type == 'Android') {
var img = '<li class="weui-uploader__file plugin_icon" plugin-icon="' + imageId + '"><img src="http://akaxin/img' + imageLocalPath + '" style="height:75px; width:75px;" /></li>';
} else {
var img = '<li class="weui-uploader__file plugin_icon" plugin-icon="' + imageId + '"><img src="' + imageLocalPath + '" style="height:75px; width:75px;" /></li>';
}
$('#uploaderFiles').html(img);
$('.weui-uploader__info').html('1/1');
} else {
$.toast('上传图片失败', 'forbidden');
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>扩展管理-错误提示</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
.icon-box {
margin-bottom: 25px;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center
}
.icon-box i {
margin-right: 18px
}
.icon-box__ctn {
-webkit-flex-shrink: 100;
flex-shrink: 100
}
.icon-box__title {
font-weight: 400
}
.icon-box__desc {
margin-top: 6px;
font-size: 12px;
color: #888
}
.icon_sp_area i:before {
margin-bottom: 5px
}
</style>
</head>
<body ontouchstart="">
<header class='basic-header'>
<h1 class="basic-title">编辑扩展信息</h1>
</header>
<div class='basic-content-padded'>
<div class="icon-box">
<i class="weui-icon-warn weui-icon_msg"></i>
<div class="icon-box__ctn">
<h3 class="icon-box__title">扩展不存在</h3>
<p class="icon-box__desc">当前扩展已经被删除!</p>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,149 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>小程序管理</title>
</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.margin_top_30px {
margin-top: 30px;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="bd margin_top_30px">
<div class="page__bd">
<div class="weui-cells__title"></div>
<div class="weui-cells">
<a class="weui-cell weui-cell_access manage-plugin-add-html" url-data="/plugin/addPage"
href="javascript:;">
<div class="weui-cell__bd">
<p>添加小程序</p>
</div>
<div class="weui-cell__ft">
</div>
</a>
<a class="weui-cell weui-cell_access manage-plugin-html" url-data="/plugin/listPage"
href="javascript:;">
<div class="weui-cell__bd">
<p>小程序列表</p>
</div>
<div class="weui-cell__ft">
</div>
</a>
</div>
</div>
</div>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageUpload(callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageUpload(callback);
} else if (type == 'IOS') {
ios_imageUpload(callback);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageDownload(imageid, callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageDownload(imageid, callback);
} else if (type == 'IOS') {
ios_imageDownload(imageid, callback);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(document).on("click", ".manage-plugin-html", function () {
var reqUri = $(this).attr('url-data');
reqHtml(reqUri, "");
});
$(document).on("click", ".manage-plugin-add-html", function () {
var reqUri = $(this).attr('url-data');
reqHtml(reqUri, "");
});
</script>
</body>
</html>

View File

@ -0,0 +1,210 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>小程序列表</title>
</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="weui-cells__title weui-cell">
小程序列表
</div>
<div class="weui-cells plugin-lists"></div>
<div class="weui-loadmore weui-loadmore_line loadmore_plugin_list">
<span class="weui-loadmore__tips"></span>
</div>
<input type='hidden' id='init_url' url-data="/plugin/pluginList"/>
<input type='hidden' id='del_plugin' plugin-id=""/>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
$(function () {
showList();
});
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageUpload(callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageUpload(callback);
} else if (type == 'IOS') {
ios_imageUpload(callback);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageDownload(imageid, callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageDownload(imageid, callback);
} else if (type == 'IOS') {
ios_imageDownload(imageid, callback);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(document).on('click', '.update-plugin', function () {
var reqUri = $(this).attr('url-data');
var pluginId = $(this).attr('plugin-id');
var params = {
'plugin_id': pluginId,
};
reqHtml(reqUri, JSON.stringify(params));
});
$(document).on("click", ".delete-plugin", function () {
var pluginId = $(this).attr('plugin-id');
var reqUri = $(this).attr('url-data');
$('#del_plugin').attr('plugin-id', pluginId);
$.confirm({
title: '删除插件',
text: '插件删除后,将不能使用!',
onOK: function () {
var params = {
'plugin_id': pluginId,
};
reqUrl(reqUri, JSON.stringify(params), "delPlugin");
delPlugin('success');
$.closeModal();
},
onCancel: function () {
console.log('cancle');
toast('取消操作');
$.closeModal();
}
});
});
function delPlugin(result) {
if (result == 'success') {
var pluginId = $('#del_plugin').attr('plugin-id');
$('#' + pluginId).remove();
$.toast('删除成功');
} else {
$.toast('删除失败', 'forbidden');
}
}
var page = 0;
var loading = false;
function showList() {
if (loading) {
$('.loadmore_plugin_list').addClass('weui-loadmore_line');
$('.loadmore_plugin_list span').html('暂无数据');
$('.loadmore_plugin_list i').remove();
return
}
page = page + 1;
var reqUri = $('#init_url').attr('url-data');
var params = {
"page": page.toString()
};
reqUrl(reqUri, JSON.stringify(params), 'addpluginToList');
loading = true;
}
$(document.body).infinite().on("infinite", function () {
showList();
});
function addpluginToList(results) {
var JsonData = eval("(" + results + ")");
var data = JsonData.pluginData;
var html = '';
$.each(data, function (index, plugin) {
var html = '<a class="weui-cell weui-cell_access update-plugin" url-data="/plugin/editPage" plugin-id="' + plugin.id + '" href="javascript:;" > <div class="weui-cell__bd"> <p>' + plugin.name + '</p> </div> <div class="weui-cell__ft"></div> </a>';
$('.plugin-lists').append(html);
});
loading = JsonData.loading;
if (loading == true) {
$(".weui-loadmore__tips").html("到底啦");
} else {
$(".weui-loadmore__tips").html("加载更多");
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,625 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>编辑小程序</title>
</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style>
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.basic-title {
text-align: center;
font-weight: 400;
color: #1E88E5;
margin: 0 15%;
}
.basic-sub-title {
text-align: center;
color: #1E88E5;
}
.basic-header {
padding: 35px 0;
}
css
.basic-content-padded {
padding: 15px;
}
.margin_top_30px {
margin-top: 30px;
}
.basic-second-title {
text-align: center;
color: #1E88E5;
font-weight: 400;
margin: 0 15%;
}
.basic-weui-grid {
position: relative;
float: left;
padding: 5px;
width: 60px;
height: 60px;
}
.basic-color {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn_primary {
background-color: #1E88E5;
}
.basic-weui-btn {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:hover {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:active {
background-color: #1E88E5 !important;
color: #FFFFFF;
}
.basic-weui-btn_mini {
display: inline-block;
padding: 0 1.32em;
line-height: 2.3;
}
.weui-dialog__btn {
color: #1E88E5;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.basic-color_bg {
background-color: #f4f4f4;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="weui-cells weui-cells_form">
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">ID</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input plugin_id" type="text" th:value="${plugin_id}" style="text-align: right;" disabled="disabled">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">名称</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input plugin_name" type="text" th:value="${name}" placeholder="显示给用户看的名字" style="text-align: right;">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">ApiServer地址</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input plugin_api_url" type="text" th:value="${api_url}" pattern="[a-z0-9]*"
placeholder="纯网页小程序可以不填" style="text-align: right;">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">落地页URL</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input plugin_url_page" type="text" th:value="${url_page}" pattern="[a-z0-9]*"
placeholder="纯网页小程序请填写页面完整URL" style="text-align: right;">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<div class="weui-uploader">
<div class="weui-uploader__hd">
<p class="weui-uploader__title">Logo</p>
<div class="weui-uploader__info" th:if="${plugin_icon}!=null">1/1</div>
<div class="weui-uploader__info" th:unless="${plugin_icon}!=null">0/1</div>
</div>
<div class="weui-uploader__bd">
<ul class="weui-uploader__files" id="uploaderFiles">
<li class="weui-uploader__file plugin_icon" id="plugin_info_icon"
th:attr="plugin-icon=${plugin_icon}" th:if="${plugin_icon}!=null"></li>
</ul>
<div class="weui-uploader__input-box">
<input id="uploaderInput" class="weui-uploader__input uploaderInput" type="file"
accept="image/*" multiple="">
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<div class="weui-cells__title weui-cell">
基本设置
</div>
<div class="weui-cells">
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">排序序号</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input order" type="text" pattern="[0-9]*" th:value="${order}" style="text-align: right;">
</div>
</div>
<a class="weui-cell weui-cell_access position" href="javascript:;" th:attr="data=${position}">
<div class="weui-cell__bd">
<p>小程序位置</p>
</div>
<div class="weui-cell__ft position-txt" th:if="${position} == 0">首页小程序</div>
<div class="weui-cell__ft position-txt" th:unless="${position} == 0">消息帧小程序</div>
</a>
<a class="weui-cell weui-cell_access per_status" href="javascript:;" th:attr="data=${per_status}">
<div class="weui-cell__bd">
<p>小程序状态</p>
</div>
<div class="weui-cell__ft per_status-txt" th:if="${per_status} == 0">仅管理员可用</div>
<div class="weui-cell__ft per_status-txt" th:unless="${per_status} == 0">所有用户可用</div>
</a>
<a class="weui-cell weui-cell_access display_mode" href="javascript:;" th:attr="data=${display_mode}">
<div class="weui-cell__bd">
<p>展现方式</p>
</div>
<div class="weui-cell__ft display_mode-txt" th:if="${display_mode} == 0">新页面</div>
<div class="weui-cell__ft display_mode-txt" th:unless="${display_mode} == 0">浮屏</div>
</a>
</div>
<div th:if="${authKeyState} == 1">
<div class="weui-cells__title weui-cell" th:if="${authKeyState} == 1">
高级设置
</div>
<div class="weui-cells">
<div class="weui-cell">
<div class="weui-cell__hd">密钥(Authkey)</div>
<div class="weui-cell__bd">
<!--<input class="weui-input subgenus_admin" type="text" th:value="${auth_key}" style="text-align: right;"-->
<!--disabled>-->
<div class="weui-cell__ft">
<a href="javascript:;"
class="weui-btn basic-weui-btn generate-authKey weui-btn_mini basic-color"
url-data="/plugin/reSet" th:attr="plugin-id=${plugin_id}" style="text-align: left;">生成新的秘钥</a>
</div>
</div>
<br>
</div>
<div class="weui-cell">
<button class="weui-input subgenus_admin authkey" th:text="${auth_key}"
th:attr="data-clipboard-text=${auth_key}"></button>
</div>
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">允许访问的IP</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input allow_ip" type="text"
pattern="(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)"
th:value="${allow_ip}" style="text-align: right;">
</div>
</div>
</div>
</div>
<div class="weui-btn-area">
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color update_plugin_info"
url-data="/plugin/editPlugin"
href="javascript:" id="addPluginButton" th:attr="plugin-id=${plugin_id}">确定</a>
<a class="weui-btn weui-btn_warn delete-plugin" url-data="/plugin/delPlugin" href="javascript:"
id="addPluginButton" th:attr="plugin-id=${plugin_id}">删除小程序</a>
</div>
<input type='hidden' id='host_name'/>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type='text/javascript'
src="https://cdn.staticfile.org/clipboard.js/1.5.15/clipboard.min.js"></script>
<script type="text/javascript">
var clipboard = new Clipboard('.authkey');
clipboard.on('success', function () {
$.toast('复制成功');
});
clipboard.on('error', function () {
$.toast('复制失败', 'forbidden');
});
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageUpload(callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageUpload(callback);
} else if (type == 'IOS') {
ios_imageUpload(callback);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageDownload(imageid, callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageDownload(imageid, callback);
} else if (type == 'IOS') {
ios_imageDownload(imageid, callback);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
function isDomain(siteAddress) {
siteAddress=siteAddress.replace(/\s/g,"");
if (siteAddress.indexOf("://") > -1) {
hostname = siteAddress.split('/')[2];
} else {
hostname = siteAddress.split('/')[0];
}
var domain = hostname.split(':')[0];
domain = domain.split('?')[0];
if (domain) {
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(domain)) {
return true;
}
var re2 = /^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/;
if (re2.test(domain)) {
return true;
}
}
return false;
}
$(document).on("click", ".delete-plugin", function () {
var pluginId = $(this).attr('plugin-id');
var reqUri = $(this).attr('url-data');
$('#del_plugin').attr('plugin-id', pluginId);
$.confirm({
title: '删除',
text: '删除后,将不能使用!',
onOK: function () {
var params = {
'plugin_id': pluginId,
};
reqUrl(reqUri, JSON.stringify(params), "delPlugin");
$.closeModal();
},
onCancel: function () {
console.log('cancle');
toast('取消操作');
$.closeModal();
}
});
});
function delPlugin(result) {
if (result == 'success') {
$('.update_plugin_info').removeClass('weui-btn_primary');
$('.update_plugin_info').removeClass('basic-color');
$('.update_plugin_info').removeClass('basic-weui-btn');
$('.update_plugin_info').addClass('weui-btn_disabled');
$('.update_plugin_info').addClass('weui-btn_default');
$('.update_plugin_info').prop('disabled', true);
$('.delete-plugin').addClass('weui-btn_disabled');
$('.delete-plugin').prop('disabled', true);
$.toast('删除成功');
} else {
$.toast('删除失败', 'forbidden');
}
}
$(document).on('click', ".update_plugin_info", function () {
var pluginId = $(this).attr('plugin-id');
var reqUri = $(this).attr('url-data');
var apiUrl = $('.plugin_api_url').val();
var urlPage = $('.plugin_url_page').val();
var name = $('.plugin_name').val();
var pluginIcon = $('.plugin_icon').attr('plugin-icon');
var perStatus = $(".per_status").attr("data");
var position = $(".position").attr("data");
var order = $(".order").val();
var allowIp = $(".allow_ip").val();
var displayMode = $(".display_mode").attr("data");
if (!name || name.length < 1) {
$.toptip('名称不能为空', 'error');
return false;
}
if (!position || position.length < 1) {
$.toptip('请选择小程序位置', 'error');
return false;
}
if (!perStatus || perStatus.length < 1) {
$.toptip('请选择状态', 'error');
return false;
}
$.confirm({
title: '修改',
text: '修改后,将会更新原有信息!',
onOK: function () {
var params = {
'plugin_id': pluginId,
'url_page': urlPage,
'api_url': apiUrl,
'per_status': perStatus,
'position': position,
'plugin_icon': pluginIcon,
'name': name,
'order': order,
'allow_ip': allowIp,
'display_mode':displayMode
};
reqUrl(reqUri, JSON.stringify(params), "updatePlugin");
$('.update_plugin_info').removeClass('weui-btn_primary');
$('.update_plugin_info').removeClass('basic-color');
$('.update_plugin_info').removeClass('basic-weui-btn');
$('.update_plugin_info').addClass('weui-btn_disabled');
$('.update_plugin_info').addClass('weui-btn_default');
$('.update_plugin_info').prop('disabled', true);
$.closeModal();
},
onCancel: function () {
console.log('cancle');
toast('取消操作');
$.closeModal();
}
});
});
function updatePlugin(result) {
$('.update_plugin_info').addClass('weui-btn_primary');
$('.update_plugin_info').addClass('basic-color');
$('.update_plugin_info').addClass('basic-weui-btn');
$('.update_plugin_info').removeClass('weui-btn_disabled');
$('.update_plugin_info').removeClass('weui-btn_default');
$('.update_plugin_info').prop('disabled', false);
if (result == 'success') {
$.toast('修改成功');
} else {
$.toast('修改失败', 'forbidden');
}
}
$(document).on("click", '.uploaderInput', function () {
reqImageUpload("imageUpload");
});
function imageUpload(result, imageId, imageLocalPath) {
var type = getOsType();
if (result == 1) {
if (type == 'Android') {
var img = '<li class="weui-uploader__file plugin_icon" plugin-icon="' + imageId + '"><img src="http://akaxin/img' + imageLocalPath + '" style="height:75px; width:75px;" /></li>';
} else {
var img = '<li class="weui-uploader__file plugin_icon" plugin-icon="' + imageId + '"><img src="' + imageLocalPath + '" style="height:75px; width:75px;" /></li>';
}
$('#uploaderFiles').html(img);
$('.weui-uploader__info').html('1/1');
} else {
$.toast('图片上传失败', 'forbidden');
}
}
$('.plugin_icon').ready(function () {
var pluginIcon = $('.plugin_icon').attr('plugin-icon');
reqImageDownload(pluginIcon, "jsimageDownload");
});
function jsimageDownload(result, imageid, imageLocalPath) {
var type = getOsType();
if (type == 'Android') {
var html = '<img src="http://akaxin/img' + imageLocalPath + '" style="height:75px; width:75px;" />';
} else {
var html = '<img src="' + imageLocalPath + '" style="height:75px; width:75px;" />';
}
$('.plugin_icon').html(html);
}
$(document).on("click", '.position', function () {
$.actions({
title: "",
onClose: function () {
console.log("close");
},
actions: [{
text: "首页位置",
className: "color-primary weui-dialog__btn ",
onClick: function () {
$(".position-txt").html("首页位置");
$(".position").attr("data", "0");
}
},
{
text: "聊天界面",
className: "color-warning weui-dialog__btn",
onClick: function () {
$(".position-txt").html("聊天界面");
$(".position").attr("data", "1");
}
}
]
});
});
$(document).on("click", ".generate-authKey", function () {
var pluginId = $(this).attr('plugin-id');
var reqUri = $(this).attr('url-data');
$.confirm({
title: '重置AuthKey',
text: '确定在重置AuthKey?',
onOK: function () {
var params = {
'plugin_id': pluginId,
};
reqUrl(reqUri, JSON.stringify(params), "generateAuthKey");
$.closeModal();
},
onCancel: function () {
console.log('cancle');
toast('取消操作');
$.closeModal();
}
});
});
function generateAuthKey(result) {
if (result == 'false') {
$.toast("重置失败", "forbidden");
} else {
$.toast("重置成功");
$('.authkey').html(result);
$('.authkey').attr('data-clipboard-text', result);
}
}
$(document).on("click", '.per_status', function () {
$.actions({
title: "",
onClose: function () {
console.log("close");
},
actions: [{
text: "仅管理员可用",
className: "color-primary weui-dialog__btn ",
onClick: function () {
$(".per_status-txt").html("仅管理员可用");
$(".per_status").attr("data", "0");
}
},
{
text: "所有用户可用",
className: "color-warning weui-dialog__btn",
onClick: function () {
$(".per_status-txt").html("所有用户可用");
$(".per_status").attr("data", "1");
}
}
]
});
});
$(document).on("click", '.display_mode', function () {
$.actions({
title: "",
onClose: function () {
console.log("close");
},
actions: [{
text: "新页面展示",
className: "color-primary weui-dialog__btn ",
onClick: function () {
$(".display_mode-txt").html("新页面展示");
$(".display_mode").attr("data", "0");
}
},
{
text: "浮屏(聊天界面专用)",
className: "color-warning weui-dialog__btn",
onClick: function () {
$(".display_mode-txt").html("浮屏(聊天界面专用)");
$(".display_mode").attr("data", "1");
}
}
]
});
});
</script>
</div>
</body>
</html>

View File

@ -0,0 +1,70 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>用户广场</title>
</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<link rel="stylesheet" href-data="/Public/css/style.css"/>
<style type="text/css">
> .icon-box {
margin-bottom: 25px;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center
}
.icon-box i {
margin-right: 18px
}
.icon-box__ctn {
-webkit-flex-shrink: 100;
flex-shrink: 100
}
.icon-box__title {
font-weight: 400
}
.icon-box__desc {
margin-top: 6px;
font-size: 12px;
color: #888
}
.icon_sp_area {
margin-top: 10px;
text-align: left
}
.icon_sp_area i:before {
margin-bottom: 5px
}
</style>
</head>
<body ontouchstart="">
<header class='basic-header'>
<h1 class="basic-title">用户广场</h1>
</header>
<div class='basic-content-padded'>
<div class="icon-box">
<i class="weui-icon-warn weui-icon_msg"></i>
<div class="icon-box__ctn">
<h3 class="icon-box__title">请求失败</h3>
<p class="icon-box__desc">请联系站点管理人员</p>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,310 @@
<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>用户广场</title>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style>
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.basic-title {
text-align: center;
font-weight: 400;
color: #1E88E5;
margin: 0 15%;
}
.basic-sub-title {
text-align: center;
color: #1E88E5;
}
.basic-header {
padding: 35px 0;
}
css
.basic-content-padded {
padding: 15px;
}
.basic-second-title {
text-align: center;
color: #1E88E5;
font-weight: 400;
margin: 0 15%;
}
.basic-weui-grid {
position: relative;
float: left;
padding: 5px;
width: 60px;
height: 60px;
}
.basic-color {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn_primary {
background-color: #1E88E5;
}
.basic-weui-btn {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:hover {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:active {
background-color: #1E88E5 !important;
color: #FFFFFF;
}
.basic-weui-btn_mini {
display: inline-block;
padding: 0 1.32em;
line-height: 2.3;
}
.weui-dialog__btn {
color: #1E88E5;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.basic-color_bg {
background-color: #f4f4f4;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart=''>
<div class="weui-cells" id='member-lists' style="margin-top: 0px;">
</div>
<input type='hidden' id='init_url' url-data="/userSquare/pullMemberList"/>
<input type='hidden' id='site_user_id' th:attr="data=${site_user_id},user-name=${site_user_name}"/>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
$(function () {
$('#member-lists').html("");
loadSiteMember();
});
var page = 0;
var loading = false;
// 下拉加载更多数据
$(document.body).infinite().on("infinite", function () {
if(page == 0){
$('#member-lists').html("");
}
loadSiteMember();
});
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 || u.indexOf('Windows Phone') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageUpload(callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageUpload(callback);
} else if (type == 'IOS') {
ios_imageUpload(callback);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageDownload(imageid, callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageDownload(imageid, callback);
} else if (type == 'IOS') {
ios_imageDownload(imageid, callback);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(document).on("click", ".add-member-friend", function () {
var siteUserId = $(this).attr('data');
var url = $(this).attr('url-data');
var siteUserName = $('#site_user_id').attr('user-name');
var applyReason = "";
if (siteUserName.length > 0) {
applyReason = "你好,我是 " + siteUserName;
}
$.prompt({
input: applyReason,
text: "",
title: "申请添加好友",
onOK: function (text) {
var userInfo = {
'site_user_id': siteUserId,
"apply_reason": text
};
reqUrl(url, JSON.stringify(userInfo), "applyFriend");
},
onCancel: function () {
console.log('cancle');
toast('取消操作');
$.closeModal();
},
});
});
function loadSiteMember() {
if (loading) {
$('.loadmore_site_member').addClass('weui-loadmore_line');
$('.loadmore_site_member span').html('暂无数据');
$('.loadmore_site_member i').remove();
return false;
}
page = page + 1;
var reqUri = $('#init_url').attr('url-data');
var params = {
"pageNum": page.toString()
};
reqUrl(reqUri, JSON.stringify(params), 'addMemberToList');
}
function addMemberToList(results) {
results = eval("(" + results + ")");
var data = results.Data;
var currentSiteUserId = $('#site_user_id').attr('data');
$.each(data, function (index, user) {
var imageid = user.site_user_photo;
if (currentSiteUserId != user.site_user_id) {
var html = '<div class="weui-cell">'
+'<div class="weui-cell__hd user-photo" id="'+imageid+'"><img src="#" style="height:55px; width:55px;border-radius:50%" /></div>';
//+'<div class="weui-cell__bd"><p>' + user.site_user_name + '</p><p>' + user.site_user_name + '</p></div>';
if (user.site_user_relation == 1) {
html +='<div class="weui-cell__bd"><p>' + user.site_user_name + '</p><p style="color:#9b9b9b;font-size:12px;">TA是你的好友</p></div>';
html +='<p style="color:#9b9b9b;font-size:14px;"><i class="weui-icon-success-no-circle"></i></p>';
} else {
html +='<div class="weui-cell__bd"><p>' + user.site_user_name + '</p><p style="color:#9b9b9b;font-size:12px;">点击添加好友</p></div>'
+ '<a href="javascript:;" class="weui-btn basic-weui-btn weui-btn_mini add-member-friend" data="' + user.site_user_id + '" url-data="/userSquare/applyFriend">添加好友</a>';
}
html += '</div>';
$('#member-lists').append(html);
if(imageid!=null && imageid!=""){
reqImageDownload(imageid, "reloadUserPhoto");
}
}
});
loading = results.loading;
if (loading == true) {
$(".weui-loadmore__tips").html("没有更多数据了");
} else {
$(".weui-loadmore__tips").html("加载更多");
}
}
function reloadUserPhoto(success, imageid, imageLocalPath) {
var type = getOsType();
var imgSrc = imageLocalPath;
if (type == 'Android') {
imgSrc = "http://akaxin/img" + imageLocalPath;
}
var html = '<img src="' + imgSrc + '" style="height:50px; width:50px;border-radius:50%" />';
$('#'+imageid).html(html);
}
function applyFriend(result) {
result = eval("(" + result + ")");
if (result[0] == '成功') {
$.toast("发送请求成功");
var $1 = $('[data=' + result[1] + ']');
$1.attr("style", "color:#9b9b9b;font-size:14px;");
$1.attr("class", "");
$1.html("等待通过");
} else {
$.toast(result[0], "forbidden");
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,141 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>邀请码</title>
</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.margin_top_30px {
margin-top: 30px;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="bd margin_top_30px">
<div class="page__bd">
<div class="weui-cells__title"></div>
<div class="weui-cells">
<a class="weui-cell weui-cell_access invite-code-unused" url-data="/uic/unused"
href="javascript:;">
<div class="weui-cell__bd">
<p>未使用列表</p>
</div>
<div class="weui-cell__ft">
</div>
</a>
<a class="weui-cell weui-cell_access invite-code-used" url-data="/uic/used"
href="javascript:;">
<div class="weui-cell__bd">
<p>已使用列表</p>
</div>
<div class="weui-cell__ft">
</div>
</a>
</div>
</div>
</div>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 || u.indexOf('Windows Phone') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(document).on("click", ".invite-code-used", function () {
var url = $(this).attr('url-data');
var params = {
'code_status': 'used',
};
reqHtml(url, JSON.stringify(params));
});
$(document).on("click", ".invite-code-unused", function () {
var url = $(this).attr('url-data');
var params = {
'code_status': 'unused',
};
reqHtml(url, JSON.stringify(params));
});
$(document).on("click", ".invite-code-inval", function () {
var url = $(this).attr('url-data');
var params = {
'code_status': 'invalidation',
};
reqHtml(url, JSON.stringify(params));
});
</script>
</body>
</html>

View File

@ -0,0 +1,239 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>未使用列表</title>
</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style>
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.basic-color {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:hover {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:active {
background-color: #1E88E5 !important;
color: #FFFFFF;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="weui-cells__title weui-cell" style="margin: auto;">
<div class="weui-cell__hd"><img src=""></div>
<div class="weui-cell__bd">
<p>未使用列表</p>
</div>
<div class="weui-cell__ft">
<a href="javascript:;" class="weui-btn basic-weui-btn generate-code weui-btn_mini basic-color"
url-data="/uic/addUic" style="text-align: left;">生成新的邀请码</a>
</div>
</div>
<div class="weui-cells" id="invitecode-lists">
</div>
<div class="weui-loadmore weui-loadmore_line loadmore_site_invitecode">
<span class="weui-loadmore__tips"></span>
</div>
</div>
<input type='hidden' id='init_url' url-data="/uic/uicList" data-type="unused"/>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
//初始化事件
$(function () {
unusedlist();
});
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 || u.indexOf('Windows Phone') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
function refreshCurrentPage() {
var type = getOsType();
if (type == 'Android') {
Android.refreshCurrentPage();
}
}
$(document).on("click", ".generate-code", function () {
var url = $(this).attr('url-data');
$.confirm({
title: '生成邀请码',
text: '确定在生成一批新的邀请码?',
onOK: function () {
reqUrl(url, "", "generateInviteCode");
$.closeModal();
},
onCancel: function () {
console.log('cancle');
toast('取消操作');
$.closeModal();
}
});
});
function generateInviteCode(result) {
if (result == 'success') {
$.toast("生成成功");
// refreshCurrentPage();
var params = {
"page": "1",
"code_status": "0"
};
reqUrl("/uic/uicList", JSON.stringify(params), "redisplay");
} else if (result == 'NO_PERMISSION') {
$.toast("没有权限,请稍后再试", "forbidden");
} else {
$.toast("生成失败", "forbidden");
}
}
var page = 0;
var loading = false;
function unusedlist() {
if (loading) {
$('.loadmore_site_invitecode').addClass('weui-loadmore_line');
$('.loadmore_site_invitecode span').html('暂无数据');
$('.loadmore_site_invitecode i').remove();
return
}
page = page + 1;
var reqUri = $('#init_url').attr('url-data');
var codeStatus = $('#init_url').attr('data-type');
if (codeStatus == "unused") {
codeStatus = 0;
} else {
codeStatus = 1;
}
var params = {
"page": page.toString(),
"code_status": codeStatus.toString()
};
reqUrl(reqUri, JSON.stringify(params), 'addInviteCodeToList');
loading = true;
}
$(document.body).infinite().on("infinite", function () {
unusedlist();
});
function addInviteCodeToList(results) {
var res = eval("(" + results + ")");
var data = res.uicData;
var html = '';
$.each(data, function (index, uic) {
var html = '<div class="weui-cell"> <div class="weui-cell__bd"> <p>' + uic.uic + '</p> </div> </div>';
$('#invitecode-lists').append(html);
});
loading = res.loading;
if (loading == true) {
$(".weui-loadmore__tips").html("到底啦");
} else {
$(".weui-loadmore__tips").html("加载更多");
}
}
function redisplay(results) {
$('#invitecode-lists').html("");
var res = eval("(" + results + ")");
var data = res.uicData;
var html = '';
$.each(data, function (index, uic) {
var html = '<div class="weui-cell"> <div class="weui-cell__bd"> <p>' + uic.uic + '</p> </div> </div>';
$('#invitecode-lists').append(html);
});
loading = res.loading;
if (loading == true) {
$(".weui-loadmore__tips").html("到底啦");
} else {
$(".weui-loadmore__tips").html("加载更多");
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,155 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>已使用列表</title>
</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style>
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="weui-cells__title weui-cell">
已使用列表
</div>
<div class="weui-cells" id="invitecode-lists">
</div>
<div class="weui-loadmore weui-loadmore_line loadmore_site_invitecode">
<span class="weui-loadmore__tips"></span>
</div>
<input type='hidden' id='init_url' url-data="/uic/uicList" data-type="used"/>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
//初始化事件
$(function () {
usedlist();
});
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 || u.indexOf('Windows Phone') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
var page = 0;
var loading = false;
function usedlist() {
if (loading) {
$('.loadmore_site_invitecode').addClass('weui-loadmore_line');
$('.loadmore_site_invitecode span').html('暂无数据');
$('.loadmore_site_invitecode i').remove();
return
}
page = page + 1;
var reqUri = $('#init_url').attr('url-data');
var codeStatus = $('#init_url').attr('data-type');
if (codeStatus == "unused") {
codeStatus = 0;
} else {
codeStatus = 1;
}
var params = {
"page": page.toString(),
"code_status": codeStatus.toString()
};
reqUrl(reqUri, JSON.stringify(params), 'addInviteCodeToList');
loading = true;
}
$(document.body).infinite().on("infinite", function () {
usedlist();
});
function addInviteCodeToList(results) {
console.log('回调-addInviteCodeToList');
var res = eval("(" + results + ")");
var data = res.uicData;
var html = '';
$.each(data, function (index, uic) {
var html = '<div class="weui-cell"> <div class="weui-cell__bd"> <p>' + uic.uic + '</p> </div> <div class="weui-cell__ft">' + uic.siteUserName + '</div> </div>';
$('#invitecode-lists').append(html);
});
loading = res.loading;
if (loading == true) {
$(".weui-loadmore__tips").html("到底啦");
} else {
$(".weui-loadmore__tips").html("加载更多");
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,68 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>编辑用户信息-报错页面</title>
</title>
<!-- 引入 WeUI -->
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
.icon-box {
margin-bottom: 25px;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center
}
.icon-box i {
margin-right: 18px
}
.icon-box__ctn {
-webkit-flex-shrink: 100;
flex-shrink: 100
}
.icon-box__title {
font-weight: 400
}
.icon-box__desc {
margin-top: 6px;
font-size: 12px;
color: #888
}
.icon_sp_area {
margin-top: 10px;
text-align: left
}
.icon_sp_area i:before {
margin-bottom: 5px
}
</style>
</head>
<body ontouchstart="">
<header class='basic-header'>
<h1 class="basic-title">编辑用户信息</h1>
</header>
<div class='basic-content-padded'>
<div class="icon-box">
<i class="weui-icon-warn weui-icon_msg"></i>
<div class="icon-box__ctn">
<h3 class="icon-box__title">用户不存在</h3>
<p class="icon-box__desc">当前用户已经删除站点身份,或者当前用户已经处于封禁状态!</p>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,238 @@
<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<title>用户管理</title>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
<style type="text/css">
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.basic-color_bg {
background-color: #f4f4f4;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart>
<div class="weui-pull-to-refresh__layer">
<div class='weui-pull-to-refresh__arrow'></div>
<div class='weui-pull-to-refresh__preloader'></div>
<div class="down">下拉刷新</div>
<div class="up">释放刷新</div>
<div class="refresh">正在刷新</div>
</div>
<div class="defaultFriends">
<div class="weui-cells__title weui-cell default_user_lists" th:unless="${userDefaultSize} == 0">
站点默认好友列表
</div>
<div class="weui-cells demos-content-padded default_user_lists" id='default_user_lists'
th:unless="${userDefaultSize} == 0">
<a class="weui-cell weui-cell_access update-site-user" th:each="user:${userList}" url-data="/user/profile"
th:attr="id=${user.siteUserId}"
href="javascript:;">
<div class="weui-cell__hd" name="user_image" th:attr="id=${user.userPhoto}"></div>
<div class="weui-cell__bd site_user_name"><p th:text="${user.userName}"></p></div>
<div class="weui-cell__ft"></div>
</a>
</div>
</div>
<div class="siteMembers">
<div class="weui-cells__title weui-cell ">
站点成员列表
</div>
<div class="weui-cells demos-content-padded" id='user-lists'>
</div>
</div>
<!-- <input type='hidden' id='init_url' url-data='/user/userList'> -->
<div class="weui-loadmore weui-loadmore_line loadmore_site_user ">
<span class="weui-loadmore__tips basic-color_bg"></span>
</div>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 || u.indexOf('Windows Phone') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageUpload(callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageUpload(callback);
} else if (type == 'IOS') {
ios_imageUpload(callback);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageDownload(imageid, callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageDownload(imageid, callback);
} else if (type == 'IOS') {
ios_imageDownload(imageid, callback);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(function () {
$('#user-lists').html("");
userList();
});
var page = 0;
var loading = false;
$(document.body).infinite().on("infinite", function () {
if(page == 0){
$('#user-lists').html("");
}
userList()
});
$(document).on('click', ".update-site-user", function () {
var siteUserId = $(this).attr('id');
var reqUri = $(this).attr('url-data');
var userInfo = {
'site_user_id': siteUserId,
};
reqHtml(reqUri, JSON.stringify(userInfo));
});
function userList() {
if (loading) {
$('.loadmore_site_user').addClass('weui-loadmore_line');
$('.loadmore_site_user span').html('到底啦');
return
}
page = page + 1;
//var reqUri = $('#init_url').attr('url-data');
var reqUri = "/user/userList";
var params = {
"page": page.toString(),
};
reqUrl(reqUri, JSON.stringify(params), 'addUserToList');
}
function addUserToList(results) {
results = eval("(" + results + ")");
var data = results.userData;
var html = '';
$.each(data, function (index, user) {
var html = '<a class="weui-cell weui-cell_access update-site-user" url-data="/user/profile" id="' + user.siteUserId + '" href="javascript:;" > <div class="weui-cell__hd" name="user_image" id="' + user.userPhoto + '" > </div> <div class="weui-cell__bd site_user_name" > <p>' + user.userName + '</p> </div> <div class="weui-cell__ft"></div> </a>';
$('#user-lists').append(html);
});
loading = results.loading;
if (loading == true) {
$(".weui-loadmore__tips").html("没有更多数据了");
} else {
$(".weui-loadmore__tips").html("加载更多");
}
}
$(document.body).pullToRefresh(function () {
reqUrl("/user/refresh", null, "doRefresh");
$('#user-lists').html("");
page = 0;
loading = false;
userList();
$(document.body).pullToRefreshDone();
});
function doRefresh(results) {
results = eval("(" + results + ")");
var size = results.size;
if (size <= 0) {
$('.defaultFriends').html("");
} else {
$('.defaultFriends').html("");
var defHtml = '<div class="weui-cells__title weui-cell default_user_lists" th:unless="${userDefaultSize} == 0">站点默认好友列表</div>' +
'<div class="weui-cells demos-content-padded default_user_lists" id=\'default_user_lists\' th:unless="${userDefaultSize} == 0"></div>';
$('.defaultFriends').append(defHtml);
var data = results.data;
var html = '';
$.each(data, function (index, user) {
var html = '<a class="weui-cell weui-cell_access update-site-user" url-data="/user/profile" id="' + user.siteUserId + '" href="javascript:;" > <div class="weui-cell__hd" name="user_image" id="' + user.userPhoto + '" > </div> <div class="weui-cell__bd site_user_name" > <p>' + user.userName + '</p> </div> <div class="weui-cell__ft"></div> </a>';
$('#' + user.siteUserId).remove();
$('#default_user_lists').append(html);
});
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,413 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,initial-scale=1,user-scalable=0">
<title>编辑用户信息</title>
<!-- 引入 WeUI -->
<link rel="stylesheet"
href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css" />
<link rel="stylesheet"
href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css" />
<style type="text/css">
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.margin_top_30px {
margin-top: 30px;
}
.basic-color {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:hover {
background-color: #1E88E5;
color: #FFFFFF;
}
.basic-weui-btn:active {
background-color: #1E88E5 !important;
color: #FFFFFF;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div class="weui-cells weui-cells_form margin_top_30px">
<input class="site_user_id" type="hidden" th:attr="data=${siteUserId}">
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">用户昵称</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input user_name" type="text" name="user_name"
th:value="${userName}" placeholder="用户昵称" maxlength="16">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">站点账号</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input site_login_id" type="text"
name="site_login_id" th:value="${siteLoginId}" placeholder="站点账号"
maxlength="16">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<div class="weui-uploader">
<div class="weui-uploader__hd">
<p class="weui-uploader__title">图片上传</p>
<div class="weui-uploader__info" th:if="${userPhoto}!=null">1/1</div>
<div class="weui-uploader__info" th:unless="${userPhoto}!=null">0/1</div>
</div>
<div class="weui-uploader__bd">
<ul class="weui-uploader__files" id="uploaderFiles">
<li class="weui-uploader__file user_photo" id="user_photo"
th:attr="user-photo=${userPhoto}" th:if="${userPhoto}!=null"></li>
</ul>
<div class="weui-uploader__input-box">
<input id="uploaderInput"
class="weui-uploader__input uploaderInput" type="file"
accept="image/*" multiple="">
</div>
</div>
</div>
</div>
</div>
<div class="weui-btn-area">
<a
class="weui-btn basic-weui-btn weui-btn_primary basic-color update_user_info"
url-data="/user/updateProfile" href="javascript:"
id="update_user_info">确定</a>
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color site_manager"
url-data="/user/setSiteManager" href="javascript:" id="site_manager"
th:if="${managerState}==0" th:attr="managerState=${managerState}">设为管理员身份</a>
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color site_manager"
url-data="/user/deleteSiteManager" href="javascript:"
id="site_manager" th:if="${managerState}==1"
th:attr="managerState=${managerState}">删除管理员身份</a>
<a class="weui-btn basic-weui-btn weui-btn_primary basic-color user_default"
url-data="/user/setUserDefaultFriend" href="javascript:"
id="user_default" th:if="${defaultState}==0"
th:attr="defaultState=${defaultState}">设为新用户默认好友</a> <a
class="weui-btn basic-weui-btn weui-btn_primary basic-color user_default"
url-data="/user/deleteUserDefaultFriend" href="javascript:"
id="user_default" th:if="${defaultState}==1"
th:attr="defaultState=${defaultState}">取消新用户默认好友</a>
<a href="javascript:;" name='sealup-user' th:attr="data=${siteUserId},userStatus=${userStatus}"
class="sealup-site-user weui-btn weui-btn_warn " url-data="/user/sealup" th:if="${userStatus}==0" >封禁用户</a>
<a href="javascript:;" name='sealup-user' th:attr="data=${siteUserId},userStatus=${userStatus}"
class="sealup-site-user weui-btn weui-btn_warn" url-data="/user/sealup" th:if="${userStatus}==1">解封用户</a>
<!-- 删除用户 -->
<a class="weui-btn weui-btn_warn delUser" url-data="/user/delUser"
href="javascript:" id="delUser">删除用户</a>
</div>
</div>
<script type="text/javascript"
src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript"
src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript"
src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1
|| u.indexOf('Windows Phone') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqUrl(reqUri, params, callbackName) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
//console.log('utl' + type);
if (type == 'Android') {
Android.requestPost(reqUri, params, callbackName);
} else if (type == 'IOS') {
ios_requestPost(reqUri, params, callbackName);
} else {
$.toast('暂时不支持该设备');
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
if (type == 'Android') {
Android.requestPage(reqUri, params)
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageUpload(callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageUpload(callback);
} else if (type == 'IOS') {
ios_imageUpload(callback);
} else {
$.toast('暂时不支持该设备');
}
}
function reqImageDownload(imageid, callback) {
var type = getOsType();
if (type == 'Android') {
Android.imageDownload(imageid, callback);
} else if (type == 'IOS') {
ios_imageDownload(imageid, callback);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(document).on("click", ".sealup-site-user", function() {
var siteUserId = $(this).attr('data');
var url = $(this).attr('url-data');
var userStatus = $(this).attr('userStatus');
var confirmTitle = "确定要封禁用户?";
var status = "1";
if(userStatus==1){
confirmTitle = "确认要解封用户?";
status = "0";
}
$.confirm({
title : confirmTitle,
//text : confirmText,
onOK : function() {
var userInfo = {
'site_user_id' : siteUserId,
'user_status' : status
};
reqUrl(url, JSON.stringify(userInfo), "sealupSiteUser");
$.closeModal();
},
onCancel : function() {
toast('取消操作');
$.closeModal();
}
});
});
function sealupSiteUser(results) {
if (results == 'success') {
var userStatus = $('.sealup-site-user').attr('userStatus');
if(userStatus == 0){
$('.sealup-site-user').attr('userStatus', '1');
$('.sealup-site-user').html('解封用户');
}else if(userStatus == 1){
$('.sealup-site-user').attr('userStatus', '0');
$('.sealup-site-user').html('封禁用户');
}
$.toast("操作成功");
} else {
$.toast("操作失败", "forbidden");
}
}
$(document).on("click", ".update_user_info", function() {
var userName = $('.user_name').val();
var siteLoginId = $('.site_login_id').val();
var siteUserId = $('.site_user_id').attr('data');
var userPhoto = $('.user_photo').attr('user-photo');
$('#edit_user_id').attr('user_name', userName);
var userInfo = {
"siteUserId" : siteUserId,
"siteLoginId" : siteLoginId,
"userName" : userName,
"userPhoto" : userPhoto
};
var reqUri = $(this).attr('url-data');
reqUrl(reqUri, JSON.stringify(userInfo), 'updateSiteUser');
});
function updateSiteUser(results) {
if (results == 'success') {
var userName = $('#edit_user_id').attr('user_name');
$('.user_name').attr('value', userName);
$.toast("操作成功");
} else {
$.toast("操作失败", "forbidden");
}
}
$(document).on("click", ".site_manager", function() {
var siteUserId = $('.site_user_id').attr('data');
var userInfo = {
"siteUserId" : siteUserId
};
var reqUri = $(this).attr('url-data');
reqUrl(reqUri, JSON.stringify(userInfo), 'siteManagerResult');
});
function siteManagerResult(results) {
if (results == 'success') {
var managerStatus = $('.site_manager').attr('managerState');
if(managerStatus==0){
$('.site_manager').attr('managerState', '1');
$('.site_manager').attr('url-data', '/user/deleteSiteManager');
$('.site_manager').html('取消管理员身份');
}else if(managerStatus==1){
$('.site_manager').attr('managerState', '0');
$('.site_manager').attr('url-data', '/user/setSiteManager');
$('.site_manager').html('设为管理员身份');
}
$.toast("操作成功");
} else {
$.toast("操作失败", "forbidden");
}
}
$(document).on("click", ".user_default", function() {
var siteUserId = $('.site_user_id').attr('data');
var userInfo = {
"siteUserId" : siteUserId
};
var reqUri = $(this).attr('url-data');
reqUrl(reqUri, JSON.stringify(userInfo), 'userDefaultResult');
});
function userDefaultResult(results) {
if (results == 'success') {
$.toast("操作成功");
var attr = $('.user_default').attr('defaultState');
if (attr == '0') {
$('.user_default').attr('defaultState', '1');
$('.user_default').attr('url-data', '/user/deleteUserDefaultFriend');
$('.user_default').html('取消默认好友');
} else {
$('.user_default').attr('defaultState', '0');
$('.user_default').attr('url-data', '/user/setUserDefaultFriend');
$('.user_default').html('设为默认好友');
}
} else {
$.toast("操作失败", "forbidden");
}
}
$(document).on("click", ".delUser", function() {
var siteUserId = $('.site_user_id').attr('data');
var reqUri = $(this).attr('url-data');
$.confirm({
title : '删除用户',
text : '删除后,用户将被从站点彻底抹除',
onOK : function() {
var userInfo = {
"siteUserId" : siteUserId
};
reqUrl(reqUri, JSON.stringify(userInfo), 'delUserResult');
$.closeModal();
},
onCancel : function() {
console.log('cancle');
toast('取消操作');
$.closeModal();
}
});
});
function delUserResult(results) {
if (results == 'success') {
$.toast("操作成功");
} else {
$.toast("操作失败", "forbidden");
}
}
$(document).on("click", '.uploaderInput', function() {
reqImageUpload("jsimageUpload");
});
function jsimageUpload(result, imageId, imageLocalPath) {
var type = getOsType();
if (result == 1) {
if (type == 'Android') {
var img = '<li class="weui-uploader__file user_photo" user-photo="' + imageId + '"><img src="http://akaxin/img' + imageLocalPath + '" style="height:75px; width:75px;" /></li>';
} else {
var img = '<li class="weui-uploader__file user_photo" user-photo="' + imageId + '"><img src="' + imageLocalPath + '" style="height:75px; width:75px;" /></li>';
}
$('#uploaderFiles').html(img);
$('.weui-uploader__info').html('1/1');
} else {
$.toast('上传图片失败', 'forbidden');
}
}
$(window).load(function() {
var imageid = $('.user_photo').attr('user-photo');
reqImageDownload(imageid, "jsimageDownload");
});
function jsimageDownload(result, imageid, imageLocalPath) {
var type = getOsType();
if (type == 'Android') {
var html = '<img src="http://akaxin/img' + imageLocalPath + '" style="height:75px; width:75px;" />';
} else {
var html = '<img src="' + imageLocalPath + '" style="height:75px; width:75px;" />';
}
$('#user_photo').html(html);
}
</script>
</body>
</html>

View File

@ -0,0 +1,130 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,initial-scale=1,user-scalable=0">
<title>Web消息测试</title>
<!-- 引入 WeUI -->
<link rel="stylesheet"
href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css" />
<link rel="stylesheet"
href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css" />
<style type="text/css">
body, html {
height: 100%;
background-color: #f4f4f4;
-webkit-tap-highlight-color: transparent;
}
.margin_top_30px {
margin-top: 30px;
}
footer {
text-align: center;
font-size: 14px;
padding: 20px;
}
.weui-loadmore_line .weui-loadmore__tips {
background-color: #f4f4f4;
}
footer a {
color: #999;
text-decoration: none;
}
</style>
</head>
<body ontouchstart="">
<div id="basic-config" class="weui-cells margin_top_30px">
<a class="weui-cell weui-cell_access url-data" url-data="/webMessage/testU2Web"
href="javascript:;">
<div class="weui-cell__bd">
<p>测试U2-Web消息</p>
</div>
<div class="weui-cell__ft"></div>
</a>
<a class="weui-cell weui-cell_access url-data" url-data="/webMessage/testU2WebNotice"
href="javascript:;">
<div class="weui-cell__bd">
<p>测试U2-WebNotice消息</p>
</div>
<div class="weui-cell__ft"></div>
</a>
<a class="weui-cell weui-cell_access url-data" url-data="/webMessage/testGroupWeb"
href="javascript:;">
<div class="weui-cell__bd">
<p>测试Group-Web消息</p>
</div>
<div class="weui-cell__ft"></div>
</a>
<a class="weui-cell weui-cell_access url-data" url-data="/webMessage/testGroupWebNotice"
href="javascript:;">
<div class="weui-cell__bd">
<p>测试Group-Web-Notice消息</p>
</div>
<div class="weui-cell__ft"></div>
</a>
</div>
<script type="text/javascript"
src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript"
src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript"
src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">
function getOsType() {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1
|| u.indexOf('Windows Phone') > -1) {
return 'Android';
} else if (u.indexOf('iPhone') > -1) {
return 'IOS';
} else {
return 'PC';
}
}
function reqHtml(reqUri, params) {
reqUri = "/akaxin" + reqUri;
var type = getOsType();
console.log(type);
if (type == 'Android') {
Android.requestPage(reqUri, params);
} else if (type == 'IOS') {
ios_requestPage(reqUri, params);
} else {
$.toast('暂时不支持该设备');
}
}
function toast(msg) {
var type = getOsType();
console.log(type);
if (type == 'Android') {
Android.showToast(msg);
} else if (type == 'IOS') {
$.toast(msg);
} else {
$.toast('暂时不支持该设备');
}
}
$(document).on("click", ".url-data", function() {
var reqUri = $(this).attr('url-data');
reqHtml(reqUri, "");
});
</script>
</body>
</html>

7
openzaly-boot/.gitignore vendored Executable file
View File

@ -0,0 +1,7 @@
/target/
/.classpath
/.DS_Store
/.project
/openzalyDB.sqlite3
/site-logs
/site-file

View File

@ -0,0 +1,82 @@
#
# 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

105
openzaly-boot/pom.xml Executable file
View File

@ -0,0 +1,105 @@
<!-- - 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. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.akaxin</groupId>
<artifactId>openzaly-parent</artifactId>
<version>0.0.1</version>
</parent>
<groupId>com.akaxin.site</groupId>
<artifactId>openzaly-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.2.RELEASE</version>
<configuration>
<!-- 指定该Main Class为全局的唯一入口 -->
<mainClass>com.akaxin.site.boot.main.Bootstrap</mainClass>
<layout>ZIP</layout>
<!-- 热部署生效必须加 -->
<fork>true</fork>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.akaxin.site.boot.main.Bootstrap</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.artifactId}</finalName>
<descriptors>
<descriptor>src/assembly-zip.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin> -->
</plugins>
</build>
<dependencies>
<!-- 启动Netty服务器依赖包 -->
<dependency>
<groupId>com.akaxin.site</groupId>
<artifactId>openzaly-connector</artifactId>
<version>0.0.1-RELEASE</version>
</dependency>
<!-- 启动后台管理依赖包 -->
<dependency>
<groupId>com.akaxin.site</groupId>
<artifactId>openzaly-admin</artifactId>
<version>0.0.1-RELEASE</version>
</dependency>
<!--命令行工具-->
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>make-assembly</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/main/resources/</directory>
<outputDirectory>.</outputDirectory>
</fileSet>
<fileSet>
<directory>../lib/</directory>
<outputDirectory>/lib/</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/lib/</outputDirectory>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</assembly>

View File

@ -0,0 +1,14 @@
package com.akaxin.site.boot.config;
/**
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-03-26 19:07:30
*/
public interface AkxProject {
String PROJECT_NAME = "openzaly-boot";
String PROJECT_LOG_NAME = "openzaly-boot";
String PLN = "[openzaly-boot]";
}

View File

@ -0,0 +1,95 @@
/**
* 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.
*/
package com.akaxin.site.boot.config;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import com.akaxin.proto.core.ConfigProto;
import com.akaxin.site.boot.utils.PropertiesUtils;
/**
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-01-24 12:50:20
*/
public class ConfigHelper implements ConfigKey {
private static Properties prop;
private ConfigHelper() {
}
public static Properties loadOZProperties() {
if (prop == null) {
// 加载openzaly.property 配置文件
prop = PropertiesUtils.getOZProperties();
}
return prop;
}
/**
* 获取服务启动时设置的配置参数如果启动未设置则通过配置文件获取默认的值
*
* @param configName
* @return
*/
public static String getStringConfig(String configName) {
String configValue = System.getProperty(configName);
if (StringUtils.isEmpty(configValue)) {
Object obj = loadOZProperties().get(configName);
return obj != null ? obj.toString() : null;
}
return configValue;
}
public static int getIntConfig(String configName) {
String configValue = System.getProperty(configName);
if (StringUtils.isBlank(configValue)) {
configValue = loadOZProperties().get(configName).toString();
}
return Integer.parseInt(configValue);
}
public static Map<Integer, String> getConfigMap() {
Map<Integer, String> configMap = new HashMap<Integer, String>();
configMap.put(ConfigProto.ConfigKey.SITE_VERSION_VALUE, getStringConfig(SITE_VERSION));
configMap.put(ConfigProto.ConfigKey.SITE_ADDRESS_VALUE, getStringConfig(SITE_ADDRESS));
configMap.put(ConfigProto.ConfigKey.SITE_PORT_VALUE, getStringConfig(SITE_PORT));
// 扩展的http功能接口
configMap.put(ConfigProto.ConfigKey.SITE_HTTP_ADDRESS_VALUE, getStringConfig(PLUGIN_API_ADDRESS));
configMap.put(ConfigProto.ConfigKey.SITE_HTTP_PORT_VALUE, getStringConfig(PLUGIN_API_PORT));
String basePath = System.getProperty("user.dir");
configMap.put(ConfigProto.ConfigKey.PIC_PATH_VALUE, basePath);// 存放资源的位置
configMap.put(ConfigProto.ConfigKey.DB_PATH_VALUE, basePath);
// 默认100人
configMap.put(ConfigProto.ConfigKey.GROUP_MEMBERS_COUNT_VALUE, "100");
// 默认二人绝密聊天状态开启二人绝密聊天功能
configMap.put(ConfigProto.ConfigKey.U2_ENCRYPTION_STATUS_VALUE,
ConfigProto.U2EncryptionConfig.U2_OPEN_VALUE + "");
// 默认匿名
configMap.put(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE, ConfigProto.RealNameConfig.REALNAME_NO_VALUE + "");
// 默认开启邀请码
configMap.put(ConfigProto.ConfigKey.INVITE_CODE_STATUS_VALUE, ConfigProto.InviteCodeConfig.UIC_YES_VALUE + "");
// 默认Push状态不显示push内容
configMap.put(ConfigProto.ConfigKey.PUSH_CLIENT_STATUS_VALUE,
String.valueOf(ConfigProto.PushClientStatus.PUSH_HIDDEN_TEXT_VALUE));
return configMap;
}
}

View File

@ -0,0 +1,47 @@
/**
* 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.
*/
package com.akaxin.site.boot.config;
/**
* 站点服务相关配置字段
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-01-24 19:49:19
*/
public interface ConfigKey {
// 站点版本
public String SITE_VERSION = "openzaly.version";
// 站点服务地址提供用户和站点之间连接使用
public String SITE_ADDRESS = "site.address";
// 站点服务监听端口
public String SITE_PORT = "site.port";
// 站点启动的http服务地址内部扩展功能访问使用
public String PLUGIN_API_ADDRESS = "pluginapi.address";
// http服务监听端口
public String PLUGIN_API_PORT = "pluginapi.port";
// 站点管理扩展地址&&端口
public String SITE_ADMIN_ADDRESS = "site.admin.address";
public String SITE_ADMIN_PORT = "site.admin.port";
// 站点管理员
public String SITE_ADMINISTRATORS = "site.administrators";
// 站点管理员首次登陆站点设置的邀请码
public String SITE_ADMIN_UIC = "site.uic";
// 存放站点图片音频相关文件路径
public String SITE_BASE_DIR = "site.baseDir";
// 最大成员人数
public String GROUP_MEMBERS_COUNT = "group.members.count";
}

View File

@ -0,0 +1,57 @@
package com.akaxin.site.boot.config;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger;
import com.akaxin.common.logs.LogCreater;
import com.akaxin.common.logs.LogUtils;
import com.akaxin.proto.core.ConfigProto;
import com.akaxin.site.business.impl.site.SiteConfig;
import com.akaxin.site.message.utils.SiteConfigHelper;
/**
* 站点配置监听器定时更新缓存中数据
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-02-01 14:52:50
*/
public class ConfigListener {
private static String logPath;
private static Logger logger;
static {
Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
doListenning();
}
}, 20, 20, TimeUnit.SECONDS);
}
public static void startListenning() {
LogUtils.info(getLogger(), "start config listenning");
}
public static void doListenning() {
Map<Integer, String> imConfigMap = SiteConfigHelper.updateConfig();
LogUtils.info(getLogger(), "update im site config={}", imConfigMap);
Map<Integer, String> apiConfigMap = SiteConfig.updateConfig();
LogUtils.info(getLogger(), "update api site config={}", apiConfigMap);
}
private static Logger getLogger() {
String currentPath = SiteConfigHelper.getConfig(ConfigProto.ConfigKey.DB_PATH);
if (logger == null || !currentPath.equals(logPath)) {
logPath = currentPath;
logger = LogCreater.createTimeLogger("config", currentPath + "/site-logs");
}
return logger;
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,329 @@
/**
* Copyright 2018-2028 Akaxin Group
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.akaxin.site.boot.main;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Base64;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Level;
import com.akaxin.common.command.Command;
import com.akaxin.common.command.CommandResponse;
import com.akaxin.common.constant.HttpUriAction;
import com.akaxin.common.constant.RequestAction;
import com.akaxin.common.executor.AbstracteExecutor;
import com.akaxin.common.logs.AkxLog4jManager;
import com.akaxin.common.utils.StringHelper;
import com.akaxin.proto.core.FileProto.FileType;
import com.akaxin.site.boot.config.AkxProject;
import com.akaxin.site.boot.config.ConfigHelper;
import com.akaxin.site.boot.config.ConfigKey;
import com.akaxin.site.boot.config.ConfigListener;
import com.akaxin.site.boot.config.SiteDefaultIcon;
import com.akaxin.site.boot.spring.OpenzalySpringBoot;
import com.akaxin.site.boot.utils.BootLog;
import com.akaxin.site.boot.utils.Helper;
import com.akaxin.site.business.utils.FilePathUtils;
import com.akaxin.site.business.utils.FileServerUtils;
import com.akaxin.site.connector.exception.HttpServerException;
import com.akaxin.site.connector.exception.TcpServerException;
import com.akaxin.site.connector.handler.ApiRequestHandler;
import com.akaxin.site.connector.handler.HttpRequestHandler;
import com.akaxin.site.connector.handler.ImMessageHandler;
import com.akaxin.site.connector.handler.ImSiteAuthHandler;
import com.akaxin.site.connector.handler.WSRequestHandler;
import com.akaxin.site.connector.http.HttpServer;
import com.akaxin.site.connector.netty.NettyServer;
import com.akaxin.site.connector.ws.WsServer;
import com.akaxin.site.storage.DataSourceManager;
import com.akaxin.site.storage.dao.config.DBConfig;
import com.akaxin.site.storage.dao.sqlite.manager.PluginArgs;
import com.akaxin.site.storage.exception.InitDatabaseException;
import com.akaxin.site.storage.exception.NeedInitMysqlException;
import com.akaxin.site.storage.exception.UpgradeDatabaseException;
/**
* <pre>
* Openzaly是Akaxin聊天软件的服务端开源项目当你第一次从github上下载源码至本地后可以通过
* Bootstrap中的main方法启动Openzaly服务器代码Openzaly-server配合Akaxin客户端协同使用
* Akaxin客户端可以在苹果的Appstore以及<a href='www.akaxin.com'>Akaxin官方下载</a>
*
* Openzaly-boot是Openzaly项目中的启动模块主要负责项目的初始化事件监听日志等级变更
* 助文档标准化输出服务启动
*
* 1.帮助文档
* Openzaly启动支持自定义参数这些参数通过用户启动命令中增加[-h|-help]获取具体执行如下
* java -jar openzaly-server.jar -h
* java -jar openzaly-server.jar -help
*
* 2.初始化工作
* 项目启动前期需要初始化服务端数据当前需要初始化的数据包括
* a.初始化数据库自动创建SQLite中需要的table
* b.站点服务的默认配置或者用户自定义的配置信息
* c.默认后台管理与用户广场的ICON设置
*
* 3.日志等级变更
* Openzaly项目中使用的日志框架为Log4j+SLF4J默认的日志等级为INFO级别在后台管理中支持
* 用户通过配置信息修改来实时变更项目中的日志级别从而达到在不停止服务情况下修改日志级别
*
* 4.服务启动
* Openzaly项目启动的主要部分包含三个服务的启动分别如下
* a.提供扩展使用的Netty-Http服务
* 使用Netty框架启动Http服务当开发者开发站点的扩展功能可以调用此Http接口实现与站点之
* 间的交互
*
* b.提供客户端访问Netty-Tcp服务
* Akaxin的客户端Andorid与IOS通过tcp连接保持与站点之间的长连接实现用户与Openzaly
* 之间的IM功能以及部分API访问请求
*
* c.提供WEBIM使用的WebSocket服务
* 暂时此功能未上线
*
* 5.标准化输出
* 在标准输出界面输出Openzaly的启动情况log日志信息中支持更详细的启动记录
*
*
* Begin from here,start the Openzaly server for clients
* ......
*
* </pre>
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018.01.01 11:23:42
*/
public class Bootstrap {
public static void main(String[] args) {
// set root dir
try {
setBaseDir();
} catch (IOException ioe) {
BootLog.error("openzaly set base dir error");
System.exit(-100);
}
// 增加 -h|-help 启动参数 输出帮助文档
// use java -jar -h|-help ,get more help message
if (Helper.startHelper(args)) {
return;
}
PrintWriter pwriter = new PrintWriter(System.out);
Helper.showAkaxinBanner(pwriter);
Helper.buildEnvToSystemOut(pwriter);
String nettyTcpHost = "0.0.0.0";
int nettyTcpPort = 2021;
String pluginAPiAddress = "0.0.0.0";
int pluginAPiPort = 8280;
try {
setDefaultSystemLogLevel();
// client tcp address from openzaly.properties
nettyTcpHost = ConfigHelper.getStringConfig(ConfigKey.SITE_ADDRESS);
nettyTcpPort = ConfigHelper.getIntConfig(ConfigKey.SITE_PORT);
// plugin http address from openzaly.properties
pluginAPiAddress = ConfigHelper.getStringConfig(ConfigKey.PLUGIN_API_ADDRESS);
pluginAPiPort = ConfigHelper.getIntConfig(ConfigKey.PLUGIN_API_PORT);
// add site config to database
initDataSource();
// use thread to update site-config cached in memory
addConfigListener();
// start server
startNettyHttpServer(pluginAPiAddress, pluginAPiPort);// 0.0.0.0:8280
startNettyTcpServer(nettyTcpHost, nettyTcpPort);// 0.0.0.0:2021
// disable websocket server
// startWebSocketServer("0.0.0.0", 9090);// 0.0.0.0:9090
// start spring boot for openzaly-admin
initSpringBoot(args);
Helper.startSuccess(pwriter);
BootLog.info("start openzaly-server successfully");
} catch (Exception e) {
Helper.startFail(pwriter);
BootLog.error("start Openzaly-server error", e);
BootLog.error("Openzaly-server exit...");
System.exit(-1);// system exit
} catch (TcpServerException e) {
String errMessage = StringHelper.format("openzaly tcp-server {}:{} {}", nettyTcpHost, nettyTcpPort,
e.getCause().getMessage());
Helper.startFailWithError(pwriter, errMessage);
BootLog.error("start Openzaly with tcp server error", e);
BootLog.error("Openzaly-server exit...");
System.exit(-2);// system exit
} catch (HttpServerException e) {
String errMessage = StringHelper.format("openzaly http-server {}:{} {}", pluginAPiAddress, pluginAPiPort,
e.getCause().getMessage());
Helper.startFailWithError(pwriter, errMessage);
BootLog.error("start Openzaly with http server error", e);
BootLog.error("Openzaly-server exit...");
System.exit(-3);// system exit
} catch (InitDatabaseException e) {
String errMessage = StringHelper.format("openzaly init database error {}", e.getCause().getMessage());
Helper.startFailWithError(pwriter, errMessage);
BootLog.error("start Openzaly with init database error", e);
BootLog.error("Openzaly-server exit...");
System.exit(-4);// system exit
} catch (UpgradeDatabaseException e) {
Helper.printUpgradeWarn(pwriter);
BootLog.error("Openzaly-server current is an old version ,we need to upgrade.", e);
System.exit(-5);// system exit
} catch (NeedInitMysqlException e) {
Helper.printInitMysqlWarn(pwriter);
BootLog.error("Openzaly-server need to init mysql.", e);
System.exit(-6);// system exit
} finally {
if (pwriter != null) {
pwriter.close();
}
}
}
private static void setBaseDir() throws IOException {
String baseDir = ConfigHelper.getStringConfig(ConfigKey.SITE_BASE_DIR);
if (StringUtils.isNotBlank(baseDir)) {
File file = new File(baseDir);
if (!file.isDirectory()) {
file.mkdirs();
}
System.setProperty("user.dir", file.getCanonicalPath());
}
}
private static void setDefaultSystemLogLevel() {
// 更新日志级别
AkxLog4jManager.setLogLevel(Level.INFO);
BootLog.info("{} set system log level={}", AkxProject.PLN, Level.INFO);
}
/**
* 初始化数据源
*
* @throws InitDatabaseException
* @throws UpgradeDatabaseException
* @throws NeedInitMysqlException
*/
private static void initDataSource()
throws InitDatabaseException, UpgradeDatabaseException, NeedInitMysqlException {
String adminHost = ConfigHelper.getStringConfig(ConfigKey.SITE_ADMIN_ADDRESS);
int adminPort = ConfigHelper.getIntConfig(ConfigKey.SITE_ADMIN_PORT);
String dbDir = System.getProperty("user.dir");
String adminUic = ConfigHelper.getStringConfig(ConfigKey.SITE_ADMIN_UIC);
Map<Integer, String> siteConfigMap = ConfigHelper.getConfigMap();
DBConfig config = new DBConfig();
config.setConfigMap(siteConfigMap);
config.setDbDir(dbDir);
config.setAdminAddress(adminHost);
config.setAdminPort(adminPort);
config.setAdminUic(adminUic);
config.setAdminServerName(PluginArgs.SITE_ADMIN_NAME);
config.setAdminIcon(getDefaultIcon(SiteDefaultIcon.DEFAULT_SITE_ADMIN_ICON));
config.setParam(PluginArgs.FRIEND_SQUARE, getDefaultIcon(SiteDefaultIcon.DEFAULT_FRIEND_SQUARE_ICON));
BootLog.info("{} init datasource config={}", AkxProject.PLN, config.toString());
DataSourceManager.init(config);
}
/**
* 启动Http服务提供与扩展服务之间的haihttp application interface接口功能
*
* @throws HttpServerException
*/
private static void startNettyHttpServer(String address, int port) throws HttpServerException {
new HttpServer() {
@Override
public void loadExecutor(AbstracteExecutor<Command, CommandResponse> executor) {
executor.addChain(HttpUriAction.HTTP_ACTION.getRety(), new HttpRequestHandler());
}
}.start(address, port);
BootLog.info("{} start http server {}:{} ok.", AkxProject.PLN, address, port);
}
/**
* 启动Netty服务器提供用户与站点服务之间的长链接功能
*
* @param address
* @param port
* @throws TcpServerException
*/
private static void startNettyTcpServer(String address, int port) throws TcpServerException {
new NettyServer() {
@Override
public void loadExecutor(AbstracteExecutor<Command, CommandResponse> executor) {
executor.addChain(RequestAction.IM_SITE.getName(), new ImSiteAuthHandler());
executor.addChain(RequestAction.IM.getName(), new ImMessageHandler());
executor.addChain(RequestAction.API.getName(), new ApiRequestHandler());
}
}.start(address, port);
BootLog.info("{} start netty server {}:{} ok.", AkxProject.PLN, address, port);
}
// websocket for web-im
private static void startWebSocketServer(String address, int port) throws Exception {
new WsServer() {
@Override
public void loadExecutor(AbstracteExecutor<Command, CommandResponse> executor) {
executor.addChain("WS-ACTION", new WSRequestHandler());
}
}.start(address, port);
}
// springboot for openzaly web
private static void initSpringBoot(String[] args) {
OpenzalySpringBoot.main(args);
}
// add config listener,timing to update cached config value
private static void addConfigListener() {
ConfigListener.startListenning();
BootLog.info("{} start listener to site-config", AkxProject.PLN);
}
// get pic by base64
private static String getDefaultIcon(String base64Str) {
try {
String fileBasePath = System.getProperty("user.dir");
byte[] iconBytes = Base64.getDecoder().decode(base64Str);
String fileId = FileServerUtils.saveFile(iconBytes, FilePathUtils.getPicPath(fileBasePath),
FileType.SITE_PLUGIN, null);
return fileId;
} catch (Exception e) {
BootLog.error(StringHelper.format("{} set openzaly-admin default icon error", AkxProject.PLN), e);
}
return "";
}
}

View File

@ -0,0 +1,43 @@
package com.akaxin.site.boot.spring;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.stereotype.Component;
import com.akaxin.site.boot.config.ConfigHelper;
import com.akaxin.site.boot.config.ConfigKey;
@Component
public class CustomizationWebServerBean implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {
private static Logger logger = LoggerFactory.getLogger(CustomizationWebServerBean.class);
@Override
public void customize(ConfigurableServletWebServerFactory server) {
String adminAddress = ConfigHelper.getStringConfig(ConfigKey.SITE_ADMIN_ADDRESS);
String adminPort = ConfigHelper.getStringConfig(ConfigKey.SITE_ADMIN_PORT);
// set admin port
if (StringUtils.isNumeric(adminPort)) {
server.setPort(Integer.valueOf(adminPort));
} else {
server.setPort(8288);
}
// set admin address
if (StringUtils.isNotEmpty(adminAddress)) {
try {
InetAddress address = InetAddress.getByName(adminAddress);
server.setAddress(address);
} catch (UnknownHostException e) {
}
}
server.setContextPath("/akaxin");
}
}

View File

@ -0,0 +1,20 @@
package com.akaxin.site.boot.spring;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableAutoConfiguration
public class OpenzalyConfiguration {
// @Bean
// public ConfigurableServletWebServerFactory webServerFactory() {
// TomcatServletWebServerFactory webserver = new TomcatServletWebServerFactory();
//// webserver.setPort(80822);
//// webserver.setContextPath("/akaxin");
// return webserver;
// }
}

View File

@ -0,0 +1,45 @@
/**
* 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.
*/
package com.akaxin.site.boot.spring;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* <pre>
* openzaly支持springboot框架在启动main中会同样启动springboot
*
* 在maven modules中springboot会存在启动main中扫描不到其他modules中的package两种方法解决
* 其一@SpringBootApplication(scanBasePackages={"com.akaxin.site.*"})
* 其二SpringApplication.run(Class<?>...clazzs ,args),clazzs 把需要加载的主类添加上
* </pre>
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-06-05 19:25:55
*/
@SpringBootApplication(scanBasePackages = { "com.akaxin.site.*" })
public class OpenzalySpringBoot {
public static void main(String[] args) {
SpringApplication application = new SpringApplication(OpenzalySpringBoot.class);
application.setBannerMode(Banner.Mode.OFF);
// application.setDefaultProperties(properties);
application.run(args);
}
}

View File

@ -0,0 +1,24 @@
package com.akaxin.site.boot.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BootLog {
private static final Logger logger = LoggerFactory.getLogger(BootLog.class);
public static void info(String message) {
logger.info(message);
}
public static void info(String message, Object... objs) {
logger.info(message, objs);
}
public static void error(String message, Throwable t) {
logger.error(message, t);
}
public static void error(String message) {
logger.error(message);
}
}

View File

@ -0,0 +1,241 @@
package com.akaxin.site.boot.utils;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.akaxin.common.utils.PrintUtils;
import com.akaxin.common.utils.StringHelper;
import com.akaxin.site.boot.config.ConfigHelper;
import com.akaxin.site.boot.config.ConfigKey;
import com.akaxin.site.storage.DataSourceManager;
import com.akaxin.site.storage.dao.config.DBConfig;
import com.akaxin.site.storage.dao.config.DBType;
import com.akaxin.site.storage.dao.sql.SQLConst;
import com.akaxin.site.storage.exception.MigrateDatabaseException;
import com.akaxin.site.storage.exception.NeedInitMysqlException;
import com.akaxin.site.storage.exception.UpgradeDatabaseException;
public class Helper {
private static final Logger logger = LoggerFactory.getLogger(Helper.class);
/**
*
* @param args
* @return true:only print helper message false:start openzaly-server
*/
public static boolean startHelper(String[] args) {
PrintWriter pw = null;
try {
Options options = new Options();
options.addOption("h", false, "help message list");
options.addOption("help", false, "help message list");
options.addOption("team", false, "specify openzaly TEAM edition and init database config");
options.addOption("upgrade", false, "upgrade openzaly server and database");
options.addOption("migrate", false, "migrate data from sqlite to mysql");
DefaultParser posixParser = new DefaultParser();
CommandLine commandLine = posixParser.parse(options, args);
if (commandLine.hasOption("h") || commandLine.hasOption("help")) {
pw = new PrintWriter(System.out);
// 1.print logo
showAkaxinBanner(pw);
// 2.print Userage
HelpFormatter helpFormatter = new HelpFormatter();
helpFormatter.printHelp("java [<name>=value] -jar openzaly-server.jar [-h|-help]", options, false);
// 3.print helper message
printHelperMessage(pw);
return true;
} else if (commandLine.hasOption("upgrade")) {
pw = new PrintWriter(System.out);
upgrade(pw);
return true;
} else if (commandLine.hasOption("team") || commandLine.hasOption("TEAM")
|| commandLine.hasOption("Team")) {
pw = new PrintWriter(System.out);
initMysqlDatabase(pw);
return true;
} else if (commandLine.hasOption("migrate")) {
migrateSqlite2Mysql();
return true;
}
return false;
} catch (ParseException e) {
logger.error("print helper with startHelper error", e);
} finally {
if (pw != null) {
pw.close();
}
}
return true;
}
public static void showAkaxinBanner(PrintWriter pw) {
BufferedReader buffer = null;
try {
InputStream inputStream = Helper.class.getResourceAsStream("/logo.txt");
buffer = new BufferedReader(new InputStreamReader(inputStream));
String line = null;
while ((line = buffer.readLine()) != null) {
pw.println(line);
}
pw.flush();
inputStream.close();
} catch (Exception e) {
logger.error("read helper message from file error", e);
} finally {
// 关闭buffer
try {
if (buffer != null) {
buffer.close();
}
} catch (IOException e) {
logger.error("buffer close error with IOException");
}
}
}
public static void buildEnvToSystemOut(PrintWriter pwriter) {
pwriter.println();
// openzaly version
String ozVersion = ConfigHelper.getStringConfig(ConfigKey.SITE_VERSION);
pwriter.println("openzaly-version : " + ozVersion);
// os
String osName = System.getProperty("os.name");
String dataModel = System.getProperty("sun.arch.data.model"); // 32位 or 64位
pwriter.println("OS Name : " + osName + " " + dataModel + "");
// java version
String javaVersion = System.getProperty("java.version"); // 获取JDK版本
pwriter.println("java-version : " + javaVersion);
pwriter.println();
pwriter.println("[OK] openzaly-server is starting...");
pwriter.flush();
}
public static void startSuccess(PrintWriter pwriter) {
pwriter.println("[OK] start openzaly-server successfully");
pwriter.flush();
}
public static void startFail(PrintWriter pwriter) {
pwriter.println("[Error] start openzaly-server failed, server exit...");
pwriter.println();
pwriter.flush();
}
public static void startFailWithError(PrintWriter pwriter, String errMessage) {
pwriter.println("[Error] error message:" + errMessage);
pwriter.println("[Error] start openzaly-server failed, server exit...");
pwriter.println();
pwriter.flush();
}
public static void printUpgradeWarn(PrintWriter pwriter) {
pwriter.println("[Error] openzaly-server is an old version, you can execute following command to upgrade:");
pwriter.println();
pwriter.println("\t java -jar openzaly-server.jar -upgrade");
pwriter.println();
pwriter.flush();
}
public static void printInitMysqlWarn(PrintWriter pwriter) {
pwriter.println("[Error] openzaly-server need to init mysql first, you can execute following command:");
pwriter.println();
pwriter.println("\t java -jar openzaly-server.jar -init");
pwriter.println();
pwriter.flush();
}
private static void printHelperMessage(PrintWriter pw) {
pw.println();
pw.println("example:java -Dsite.port=2021 -jar openzaly-server.jar ");
pw.println();
pw.println("\t-Dsite.address \t\topenzaly Netty address default:0.0.0.0");
pw.println("\t-Dsite.port \t\topenzaly Netty port default:2021");
pw.println("\t-Dpluginapi.address \topenzaly PluginAddress default: 0.0.0.0");
pw.println("\t-Dpluginapi.port \topenzaly PluginApi port default:8280");
pw.println("\t-Dsite.admin.port \topenzaly admin port default:8288");
pw.println("\t-Dsite.uic \topenzaly first uic for admin port default: \"000000\"");
pw.println("\t-Dsite.baseDir \t\topenzaly openzaly-server root dir default:./");
pw.println();
pw.flush();
}
private static void upgrade(PrintWriter pw) {
pw.println();
pw.println("[INFO] start to upgrade openzaly-server...");
try {
String dbDir = ConfigHelper.getStringConfig(ConfigKey.SITE_BASE_DIR);
String siteVersion = ConfigHelper.getStringConfig(ConfigKey.SITE_VERSION);
DBConfig config = new DBConfig();
config.setDbDir(dbDir);
config.setDb(DBType.PERSONAL);
// 升级
int dbUserVersion = DataSourceManager.upgradeDB(config);
int needVersion = SQLConst.SITE_DB_VERSION_11;
pw.println("[INFO] upgrade openzaly-server version : " + siteVersion);
if (needVersion == dbUserVersion) {
pw.println("[OK] upgrade database user-version : " + dbUserVersion);
pw.println("[OK] upgrade openzaly-server finish ...");
} else {
pw.println("[ERROR] upgrade database user-version : " + dbUserVersion);
pw.println("[ERROR] upgrade openzaly-server fail ...");
}
} catch (UpgradeDatabaseException e) {
pw.println("[ERROR] upgrade openzaly-server error");
logger.error("upgrade database error", e);
}
pw.println();
pw.flush();
}
private static void initMysqlDatabase(PrintWriter pw) {
pw.println("[INFO] starting init mysql");
try {
DataSourceManager.initMysqlConfig();
pw.println("[OK] init mysql finish ,please execute command to start openzaly-server");
pw.println();
pw.println("\t java -jar openzaly-server.jar");
} catch (FileNotFoundException e) {
logger.error("init mysql error,", e);
pw.println(StringHelper.format("[ERROR] init mysql error:[{}]", e.getMessage()));
} catch (IOException e) {
logger.error("init mysql error,", e);
pw.println(StringHelper.format("[ERROR] init mysql error:[{}]", e.getMessage()));
}
pw.println();
pw.flush();
}
/**
* 把sqlite数据迁移mysql中
*
*/
private static void migrateSqlite2Mysql() {
PrintUtils.print("[INFO]openzaly is migrating sqlite to mysql...");
try {
DataSourceManager.migrateDB();
PrintUtils.print("[OK] migrate sqlite to mysql finish");
} catch (MigrateDatabaseException e) {
PrintUtils.print("[ERROR] migrate sqlite to mysql error,msg={}", e.getMessage());
} catch (NeedInitMysqlException e) {
PrintUtils.print("[ERROR] please execute command before migrate database.");
PrintUtils.print();
PrintUtils.print("java -jar openzaly-server.jar -init");
PrintUtils.print();
}
PrintUtils.flush();
}
}

View File

@ -0,0 +1,94 @@
/**
* 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.
*/
package com.akaxin.site.boot.utils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 通过openzaly.properties加载配置项
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-01-24 19:45:17
*/
public class PropertiesUtils {
private static final Logger logger = LoggerFactory.getLogger(PropertiesUtils.class);
public static Properties getOZProperties() {
InputStream inputStream = null;
Properties properties = new Properties();
try {
inputStream = PropertiesUtils.class.getResourceAsStream("/openzaly-server.config");
properties.load(inputStream);
} catch (IOException e) {
logger.error("load properties from openzaly.properties error,user default", e);
properties = getDefaultProperties();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
logger.error("inputStream close error", e);
}
}
}
return properties;
}
/**
* when load openzaly.properties into System properties error,invoke
* getDefaultProperties method
*
* @return
*/
public static Properties getDefaultProperties() {
Properties properties = new Properties();
properties.put("site.project.env", "ONLINE");
properties.put("site.version", "0.9.5");
properties.put("site.address", "0.0.0.0");
properties.put("site.port", "2021");
properties.put("pluginapi.address", "0.0.0.0");
properties.put("pluginapi.port", "8280");
properties.put("site.admin.address", "127.0.0.1");
properties.put("site.admin.port", "8288");
properties.put("site.admin.uic", "000000");
properties.put("site.baseDir", "./");
properties.put("group.members.count", "100");
return properties;
}
public static Properties getProperties(String configPath) throws IOException {
Properties properties = new Properties();
InputStream inputStream = null;
try {
inputStream = ClassLoader.getSystemResourceAsStream(configPath);
properties.load(inputStream);
return properties;
} catch (Exception e) {
logger.error("get properties error", e);
} finally {
if (inputStream != null) {
inputStream.close();
}
}
return properties;
}
}

View File

@ -0,0 +1,21 @@
#配置访问地址
server.address=127.0.0.1
#配置管理平台启动端口
server.port=8288
#设置输出日志
logging.file=${user.dir}/site-logs/admin.log
#logging.file=site-logs/admin.log
#设置日志的输出级别
logging.level.root=warn
#配置mvc前缀界面位置
spring.thymeleaf.prefix=classpath:/webapp/views/
#静态资源
spring.resources.static-locations=classpath:/webapp/static/
#设置spring的http请求编码
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
server.tomcat.uri-encoding=UTF-8
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

View File

@ -0,0 +1,31 @@
# ------ log4j ------
log4j.rootLogger=INFO,debug,info,warn,error
#log4j.appender.console=org.apache.log4j.ConsoleAppender
#log4j.appender.console.Target=System.out
#log4j.appender.console.layout=org.apache.log4j.PatternLayout
#log4j.appender.console.layout.ConversionPattern=[%p] %d [%c] %m%n
log4j.appender.debug=org.apache.log4j.DailyRollingFileAppender
log4j.appender.debug.File=${user.dir}/site-logs/debug.log
log4j.appender.debug.Threshold=DEBUG
log4j.appender.debug.layout=org.apache.log4j.PatternLayout
log4j.appender.debug.layout.ConversionPattern=[%p] %d [%c] %m%n
log4j.appender.info=org.apache.log4j.DailyRollingFileAppender
log4j.appender.info.File=${user.dir}/site-logs/info.log
log4j.appender.info.Threshold=INFO
log4j.appender.info.layout=org.apache.log4j.PatternLayout
log4j.appender.info.layout.ConversionPattern=[%p] %d [%c] %m%n
log4j.appender.warn=org.apache.log4j.DailyRollingFileAppender
log4j.appender.warn.File=${user.dir}/site-logs/error.log
log4j.appender.warn.Threshold=WARN
log4j.appender.warn.layout=org.apache.log4j.PatternLayout
log4j.appender.warn.layout.ConversionPattern=[%p] %d [%c] %m%n
log4j.appender.error=org.apache.log4j.DailyRollingFileAppender
log4j.appender.error.File=${user.dir}/site-logs/error.log
log4j.appender.error.Threshold=ERROR
log4j.appender.error.layout=org.apache.log4j.PatternLayout
log4j.appender.error.layout.ConversionPattern=[%p] %d [%c] %m%n

View File

@ -0,0 +1,16 @@
/ \
/ . \
\ . \
/ \ \ / _ _ __ _ __ __ ___ _ _
/ . \ | / / \ / \ | |/ / / \ \ \/ / |_ _| | \ | |
/ . _ \ / / . \ / _ \ | ' / / _ \ \ / | | | \| |
\ / / \ - . / / ___ \ | . \ / ___ \ / \ | | | |\ |
\ / / | \ / /_/ \_\ |_|\_\ /_/ \_\ /_/\_\ |___| |_| \_|
/ . \ \ /
\ . \
\ /
\ /
Akaxin is an open source and free proprietary IM software,you can build private openzaly-server for everyone in any server.

View File

@ -0,0 +1,100 @@
#
# 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=TEAM
# openzaly version
openzaly.version=1.1.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}
## if openzaly.edition = personal/PERSONAL OR migrate sqlite to mysql
##openzaly.sqlite.url=openzalyDB.sqlite3
## if openzaly.edition = team/TEAM
##***************mysql master**************
##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
##***************mysql slave**************
##openzaly.mysql.slave.host=localhost
##openzaly.mysql.slave.port=3306
##openzaly.mysql.slave.database=openzaly
##openzaly.mysql.slave.username=root
##openzaly.mysql.slave.password=1234567890
##openzaly.mysql.slave.initial-size=10
##openzaly.mysql.slave.max-size=100
##openzaly.mysql.slave.max-idle=60
##openzaly.mysql.slave.useUnicode=true
##openzaly.mysql.slave.characterEncoding=utf-8
##openzaly.mysql.slave.verifyServerCertificate=false
##openzaly.mysql.slave.useSSL=true
## if openzaly.edition = enterprise/ENTERPRISE
#### support support im server distribution
## if openzaly.edition = ultimate edition
#### openzaly support customed for team or enterprise

View File

@ -0,0 +1,17 @@
package com.akaxin.site.boot.test;
import java.util.Base64;
import com.akaxin.site.business.utils.FileServerUtils;
public class TestDefaultIcon {
public static void main(String args[]) {
// String fileUrl = "site-admin-icon.jpg";
String fileUrl = "管理.png";
byte[] fileBytes = FileServerUtils.fileToBinary(fileUrl);
String str = Base64.getEncoder().encodeToString(fileBytes);
System.out.println(str);
}
}

View File

@ -0,0 +1,28 @@
package com.akaxin.site.boot.test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.akaxin.proto.core.FileProto.FileType;
import com.akaxin.site.business.utils.FilePathUtils;
import com.akaxin.site.business.utils.FileServerUtils;
public class TestFile {
private static final Logger logger = LoggerFactory.getLogger(TestFile.class);
private static String getDefaultSiteAdminIcon() {
try {
byte[] iconBytes = FileServerUtils.fileToBinary("Test.jpg");
String fileId = FileServerUtils.saveFile(iconBytes, FilePathUtils.getPicPath(), FileType.GROUP_PORTRAIT,
null);
return fileId;
} catch (Exception e) {
logger.error("get default icon error", e);
}
return "";
}
public static void main(String args[]) {
System.out.println(getDefaultSiteAdminIcon());
}
}

View File

@ -0,0 +1,16 @@
package com.akaxin.site.boot.test;
import java.util.HashMap;
import java.util.Map;
import com.akaxin.common.http.ZalyHttpClient;
import com.akaxin.common.utils.GsonUtils;
public class TestHttpClient {
public static void main(String args[]) throws Exception {
Map<String, String> map = new HashMap<String, String>();
map.put("test", "aaaaa");
byte[] body = ZalyHttpClient.getInstance().postString("http://localhost:8080/hai/user/queryList", GsonUtils.toJson(map));
System.out.println("body=" + new String(body));
}
}

View File

@ -0,0 +1,7 @@
package com.akaxin.site.boot.test;
public class TestSystemPro {
public static void main(String[] args) {
System.out.println(System.getProperty("test.abc"));
}
}

1
openzaly-business/.gitignore vendored Executable file
View File

@ -0,0 +1 @@
/target/

53
openzaly-business/pom.xml Executable file
View File

@ -0,0 +1,53 @@
<!-- - 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. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.akaxin</groupId>
<artifactId>openzaly-parent</artifactId>
<version>0.0.1</version>
</parent>
<groupId>com.akaxin.site</groupId>
<artifactId>openzaly-business</artifactId>
<version>0.0.1-RELEASE</version>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.akaxin.common</groupId>
<artifactId>openzaly-common</artifactId>
<version>0.0.1-RELEASE</version>
</dependency>
<dependency>
<groupId>com.akaxin.proto</groupId>
<artifactId>openzaly-protobuf</artifactId>
<version>0.0.1-RELEASE</version>
</dependency>
<dependency>
<groupId>com.akaxin.site</groupId>
<artifactId>openzaly-storage</artifactId>
<version>0.0.1-RELEASE</version>
</dependency>
<dependency>
<groupId>com.akaxin.site</groupId>
<artifactId>openzaly-message</artifactId>
<version>0.0.1-RELEASE</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,10 @@
package com.akaxin.site.business.api;
import com.akaxin.common.command.Command;
import com.akaxin.common.command.CommandResponse;
public interface IRequest {
public CommandResponse process(Command command);
}

View File

@ -0,0 +1,5 @@
package com.akaxin.site.business.bean;
public class MsgNoticeBean {
}

View File

@ -0,0 +1,71 @@
package com.akaxin.site.business.bean;
import org.apache.commons.lang3.StringUtils;
import com.akaxin.common.utils.GsonUtils;
public class PlatformPhoneBean {
private String phoneId;
private String countryCode;
private String userIdPubk;
/**
* @return the phoneId
*/
public String getPhoneId() {
return phoneId;
}
/**
* @param phoneId
* the phoneId to set
*/
public void setPhoneId(String phoneId) {
this.phoneId = phoneId;
}
/**
* @return the countryCode
*/
public String getCountryCode() {
return countryCode;
}
/**
* @param countryCode
* the countryCode to set
*/
public void setCountryCode(String countryCode) {
this.countryCode = countryCode;
}
/**
* @return the countryCode_phoneId
*/
public String getFullPhoneId() {
if (StringUtils.isNotEmpty(this.countryCode)) {
return this.countryCode + "_" + phoneId;
}
return "+86_" + phoneId;
}
/**
* @return the userIdPubk
*/
public String getUserIdPubk() {
return userIdPubk;
}
/**
* @param userIdPubk
* the userIdPubk to set
*/
public void setUserIdPubk(String userIdPubk) {
this.userIdPubk = userIdPubk;
}
public String toString() {
return GsonUtils.toJson(this);
}
}

View File

@ -0,0 +1,54 @@
package com.akaxin.site.business.cache;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
/**
* 缓存websession过期1分钟
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-05-07 19:25:38
*/
public class WebSessionCache {
private static final Logger logger = LoggerFactory.getLogger(WebSessionCache.class);
/**
* 最大数量1000个 最长过期时间1分钟
*
*/
private static Cache<String, String> webSessCache = CacheBuilder.newBuilder().maximumSize(1000)
.expireAfterWrite(60, TimeUnit.SECONDS).build();
public static String getSiteUserId(String sessionId) {
String siteUserId = webSessCache.getIfPresent(sessionId);
if (StringUtils.isNotEmpty(siteUserId)) {
webSessCache.invalidate(sessionId);
}
return siteUserId;
}
public static void putWebAuthSession(String sessionId, String siteUserId) {
webSessCache.put(sessionId, siteUserId);
}
public static void main(String[] args) {
webSessCache.put("101", "hello world!");
String hello = getSiteUserId("101");
System.out.println("hello = " + hello);
String hello2 = getSiteUserId("101");
System.out.println("hello = " + hello2);
String hello3 = getSiteUserId("1012");
System.out.println("hello = " + hello3);
}
}

View File

@ -0,0 +1,6 @@
package com.akaxin.site.business.constant;
public interface AkxProject {
// String PLN = "[openzaly-business]";
}

View File

@ -0,0 +1,22 @@
/**
* 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.
*/
package com.akaxin.site.business.constant;
public interface GroupConfig {
int GROUP_MAX_MEMBER_COUNT = 200;
int GROUP_MIN_MEMBER_COUNT = 4;
}

Some files were not shown because too many files have changed in this diff Show More