REQ-2303: 支持自定义按钮
This commit is contained in:
parent
ebef8d1023
commit
f00e59a647
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.message.domain.dto;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.CustomButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.domain.entity.PendingMessageRecord;
|
||||
import cn.axzo.msg.center.service.dto.IdentityDTO;
|
||||
import cn.axzo.msg.center.service.dto.MessageCardContentItemDTO;
|
||||
@ -204,7 +204,7 @@ public class PendingMessageDTO implements Serializable {
|
||||
/**
|
||||
* 自定义按钮
|
||||
*/
|
||||
private List<CustomButton> customButtons;
|
||||
private List<ProposedButton> proposedButtons;
|
||||
|
||||
@Deprecated
|
||||
public static PendingMessageDTO from(PendingMessageRecord pendingMessageRecord) {
|
||||
@ -281,7 +281,7 @@ public class PendingMessageDTO implements Serializable {
|
||||
.isCreatedToday(isCreatedToday)
|
||||
.isRead(isRead)
|
||||
.todoType(todoType)
|
||||
.customButtons(customButtons)
|
||||
.proposedButtons(proposedButtons)
|
||||
.templateCategory(templateCategory)
|
||||
.identityCode(this.identityCode)
|
||||
.templateCode(this.templateCode)
|
||||
|
||||
@ -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.CustomButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
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;
|
||||
@ -83,10 +83,10 @@ public class PendingMessagePushParam extends PendingSendInfo implements Serializ
|
||||
/**
|
||||
* 自定义按钮
|
||||
*/
|
||||
private List<CustomButton> customButtons;
|
||||
private List<ProposedButton> proposedButtons;
|
||||
|
||||
public List<CustomButton> determineCustomButtons() {
|
||||
return customButtons == null ? Collections.emptyList() : customButtons;
|
||||
public List<ProposedButton> determineCustomButtons() {
|
||||
return proposedButtons == null ? Collections.emptyList() : proposedButtons;
|
||||
}
|
||||
|
||||
public static PendingMessagePushParam from(PendingMessagePushRequest request) {
|
||||
|
||||
@ -779,7 +779,7 @@ public class PendingMessageNewServiceImpl implements PendingMessageNewService {
|
||||
// 其它信息
|
||||
pendingMessage.setTodoType(adapter.getTodoType());
|
||||
pendingMessage.setIsRead(adapter.isRead());
|
||||
pendingMessage.setCustomButtons(adapter.getCustomButtons());
|
||||
pendingMessage.setProposedButtons(adapter.getCustomButtons());
|
||||
|
||||
Map<String, MessageTemplateDTO> templateCode2Template = messageTemplates.stream()
|
||||
.collect(toMap(MessageTemplateDTO::getCode, identity()));
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.message.service.todo;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.CustomButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.common.utils.BizAssertions;
|
||||
import cn.axzo.msg.center.domain.entity.PendingRecordAdapter;
|
||||
import cn.axzo.msg.center.domain.entity.PendingRecordExt;
|
||||
@ -255,7 +255,7 @@ public class TodoRecordAdapter implements PendingRecordAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomButton> getCustomButtons() {
|
||||
return forBusiness ? business.getCustomButtons() : todo.getCustomButtons();
|
||||
public List<ProposedButton> getCustomButtons() {
|
||||
return forBusiness ? business.getProposedButtons() : todo.getProposedButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ class TodoRecordBuilder {
|
||||
business.setBizFinalState(null);
|
||||
// 不能存成null, 因为老的流程数据没有传这个按钮, 需要做查询兼容
|
||||
// 是否为老的流程数据, 主要判断这个字段是否为null
|
||||
business.setCustomButtons(request.determineCustomButtons());
|
||||
business.setProposedButtons(request.determineCustomButtons());
|
||||
return business;
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ class TodoRecordBuilder {
|
||||
todo.setExecutorType(executor.identityTypeOrDefault());
|
||||
// 不能存成null, 因为老的流程数据没有传这个按钮, 需要做查询兼容
|
||||
// 是否为老的流程数据, 主要判断这个字段是否为null
|
||||
todo.setCustomButtons(request.determineCustomButtons());
|
||||
todo.setProposedButtons(request.determineCustomButtons());
|
||||
}
|
||||
return todos;
|
||||
}
|
||||
|
||||
@ -1,57 +0,0 @@
|
||||
package cn.axzo.msg.center.api.custombutton;
|
||||
|
||||
import cn.axzo.msg.center.service.enums.RouterButtonSourceEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自定义按钮
|
||||
*
|
||||
* @author yanglin
|
||||
*/
|
||||
@Data
|
||||
public class CustomButton {
|
||||
/**
|
||||
* 自定义按钮的key
|
||||
*/
|
||||
private String buttonKey;
|
||||
/**
|
||||
* 自定义按钮的名称
|
||||
*/
|
||||
private String buttonName;
|
||||
/**
|
||||
* 按钮类型
|
||||
*/
|
||||
private RouterButtonSourceEnum source;
|
||||
/**
|
||||
* 自定义按钮配置
|
||||
*/
|
||||
private List<CustomButtonConfig> configs;
|
||||
|
||||
public List<CustomButtonConfig> determineConfigs() {
|
||||
return configs == null ? Collections.emptyList() : configs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建按钮
|
||||
*/
|
||||
public static CustomButton createButton(String buttonKey, CustomButtonConfig... configs) {
|
||||
CustomButton customButton = new CustomButton();
|
||||
customButton.setButtonKey(buttonKey);
|
||||
customButton.setConfigs(configs == null ? Collections.emptyList() : Arrays.asList(configs));
|
||||
return customButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建按钮
|
||||
*/
|
||||
public static CustomButton createButton(String buttonKey, List<CustomButtonConfig> configs) {
|
||||
CustomButton customButton = new CustomButton();
|
||||
customButton.setButtonKey(buttonKey);
|
||||
customButton.setConfigs(configs);
|
||||
return customButton;
|
||||
}
|
||||
}
|
||||
@ -22,17 +22,17 @@ public class CustomButtonFilter {
|
||||
}
|
||||
|
||||
public static List<ButtonRouterDTO> filterCustomButtons(PendingMessageResponse response, boolean forPromoter) {
|
||||
Function<String, CustomButton> findCustomBtnFun = btnKey -> {
|
||||
if (CollectionUtils.isEmpty(response.getCustomButtons()))
|
||||
Function<String, ProposedButton> findCustomBtnFun = btnKey -> {
|
||||
if (CollectionUtils.isEmpty(response.getProposedButtons()))
|
||||
return null;
|
||||
return response.getCustomButtons().stream()
|
||||
return response.getProposedButtons().stream()
|
||||
.filter(i -> btnKey.equals(i.getButtonKey()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
};
|
||||
Function<ButtonRouterDTO, Boolean> syncBtnFun = btn -> {
|
||||
// 没有配置可见的自定义的按钮
|
||||
CustomButton customBtn = findCustomBtnFun.apply(btn.getKey());
|
||||
ProposedButton customBtn = findCustomBtnFun.apply(btn.getKey());
|
||||
if (customBtn == null || CollectionUtils.isEmpty(customBtn.getConfigs()))
|
||||
return false;
|
||||
return customBtn.getConfigs().stream()
|
||||
@ -42,7 +42,7 @@ public class CustomButtonFilter {
|
||||
};
|
||||
return response.getButtonRouters().stream()
|
||||
.filter(routerBtn -> {
|
||||
CustomButton syncBtn = findCustomBtnFun.apply(routerBtn.getKey());
|
||||
ProposedButton syncBtn = findCustomBtnFun.apply(routerBtn.getKey());
|
||||
boolean isNormalCustomBtn = syncBtn == null && routerBtn.getSource() == RouterButtonSourceEnum.CUSTOM;
|
||||
return isNormalCustomBtn || syncBtnFun.apply(routerBtn);
|
||||
})
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
package cn.axzo.msg.center.api.custombutton;
|
||||
|
||||
import cn.axzo.msg.center.service.enums.RouterButtonSourceEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 提前设定的按钮
|
||||
*
|
||||
* @author yanglin
|
||||
*/
|
||||
@Data
|
||||
public class ProposedButton {
|
||||
/**
|
||||
* 自定义按钮的key
|
||||
*/
|
||||
private String buttonKey;
|
||||
/**
|
||||
* 自定义按钮的名称
|
||||
*/
|
||||
private String buttonName;
|
||||
/**
|
||||
* 按钮类型
|
||||
*/
|
||||
private RouterButtonSourceEnum source;
|
||||
/**
|
||||
* 提前设定的按钮配置
|
||||
*/
|
||||
private List<ProposedButtonConfig> configs;
|
||||
|
||||
public List<ProposedButtonConfig> determineConfigs() {
|
||||
return configs == null ? Collections.emptyList() : configs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建按钮
|
||||
*/
|
||||
public static ProposedButton createButton(String buttonKey, ProposedButtonConfig... configs) {
|
||||
ProposedButton proposedButton = new ProposedButton();
|
||||
proposedButton.setButtonKey(buttonKey);
|
||||
proposedButton.setConfigs(configs == null ? Collections.emptyList() : Arrays.asList(configs));
|
||||
return proposedButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建按钮
|
||||
*/
|
||||
public static ProposedButton createButton(String buttonKey, List<ProposedButtonConfig> configs) {
|
||||
ProposedButton proposedButton = new ProposedButton();
|
||||
proposedButton.setButtonKey(buttonKey);
|
||||
proposedButton.setConfigs(configs);
|
||||
return proposedButton;
|
||||
}
|
||||
}
|
||||
@ -16,12 +16,12 @@ import java.util.Set;
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
/**
|
||||
* 自定义按钮配置
|
||||
* 提前设定的按钮配置
|
||||
*
|
||||
* @author yanglin
|
||||
*/
|
||||
@Data
|
||||
public class CustomButtonConfig {
|
||||
public class ProposedButtonConfig {
|
||||
|
||||
/**
|
||||
* 适用的按钮的角色
|
||||
@ -35,14 +35,14 @@ public class CustomButtonConfig {
|
||||
/**
|
||||
* 创建对待办发起人总是可见的按钮, 忽略业务最终状态
|
||||
*/
|
||||
public static CustomButtonConfig alwaysVisibleForPromoter() {
|
||||
public static ProposedButtonConfig alwaysVisibleForPromoter() {
|
||||
return visibleForPromoterAndBizStates(Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建对待办发起人总是可见的按钮, 忽略待办状态
|
||||
*/
|
||||
public static CustomButtonConfig alwaysVisibleForExecutor() {
|
||||
public static ProposedButtonConfig alwaysVisibleForExecutor() {
|
||||
return visibleForExecutorAndTodoStates(Collections.emptyList());
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ public class CustomButtonConfig {
|
||||
*
|
||||
* @param visibleBizFinalStates 按钮可见的状态. 为空则忽略状态, 都可见
|
||||
*/
|
||||
public static CustomButtonConfig visibleForPromoterAndBizStates(BizFinalStateEnum... visibleBizFinalStates) {
|
||||
public static ProposedButtonConfig visibleForPromoterAndBizStates(BizFinalStateEnum... visibleBizFinalStates) {
|
||||
BizFinalStateEnum[] states = visibleBizFinalStates;
|
||||
if (states == null)
|
||||
states = new BizFinalStateEnum[0];
|
||||
@ -63,7 +63,7 @@ public class CustomButtonConfig {
|
||||
*
|
||||
* @param visibleTodoStates 按钮可见的状态. 为空则忽略状态, 都可见
|
||||
*/
|
||||
public static CustomButtonConfig visibleForExecutorAndTodoStates(PendingMessageStateEnum... visibleTodoStates) {
|
||||
public static ProposedButtonConfig visibleForExecutorAndTodoStates(PendingMessageStateEnum... visibleTodoStates) {
|
||||
PendingMessageStateEnum[] states = visibleTodoStates;
|
||||
if (states == null)
|
||||
states = new PendingMessageStateEnum[0];
|
||||
@ -75,16 +75,16 @@ public class CustomButtonConfig {
|
||||
*
|
||||
* @param visibleBizFinalStates 按钮可见的状态. 为空则忽略状态, 都可见
|
||||
*/
|
||||
public static CustomButtonConfig visibleForPromoterAndBizStates(List<BizFinalStateEnum> visibleBizFinalStates) {
|
||||
CustomButtonConfig customButtonConfig = new CustomButtonConfig();
|
||||
customButtonConfig.setActorType(TodoActorType.TODO_PROMOTER);
|
||||
public static ProposedButtonConfig visibleForPromoterAndBizStates(List<BizFinalStateEnum> visibleBizFinalStates) {
|
||||
ProposedButtonConfig proposedButtonConfig = new ProposedButtonConfig();
|
||||
proposedButtonConfig.setActorType(TodoActorType.TODO_PROMOTER);
|
||||
if (visibleBizFinalStates != null) {
|
||||
Set<String> visibleStates = visibleBizFinalStates.stream()
|
||||
.map(Enum::name)
|
||||
.collect(toSet());
|
||||
customButtonConfig.setVisibleStates(visibleStates);
|
||||
proposedButtonConfig.setVisibleStates(visibleStates);
|
||||
}
|
||||
return customButtonConfig;
|
||||
return proposedButtonConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,16 +92,16 @@ public class CustomButtonConfig {
|
||||
*
|
||||
* @param visibleTodoStates 按钮可见的状态. 为空则忽略状态, 都可见
|
||||
*/
|
||||
public static CustomButtonConfig visibleForExecutorAndTodoStates(List<PendingMessageStateEnum> visibleTodoStates) {
|
||||
CustomButtonConfig customButtonConfig = new CustomButtonConfig();
|
||||
customButtonConfig.setActorType(TodoActorType.TODO_EXECUTOR);
|
||||
public static ProposedButtonConfig visibleForExecutorAndTodoStates(List<PendingMessageStateEnum> visibleTodoStates) {
|
||||
ProposedButtonConfig proposedButtonConfig = new ProposedButtonConfig();
|
||||
proposedButtonConfig.setActorType(TodoActorType.TODO_EXECUTOR);
|
||||
if (visibleTodoStates != null) {
|
||||
Set<String> visibleStates = visibleTodoStates.stream()
|
||||
.map(Enum::name)
|
||||
.collect(toSet());
|
||||
customButtonConfig.setVisibleStates(visibleStates);
|
||||
proposedButtonConfig.setVisibleStates(visibleStates);
|
||||
}
|
||||
return customButtonConfig;
|
||||
return proposedButtonConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.api.response.v3;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.CustomButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.service.enums.BizCategoryEnum;
|
||||
import cn.axzo.msg.center.service.enums.BizFinalStateEnum;
|
||||
import cn.axzo.msg.center.service.enums.IdentityTypeEnum;
|
||||
@ -168,5 +168,5 @@ public class SearchPendingMessageResp {
|
||||
/**
|
||||
* 自定义按钮
|
||||
*/
|
||||
private List<CustomButton> customButtons;
|
||||
private List<ProposedButton> proposedButtons;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.service.pending.request;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.CustomButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.service.dto.PersonDTO;
|
||||
import cn.axzo.msg.center.service.enums.BizCategoryEnum;
|
||||
import cn.axzo.msg.center.service.enums.BizFinalStateEnum;
|
||||
@ -129,7 +129,7 @@ public class PendingMessagePushRequest implements Serializable {
|
||||
/**
|
||||
* 自定义按钮
|
||||
*/
|
||||
private List<CustomButton> customButtons;
|
||||
private List<ProposedButton> proposedButtons;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.service.pending.response;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.CustomButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.api.custombutton.CustomButtonFilter;
|
||||
import cn.axzo.msg.center.service.dto.ButtonRouterDTO;
|
||||
import cn.axzo.msg.center.service.dto.DetailRouterDTO;
|
||||
@ -228,7 +228,7 @@ public class PendingMessageResponse implements Serializable {
|
||||
/**
|
||||
* 自定义按钮
|
||||
*/
|
||||
private List<CustomButton> customButtons;
|
||||
private List<ProposedButton> proposedButtons;
|
||||
|
||||
public void adjustCustomButtons(boolean forPromoter) {
|
||||
CustomButtonFilter.adjustCustomButtons(this, forPromoter);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.domain.entity;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.CustomButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.service.enums.BizCategoryEnum;
|
||||
import cn.axzo.msg.center.service.enums.BizFinalStateEnum;
|
||||
import cn.axzo.msg.center.service.enums.IdentityTypeEnum;
|
||||
@ -122,7 +122,7 @@ public interface PendingRecordAdapter {
|
||||
return null;
|
||||
}
|
||||
|
||||
default List<CustomButton> getCustomButtons() {
|
||||
default List<ProposedButton> getCustomButtons() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.domain.entity;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.CustomButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.domain.persistence.BaseEntityExt;
|
||||
import cn.axzo.msg.center.domain.utils.IgnorePropsJsonTypeHandler;
|
||||
import cn.axzo.msg.center.service.enums.IdentityTypeEnum;
|
||||
@ -158,7 +158,7 @@ public class Todo extends BaseEntityExt<Todo> {
|
||||
* 自定义按钮
|
||||
*/
|
||||
@TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
|
||||
private List<CustomButton> customButtons;
|
||||
private List<ProposedButton> proposedButtons;
|
||||
|
||||
// !! helper
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.msg.center.domain.entity;
|
||||
|
||||
import cn.axzo.msg.center.api.custombutton.CustomButton;
|
||||
import cn.axzo.msg.center.api.custombutton.ProposedButton;
|
||||
import cn.axzo.msg.center.domain.persistence.BaseEntityExt;
|
||||
import cn.axzo.msg.center.domain.utils.IgnorePropsJsonTypeHandler;
|
||||
import cn.axzo.msg.center.service.enums.BizCategoryEnum;
|
||||
@ -131,7 +131,7 @@ public class TodoBusiness extends BaseEntityExt<TodoBusiness> {
|
||||
* 自定义按钮
|
||||
*/
|
||||
@TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
|
||||
private List<CustomButton> customButtons;
|
||||
private List<ProposedButton> proposedButtons;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user