package com.rongwei.bsserver.sys.controller;


import com.rongwei.bscommon.sys.service.KbKnowledgeLedgerService;
import com.rongwei.bscommon.sys.utils.ExceptionUtils;
import com.rongwei.rwcommon.base.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 知识库台账 前端控制器
 * </p>
 *
 * @author sc
 * @since 2024-01-08
 */
@Slf4j
@RestController
@RequestMapping("/knowledgeLedger")
public class KbKnowledgeLedgerController {

    @Autowired
    private KbKnowledgeLedgerService kbKnowledgeLedgerService;

    /**
     * 定时任务，每天凌晨执行一次，检查知识库台账中，文档状态（FILESTATUS）为：生效，并且失效时间（FAILTUREDATE）在今天之前 的文档，将状态改为：过期
     * @return
     */
    @PostMapping("/checkFailtureDate")
    public R checkFailtureDate(){
        try {
            return kbKnowledgeLedgerService.checkFailtureDate();
        }catch (Exception e){
            ExceptionUtils.printExceptionDetail(e,"异常为：");
            log.error(e.getMessage());
            return R.error(e.getMessage());
        }
    }

}

