package org.dromara.zhishu.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.zhishu.domain.ShopGoodsPublishedLog;
import org.dromara.zhishu.mapper.ShopGoodsPublishedLogMapper;
import org.dromara.zhishu.service.ShopGoodsPublishedLogService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class ShopGoodsPublishedLogServiceImpl extends ServiceImpl<ShopGoodsPublishedLogMapper, ShopGoodsPublishedLog> implements ShopGoodsPublishedLogService {

    private final ShopGoodsPublishedLogMapper shopGoodsPublishedLogMapper;

    @Override
    public ShopGoodsPublishedLog queryPublishedLogByOrderSn(String platformId, String aboutId, Integer platformType, Integer logType, Integer operationType) {
        List<ShopGoodsPublishedLog> list = new LambdaQueryChainWrapper<>(shopGoodsPublishedLogMapper)
                .eq(ShopGoodsPublishedLog::getDelFlag, "0")
                .eq(ShopGoodsPublishedLog::getPlatformId, platformId)
                .eq(ShopGoodsPublishedLog::getAboutId, aboutId)
                .eq(ShopGoodsPublishedLog::getPlatformType, platformType)
                .eq(ShopGoodsPublishedLog::getLogType, logType)
                .eq(ShopGoodsPublishedLog::getOperationType, operationType)
                .list();
        if (!list.isEmpty())
            return list.get(0);
        return null;
    }
}
