perf:调整消息日志相关代码

This commit is contained in:
曾文豪
2024-08-05 14:46:54 +08:00
parent cdae6a9868
commit ad90c83cf7
11 changed files with 85 additions and 171 deletions

View File

@@ -4,8 +4,8 @@ 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.message.pojos.MessageReqResp;
import com.tiesheng.message.pojos.UserChannel;
import com.tiesheng.util.pojos.ApiResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -61,18 +61,18 @@ public class TsMessageService {
* @param userChannel
* @param body
*/
public MessageReqResp send(UserChannel userChannel, JSONObject body) {
public ApiResp<String> send(UserChannel userChannel, JSONObject body) {
if (StrUtil.isEmpty(userChannel.getUser()) || StrUtil.isEmpty(userChannel.getChannel())) {
return null;
return ApiResp.resp130("消息对象或消息通道不存在");
}
TsMessageSender messageSender = CollUtil.findOne(messageSenderList,
sender -> Objects.equals(sender.getChannel(), userChannel.getChannel()) && sender.support());
if (messageSender != null) {
messageSender.send(userChannel.getUser(), body);
return messageSender.send(userChannel.getUser(), body);
}
return null;
return ApiResp.resp130("消息未成功发送");
}
}