package com.rongwei.bscommon.sys.service.impl;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rongwei.bscommon.sys.dao.KbKnowledgeLedgerDao;
import com.rongwei.bscommon.sys.service.KbKnowledgeLedgerService;
import com.rongwei.bsentity.domain.KbKnowledgeLedger;
import com.rongwei.rwcommon.base.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 知识库台账 服务实现类
 * </p>
 *
 * @author sc
 * @since 2024-01-08
 */
@Slf4j
@Service
public class KbKnowledgeLedgerServiceImpl extends ServiceImpl<KbKnowledgeLedgerDao, KbKnowledgeLedger> implements KbKnowledgeLedgerService {

    @Override
    public R checkFailtureDate() {
        KbKnowledgeLedger kbKnowledgeLedger = new KbKnowledgeLedger();
        kbKnowledgeLedger.setFilestatus("过期");
        //修改状态
        this.update(kbKnowledgeLedger, new QueryWrapper<KbKnowledgeLedger>().lambda()
                .eq(KbKnowledgeLedger::getFilestatus, "生效")
                .lt(KbKnowledgeLedger::getFailturedate, DateUtil.date()));
        return R.ok();
    }
}
