package cn.superdesk.uniorder.notify;

import cn.hutool.core.date.DateUtil;
import cn.superdesk.uniorder.common.enums.common.CommonSoftDeleteEnum;
import cn.superdesk.uniorder.common.enums.sys.notify.SysNotifyCategoryDefaultEnum;
import cn.superdesk.uniorder.common.enums.thirdpart.jd.SysQuartzScheduleTaskStatementOfAccountRunStateEnum;
import cn.superdesk.uniorder.dao.entity.sys.notify.SysNotify;

/**
 * @Description: TODO
 * 系统 通知 mark by linjinyu at 20210302
 * 重构 方法 mark by linjinyu at 20210604
 * @Author: linjinyu
 * @CreateDate: 2021/6/3 上午10:35
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/6/3 上午10:35
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public class NotifyUtils {

    /**
     * 暂时这样,这里的一些数值不是最终入库的
     *
     * @param title   "Excel导出任务已完成-" + targetFileName
     * @param content relativePath + targetFileName
     * @return
     */
    public static SysNotify createSysNotify(
            String title,
            String content,
            SysQuartzScheduleTaskStatementOfAccountRunStateEnum taskState) {

        SysNotify sysNotify = new SysNotify();

        sysNotify.setTaskState(taskState.getKey());

        sysNotify.setIsDeleted(CommonSoftDeleteEnum.正常.getKey());
        sysNotify.setCategoryId(SysNotifyCategoryDefaultEnum.系统预留.getKey());

        // 现在默认都是从系统发
        sysNotify.setFromTime(DateUtil.date());
        sysNotify.setFromUserId(1L);

        sysNotify.setToTime(DateUtil.date());
        sysNotify.setToUserId(1L);
        sysNotify.setIdentifier("");

        sysNotify.setIsReaded(0);
//		sysNotify.setReadTime();

        sysNotify.setTemplateId(0);
        sysNotify.setTitle(title);
        sysNotify.setContent(content);

        sysNotify.setMessageBody("{}");

        /**
         * mark by linjinyu at 2021-06-03 10:20:30 - 设计思路
         * 1. TemplateId + MessageBody => Content
         * 2. MessageBody(Json)
         * 3. Content(Text|Html|Markdown)
         * 外加 CategoryId
         * 决定前端显示交互逻辑，不仅仅是一个通知手段
         */

        return sysNotify;
    }
}
