package cn.axzo.msg.center.api.request.v3;

import cn.axzo.msg.center.service.enums.PendingMessageStateEnum;
import cn.axzo.msg.center.service.enums.TodoType;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @author yanglin
 */
@Setter
@Getter
public class SearchPendingMessageReq {
    private String promoterPhone;
    private String executorPhone;
    private Long executorPersonId;
    private List<TodoType> todoTypes;
    /**
     * 消息的唯一标识
     */
    private List<String> identityCodes;
    /**
     * 模板编码
     */
    private String templateCode;
    /**
     * 消息标题
     */
    private String title;
    /**
     * 消息内容
     */
    private String content;
    /**
     * 消息所属企业ID
     */
    private Long ouId;
    /**
     * 待办状态
     */
    private PendingMessageStateEnum state;
    /**
     * 关联业务主键
     */
    private String bizCode;
    /**
     * 流程类代办的流程结点编码
     */
    private String subBizCode;

    @JsonFormat(pattern = "yyyy-MM-hh HH:mm")
    private Date startTime;
    @JsonFormat(pattern = "yyyy-MM-hh HH:mm")
    private Date endTime;
    private int limit = 10;

    public List<TodoType> determineTodoTypes() {
        return CollectionUtils.isEmpty(todoTypes) ? Collections.singletonList(TodoType.EXECUTABLE) : todoTypes;
    }
}