package com.ruoyi.frequency.orderreceiving.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.code.PublicCommon;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.frequency.orderreceiving.entity.OrderReceiving;
import com.ruoyi.frequency.orderreceiving.mapper.OrderReceivingMapper;
import com.ruoyi.frequency.orderreceiving.service.OrderReceivingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 现师接单Service业务层处理
 *
 * @author zj
 * @date 2023-10-13
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class OrderReceivingServiceImpl extends ServiceImpl<OrderReceivingMapper, OrderReceiving>  implements OrderReceivingService
{
    @Autowired
    private OrderReceivingMapper orderReceivingMapper;

    /**
     * 查询现师接单
     *
     * @param id 现师接单主键
     * @return 现师接单
     */
    @Override
    public OrderReceiving selectOrderReceivingById(Long id)
    {
        return orderReceivingMapper.selectOrderReceivingById(id);
    }

    /**
     * 查询现师接单列表
     *
     * @param orderReceiving 现师接单
     * @return 现师接单
     */
    @Override
    public List<OrderReceiving> selectOrderReceivingList(OrderReceiving orderReceiving)
    {
        return orderReceivingMapper.selectOrderReceivingList(orderReceiving);
    }

    /**
     * 新增现师接单
     *
     * @param orderReceiving 现师接单
     * @return 结果
     */
    @Override
    public int insertOrderReceiving(OrderReceiving orderReceiving)
    {
        return orderReceivingMapper.insertOrderReceiving(orderReceiving);
    }

    /**
     * 修改现师接单
     *
     * @param orderReceiving 现师接单
     * @return 结果
     */
    @Override
    public int updateOrderReceiving(OrderReceiving orderReceiving)
    {
        orderReceiving.setUpdateTime(DateUtils.getNowDate());
        return orderReceivingMapper.updateOrderReceiving(orderReceiving);
    }

    /**
     * 批量删除现师接单
     *
     * @param ids 需要删除的现师接单主键
     * @return 结果
     */
    @Override
    public int deleteOrderReceivingByIds(Long[] ids)
    {
        this.lambdaUpdate().set(OrderReceiving::getDelFlag,PublicCommon.删除).in(OrderReceiving::getId,ids).update();
        return ids.length;
    }

    /**
     * 删除现师接单信息
     *
     * @param id 现师接单主键
     * @return 结果
     */
    @Override
    public int deleteOrderReceivingById(Long id)
    {
        this.lambdaUpdate().set(OrderReceiving::getDelFlag,PublicCommon.删除).eq(OrderReceiving::getId,id).update();
        return 1;
    }
}
