package com.inspect.patrol.linkage.notify;

import java.util.List;
import java.util.stream.Collectors;

public class NotifyMessage {
    private final String DEFECT_VALUE = "1";
    private String objectId;
    private String taskId;
    private List<NotifyMessage.Result> results;

    public String searchDefectOfPatrolPointId() {
        return this.results.stream().anyMatch((item) -> "1".equals(item.value)) ? this.objectId : null;
    }

    public String getTaskId() {
        return this.taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public String getObjectId() {
        return this.objectId;
    }

    public void setObjectId(String objectId) {
        this.objectId = objectId;
    }

    public List<NotifyMessage.Result> getResults() {
        return this.results;
    }

    public void setResults(List<NotifyMessage.Result> results) {
        this.results = results;
    }

    public String toResult() {
        return this.results.stream().map((item) -> item.getDesc()).collect(Collectors.joining(","));
    }

    public static class Result {
        private String type;
        private String value;
        private String code;
        private String resImageUrl;
        private String pos;
        private String conf;
        private String desc;

        public String getType() {
            return this.type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getValue() {
            return this.value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public String getCode() {
            return this.code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getResImageUrl() {
            return this.resImageUrl;
        }

        public void setResImageUrl(String resImageUrl) {
            this.resImageUrl = resImageUrl;
        }

        public String getPos() {
            return this.pos;
        }

        public void setPos(String pos) {
            this.pos = pos;
        }

        public String getConf() {
            return this.conf;
        }

        public void setConf(String conf) {
            this.conf = conf;
        }

        public String getDesc() {
            return this.desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }
    }
}
