package com.rongwei.training.controller;

import com.rongwei.rwcommon.base.R;
import com.rongwei.trainingcommon.sys.service.TrainingSendNotifyService;
import com.rongwei.trainingcommon.sys.service.impl.TrainingSendNotifyServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * SendNotifyController class
 *
 * @author XH
 * @date 2023/12/15
 */
@RestController
@RequestMapping("/notify")
@Slf4j
public class SendNotifyController {
    @Autowired
    private TrainingSendNotifyService sendNotifyService;

    @Scheduled(cron = "0 0 0 ? * *")
    @PostMapping("/end/reminder-email")
    public R endReminderMail() {
        log.info("开始发送培训课程提醒邮件");
        return sendNotifyService.endReminderEmail();
    }

    @Scheduled(cron = "0 0 0 ? * *")
    @PostMapping("/end/reminder-email/paper")
    public R endReminderPaperMail() {
        log.info("开始发送培训试卷截止提醒邮件");
        return sendNotifyService.endReminderPaperMail();
    }


    @PostMapping("/training/plan")
    public void trainingPlan() {
        log.info("开始发送考试提醒通知");
        sendNotifyService.trainingPlan();
    }

    @Scheduled(cron = "0 0 0 ? * *")
    @PostMapping("/questionnaire/survey")
    public void questionnaireSurvey() {
        log.info("开始发送问卷调查通知");
        sendNotifyService.questionnaireSurvey();
    }
}
