package com.fs.hisStore.dto;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;


public class ExpressResultDTO extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public ExpressResultDTO() {

    }

    private static String getCurrentTimeString() {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return LocalDateTime.now().format(formatter);
    }

    public static ExpressResultDTO success(String EBusinessID) {
        ExpressResultDTO result = new ExpressResultDTO();
        result.put("EBusinessID", EBusinessID);
        result.put("UpdateTime", getCurrentTimeString());
        result.put("Success", true);
        result.put("Reason", "");
        return result;
    }

    public static ExpressResultDTO error(String EBusinessID, String reason) {
        ExpressResultDTO result = new ExpressResultDTO();
        result.put("EBusinessID", EBusinessID);
        result.put("UpdateTime", getCurrentTimeString());
        result.put("Success", false);
        result.put("Reason", reason);
        return result;
    }

    @Override
    public ExpressResultDTO put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
