package cn.iocoder.yudao.framework.common.util.corp;

import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.string.StringUtil;

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

import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

public class CorpMsgUtil {

    private static String datePrefix = "<div class=\"gray\">";

    private static String dateSuffix = "</div>";

    private static String classPrefix = "<div class=\"";

    private static String classSuffix = "\">";

    private static String contentPrefix = "<div class=\"normal\">";

    private static String contentSuffix = "</div>";

    // 灰色
    public static String GRAY = "gray";
    // 高亮
    public static String HIGHLIGHT = "highlight";
    // 默认黑色
    public static String NORMAL = "normal";
    // 按钮名称
    public static String BTNTXT_DETAIL_NOTICE = "详情";
    public static String BTNTXT_DETAIL_HANDLED = "马上处理";

    public static String TITLE_COPY = "抄送通知";
    public static String TITLE_HANDLED = "待审批通知";

    public static String TITLE_REFUSE = "审批驳回通知";

    public static String TITLE_APPROVE = "审批通过通知";

    public static String TITLE_CANCEL = "审批撤销通知";

    public static String TITLE_TODO = "待办事项通知";

    public static String getDescription(String date, String content) {
        StringBuffer stringBuffer = new StringBuffer();
        if (StringUtil.isNotEmpty(date)) {
            stringBuffer.append(datePrefix).append(date).append(dateSuffix);
        }
        stringBuffer.append(content);
        return stringBuffer.toString();
    }

    public static String getContent(String content, String color) {
        if (StringUtil.isEmpty(color)) {
            color = NORMAL;
        }
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(classPrefix).append(color).append(classSuffix).append(content).append(contentSuffix);
        return stringBuffer.toString();
    }

    public static String builderHandledContent(String tenantName, String typeName, String content, String applyTime, String reason) {
        String fianllContent = "所属组织：" + tenantName + "\n" +
                "申请类型：" + typeName + "\n" +
                "申请事由：" + content;
        if (StringUtil.isNotEmptyORNull(applyTime)) {
            fianllContent += "\n申请时间：" + applyTime;
        }
        return fianllContent;
    }

    public static String builderCopyContent(String tenantName, String content) {
        String fianllContent = "所属组织：" + tenantName + "\n" +
                "抄送内容：" + content;
        return fianllContent;
    }

    public static String builderCancelContent(String tenantName, String typeName, String content) {
        String fianllContent = "所属组织：" + tenantName + "\n" +
                "申请类型：" + typeName + "\n" +
                "申请事由：" + content;
        return fianllContent;
    }

    public static String builderTodoContent(String content) {
        String fianllContent = content;
        return fianllContent;
    }


    public static void main(String[] args) {

        // LocalDateTime.now()格式化时间

        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String format = now.format(formatter);

        System.out.println("format = " + format);

    }

}
