publish 2.0.0.rc13
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
package com.tiesheng.web.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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Service
|
||||
public class CoreMessageService {
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送所有消息
|
||||
*
|
||||
* @param userIds
|
||||
* @param body
|
||||
*/
|
||||
public void all(List<String> userIds, JSONObject body) {
|
||||
messageSenderList.stream().filter(TieshengMessageSender::support)
|
||||
.forEach(sender -> {
|
||||
for (String user : userIds) {
|
||||
insertMessageLog(sender.send(user, body));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param channels
|
||||
* @param body
|
||||
* @param channels 消息通道,如果为all时,表示发送全部通道
|
||||
*/
|
||||
public void multiple(List<UserChannel> channels, JSONObject body) {
|
||||
if (ArrayUtil.isEmpty(channels)) {
|
||||
return;
|
||||
}
|
||||
|
||||
messageSenderList.stream().filter(TieshengMessageSender::support)
|
||||
.forEach(sender -> channels.stream().filter(it -> Objects.equals(it.getChannel(), sender.getChannel()))
|
||||
.forEach(it -> insertMessageLog(sender.send(it.getUser(), body))));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param userChannel
|
||||
* @param body
|
||||
*/
|
||||
public MessageReqResp send(UserChannel userChannel, JSONObject body) {
|
||||
|
||||
if (StrUtil.isEmpty(userChannel.getUser()) || StrUtil.isEmpty(userChannel.getChannel())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TieshengMessageSender 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;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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