publish 2.0.0.rc13
This commit is contained in:
@@ -24,7 +24,6 @@ import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.FileUploadPath;
|
||||
import com.tiesheng.util.service.TsCacheService;
|
||||
import com.tiesheng.web.service.CoreLogService;
|
||||
import com.tiesheng.web.service.CoreMessageService;
|
||||
import com.tiesheng.web.util.ProcessImportConsumer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@@ -8,7 +8,7 @@ import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.tiesheng.message.pojos.MessageReqResp;
|
||||
import com.tiesheng.message.service.TieshengMessageSender;
|
||||
import com.tiesheng.message.service.TsMessageSender;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.service.http.OkHttpUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -30,7 +30,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "tiesheng.aliyun")
|
||||
public class AliyunSmsSender implements TieshengMessageSender {
|
||||
public class AliyunSmsSender implements TsMessageSender {
|
||||
|
||||
/**
|
||||
* 请求地址
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.tiesheng.message.pojos.MessageReqResp;
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
public interface TieshengMessageSender {
|
||||
public interface TsMessageSender {
|
||||
|
||||
|
||||
/**
|
||||
@@ -1,15 +1,11 @@
|
||||
package com.tiesheng.web.service;
|
||||
package com.tiesheng.message.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.tiesheng.web.mapper.CoreLogMessageMapper;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogMessage;
|
||||
import com.tiesheng.message.pojos.MessageReqResp;
|
||||
import com.tiesheng.message.pojos.UserChannel;
|
||||
import com.tiesheng.message.service.TieshengMessageSender;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -20,25 +16,10 @@ import java.util.Objects;
|
||||
* @author hao
|
||||
*/
|
||||
@Service
|
||||
public class CoreMessageService {
|
||||
public class TsMessageService {
|
||||
|
||||
@Autowired
|
||||
List<TieshengMessageSender> messageSenderList;
|
||||
@Autowired
|
||||
CoreLogMessageMapper coreLogMessageMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 插入数据
|
||||
*
|
||||
* @param reqResp
|
||||
*/
|
||||
private void insertMessageLog(MessageReqResp reqResp) {
|
||||
if (reqResp == null) {
|
||||
return;
|
||||
}
|
||||
coreLogMessageMapper.insert(BeanUtil.copyProperties(reqResp, CoreLogMessage.class));
|
||||
}
|
||||
List<TsMessageSender> messageSenderList;
|
||||
|
||||
/**
|
||||
* 发送所有消息
|
||||
@@ -47,10 +28,10 @@ public class CoreMessageService {
|
||||
* @param body
|
||||
*/
|
||||
public void all(List<String> userIds, JSONObject body) {
|
||||
messageSenderList.stream().filter(TieshengMessageSender::support)
|
||||
messageSenderList.stream().filter(TsMessageSender::support)
|
||||
.forEach(sender -> {
|
||||
for (String user : userIds) {
|
||||
insertMessageLog(sender.send(user, body));
|
||||
sender.send(user, body);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -68,9 +49,9 @@ public class CoreMessageService {
|
||||
return;
|
||||
}
|
||||
|
||||
messageSenderList.stream().filter(TieshengMessageSender::support)
|
||||
messageSenderList.stream().filter(TsMessageSender::support)
|
||||
.forEach(sender -> channels.stream().filter(it -> Objects.equals(it.getChannel(), sender.getChannel()))
|
||||
.forEach(it -> insertMessageLog(sender.send(it.getUser(), body))));
|
||||
.forEach(it -> sender.send(it.getUser(), body)));
|
||||
}
|
||||
|
||||
|
||||
@@ -86,12 +67,10 @@ public class CoreMessageService {
|
||||
return null;
|
||||
}
|
||||
|
||||
TieshengMessageSender messageSender = CollUtil.findOne(messageSenderList,
|
||||
TsMessageSender messageSender = CollUtil.findOne(messageSenderList,
|
||||
sender -> Objects.equals(sender.getChannel(), userChannel.getChannel()) && sender.support());
|
||||
if (messageSender != null) {
|
||||
MessageReqResp reqResp = messageSender.send(userChannel.getUser(), body);
|
||||
insertMessageLog(reqResp);
|
||||
return reqResp;
|
||||
messageSender.send(userChannel.getUser(), body);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.tiesheng.platform.config.ding.bean.*;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.service.TsCacheService;
|
||||
@@ -15,7 +16,6 @@ import okhttp3.Response;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -78,13 +78,16 @@ public class PlatformDingConfig {
|
||||
request.newBuilder().header("x-acs-dingtalk-access-token", accessToken);
|
||||
try {
|
||||
Response response = OkHttpUtil.ofHttpClient().build().newCall(request).execute();
|
||||
if (response.isSuccessful() || response.body() != null) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
String rawBody = response.body().string();
|
||||
DingResponse<T> bean = JSONUtil.toBean(rawBody, typeReference, true);
|
||||
bean.setRawBody(rawBody);
|
||||
return bean;
|
||||
} else {
|
||||
LogFactory.get().info(response.body().string());
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
} catch (Exception e) {
|
||||
LogFactory.get().error(e);
|
||||
}
|
||||
|
||||
return DingResponse.ofError();
|
||||
@@ -279,6 +282,7 @@ public class PlatformDingConfig {
|
||||
* @param actionUrl
|
||||
* @param userIds
|
||||
* @return
|
||||
* @see <a href='https://open.dingtalk.com/document/orgapp/asynchronous-sending-of-enterprise-session-messages' </a>
|
||||
*/
|
||||
public DingResponse<String> messageNotification(String service, String title, String markdown, String actionUrl, List<String> userIds) {
|
||||
|
||||
@@ -288,18 +292,20 @@ public class PlatformDingConfig {
|
||||
|
||||
DingConfigBean configBean = getConfigBean(service);
|
||||
|
||||
JSONObject actionCard = new JSONObject();
|
||||
actionCard.set("title", title);
|
||||
actionCard.set("markdown", markdown);
|
||||
|
||||
if (StrUtil.isNotEmpty(actionUrl)) {
|
||||
actionCard.set("single_title", "点击查看");
|
||||
actionCard.set("single_url", actionUrl);
|
||||
}
|
||||
|
||||
JSONObject msg = new JSONObject();
|
||||
msg.set("msgtype", "action_card");
|
||||
msg.set("action_card", actionCard);
|
||||
|
||||
if (StrUtil.isEmpty(actionUrl)) {
|
||||
msg.set("msgtype", "markdown");
|
||||
msg.set("markdown", JSONUtil.createObj()
|
||||
.set("title", title).set("text", markdown)
|
||||
);
|
||||
} else {
|
||||
msg.set("msgtype", "action_card");
|
||||
msg.set("action_card", JSONUtil.createObj()
|
||||
.set("title", title).set("markdown", markdown)
|
||||
.set("single_title", "点击查看").set("single_url", actionUrl)
|
||||
);
|
||||
}
|
||||
|
||||
JSONObject body = new JSONObject();
|
||||
body.putOpt("agent_id", configBean.getAgentId());
|
||||
|
||||
@@ -4,7 +4,6 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogLogin;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogMessage;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogOperation;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogProcess;
|
||||
import com.tiesheng.util.pojos.PageDTO;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tiesheng.web.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogApi;
|
||||
|
||||
public interface CoreLogApiMapper extends BaseMapper<CoreLogApi> {
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.tiesheng.web.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogMessage;
|
||||
|
||||
public interface CoreLogMessageMapper extends BaseMapper<CoreLogMessage> {
|
||||
}
|
||||
@@ -1,14 +1,17 @@
|
||||
package com.tiesheng.web.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 日志-消息
|
||||
*/
|
||||
@TableName(value = "core_log_message")
|
||||
public class CoreLogMessage extends DaoBase {
|
||||
* 日志-调用
|
||||
*/
|
||||
@TableName(value = "core_log_api")
|
||||
public class CoreLogApi extends DaoBase {
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@@ -16,10 +19,10 @@ public class CoreLogMessage extends DaoBase {
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 发送对象
|
||||
* 请求地址
|
||||
*/
|
||||
@TableField(value = "target")
|
||||
private String target;
|
||||
@TableField(value = "url")
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 发送内容
|
||||
@@ -58,21 +61,21 @@ public class CoreLogMessage extends DaoBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发送对象
|
||||
* 获取请求地址
|
||||
*
|
||||
* @return target - 发送对象
|
||||
* @return url - 请求地址
|
||||
*/
|
||||
public String getTarget() {
|
||||
return target;
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置发送对象
|
||||
* 设置请求地址
|
||||
*
|
||||
* @param target 发送对象
|
||||
* @param url 请求地址
|
||||
*/
|
||||
public void setTarget(String target) {
|
||||
this.target = target;
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,4 +131,4 @@ public class CoreLogMessage extends DaoBase {
|
||||
public void setResult(Integer result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
import com.tiesheng.util.service.TsServiceBase;
|
||||
import com.tiesheng.web.mapper.CoreLogLoginMapper;
|
||||
import com.tiesheng.web.mapper.CoreLogMessageMapper;
|
||||
import com.tiesheng.web.mapper.CoreLogOperationMapper;
|
||||
import com.tiesheng.web.mapper.CoreLogProcessMapper;
|
||||
import com.tiesheng.web.pojos.RequestUserInfo;
|
||||
|
||||
@@ -22,21 +22,21 @@ CREATE TABLE `core_log_login`
|
||||
-- ----------------------------
|
||||
-- Table structure for core_log_message
|
||||
-- ----------------------------
|
||||
CREATE TABLE `core_log_message`
|
||||
CREATE TABLE `core_log_api`
|
||||
(
|
||||
`id` varchar(50) NOT NULL,
|
||||
`create_time` datetime NOT NULL,
|
||||
`update_time` datetime NOT NULL,
|
||||
`is_deleted` int(6) NOT NULL DEFAULT '0',
|
||||
`type` varchar(50) DEFAULT NULL COMMENT '类型',
|
||||
`target` varchar(255) DEFAULT NULL COMMENT '发送对象',
|
||||
`url` text DEFAULT NULL COMMENT '请求地址',
|
||||
`content` text COMMENT '发送内容',
|
||||
`resp_body` text COMMENT '返回结果',
|
||||
`result` int(6) NOT NULL DEFAULT '0' COMMENT '结果',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
ROW_FORMAT = DYNAMIC COMMENT ='日志-消息';
|
||||
ROW_FORMAT = DYNAMIC COMMENT ='日志-调用';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for core_log_process
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
<?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.tiesheng.web.mapper.CoreLogMessageMapper">
|
||||
<resultMap id="BaseResultMap" type="com.tiesheng.web.pojos.dao.CoreLogMessage">
|
||||
<mapper namespace="com.tiesheng.web.mapper.CoreLogApiMapper">
|
||||
<resultMap id="BaseResultMap" type="com.tiesheng.web.pojos.dao.CoreLogApi">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table core_log_message-->
|
||||
<!--@Table core_log_api-->
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
||||
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||
<result column="target" jdbcType="VARCHAR" property="target" />
|
||||
<result column="url" jdbcType="LONGVARCHAR" property="url" />
|
||||
<result column="content" jdbcType="LONGVARCHAR" property="content" />
|
||||
<result column="resp_body" jdbcType="LONGVARCHAR" property="respBody" />
|
||||
<result column="result" jdbcType="INTEGER" property="result" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, create_time, update_time, is_deleted, `type`, target, content, resp_body, `result`
|
||||
id, create_time, update_time, is_deleted, `type`, url, content, resp_body, `result`
|
||||
</sql>
|
||||
</mapper>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user