package com.rongwei.savecheck.controller;

import com.rongwei.rwcommon.base.R;
import com.rongwei.sfcommon.sys.service.impl.AspSafeAttachmentsServiceImpl;
import lombok.extern.slf4j.Slf4j;
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;

/**
 * AspSafeAttachmentsController class
 *
 * @author XH
 * @date 2024/06/15
 */
@RestController
@RequestMapping("/safe/attachments")
public class AspSafeAttachmentsController {
    private final Logger log = LoggerFactory.getLogger(this.getClass().getName());

    @Autowired
    private AspSafeAttachmentsServiceImpl aspSafeAttachmentsService;

    @Scheduled(cron = "0 0 3 ? * *")
    @PostMapping("/state")
    public R stateUpdateScheduledTasks(){
        log.info("安全附件定时任务,更改安全附件预警级别");
        return aspSafeAttachmentsService.stateUpdateScheduledTasks();
    }

    @PostMapping("/import")
    public R importExport(@RequestBody Map<String, String> queryParameter){
        log.info("开始导入安全附件信息");
        return  aspSafeAttachmentsService.importExcel(queryParameter);
    }
}
