refactor: 飞书显示@其他用户
This commit is contained in:
parent
3c303e97e0
commit
14abc1a82e
|
@ -57,7 +57,7 @@
|
||||||
</select>
|
</select>
|
||||||
<select id="queryTypeByIds" parameterType="java.lang.String" resultType="io.metersphere.notice.domain.UserDetail">
|
<select id="queryTypeByIds" parameterType="java.lang.String" resultType="io.metersphere.notice.domain.UserDetail">
|
||||||
SELECT
|
SELECT
|
||||||
email,phone
|
email,phone,name
|
||||||
from user
|
from user
|
||||||
WHERE id IN
|
WHERE id IN
|
||||||
<foreach collection="list" item="id" index="index"
|
<foreach collection="list" item="id" index="index"
|
||||||
|
|
|
@ -4,6 +4,7 @@ import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class UserDetail {
|
public class UserDetail {
|
||||||
|
private String name;
|
||||||
private String email;
|
private String email;
|
||||||
private String phone;
|
private String phone;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,10 @@ public abstract class AbstractNoticeSender implements NoticeSender {
|
||||||
return phoneList.stream().distinct().collect(Collectors.toList());
|
return phoneList.stream().distinct().collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected List<UserDetail> getUserDetails(NoticeModel noticeModel, List<String> userIds) {
|
||||||
|
return userService.queryTypeByIds(userIds);
|
||||||
|
}
|
||||||
|
|
||||||
private List<Receiver> getRealUserIds(List<String> userIds, NoticeModel noticeModel, String event) {
|
private List<Receiver> getRealUserIds(List<String> userIds, NoticeModel noticeModel, String event) {
|
||||||
List<Receiver> toUsers = new ArrayList<>();
|
List<Receiver> toUsers = new ArrayList<>();
|
||||||
Map<String, Object> paramMap = noticeModel.getParamMap();
|
Map<String, Object> paramMap = noticeModel.getParamMap();
|
||||||
|
|
|
@ -1,22 +1,38 @@
|
||||||
package io.metersphere.notice.sender.impl;
|
package io.metersphere.notice.sender.impl;
|
||||||
|
|
||||||
import io.metersphere.notice.domain.MessageDetail;
|
import io.metersphere.notice.domain.MessageDetail;
|
||||||
|
import io.metersphere.notice.domain.Receiver;
|
||||||
|
import io.metersphere.notice.domain.UserDetail;
|
||||||
import io.metersphere.notice.sender.AbstractNoticeSender;
|
import io.metersphere.notice.sender.AbstractNoticeSender;
|
||||||
import io.metersphere.notice.sender.NoticeModel;
|
import io.metersphere.notice.sender.NoticeModel;
|
||||||
import io.metersphere.notice.util.LarkClient;
|
import io.metersphere.notice.util.LarkClient;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class LarkNoticeSender extends AbstractNoticeSender {
|
public class LarkNoticeSender extends AbstractNoticeSender {
|
||||||
|
|
||||||
public void sendLark(MessageDetail messageDetail, String context) {
|
public void sendLark(MessageDetail messageDetail, NoticeModel noticeModel, String context) {
|
||||||
//TextMessage message = new TextMessage(context);
|
//TextMessage message = new TextMessage(context);
|
||||||
|
List<String> userIds = noticeModel.getReceivers().stream()
|
||||||
|
.map(Receiver::getUserId)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<UserDetail> userDetails = super.getUserDetails(noticeModel, userIds);
|
||||||
|
List<String> collect = userDetails.stream()
|
||||||
|
.map(ud -> "<at email=\"" + ud.getEmail() + "\">" + ud.getName() + "</at>")
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
context += StringUtils.join(collect, " ");
|
||||||
LarkClient.send(messageDetail.getWebhook(), context);
|
LarkClient.send(messageDetail.getWebhook(), context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void send(MessageDetail messageDetail, NoticeModel noticeModel) {
|
public void send(MessageDetail messageDetail, NoticeModel noticeModel) {
|
||||||
String context = super.getContext(messageDetail, noticeModel);
|
String context = super.getContext(messageDetail, noticeModel);
|
||||||
sendLark(messageDetail, context);
|
sendLark(messageDetail, noticeModel, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue