package com.rongwei.savecheck.controller;

import com.rongwei.rwcommon.base.R;
import com.rongwei.sfcommon.sys.service.HiddenDangerTaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * HiddenDangerTaskController class
 *
 * @author XH
 * @date 2023/10/20
 */
@RestController
@RequestMapping("/hidden-danger")
public class HiddenDangerTaskController {
    private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
    @Autowired
    private HiddenDangerTaskService hiddenDangerTaskService;

    /**
     * 隐患跟踪任务整改提醒 邮件
     *
     * @param map
     * @return
     */
    @PostMapping("/rectification/mail")
    public R rectificationMail(@RequestBody Map<String, String> map) {
        log.info("隐患跟踪任务整改提现!参数为：{}", map);
        return hiddenDangerTaskService.rectificationMail(map);
    }

    /**
     * 隐患跟踪任务验证提醒 邮件
     * 定时任务 每天8点
     *
     * @param map
     * @return
     */
    @Scheduled(cron = "0 0 8 ? * Fri")
    @PostMapping("/verify/mail")
    public void verifyMail() {
        log.info("隐患跟踪任务整改提现定时任务!");
        hiddenDangerTaskService.verifyMail();
    }

    /**
     * 隐患跟踪任务整改提醒 邮件
     * 定时任务 每天8点
     *
     * @param map
     * @return
     */
    @PostMapping("/send-back/mail")
    public void sendBackMail(@RequestBody Map<String, String> map) {
        log.info("隐患跟踪任务整改提醒!参数为：{}", map);
        hiddenDangerTaskService.sendBackMail(map);
    }


}
