Commit 22fbc783 by hweeeeeei

修改模块名: common为core

parent 69e690d1
......@@ -29,7 +29,7 @@
<dependency>
<groupId>io.geekidea.springbootplus</groupId>
<artifactId>common</artifactId>
<artifactId>core</artifactId>
</dependency>
</dependencies>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wecloud.im.mapper.ImInboxMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id
, create_time, update_time, read_time, receiver_time, fk_appid, receiver, fk_msg_id, read_msg_status, receiver_msg_status, fk_conversation_id
</sql>
<update id="updateImMsgReceivedByIds">
UPDATE im_inbox
SET `im_inbox`.`update_time` = NOW(),
`im_inbox`.`receiver_msg_status` = 1,
`im_inbox`.`receiver_time` = NOW()
WHERE
im_inbox.receiver = #{clientId}
AND im_inbox.fk_msg_id IN
<foreach collection="msgIds" item="deptId" index="i" open="(" close=")" separator=",">
#{deptId}
</foreach>
</update>
<update id="updateImMsgReadByIds">
UPDATE im_inbox
SET `im_inbox`.`update_time` = NOW(),
`im_inbox`.`read_msg_status` = 1,
`im_inbox`.`receiver_time` = NOW(),
`im_inbox`.`read_time` = NOW()
WHERE
im_inbox.receiver = #{clientId}
AND im_inbox.fk_msg_id IN
<foreach collection="msgIds" item="deptId" index="i" open="(" close=")" separator=",">
#{deptId}
</foreach>
</update>
<select id="getImInboxById" resultType="com.wecloud.im.param.ImInboxQueryVo">
select
<include refid="Base_Column_List"/>
from im_Inbox where id = #{id}
</select>
<select id="getImInboxPageList" parameterType="com.wecloud.im.param.ImInboxPageParam"
resultType="com.wecloud.im.param.ImInboxQueryVo">
select
<include refid="Base_Column_List"/>
from im_Inbox
</select>
<select id="countMyNotReadCount" resultType="java.lang.Integer">
SELECT COUNT(id)
FROM im_inbox
WHERE receiver = #{clientId}
AND receiver_msg_status = 0
</select>
</mapper>
......@@ -149,7 +149,7 @@
<logger name="org.apache.catalina.connector.CoyoteAdapter" level="OFF"/>
<root level="INFO">
<appender-ref ref="ELASTIC"/>
<!-- <appender-ref ref="ELASTIC"/>-->
<appender-ref ref="CONSOLE"/>
<appender-ref ref="ASYNC_FILE"/>
<appender-ref ref="ASYNC_ERROR_FILE"/>
......
......@@ -11,8 +11,8 @@
<version>2.0</version>
</parent>
<artifactId>common</artifactId>
<name>common</name>
<artifactId>core</artifactId>
<name>core</name>
<description>应用服务模块</description>
<dependencies>
......@@ -68,8 +68,6 @@
<!-- netty-->
<!-- fastbootWeixin的核心依赖 -->
<dependency>
<groupId>com.mxixm</groupId>
......
......@@ -12,7 +12,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
/**
*
* @description 用以mysql中json格式的字段,进行转换的自定义转换器,转换为实体类的JSONArray属性
* MappedTypes注解中的类代表此转换器可以自动转换为的java对象
* MappedJdbcTypes注解中设置的是对应的jdbctype
......@@ -25,20 +24,22 @@ public class ArrayJsonHandler extends BaseTypeHandler<JSONArray> {
public void setNonNullParameter(PreparedStatement ps, int i, JSONArray parameter, JdbcType jdbcType) throws SQLException {
ps.setString(i, String.valueOf(parameter.toJSONString()));
}
//根据列名,获取可以为空的结果
@Override
public JSONArray getNullableResult(ResultSet rs, String columnName) throws SQLException {
String sqlJson = rs.getString(columnName);
if (null != sqlJson){
if (null != sqlJson) {
return JSONArray.parseArray(sqlJson);
}
return null;
}
//根据列索引,获取可以为空的结果
@Override
public JSONArray getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
String sqlJson = rs.getString(columnIndex);
if (null != sqlJson){
if (null != sqlJson) {
return JSONArray.parseArray(sqlJson);
}
return null;
......@@ -47,7 +48,7 @@ public class ArrayJsonHandler extends BaseTypeHandler<JSONArray> {
@Override
public JSONArray getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
String sqlJson = cs.getString(columnIndex);
if (null != sqlJson){
if (null != sqlJson) {
return JSONArray.parseArray(sqlJson);
}
return null;
......
......@@ -12,7 +12,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
/**
*
* @description 用以mysql中json格式的字段,进行转换的自定义转换器,转换为实体类的JSONObject属性
* MappedTypes注解中的类代表此转换器可以自动转换为的java对象
* MappedJdbcTypes注解中设置的是对应的jdbctype
......@@ -20,27 +19,29 @@ import java.sql.SQLException;
@MappedTypes(JSONObject.class)
@MappedJdbcTypes(JdbcType.VARCHAR)
public class ObjectJsonHandler extends BaseTypeHandler<JSONObject>{
public class ObjectJsonHandler extends BaseTypeHandler<JSONObject> {
//设置非空参数
@Override
public void setNonNullParameter(PreparedStatement ps, int i, JSONObject parameter, JdbcType jdbcType) throws SQLException {
ps.setString(i, String.valueOf(parameter.toJSONString()));
}
//根据列名,获取可以为空的结果
@Override
public JSONObject getNullableResult(ResultSet rs, String columnName) throws SQLException {
String sqlJson = rs.getString(columnName);
if (null != sqlJson){
if (null != sqlJson) {
return JSONObject.parseObject(sqlJson);
}
return null;
}
//根据列索引,获取可以为空的结果
@Override
public JSONObject getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
String sqlJson = rs.getString(columnIndex);
if (null != sqlJson){
if (null != sqlJson) {
return JSONObject.parseObject(sqlJson);
}
return null;
......@@ -49,7 +50,7 @@ public class ObjectJsonHandler extends BaseTypeHandler<JSONObject>{
@Override
public JSONObject getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
String sqlJson = cs.getString(columnIndex);
if (null != sqlJson){
if (null != sqlJson) {
return JSONObject.parseObject(sqlJson);
}
return null;
......
......@@ -13,7 +13,6 @@ import org.springframework.stereotype.Component;
@Component
@Slf4j
public class NettyStart {
private final NettyChannelInitializer nettyChannelInitializer;
private static final EventLoopGroup BOSS = new NioEventLoopGroup(1);
private static final EventLoopGroup WORK = new NioEventLoopGroup();
private static final ServerBootstrap SERVER_BOOTSTRAP = new ServerBootstrap();
......@@ -43,6 +42,8 @@ public class NettyStart {
}
private final NettyChannelInitializer nettyChannelInitializer;
public NettyStart(NettyChannelInitializer nettyChannelInitializer) {
this.nettyChannelInitializer = nettyChannelInitializer;
}
......@@ -54,7 +55,7 @@ public class NettyStart {
**/
public void run(int port) {
log.info( "启动netty");
log.info("启动netty");
try {
//设置过滤器
......
......@@ -34,16 +34,6 @@ public class WsReadHandler extends SimpleChannelInboundHandler<TextWebSocketFram
private static final String PING = "ping";
private static final String PONG = "pong";
@Resource
private ReadWsData readWsData;
@Autowired
private RtcService rtcService;
@Resource
private MangerChannelService mangerChannelService;
private final static ThreadFactory NAMED_THREAD_FACTORY = new ThreadFactoryBuilder()
.setNamePrefix("WS-business-").build();
/**
......@@ -55,6 +45,12 @@ public class WsReadHandler extends SimpleChannelInboundHandler<TextWebSocketFram
new ThreadPoolExecutor(WsConstants.CPU_PROCESSORS * 5, WsConstants.CPU_PROCESSORS * 10,
10L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(10), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy());
@Resource
private ReadWsData readWsData;
@Autowired
private RtcService rtcService;
@Resource
private MangerChannelService mangerChannelService;
@Override
protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame msg) {
......
......@@ -20,6 +20,6 @@ import lombok.experimental.Accessors;
@ApiModel(value = "第三方应用表分页参数")
public class ImApplicationPageParam extends BasePageOrderParam {
private String pwd;
private static final long serialVersionUID = 1L;
private String pwd;
}
......@@ -19,5 +19,5 @@ import lombok.experimental.Accessors;
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "黑名单分页参数")
public class ImClientBlacklistPageParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
}
......@@ -18,6 +18,6 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "消息存储表分页参数")
public class ImMessagePageParam extends BasePageOrderParam{
private static final long serialVersionUID=1L;
public class ImMessagePageParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L;
}
......@@ -14,85 +14,85 @@ import java.nio.charset.StandardCharsets;
public class PushClient {
// The host
protected static final String host = "http://msg.umeng.com";
// The upload path
protected static final String uploadPath = "/upload";
// The post path
protected static final String postPath = "/api/send";
// The user agent
protected final String USER_AGENT = "Mozilla/5.0";
// This object is used for sending the post request to Umeng
protected HttpClient client = new DefaultHttpClient();
// The host
protected static final String host = "http://msg.umeng.com";
// The upload path
protected static final String uploadPath = "/upload";
// The post path
protected static final String postPath = "/api/send";
// The user agent
protected final String USER_AGENT = "Mozilla/5.0";
// This object is used for sending the post request to Umeng
protected HttpClient client = new DefaultHttpClient();
public boolean send(UmengNotification msg) throws Exception {
String timestamp = Integer.toString((int) (System.currentTimeMillis() / 1000));
msg.setPredefinedKeyValue("timestamp", timestamp);
String url = host + postPath;
String postBody = msg.getPostBody();
String sign = DigestUtils.md5Hex(("POST" + url + postBody + msg.getAppMasterSecret()).getBytes(StandardCharsets.UTF_8));
url = url + "?sign=" + sign;
HttpPost post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT);
StringEntity se = new StringEntity(postBody, "UTF-8");
post.setEntity(se);
// Send the post request and get the response
HttpResponse response = client.execute(post);
int status = response.getStatusLine().getStatusCode();
System.out.println("Response Code : " + status);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.out.println(result.toString());
if (status == 200) {
System.out.println("Notification sent successfully.");
} else {
System.out.println("Failed to send the notification!");
}
return true;
}
public boolean send(UmengNotification msg) throws Exception {
String timestamp = Integer.toString((int) (System.currentTimeMillis() / 1000));
msg.setPredefinedKeyValue("timestamp", timestamp);
String url = host + postPath;
String postBody = msg.getPostBody();
String sign = DigestUtils.md5Hex(("POST" + url + postBody + msg.getAppMasterSecret()).getBytes(StandardCharsets.UTF_8));
url = url + "?sign=" + sign;
HttpPost post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT);
StringEntity se = new StringEntity(postBody, "UTF-8");
post.setEntity(se);
// Send the post request and get the response
HttpResponse response = client.execute(post);
int status = response.getStatusLine().getStatusCode();
System.out.println("Response Code : " + status);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.out.println(result.toString());
if (status == 200) {
System.out.println("Notification sent successfully.");
} else {
System.out.println("Failed to send the notification!");
}
return true;
}
// Upload file with device_tokens to Umeng
public String uploadContents(String appkey, String appMasterSecret, String contents) throws Exception {
// Construct the json string
JSONObject uploadJson = new JSONObject();
uploadJson.put("appkey", appkey);
String timestamp = Integer.toString((int) (System.currentTimeMillis() / 1000));
uploadJson.put("timestamp", timestamp);
uploadJson.put("content", contents);
// Construct the request
String url = host + uploadPath;
String postBody = uploadJson.toString();
String sign = DigestUtils.md5Hex(("POST" + url + postBody + appMasterSecret).getBytes(StandardCharsets.UTF_8));
url = url + "?sign=" + sign;
HttpPost post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT);
StringEntity se = new StringEntity(postBody, "UTF-8");
post.setEntity(se);
// Send the post request and get the response
HttpResponse response = client.execute(post);
System.out.println("Response Code : " + response.getStatusLine().getStatusCode());
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.out.println(result.toString());
// Decode response string and get file_id from it
JSONObject respJson = new JSONObject(result.toString());
String ret = respJson.getString("ret");
if (!"SUCCESS".equals(ret)) {
throw new Exception("Failed to upload file");
}
JSONObject data = respJson.getJSONObject("data");
String fileId = data.getString("file_id");
// Set file_id into rootJson using setPredefinedKeyValue
// Upload file with device_tokens to Umeng
public String uploadContents(String appkey, String appMasterSecret, String contents) throws Exception {
// Construct the json string
JSONObject uploadJson = new JSONObject();
uploadJson.put("appkey", appkey);
String timestamp = Integer.toString((int) (System.currentTimeMillis() / 1000));
uploadJson.put("timestamp", timestamp);
uploadJson.put("content", contents);
// Construct the request
String url = host + uploadPath;
String postBody = uploadJson.toString();
String sign = DigestUtils.md5Hex(("POST" + url + postBody + appMasterSecret).getBytes(StandardCharsets.UTF_8));
url = url + "?sign=" + sign;
HttpPost post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT);
StringEntity se = new StringEntity(postBody, "UTF-8");
post.setEntity(se);
// Send the post request and get the response
HttpResponse response = client.execute(post);
System.out.println("Response Code : " + response.getStatusLine().getStatusCode());
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.out.println(result.toString());
// Decode response string and get file_id from it
JSONObject respJson = new JSONObject(result.toString());
String ret = respJson.getString("ret");
if (!"SUCCESS".equals(ret)) {
throw new Exception("Failed to upload file");
}
JSONObject data = respJson.getJSONObject("data");
String fileId = data.getString("file_id");
// Set file_id into rootJson using setPredefinedKeyValue
return fileId;
}
return fileId;
}
}
......@@ -18,312 +18,312 @@ import org.json.JSONObject;
* 推送工具类
*/
public class PushUtils {
private final String timestamp = null;
private final PushClient client = new PushClient();
private String appkey = null;
private String appMasterSecret = null;
private final String timestamp = null;
private final PushClient client = new PushClient();
private String appkey = null;
private String appMasterSecret = null;
public PushUtils(String key, String secret) {
try {
appkey = key;
appMasterSecret = secret;
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
public PushUtils(String key, String secret) {
try {
appkey = key;
appMasterSecret = secret;
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
public static void main(String[] args) {
// set your appkey and master secret here
PushUtils demo = new PushUtils("your appkey", "your master secret");
try {
public static void main(String[] args) {
// set your appkey and master secret here
PushUtils demo = new PushUtils("your appkey", "your master secret");
try {
// 安卓单推
String deviceToken = "your device_token";
String unicastText = "Android unicast text";
String unicastTicker = "Android unicast ticker";
String title = "中文的title";
demo.sendAndroidUnicast(deviceToken, unicastText, unicastTicker, title);
// 安卓单推
String deviceToken = "your device_token";
String unicastText = "Android unicast text";
String unicastTicker = "Android unicast ticker";
String title = "中文的title";
demo.sendAndroidUnicast(deviceToken, unicastText, unicastTicker, title);
// ios 单推
String deviceTokenIOS = "your device_token";
String titleIOS = "今日天气";
String subtitle = "";
String body = "今日可能下雨🌂";
demo.sendIOSUnicast(deviceTokenIOS, titleIOS, subtitle, body);
// ios 单推
String deviceTokenIOS = "your device_token";
String titleIOS = "今日天气";
String subtitle = "";
String body = "今日可能下雨🌂";
demo.sendIOSUnicast(deviceTokenIOS, titleIOS, subtitle, body);
/* these methods are all available, just fill in some fields and do the test
* demo.sendAndroidCustomizedcastFile();
* demo.sendAndroidBroadcast();
* demo.sendAndroidGroupcast();
* demo.sendAndroidCustomizedcast();
* demo.sendAndroidFilecast();
*
* demo.sendIOSBroadcast();
* demo.sendIOSGroupcast();
* demo.sendIOSCustomizedcast();
* demo.sendIOSFilecast();
*/
} catch (Exception ex) {
ex.printStackTrace();
}
}
/* these methods are all available, just fill in some fields and do the test
* demo.sendAndroidCustomizedcastFile();
* demo.sendAndroidBroadcast();
* demo.sendAndroidGroupcast();
* demo.sendAndroidCustomizedcast();
* demo.sendAndroidFilecast();
*
* demo.sendIOSBroadcast();
* demo.sendIOSGroupcast();
* demo.sendIOSCustomizedcast();
* demo.sendIOSFilecast();
*/
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void sendAndroidBroadcast() throws Exception {
AndroidBroadcast broadcast = new AndroidBroadcast(appkey, appMasterSecret);
broadcast.setTicker("Android broadcast ticker");
broadcast.setTitle("中文的title");
broadcast.setText("Android broadcast text");
broadcast.goAppAfterOpen();
broadcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
broadcast.setProductionMode();
// Set customized fields
broadcast.setExtraField("test", "helloworld");
//厂商通道相关参数
broadcast.setChannelActivity("your channel activity");
broadcast.setChannelProperties("abc");
client.send(broadcast);
}
public void sendAndroidBroadcast() throws Exception {
AndroidBroadcast broadcast = new AndroidBroadcast(appkey, appMasterSecret);
broadcast.setTicker("Android broadcast ticker");
broadcast.setTitle("中文的title");
broadcast.setText("Android broadcast text");
broadcast.goAppAfterOpen();
broadcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
broadcast.setProductionMode();
// Set customized fields
broadcast.setExtraField("test", "helloworld");
//厂商通道相关参数
broadcast.setChannelActivity("your channel activity");
broadcast.setChannelProperties("abc");
client.send(broadcast);
}
/**
* 安卓单推
*
* @param deviceToken
* @param unicastText
* @param unicastTicker
* @param title
* @throws Exception
*/
public void sendAndroidUnicast(String deviceToken, String unicastText, String unicastTicker, String title) throws Exception {
AndroidUnicast unicast = new AndroidUnicast(appkey, appMasterSecret);
// Set your device token
/**
* 安卓单推
*
* @param deviceToken
* @param unicastText
* @param unicastTicker
* @param title
* @throws Exception
*/
public void sendAndroidUnicast(String deviceToken, String unicastText, String unicastTicker, String title) throws Exception {
AndroidUnicast unicast = new AndroidUnicast(appkey, appMasterSecret);
// Set your device token
unicast.setDeviceToken(deviceToken);
unicast.setTicker(unicastTicker);
unicast.setTitle(title);
unicast.setDeviceToken(deviceToken);
unicast.setTicker(unicastTicker);
unicast.setTitle(title);
unicast.setText(unicastText);
unicast.goAppAfterOpen();
unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
unicast.setProductionMode();
// Set customized fields
unicast.setExtraField("test", "helloworld");
unicast.setChannelActivity("your channel activity");
unicast.setChannelProperties("abc");
client.send(unicast);
}
unicast.setText(unicastText);
unicast.goAppAfterOpen();
unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
unicast.setProductionMode();
// Set customized fields
unicast.setExtraField("test", "helloworld");
unicast.setChannelActivity("your channel activity");
unicast.setChannelProperties("abc");
client.send(unicast);
}
public void sendAndroidGroupcast() throws Exception {
AndroidGroupcast groupcast = new AndroidGroupcast(appkey, appMasterSecret);
/*
* Construct the filter condition:
* "where":
* {
* "and":
* [
* {"tag":"test"},
* {"tag":"Test"}
* ]
* }
*/
JSONObject filterJson = new JSONObject();
JSONObject whereJson = new JSONObject();
JSONArray tagArray = new JSONArray();
JSONObject testTag = new JSONObject();
JSONObject TestTag = new JSONObject();
testTag.put("tag", "test");
TestTag.put("tag", "Test");
tagArray.put(testTag);
tagArray.put(TestTag);
whereJson.put("and", tagArray);
filterJson.put("where", whereJson);
public void sendAndroidGroupcast() throws Exception {
AndroidGroupcast groupcast = new AndroidGroupcast(appkey, appMasterSecret);
/*
* Construct the filter condition:
* "where":
* {
* "and":
* [
* {"tag":"test"},
* {"tag":"Test"}
* ]
* }
*/
JSONObject filterJson = new JSONObject();
JSONObject whereJson = new JSONObject();
JSONArray tagArray = new JSONArray();
JSONObject testTag = new JSONObject();
JSONObject TestTag = new JSONObject();
testTag.put("tag", "test");
TestTag.put("tag", "Test");
tagArray.put(testTag);
tagArray.put(TestTag);
whereJson.put("and", tagArray);
filterJson.put("where", whereJson);
groupcast.setFilter(filterJson);
groupcast.setTicker("Android groupcast ticker");
groupcast.setTitle("中文的title");
groupcast.setText("Android groupcast text");
groupcast.goAppAfterOpen();
groupcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
groupcast.setChannelActivity("your channel activity");
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
groupcast.setProductionMode();
//厂商通道相关参数
groupcast.setChannelActivity("your channel activity");
groupcast.setChannelProperties("abc");
client.send(groupcast);
}
groupcast.setFilter(filterJson);
groupcast.setTicker("Android groupcast ticker");
groupcast.setTitle("中文的title");
groupcast.setText("Android groupcast text");
groupcast.goAppAfterOpen();
groupcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
groupcast.setChannelActivity("your channel activity");
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
groupcast.setProductionMode();
//厂商通道相关参数
groupcast.setChannelActivity("your channel activity");
groupcast.setChannelProperties("abc");
client.send(groupcast);
}
public void sendAndroidCustomizedcast() throws Exception {
AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey, appMasterSecret);
// Set your alias here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
customizedcast.setAlias("alias", "alias_type");
customizedcast.setTicker("Android customizedcast ticker");
customizedcast.setTitle("中文的title");
customizedcast.setText("Android customizedcast text");
customizedcast.goAppAfterOpen();
customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
customizedcast.setProductionMode();
//厂商通道相关参数
customizedcast.setChannelActivity("your channel activity");
customizedcast.setChannelProperties("abc");
client.send(customizedcast);
}
public void sendAndroidCustomizedcast() throws Exception {
AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey, appMasterSecret);
// Set your alias here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
customizedcast.setAlias("alias", "alias_type");
customizedcast.setTicker("Android customizedcast ticker");
customizedcast.setTitle("中文的title");
customizedcast.setText("Android customizedcast text");
customizedcast.goAppAfterOpen();
customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
customizedcast.setProductionMode();
//厂商通道相关参数
customizedcast.setChannelActivity("your channel activity");
customizedcast.setChannelProperties("abc");
client.send(customizedcast);
}
public void sendAndroidCustomizedcastFile() throws Exception {
AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey, appMasterSecret);
// Set your alias here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
String fileId = client.uploadContents(appkey, appMasterSecret, "aa" + "\n" + "bb" + "\n" + "alias");
customizedcast.setFileId(fileId, "alias_type");
customizedcast.setTicker("Android customizedcast ticker");
customizedcast.setTitle("中文的title");
customizedcast.setText("Android customizedcast text");
customizedcast.goAppAfterOpen();
customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
customizedcast.setProductionMode();
//厂商通道相关参数
customizedcast.setChannelActivity("your channel activity");
customizedcast.setChannelProperties("abc");
client.send(customizedcast);
}
public void sendAndroidCustomizedcastFile() throws Exception {
AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey, appMasterSecret);
// Set your alias here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
String fileId = client.uploadContents(appkey, appMasterSecret, "aa" + "\n" + "bb" + "\n" + "alias");
customizedcast.setFileId(fileId, "alias_type");
customizedcast.setTicker("Android customizedcast ticker");
customizedcast.setTitle("中文的title");
customizedcast.setText("Android customizedcast text");
customizedcast.goAppAfterOpen();
customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
customizedcast.setProductionMode();
//厂商通道相关参数
customizedcast.setChannelActivity("your channel activity");
customizedcast.setChannelProperties("abc");
client.send(customizedcast);
}
public void sendAndroidFilecast() throws Exception {
AndroidFilecast filecast = new AndroidFilecast(appkey, appMasterSecret);
// upload your device tokens, and use '\n' to split them if there are multiple tokens
String fileId = client.uploadContents(appkey, appMasterSecret, "aa" + "\n" + "bb");
filecast.setFileId(fileId);
filecast.setTicker("Android filecast ticker");
filecast.setTitle("中文的title");
filecast.setText("Android filecast text");
filecast.goAppAfterOpen();
filecast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
//厂商通道相关参数
filecast.setChannelActivity("your channel activity");
filecast.setChannelProperties("abc");
client.send(filecast);
}
public void sendAndroidFilecast() throws Exception {
AndroidFilecast filecast = new AndroidFilecast(appkey, appMasterSecret);
// upload your device tokens, and use '\n' to split them if there are multiple tokens
String fileId = client.uploadContents(appkey, appMasterSecret, "aa" + "\n" + "bb");
filecast.setFileId(fileId);
filecast.setTicker("Android filecast ticker");
filecast.setTitle("中文的title");
filecast.setText("Android filecast text");
filecast.goAppAfterOpen();
filecast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
//厂商通道相关参数
filecast.setChannelActivity("your channel activity");
filecast.setChannelProperties("abc");
client.send(filecast);
}
public void sendIOSBroadcast() throws Exception {
IOSBroadcast broadcast = new IOSBroadcast(appkey, appMasterSecret);
//alert值设置为字符串
//broadcast.setAlert("IOS 广播测试");
//alert的值设置为字典
broadcast.setAlert("今日天气", "", "今日可能下雨🌂");
broadcast.setBadge(0);
broadcast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
broadcast.setTestMode();
// Set customized fields
broadcast.setCustomizedField("test", "helloworld");
client.send(broadcast);
}
public void sendIOSBroadcast() throws Exception {
IOSBroadcast broadcast = new IOSBroadcast(appkey, appMasterSecret);
//alert值设置为字符串
//broadcast.setAlert("IOS 广播测试");
//alert的值设置为字典
broadcast.setAlert("今日天气", "", "今日可能下雨🌂");
broadcast.setBadge(0);
broadcast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
broadcast.setTestMode();
// Set customized fields
broadcast.setCustomizedField("test", "helloworld");
client.send(broadcast);
}
/**
* ios单推
*
* @param deviceToken
* @param title
* @param subtitle
* @param body
* @throws Exception
*/
public void sendIOSUnicast(String deviceToken, String title, String subtitle, String body) throws Exception {
IOSUnicast unicast = new IOSUnicast(appkey, appMasterSecret);
// Set your device token
/**
* ios单推
*
* @param deviceToken
* @param title
* @param subtitle
* @param body
* @throws Exception
*/
public void sendIOSUnicast(String deviceToken, String title, String subtitle, String body) throws Exception {
IOSUnicast unicast = new IOSUnicast(appkey, appMasterSecret);
// Set your device token
unicast.setDeviceToken(deviceToken);
//alert值设置为字符串
//unicast.setAlert("IOS 单播测试");
//alert的值设置为字典
unicast.setDeviceToken(deviceToken);
//alert值设置为字符串
//unicast.setAlert("IOS 单播测试");
//alert的值设置为字典
unicast.setAlert(title, subtitle, body);
unicast.setBadge(0);
unicast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
unicast.setTestMode();
// Set customized fields
unicast.setCustomizedField("test", "helloworld");
client.send(unicast);
}
unicast.setAlert(title, subtitle, body);
unicast.setBadge(0);
unicast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
unicast.setTestMode();
// Set customized fields
unicast.setCustomizedField("test", "helloworld");
client.send(unicast);
}
public void sendIOSGroupcast() throws Exception {
IOSGroupcast groupcast = new IOSGroupcast(appkey, appMasterSecret);
/*
* Construct the filter condition:
* "where":
* {
* "and":
* [
* {"tag":"iostest"}
* ]
* }
*/
JSONObject filterJson = new JSONObject();
JSONObject whereJson = new JSONObject();
JSONArray tagArray = new JSONArray();
JSONObject testTag = new JSONObject();
testTag.put("tag", "iostest");
tagArray.put(testTag);
whereJson.put("and", tagArray);
filterJson.put("where", whereJson);
System.out.println(filterJson.toString());
public void sendIOSGroupcast() throws Exception {
IOSGroupcast groupcast = new IOSGroupcast(appkey, appMasterSecret);
/*
* Construct the filter condition:
* "where":
* {
* "and":
* [
* {"tag":"iostest"}
* ]
* }
*/
JSONObject filterJson = new JSONObject();
JSONObject whereJson = new JSONObject();
JSONArray tagArray = new JSONArray();
JSONObject testTag = new JSONObject();
testTag.put("tag", "iostest");
tagArray.put(testTag);
whereJson.put("and", tagArray);
filterJson.put("where", whereJson);
System.out.println(filterJson.toString());
// Set filter condition into rootJson
groupcast.setFilter(filterJson);
//groupcast.setAlert("IOS 组播测试");
//alert的值设置为字典
groupcast.setAlert("今日天气", "subtitle", "今日可能下雨🌂");
groupcast.setBadge(0);
groupcast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
groupcast.setTestMode();
client.send(groupcast);
}
// Set filter condition into rootJson
groupcast.setFilter(filterJson);
//groupcast.setAlert("IOS 组播测试");
//alert的值设置为字典
groupcast.setAlert("今日天气", "subtitle", "今日可能下雨🌂");
groupcast.setBadge(0);
groupcast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
groupcast.setTestMode();
client.send(groupcast);
}
public void sendIOSCustomizedcast() throws Exception {
IOSCustomizedcast customizedcast = new IOSCustomizedcast(appkey, appMasterSecret);
// Set your alias and alias_type here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
customizedcast.setAlias("alias", "alias_type");
//customizedcast.setAlert("IOS 个性化测试");
//alert的值设置为字典
customizedcast.setAlert("今日天气", "", "今日可能下雨🌂");
customizedcast.setBadge(0);
customizedcast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
customizedcast.setTestMode();
client.send(customizedcast);
}
public void sendIOSCustomizedcast() throws Exception {
IOSCustomizedcast customizedcast = new IOSCustomizedcast(appkey, appMasterSecret);
// Set your alias and alias_type here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
customizedcast.setAlias("alias", "alias_type");
//customizedcast.setAlert("IOS 个性化测试");
//alert的值设置为字典
customizedcast.setAlert("今日天气", "", "今日可能下雨🌂");
customizedcast.setBadge(0);
customizedcast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
customizedcast.setTestMode();
client.send(customizedcast);
}
public void sendIOSFilecast() throws Exception {
IOSFilecast filecast = new IOSFilecast(appkey, appMasterSecret);
// upload your device tokens, and use '\n' to split them if there are multiple tokens
String fileId = client.uploadContents(appkey, appMasterSecret, "aa" + "\n" + "bb");
filecast.setFileId(fileId);
//filecast.setAlert("IOS 文件播测试");
//alert的值设置为字典
filecast.setAlert("今日天气", "", "今日可能下雨🌂");
filecast.setBadge(0);
filecast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
filecast.setTestMode();
client.send(filecast);
}
public void sendIOSFilecast() throws Exception {
IOSFilecast filecast = new IOSFilecast(appkey, appMasterSecret);
// upload your device tokens, and use '\n' to split them if there are multiple tokens
String fileId = client.uploadContents(appkey, appMasterSecret, "aa" + "\n" + "bb");
filecast.setFileId(fileId);
//filecast.setAlert("IOS 文件播测试");
//alert的值设置为字典
filecast.setAlert("今日天气", "", "今日可能下雨🌂");
filecast.setBadge(0);
filecast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
filecast.setTestMode();
client.send(filecast);
}
}
......@@ -6,77 +6,77 @@ import java.util.Arrays;
import java.util.HashSet;
public abstract class UmengNotification {
// Keys can be set in the root level
protected static final HashSet<String> ROOT_KEYS = new HashSet<String>(Arrays.asList("appkey", "timestamp", "type", "device_tokens", "alias", "alias_type", "file_id",
"filter", "production_mode", "feedback", "description", "thirdparty_id", "mipush", "mi_activity", "channel_properties"));
// Keys can be set in the policy level
protected static final HashSet<String> POLICY_KEYS = new HashSet<String>(Arrays.asList("start_time", "expire_time", "max_send_num"));
// This JSONObject is used for constructing the whole request string.
protected final JSONObject rootJson = new JSONObject();
// The app master secret
protected String appMasterSecret;
// Set predefined keys in the rootJson, for extra keys(Android) or customized keys(IOS) please
// refer to corresponding methods in the subclass.
public abstract boolean setPredefinedKeyValue(String key, Object value) throws Exception;
public String getPostBody() {
return rootJson.toString();
}
protected final String getAppMasterSecret() {
return appMasterSecret;
}
public void setAppMasterSecret(String secret) {
appMasterSecret = secret;
}
protected void setProductionMode(Boolean prod) throws Exception {
setPredefinedKeyValue("production_mode", prod.toString());
}
///正式模式
public void setProductionMode() throws Exception {
setProductionMode(true);
}
///测试模式
public void setTestMode() throws Exception {
setProductionMode(false);
}
///发送消息描述,建议填写。
public void setDescription(String description) throws Exception {
setPredefinedKeyValue("description", description);
}
///定时发送时间,若不填写表示立即发送。格式: "YYYY-MM-DD hh:mm:ss"。
public void setStartTime(String startTime) throws Exception {
setPredefinedKeyValue("start_time", startTime);
}
///消息过期时间,格式: "YYYY-MM-DD hh:mm:ss"。
public void setExpireTime(String expireTime) throws Exception {
setPredefinedKeyValue("expire_time", expireTime);
}
///发送限速,每秒发送的最大条数。
public void setMaxSendNum(Integer num) throws Exception {
setPredefinedKeyValue("max_send_num", num);
}
//厂商弹窗activity
public void setChannelActivity(String activity) throws Exception {
setPredefinedKeyValue("mipush", "true");
setPredefinedKeyValue("mi_activity", activity);
}
//厂商属性配置
public void setChannelProperties(String xiaoMiChannelId) throws Exception {
JSONObject object = new JSONObject();
object.put("xiaomi_channel_id", xiaoMiChannelId);
setPredefinedKeyValue("channel_properties", object);
}
// Keys can be set in the root level
protected static final HashSet<String> ROOT_KEYS = new HashSet<String>(Arrays.asList("appkey", "timestamp", "type", "device_tokens", "alias", "alias_type", "file_id",
"filter", "production_mode", "feedback", "description", "thirdparty_id", "mipush", "mi_activity", "channel_properties"));
// Keys can be set in the policy level
protected static final HashSet<String> POLICY_KEYS = new HashSet<String>(Arrays.asList("start_time", "expire_time", "max_send_num"));
// This JSONObject is used for constructing the whole request string.
protected final JSONObject rootJson = new JSONObject();
// The app master secret
protected String appMasterSecret;
// Set predefined keys in the rootJson, for extra keys(Android) or customized keys(IOS) please
// refer to corresponding methods in the subclass.
public abstract boolean setPredefinedKeyValue(String key, Object value) throws Exception;
public String getPostBody() {
return rootJson.toString();
}
protected final String getAppMasterSecret() {
return appMasterSecret;
}
public void setAppMasterSecret(String secret) {
appMasterSecret = secret;
}
protected void setProductionMode(Boolean prod) throws Exception {
setPredefinedKeyValue("production_mode", prod.toString());
}
///正式模式
public void setProductionMode() throws Exception {
setProductionMode(true);
}
///测试模式
public void setTestMode() throws Exception {
setProductionMode(false);
}
///发送消息描述,建议填写。
public void setDescription(String description) throws Exception {
setPredefinedKeyValue("description", description);
}
///定时发送时间,若不填写表示立即发送。格式: "YYYY-MM-DD hh:mm:ss"。
public void setStartTime(String startTime) throws Exception {
setPredefinedKeyValue("start_time", startTime);
}
///消息过期时间,格式: "YYYY-MM-DD hh:mm:ss"。
public void setExpireTime(String expireTime) throws Exception {
setPredefinedKeyValue("expire_time", expireTime);
}
///发送限速,每秒发送的最大条数。
public void setMaxSendNum(Integer num) throws Exception {
setPredefinedKeyValue("max_send_num", num);
}
//厂商弹窗activity
public void setChannelActivity(String activity) throws Exception {
setPredefinedKeyValue("mipush", "true");
setPredefinedKeyValue("mi_activity", activity);
}
//厂商属性配置
public void setChannelProperties(String xiaoMiChannelId) throws Exception {
JSONObject object = new JSONObject();
object.put("xiaomi_channel_id", xiaoMiChannelId);
setPredefinedKeyValue("channel_properties", object);
}
}
......@@ -4,9 +4,9 @@ package com.wecloud.im.push.android;
import com.wecloud.im.push.AndroidNotification;
public class AndroidBroadcast extends AndroidNotification {
public AndroidBroadcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "broadcast");
}
public AndroidBroadcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "broadcast");
}
}
......@@ -4,20 +4,20 @@ import com.wecloud.im.push.AndroidNotification;
public class AndroidCustomizedcast extends AndroidNotification {
public AndroidCustomizedcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "customizedcast");
}
public AndroidCustomizedcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "customizedcast");
}
public void setAlias(String alias, String aliasType) throws Exception {
setPredefinedKeyValue("alias", alias);
setPredefinedKeyValue("alias_type", aliasType);
}
public void setAlias(String alias, String aliasType) throws Exception {
setPredefinedKeyValue("alias", alias);
setPredefinedKeyValue("alias_type", aliasType);
}
public void setFileId(String fileId, String aliasType) throws Exception {
setPredefinedKeyValue("file_id", fileId);
setPredefinedKeyValue("alias_type", aliasType);
}
public void setFileId(String fileId, String aliasType) throws Exception {
setPredefinedKeyValue("file_id", fileId);
setPredefinedKeyValue("alias_type", aliasType);
}
}
......@@ -5,13 +5,13 @@ import org.json.JSONObject;
public class AndroidGroupcast extends AndroidNotification {
public AndroidGroupcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "groupcast");
}
public AndroidGroupcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "groupcast");
}
public void setFilter(JSONObject filter) throws Exception {
setPredefinedKeyValue("filter", filter);
}
public void setFilter(JSONObject filter) throws Exception {
setPredefinedKeyValue("filter", filter);
}
}
......@@ -4,9 +4,9 @@ package com.wecloud.im.push.ios;
import com.wecloud.im.push.IOSNotification;
public class IOSBroadcast extends IOSNotification {
public IOSBroadcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "broadcast");
}
public IOSBroadcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "broadcast");
}
}
......@@ -4,20 +4,20 @@ import com.wecloud.im.push.IOSNotification;
public class IOSCustomizedcast extends IOSNotification {
public IOSCustomizedcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "customizedcast");
}
public IOSCustomizedcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "customizedcast");
}
public void setAlias(String alias, String aliasType) throws Exception {
setPredefinedKeyValue("alias", alias);
setPredefinedKeyValue("alias_type", aliasType);
}
public void setAlias(String alias, String aliasType) throws Exception {
setPredefinedKeyValue("alias", alias);
setPredefinedKeyValue("alias_type", aliasType);
}
public void setFileId(String fileId, String aliasType) throws Exception {
setPredefinedKeyValue("file_id", fileId);
setPredefinedKeyValue("alias_type", aliasType);
}
public void setFileId(String fileId, String aliasType) throws Exception {
setPredefinedKeyValue("file_id", fileId);
setPredefinedKeyValue("alias_type", aliasType);
}
}
......@@ -5,13 +5,13 @@ import org.json.JSONObject;
public class IOSGroupcast extends IOSNotification {
public IOSGroupcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "groupcast");
}
public IOSGroupcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "groupcast");
}
public void setFilter(JSONObject filter) throws Exception {
setPredefinedKeyValue("filter", filter);
}
public void setFilter(JSONObject filter) throws Exception {
setPredefinedKeyValue("filter", filter);
}
}
......@@ -4,13 +4,13 @@ package com.wecloud.im.push.ios;
import com.wecloud.im.push.IOSNotification;
public class IOSUnicast extends IOSNotification {
public IOSUnicast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "unicast");
}
public IOSUnicast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "unicast");
}
public void setDeviceToken(String token) throws Exception {
setPredefinedKeyValue("device_tokens", token);
}
public void setDeviceToken(String token) throws Exception {
setPredefinedKeyValue("device_tokens", token);
}
}
......@@ -39,42 +39,6 @@ public class GetIpUtils {
@Value("${load-blance.server-type}")
private String SERVER_TYPE;
/**
* 内网ip
*
* @return
*/
public String getlanIp() {
if (lAN_IP == null) {
lAN_IP = getLocalIpAddress();
}
return lAN_IP;
}
/**
* 公网ip
*/
public String getPublicIp() {
if (PUBLIC_IP == null) {
switch (SERVER_TYPE) {
case LOCAL:
PUBLIC_IP = getlanIp();
break;
case AWS:
PUBLIC_IP = HttpUtil.get("http://instance-data/latest/meta-data/public-ipv4", 30);
break;
case HUAWEI_CLOUD:
PUBLIC_IP = HttpUtil.get("http://169.254.169.254/latest/meta-data/public-ipv4", 30);
break;
}
}
return PUBLIC_IP;
}
/**
* 判断是否为虚拟mac地址
*
......@@ -149,4 +113,39 @@ public class GetIpUtils {
return StringUtils.EMPTY;
}
/**
* 内网ip
*
* @return
*/
public String getlanIp() {
if (lAN_IP == null) {
lAN_IP = getLocalIpAddress();
}
return lAN_IP;
}
/**
* 公网ip
*/
public String getPublicIp() {
if (PUBLIC_IP == null) {
switch (SERVER_TYPE) {
case LOCAL:
PUBLIC_IP = getlanIp();
break;
case AWS:
PUBLIC_IP = HttpUtil.get("http://instance-data/latest/meta-data/public-ipv4", 30);
break;
case HUAWEI_CLOUD:
PUBLIC_IP = HttpUtil.get("http://169.254.169.254/latest/meta-data/public-ipv4", 30);
break;
}
}
return PUBLIC_IP;
}
}
......@@ -17,69 +17,69 @@ import io.geekidea.springbootplus.framework.core.pagination.Paging;
public interface ImClientBlacklistService extends BaseService<ImClientBlacklist> {
/**
* 当前客户端是否被拉黑
*
* @param currentClient 当前客户端
* @param toClient 对方客户端
* @return
*/
boolean isBeBlack(Long currentClient, Long toClient);
/**
* 当前客户端是否被拉黑
*
* @param currentClient 当前客户端
* @param toClient 对方客户端
* @return
*/
boolean isBeBlack(Long currentClient, Long toClient);
/**
* 拉入黑名单
*
* @param imClientBlacklistUpdate
* @return
* @throws Exception
*/
ApiResult<Boolean> addImClientBlacklist(ImClientBlacklistUpdate imClientBlacklistUpdate) throws Exception;
/**
* 拉入黑名单
*
* @param imClientBlacklistUpdate
* @return
* @throws Exception
*/
ApiResult<Boolean> addImClientBlacklist(ImClientBlacklistUpdate imClientBlacklistUpdate) throws Exception;
/**
* 移出黑名单
*
* @param imClientBlacklistUpdate
* @return
* @throws Exception
*/
ApiResult<Boolean> removeImClientBlacklist(ImClientBlacklistUpdate imClientBlacklistUpdate) throws Exception;
/**
* 移出黑名单
*
* @param imClientBlacklistUpdate
* @return
* @throws Exception
*/
ApiResult<Boolean> removeImClientBlacklist(ImClientBlacklistUpdate imClientBlacklistUpdate) throws Exception;
/**
* 保存
*
* @param imClientBlacklist
* @return
* @throws Exception
*/
boolean saveImClientBlacklist(ImClientBlacklist imClientBlacklist) throws Exception;
/**
* 保存
*
* @param imClientBlacklist
* @return
* @throws Exception
*/
boolean saveImClientBlacklist(ImClientBlacklist imClientBlacklist) throws Exception;
/**
* 修改
*
* @param imClientBlacklist
* @return
* @throws Exception
*/
boolean updateImClientBlacklist(ImClientBlacklist imClientBlacklist) throws Exception;
/**
* 修改
*
* @param imClientBlacklist
* @return
* @throws Exception
*/
boolean updateImClientBlacklist(ImClientBlacklist imClientBlacklist) throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteImClientBlacklist(Long id) throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteImClientBlacklist(Long id) throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
ImClientBlacklistQueryVo getImClientBlacklistById(Long id) throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
ImClientBlacklistQueryVo getImClientBlacklistById(Long id) throws Exception;
// /**
// * 获取分页对象
......@@ -91,12 +91,12 @@ public interface ImClientBlacklistService extends BaseService<ImClientBlacklist>
// Paging<ImClientBlacklistQueryVo> getImClientBlacklistPageList(ImClientBlacklistPageParam imClientBlacklistPageParam) throws Exception;
/**
* 获取分页对象
*
* @return
* @throws Exception
*/
ApiResult<Paging<ImClientBlacklistQueryVo>> getImClientBlacklistPageList(ImClientBlacklistPageParam imClientBlacklistPageParam) throws Exception;
/**
* 获取分页对象
*
* @return
* @throws Exception
*/
ApiResult<Paging<ImClientBlacklistQueryVo>> getImClientBlacklistPageList(ImClientBlacklistPageParam imClientBlacklistPageParam) throws Exception;
}
......@@ -25,73 +25,73 @@ import java.util.List;
public interface ImConversationMembersService extends BaseService<ImConversationMembers> {
/**
* 服务端api-会话成员表分页列表
*
* @param apiImConversationMembersPageParam
* @param imApplication
* @return
*/
ApiResult<List<ApiImConversationMembersQueryVo>> getRestApiImConversationMembersList(ApiImConversationMembersPageParam apiImConversationMembersPageParam, ImApplication imApplication);
ApiResult<Boolean> saveOrUpdateClientRemarkName(ImConvMemeClientRemarkNameParam imConvMemeClientRemarkNameParam);
/**
* 会话成员表分页列表
*
* @param imConversationMembersListParam
* @return
* @throws Exception
*/
List<ImConversationMemberListVo> getImConversationMembersList(ImConversationMembersListParam imConversationMembersListParam) throws Exception;
ApiResult<Boolean> saveOrUpdateAttr(ImConversationMemAttrUpdate imConversationMemAttrUpdate);
/**
* 保存
*
* @param imConversationMembers
* @return
* @throws Exception
*/
boolean saveImConversationMembers(ImConversationMembers imConversationMembers) throws Exception;
/**
* 修改
*
* @param imConversationMembers
* @return
* @throws Exception
*/
boolean updateImConversationMembers(ImConversationMembers imConversationMembers) throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteImConversationMembers(Long id) throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
ImConversationMembersQueryVo getImConversationMembersById(Long id) throws Exception;
/**
* 获取分页对象
*
* @param imConversationMembersPageParam
* @return
* @throws Exception
*/
Paging<ImConversationMembersQueryVo> getImConversationMembersPageList(ImConversationMembersPageParam imConversationMembersPageParam) throws Exception;
/**
* 服务端api-会话成员表分页列表
*
* @param apiImConversationMembersPageParam
* @param imApplication
* @return
*/
ApiResult<List<ApiImConversationMembersQueryVo>> getRestApiImConversationMembersList(ApiImConversationMembersPageParam apiImConversationMembersPageParam, ImApplication imApplication);
ApiResult<Boolean> saveOrUpdateClientRemarkName(ImConvMemeClientRemarkNameParam imConvMemeClientRemarkNameParam);
/**
* 会话成员表分页列表
*
* @param imConversationMembersListParam
* @return
* @throws Exception
*/
List<ImConversationMemberListVo> getImConversationMembersList(ImConversationMembersListParam imConversationMembersListParam) throws Exception;
ApiResult<Boolean> saveOrUpdateAttr(ImConversationMemAttrUpdate imConversationMemAttrUpdate);
/**
* 保存
*
* @param imConversationMembers
* @return
* @throws Exception
*/
boolean saveImConversationMembers(ImConversationMembers imConversationMembers) throws Exception;
/**
* 修改
*
* @param imConversationMembers
* @return
* @throws Exception
*/
boolean updateImConversationMembers(ImConversationMembers imConversationMembers) throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteImConversationMembers(Long id) throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
ImConversationMembersQueryVo getImConversationMembersById(Long id) throws Exception;
/**
* 获取分页对象
*
* @param imConversationMembersPageParam
* @return
* @throws Exception
*/
Paging<ImConversationMembersQueryVo> getImConversationMembersPageList(ImConversationMembersPageParam imConversationMembersPageParam) throws Exception;
}
......@@ -61,27 +61,27 @@ public interface ImInboxService extends BaseService<ImInbox> {
// Paging<ImInboxQueryVo> getImInboxPageList(ImInboxPageParam imInboxPageParam) throws Exception;
/**
* 消息修改为已接收状态
*
* @param imMsgReceivedUpdate
* @return
*/
ApiResult<Boolean> updateImMsgReceived(ImMsgReceivedStatusUpdate imMsgReceivedUpdate);
/**
* 消息修改为已接收状态
*
* @param imMsgReceivedUpdate
* @return
*/
ApiResult<Boolean> updateImMsgReceived(ImMsgReceivedStatusUpdate imMsgReceivedUpdate);
/**
* 统计未读消息数量
*
* @param clientId
* @return
*/
Integer countMyNotReadCount(Long clientId);
/**
* 统计未读消息数量
*
* @param clientId
* @return
*/
Integer countMyNotReadCount(Long clientId);
/**
* 消息修改为已读状态
*
* @return
*/
ApiResult<Boolean> updateImMsgRead(ImMsgReadStatusUpdate imMsgReadStatusUpdate) throws JsonProcessingException;
/**
* 消息修改为已读状态
*
* @return
*/
ApiResult<Boolean> updateImMsgRead(ImMsgReadStatusUpdate imMsgReadStatusUpdate) throws JsonProcessingException;
}
......@@ -12,52 +12,52 @@ import io.geekidea.springbootplus.framework.common.service.BaseService;
*/
public interface ImIosApnsService extends BaseService<ImIosApns> {
/**
* 保存
*
* @param imIosApns
* @return
* @throws Exception
*/
boolean saveImIosApns(ImIosApns imIosApns) throws Exception;
/**
* 修改
*
* @param imIosApns
* @return
* @throws Exception
*/
boolean updateImIosApns(ImIosApns imIosApns) throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteImIosApns(Long id) throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
ImIosApnsQueryVo getImIosApnsById(Long id) throws Exception;
ImIosApns getImIosApnsByAppId(Long appId);
/**
* 获取分页对象
*
* @param imIosApnsPageParam
* @return
* @throws Exception
*/
/**
* 保存
*
* @param imIosApns
* @return
* @throws Exception
*/
boolean saveImIosApns(ImIosApns imIosApns) throws Exception;
/**
* 修改
*
* @param imIosApns
* @return
* @throws Exception
*/
boolean updateImIosApns(ImIosApns imIosApns) throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteImIosApns(Long id) throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
ImIosApnsQueryVo getImIosApnsById(Long id) throws Exception;
ImIosApns getImIosApnsByAppId(Long appId);
/**
* 获取分页对象
*
* @param imIosApnsPageParam
* @return
* @throws Exception
*/
// Paging<ImIosApnsQueryVo> getImIosApnsPageList(ImIosApnsPageParam imIosApnsPageParam) throws Exception;
}
......@@ -35,15 +35,13 @@ public class ImClientLoginServiceImpl implements ImClientLoginService {
// @Autowired
// private StringRedisTemplate redisTemplate;
private static JwtProperties jwtProperties;
@Autowired
private ImApplicationService imApplicationService;
@Autowired
private ImClientService imClientService;
@Autowired
private WsInstance wsInstance;
private static JwtProperties jwtProperties;
@Autowired
private AppLoginRedisService appLoginRedisService;
......
......@@ -29,10 +29,6 @@ public enum WsRequestCmdEnum {
this.cmdCode = uriCode;
}
public int getCmdCode() {
return cmdCode;
}
/**
* 根据uriCode获取
*
......@@ -47,4 +43,8 @@ public enum WsRequestCmdEnum {
}
return null;
}
public int getCmdCode() {
return cmdCode;
}
}
......@@ -17,19 +17,17 @@ public class WsConstants {
* 当前服务器cpu核心数量()
*/
public static final Integer CPU_PROCESSORS = Runtime.getRuntime().availableProcessors();
static {
log.info("CPU_PROCESSORS:" + CPU_PROCESSORS);
}
/**
* 长连接url
*/
public static final String WS_URL = "/ws";
/**
* token
*/
public static final String TOKEN = "token";
static {
log.info("CPU_PROCESSORS:" + CPU_PROCESSORS);
}
}
......@@ -33,31 +33,24 @@ import java.util.Map;
@Slf4j
public class PushTask {
@Autowired
private ImIosApnsService imIosApnsService;
@Autowired
private ImInboxService imInboxService;
/**
* 谷歌推送地址
*/
private static final String API_URL_FCM = "https://fcm.googleapis.com/fcm/send";
/**
* 您收到一条新消息
*/
private static final String PUSH_TITLE = "You have received a new message";
/**
* 点击查看
*/
private static final String PUSH_BODY = "Click to view";
private static final String title = "title";
private static final String subTitle = "subTitle";
@Autowired
private ImIosApnsService imIosApnsService;
@Autowired
private ImInboxService imInboxService;
/**
* 异步系统推送
......
......@@ -45,10 +45,9 @@ import java.util.List;
@Slf4j
public class ImChatConcrete extends ImCmdAbstract {
private static final String TO_CONVERSATION_KEY = "toConversation";
public static final String PUSH_KEY = "push";
public static final String MSG_ID = "msgId";
private static final String TO_CONVERSATION_KEY = "toConversation";
private static final JsonMapper JSON_MAPPER = new JsonMapper();
@Autowired
......
......@@ -86,6 +86,13 @@ public class EncrypDES {
return arrOut;
}
public static void main(String[] args) throws Exception {
String code = "427d68ae59e577f7b87f05d43670df58";
EncrypDES encrypDES = new EncrypDES();
//System.out.println(encrypDES.decrypt(code));
System.out.println(encrypDES.encrypt("18011953567"));
}
/**
* 加密字节数组
*
......@@ -144,13 +151,6 @@ public class EncrypDES {
return key;
}
public static void main(String[] args) throws Exception {
String code = "427d68ae59e577f7b87f05d43670df58";
EncrypDES encrypDES = new EncrypDES();
//System.out.println(encrypDES.decrypt(code));
System.out.println(encrypDES.encrypt("18011953567"));
}
/*public static void main(String[] args) {
try {
*//*String msg1 = "1";
......
......@@ -15,6 +15,14 @@ public class SpringBeanUtils implements ApplicationContextAware {
private static ApplicationContext applicationContext;
public static Object getBean(String name) {
return applicationContext.getBean(name);
}
public static <T> T getBean(Class<T> clazz) {
return applicationContext.getBean(clazz);
}
@Override
public void setApplicationContext(ApplicationContext context) throws BeansException {
......@@ -23,12 +31,4 @@ public class SpringBeanUtils implements ApplicationContextAware {
}
}
public static Object getBean(String name) {
return applicationContext.getBean(name);
}
public static <T> T getBean(Class<T> clazz) {
return applicationContext.getBean(clazz);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wecloud.im.mapper.ImInboxMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id
, create_time, update_time, read_time, receiver_time, fk_appid, receiver, fk_msg_id, read_msg_status, receiver_msg_status, fk_conversation_id
</sql>
<update id="updateImMsgReceivedByIds">
UPDATE im_inbox
SET `im_inbox`.`update_time` = NOW(),
`im_inbox`.`receiver_msg_status` = 1,
`im_inbox`.`receiver_time` = NOW()
WHERE
im_inbox.receiver = #{clientId}
AND im_inbox.fk_msg_id IN
<foreach collection="msgIds" item="deptId" index="i" open="(" close=")" separator=",">
#{deptId}
</foreach>
</update>
<update id="updateImMsgReadByIds">
UPDATE im_inbox
SET `im_inbox`.`update_time` = NOW(),
`im_inbox`.`read_msg_status` = 1,
`im_inbox`.`receiver_time` = NOW(),
`im_inbox`.`read_time` = NOW()
WHERE
im_inbox.receiver = #{clientId}
AND im_inbox.fk_msg_id IN
<foreach collection="msgIds" item="deptId" index="i" open="(" close=")" separator=",">
#{deptId}
</foreach>
</update>
<select id="getImInboxById" resultType="com.wecloud.im.param.ImInboxQueryVo">
select
<include refid="Base_Column_List"/>
from im_Inbox where id = #{id}
</select>
<select id="getImInboxPageList" parameterType="com.wecloud.im.param.ImInboxPageParam"
resultType="com.wecloud.im.param.ImInboxQueryVo">
select
<include refid="Base_Column_List"/>
from im_Inbox
</select>
<select id="countMyNotReadCount" resultType="java.lang.Integer">
SELECT COUNT(id)
FROM im_inbox
WHERE receiver = #{clientId}
AND receiver_msg_status = 0
</select>
</mapper>
......@@ -21,11 +21,11 @@
from im_message
</select>
<select id="getOfflineListByClientAndConversation" resultType="com.wecloud.im.vo.OfflineMsgDto">
SELECT im_message.id AS msgId,
SELECT im_message.id AS msgId,
im_message.create_time,
im_message.withdraw_time,
im_message.update_date,
`im_client`.client_id AS sender,
`im_client`.client_id AS sender,
im_message.content,
im_message.withdraw,
im_message.`event`,
......@@ -37,7 +37,7 @@
(SELECT COUNT(id)
FROM im_inbox
WHERE fk_msg_id = msgId
AND receiver_msg_status = 0) AS not_receiver_count
AND receiver_msg_status = 0) AS not_receiver_count
FROM im_inbox
INNER JOIN im_message im_message ON im_message.id = im_inbox.fk_msg_id
......@@ -47,11 +47,11 @@
AND im_inbox.receiver_msg_status = 0
</select>
<select id="getHistoryMsgConversationId" resultType="com.wecloud.im.vo.OfflineMsgDto">
SELECT im_message.id AS msgId,
SELECT im_message.id AS msgId,
im_message.create_time,
im_message.withdraw_time,
im_message.update_date,
`im_client`.client_id AS sender,
`im_client`.client_id AS sender,
im_message.content,
im_message.withdraw,
im_message.`event`,
......@@ -63,7 +63,7 @@
(SELECT COUNT(id)
FROM im_inbox
WHERE fk_msg_id = msgId
AND receiver_msg_status = 0) AS not_receiver_count
AND receiver_msg_status = 0) AS not_receiver_count
FROM `im_message`
INNER JOIN `im_client` ON `im_client`.id = `im_message`.sender
WHERE fk_conversation_id = #{param.conversationId}
......
......@@ -65,7 +65,7 @@
<module>config</module>
<module>framework</module>
<module>generator</module>
<module>common</module>
<module>core</module>
<!-- <module>api-app</module>-->
<!-- <module>distribution</module>-->
<!-- <module>admin</module>-->
......@@ -291,7 +291,7 @@
</dependency>
<dependency>
<groupId>io.geekidea.springbootplus</groupId>
<artifactId>common</artifactId>
<artifactId>core</artifactId>
<version>${project.version}</version>
</dependency>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment