package cn.iocoder.yudao.module.inspection.service.impl;

import java.util.Arrays;
import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.iocoder.yudao.util.DateUtils;
import cn.iocoder.yudao.module.inspection.service.AppInspectionPartnerService;
import cn.iocoder.yudao.module.shop.entity.ShopMallPartners;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.iocoder.yudao.module.inspection.mapper.WarnMessageMapper;
import cn.iocoder.yudao.module.inspection.entity.WarnMessage;
import cn.iocoder.yudao.module.inspection.service.IWarnMessageService;

/**
 * warnMsgService业务层处理
 *
 * @author zcy
 * @date 2023-10-13
 */
@Service
public class WarnMessageServiceImpl extends ServiceImpl<WarnMessageMapper,WarnMessage> implements IWarnMessageService
{

    @Autowired
    private AppInspectionPartnerService partnerService;

    /**
     * 查询warnMsg
     *
     * @param id warnMsg主键
     * @return warnMsg
     */
    @Override
    public WarnMessage selectWarnMessageById(Long id)
    {
        return baseMapper.selectWarnMessageById(id);
    }

    /**
     * 查询warnMsg列表
     *
     * @param warnMessage warnMsg
     * @return warnMsg
     */
    @Override
    public List<WarnMessage> selectWarnMessageList(WarnMessage warnMessage) throws Exception {
        ShopMallPartners partners = partnerService.shopInfo();
        warnMessage.setPartnerId(partners.getPartnerId());
        warnMessage.setIsRead("0");
        List<WarnMessage> warnMessages = baseMapper.selectWarnMessageList(warnMessage);
        return warnMessages;
    }

    @Override
    public IPage<WarnMessage> pageList(Page page, WarnMessage warnMessage) throws Exception {
        ShopMallPartners partners = partnerService.shopInfo();
        warnMessage.setPartnerId(partners.getPartnerId());
        warnMessage.setIsRead("0");
        IPage<WarnMessage> warnMessages = baseMapper.pageList(page,warnMessage);
        return warnMessages;
    }

    /**
     * 新增warnMsg
     *
     * @param warnMessage warnMsg
     * @return 结果
     */
    @Override
    public int insertWarnMessage(WarnMessage warnMessage)
    {
        return baseMapper.insert(warnMessage);
    }

    /**
     * 修改warnMsg
     *
     * @param warnMessage warnMsg
     * @return 结果
     */
    @Override
    public int updateWarnMessage(WarnMessage warnMessage)
    {
        warnMessage.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.updateById(warnMessage);
    }

    /**
     * 批量删除warnMsg
     *
     * @param ids 需要删除的warnMsg主键
     * @return 结果
     */
    @Override
    public int deleteWarnMessageByIds(Long[] ids)
    {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除warnMsg信息
     *
     * @param id warnMsg主键
     * @return 结果
     */
    @Override
    public int deleteWarnMessageById(Long id)
    {
        return baseMapper.deleteById(id);
    }
}
