|
|
@@ -1,10 +1,14 @@
|
|
|
package com.fs.qw.vo;
|
|
|
|
|
|
import lombok.Data;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.concurrent.ThreadLocalRandom;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 企微sop附件的消息内容
|
|
|
@@ -89,6 +93,12 @@ public class QwSopTempSetting implements Serializable{
|
|
|
private String contentType;
|
|
|
//文本
|
|
|
private String value;
|
|
|
+
|
|
|
+ /** 是否开启随机发送:1-开启,0-关闭 */
|
|
|
+ private Integer isRandomSend;
|
|
|
+
|
|
|
+ /** 随机发送备选文案列表 */
|
|
|
+ private List<String> randomValueList;
|
|
|
//图片
|
|
|
private String imgUrl;
|
|
|
//链接标题
|
|
|
@@ -167,6 +177,27 @@ public class QwSopTempSetting implements Serializable{
|
|
|
/** 订阅号文章链接(contentType=13时使用,透传给小程序端用于跳转) */
|
|
|
private String articleUrl;
|
|
|
|
|
|
+ public boolean isRandomSendEnabled() {
|
|
|
+ return Objects.equals(isRandomSend, 1) || "1".equals(String.valueOf(isRandomSend));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 随机发送:从备选文案中随机选取一条写入 value
|
|
|
+ */
|
|
|
+ public void applyRandomTextValue() {
|
|
|
+ if (!"1".equals(contentType) && !"15".equals(contentType)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!isRandomSendEnabled() || randomValueList == null || randomValueList.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> validList = randomValueList.stream()
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!validList.isEmpty()) {
|
|
|
+ value = validList.get(ThreadLocalRandom.current().nextInt(validList.size()));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public Setting clone() {
|
|
|
@@ -185,6 +216,10 @@ public class QwSopTempSetting implements Serializable{
|
|
|
clone.setMiniprogramPage(this.getMiniprogramPage());
|
|
|
clone.setFileUrl(this.getFileUrl());
|
|
|
clone.setFileName(this.getFileName());
|
|
|
+ clone.setIsRandomSend(this.getIsRandomSend());
|
|
|
+ if (this.randomValueList != null) {
|
|
|
+ clone.randomValueList = new ArrayList<>(this.randomValueList);
|
|
|
+ }
|
|
|
return clone;
|
|
|
} catch (CloneNotSupportedException e) {
|
|
|
throw new AssertionError();
|