package com.ruoyi.cms.util.notice;

import com.ruoyi.cms.domain.EmployeeConfirm;
import com.ruoyi.cms.domain.Job;
import com.ruoyi.cms.domain.Notice;
import com.ruoyi.common.core.domain.entity.AppUser;

import java.util.ArrayList;
import java.util.List;

public class NoticeUtils {
    /**
     * 消息已读
     */
    public static final String NOTICE_YD="1";
    /**
     * 消息未读
     */
    public static final String NOTICE_WD="0";

    public static final String NOTICE_REMARK="notice_bar";

    public static final String NOTICE_COMENT_ZH="衷心祝贺您通过";

    public static final String NOTICE_COMENT_LY="全流程招聘考核，正式被录用，岗位为【";

    public static final String NOTICE_COMENT_FF="】";

    public static final String NOTICE_TYPE_LY="录用通知";

    public static final String NOTICE_TYPE_GWSX="您收藏的公司有新的职位发布";

    public static final String NOTICE_TYPE_XTLX="1";

    public static final String NOTICE_TYPE_SXLX="2";

    /**
     * 拼装岗位
     */
    public static final String JOB_NEW="刚刚发布职位";
    public static final String JOB_XZ="薪资";
    public static final String JOB_KKB="快去看看吧";
    public static final String JOB_QFH="“";
    public static final String JOB_HFH="”";
    public static final String JOB_ZJG="-";
    public static final String JOB_DH=",";


    /**
     * 录用通知
     * @param companyName
     * @param jobName
     * @return
     */
    public static String appUserLytz(String companyName,String jobName){
        return NoticeUtils.NOTICE_COMENT_ZH+companyName+NoticeUtils.NOTICE_COMENT_LY+jobName+NoticeUtils.NOTICE_COMENT_FF;
    }

    /**
     * “海尔集团”刚刚发布职位“产品性能分析工程师”薪资“1.5-2.5k，快去看看吧
     * @param job
     * @return
     */
    public static String appUserGwsx(Job job){
        return JOB_QFH+job.getCompanyName()+JOB_HFH+JOB_NEW+JOB_QFH+job.getJobTitle()+JOB_HFH+JOB_XZ+job.getMinSalary()+JOB_ZJG+job.getMaxSalary()+JOB_DH+JOB_KKB;
    }

    /**
     * 审核确认界面拼装消息
     */
    public static Notice createLytzNotice(EmployeeConfirm employeeConfirm, Job job) {
        Notice notice = new Notice();
        notice.setUserId(employeeConfirm.getUserId());
        notice.setBussinessId(job.getJobId());
        notice.setIsRead(NoticeUtils.NOTICE_WD);
        notice.setTitle(NoticeUtils.NOTICE_TYPE_LY);
        notice.setSubTitle(NoticeUtils.NOTICE_TYPE_LY);
        notice.setNoticeType(NoticeUtils.NOTICE_TYPE_XTLX);
        notice.setRemark(NoticeUtils.NOTICE_REMARK);
        String content = appUserLytz(job.getCompanyName(), job.getJobTitle());
        notice.setNoticeContent(content);
        return notice;
    }

    /**
     * 岗位上新
     */
    public static List<Notice> createGwsxNotice(List<AppUser> appUserList, Job job) {
        List<Notice> add=new ArrayList<>();
        appUserList.forEach(appUser -> {
            String content = appUserGwsx(job);
            Notice notice = new Notice();
            notice.setUserId(appUser.getUserId());
            notice.setBussinessId(job.getJobId());
            notice.setIsRead(NoticeUtils.NOTICE_WD);
            notice.setTitle(NoticeUtils.NOTICE_TYPE_GWSX);
            notice.setSubTitle(content);
            notice.setNoticeType(NoticeUtils.NOTICE_TYPE_SXLX);
            notice.setRemark(NoticeUtils.NOTICE_REMARK);
            notice.setNoticeContent(content);
            add.add(notice);
        });
        return add;
    }
}
