REQ-2303: 同步显示流程中的自自定义按钮
This commit is contained in:
parent
44230891aa
commit
9712bb3ffe
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.message.domain.dto;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButtons;
|
||||
import cn.axzo.msg.center.domain.entity.PendingMessageRecord;
|
||||
import cn.axzo.msg.center.service.dto.IdentityDTO;
|
||||
import cn.axzo.msg.center.service.dto.MessageCardContentItemDTO;
|
||||
@ -205,7 +205,7 @@ public class PendingMessageDTO implements Serializable {
|
||||
/**
|
||||
* 自定义按钮
|
||||
*/
|
||||
private List<ProposedButton> proposedButtons;
|
||||
private ProposedButtons proposedButtons;
|
||||
|
||||
private JSONObject bizExtParamObj;
|
||||
private JSONObject routerExtParamObj;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package cn.axzo.msg.center.message.domain.param;
|
||||
|
||||
import cn.axzo.core.utils.converter.BeanConverter;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButtons;
|
||||
import cn.axzo.msg.center.api.request.v3.PendingSendInfo;
|
||||
import cn.axzo.msg.center.service.dto.PersonDTO;
|
||||
import cn.axzo.msg.center.service.enums.OrganizationTypeEnum;
|
||||
@ -17,7 +17,6 @@ import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -83,10 +82,10 @@ public class PendingMessagePushParam extends PendingSendInfo implements Serializ
|
||||
/**
|
||||
* 提前设定的按钮
|
||||
*/
|
||||
private List<ProposedButton> proposedButtons;
|
||||
private ProposedButtons proposedButtons;
|
||||
|
||||
public List<ProposedButton> determineProposedButtons() {
|
||||
return proposedButtons == null ? Collections.emptyList() : proposedButtons;
|
||||
public ProposedButtons determineProposedButtons() {
|
||||
return proposedButtons == null ? new ProposedButtons() : proposedButtons;
|
||||
}
|
||||
|
||||
public static PendingMessagePushParam from(PendingMessagePushRequest request) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.message.service.todo;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButtons;
|
||||
import cn.axzo.msg.center.common.utils.BizAssertions;
|
||||
import cn.axzo.msg.center.domain.entity.PendingRecordAdapter;
|
||||
import cn.axzo.msg.center.domain.entity.PendingRecordExt;
|
||||
@ -17,7 +17,6 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
@ -255,7 +254,7 @@ public class TodoRecordAdapter implements PendingRecordAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProposedButton> getCustomButtons() {
|
||||
public ProposedButtons getCustomButtons() {
|
||||
return forBusiness ? business.getProposedButtons() : todo.getProposedButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,28 +22,36 @@ public class ProposedButtonFilter {
|
||||
}
|
||||
|
||||
public static List<ButtonRouterDTO> filterProposedButtons(PendingMessageResponse response, boolean forPromoter) {
|
||||
Function<String, ProposedButton> findCustomBtnFun = btnKey -> {
|
||||
if (CollectionUtils.isEmpty(response.getProposedButtons()))
|
||||
ProposedButtons buttons = response.getProposedButtons();
|
||||
Function<String, Boolean> isConfiguredProposedBtnFun = btnKey -> {
|
||||
if (buttons == null || CollectionUtils.isEmpty(buttons.getConfiguredButtonKeys()))
|
||||
return false;
|
||||
return buttons.getConfiguredButtonKeys().contains(btnKey);
|
||||
};
|
||||
Function<String, ProposedButton> findProposedBtnFun = btnKey -> {
|
||||
if (buttons == null || CollectionUtils.isEmpty(buttons.getProposedButtons()))
|
||||
return null;
|
||||
return response.getProposedButtons().stream()
|
||||
return buttons.getProposedButtons().stream()
|
||||
.filter(i -> btnKey.equals(i.getButtonKey()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
};
|
||||
Function<ButtonRouterDTO, Boolean> syncBtnFun = btn -> {
|
||||
// 没有配置可见的自定义的按钮
|
||||
ProposedButton customBtn = findCustomBtnFun.apply(btn.getKey());
|
||||
if (customBtn == null || CollectionUtils.isEmpty(customBtn.getConfigs()))
|
||||
ProposedButton proposedBtn = findProposedBtnFun.apply(btn.getKey());
|
||||
if (proposedBtn == null || CollectionUtils.isEmpty(proposedBtn.getConfigs()))
|
||||
return false;
|
||||
return customBtn.getConfigs().stream()
|
||||
return proposedBtn.getConfigs().stream()
|
||||
.anyMatch(c -> forPromoter
|
||||
? c.isVisible(response.getBizFinalState())
|
||||
: c.isVisible(response.getState()));
|
||||
};
|
||||
return response.getButtonRouters().stream()
|
||||
.filter(routerBtn -> {
|
||||
ProposedButton syncBtn = findCustomBtnFun.apply(routerBtn.getKey());
|
||||
boolean isNormalCustomBtn = syncBtn == null && routerBtn.getSource() == RouterButtonSourceEnum.CUSTOM;
|
||||
ProposedButton proposedBtn = findProposedBtnFun.apply(routerBtn.getKey());
|
||||
boolean isNormalCustomBtn = proposedBtn == null
|
||||
&& !isConfiguredProposedBtnFun.apply(routerBtn.getKey())
|
||||
&& routerBtn.getSource() == RouterButtonSourceEnum.CUSTOM;
|
||||
return isNormalCustomBtn || syncBtnFun.apply(routerBtn);
|
||||
})
|
||||
.collect(toList());
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package cn.axzo.msg.center.api.custombutton;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@Data
|
||||
public class ProposedButtons {
|
||||
/**
|
||||
* 所有配置的按钮key
|
||||
*/
|
||||
private Set<String> configuredButtonKeys;
|
||||
/**
|
||||
* 提前设定的按钮
|
||||
*/
|
||||
private List<ProposedButton> proposedButtons;
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
package cn.axzo.msg.center.service.pending.response;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButtonFilter;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButtons;
|
||||
import cn.axzo.msg.center.service.dto.ButtonRouterDTO;
|
||||
import cn.axzo.msg.center.service.dto.DetailRouterDTO;
|
||||
import cn.axzo.msg.center.service.dto.IdentityDTO;
|
||||
@ -229,7 +229,7 @@ public class PendingMessageResponse implements Serializable, TodoButtonProvider
|
||||
/**
|
||||
* 自定义按钮
|
||||
*/
|
||||
private List<ProposedButton> proposedButtons;
|
||||
private ProposedButtons proposedButtons;
|
||||
|
||||
private JSONObject bizExtParamObj;
|
||||
private JSONObject routerExtParamObj;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.service.pending.response;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButtons;
|
||||
import cn.axzo.msg.center.service.dto.ButtonRouterDTO;
|
||||
|
||||
import java.util.List;
|
||||
@ -12,6 +12,6 @@ public interface TodoButtonProvider {
|
||||
|
||||
List<ButtonRouterDTO> getButtonRouters();
|
||||
|
||||
List<ProposedButton> getProposedButtons();
|
||||
ProposedButtons getProposedButtons();
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.domain.entity;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButtons;
|
||||
import cn.axzo.msg.center.service.enums.BizCategoryEnum;
|
||||
import cn.axzo.msg.center.service.enums.BizFinalStateEnum;
|
||||
import cn.axzo.msg.center.service.enums.IdentityTypeEnum;
|
||||
@ -12,9 +12,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 尽可能地使用已经存在的方法, 减少工作量
|
||||
@ -125,8 +123,8 @@ public interface PendingRecordAdapter {
|
||||
return null;
|
||||
}
|
||||
|
||||
default List<ProposedButton> getCustomButtons() {
|
||||
return Collections.emptyList();
|
||||
default ProposedButtons getCustomButtons() {
|
||||
return null;
|
||||
}
|
||||
|
||||
default JSONObject getBizExtParamObj() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.domain.entity;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButtons;
|
||||
import cn.axzo.msg.center.domain.persistence.BaseEntityExt;
|
||||
import cn.axzo.msg.center.domain.utils.IgnorePropsJsonTypeHandler;
|
||||
import cn.axzo.msg.center.service.enums.IdentityTypeEnum;
|
||||
@ -16,7 +16,6 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
@ -158,7 +157,7 @@ public class Todo extends BaseEntityExt<Todo> {
|
||||
* 自定义按钮
|
||||
*/
|
||||
@TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
|
||||
private List<ProposedButton> proposedButtons;
|
||||
private ProposedButtons proposedButtons;
|
||||
|
||||
// !! helper
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.domain.entity;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButtons;
|
||||
import cn.axzo.msg.center.domain.persistence.BaseEntityExt;
|
||||
import cn.axzo.msg.center.domain.utils.IgnorePropsJsonTypeHandler;
|
||||
import cn.axzo.msg.center.service.enums.BizCategoryEnum;
|
||||
@ -15,7 +15,6 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
@ -131,7 +130,7 @@ public class TodoBusiness extends BaseEntityExt<TodoBusiness> {
|
||||
* 自定义按钮
|
||||
*/
|
||||
@TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
|
||||
private List<ProposedButton> proposedButtons;
|
||||
private ProposedButtons proposedButtons;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user