package com.wms.service.serviceImplements;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wms.entity.table.WmsLog;
import com.wms.mapper.LogMapper;
import com.wms.service.LogService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class LogServiceImplements extends ServiceImpl<LogMapper, WmsLog> implements LogService {
    private final LogMapper logMapper;

    @Override
    public boolean deleteWmsLogsRegularly(int interval) {
        LambdaQueryWrapper<WmsLog> lambdaQueryWrapper = new LambdaQueryWrapper<WmsLog>()
                .apply("log_time <= date_add(curdate(),INTERVAL -{0} DAY", interval);
        return super.remove(lambdaQueryWrapper);
    }
}
