package com.cyl.manager.oms.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cyl.manager.oms.domain.OmsOrderService;
import com.cyl.manager.oms.domain.OrderItem;
import com.cyl.manager.oms.mapper.OmsOrderServiceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * 预约订单服务详细信息记录表Service接口
 * 
 * @author daixiande
 */
@Service
public class OmsOrderServiceService {
    @Autowired
    private OmsOrderServiceMapper omsOrderServiceMapper;

    /**
     * 查询预约订单服务详细信息记录表
     * 
     * @param id 预约订单服务详细信息记录表主键
     * @return 预约订单服务详细信息记录表
     */
    public OmsOrderService selectOmsOrderServiceById(Long id){
        return omsOrderServiceMapper.selectById(id);
    }
    
    public OmsOrderService selectByOrderId(Long id) {
        OmsOrderService omsOrderService = new OmsOrderService();
        omsOrderService.setOrderId(id);
        List<OmsOrderService> orderServiceList = omsOrderServiceMapper.selectListBySql(omsOrderService);

        if (CollectionUtils.isEmpty(orderServiceList)){
            return null;
        }

        //TODO fix
        return orderServiceList.get(0);
    }

    public List<OmsOrderService> selectListByOrderId(Long id) {
        OmsOrderService omsOrderService = new OmsOrderService();
        omsOrderService.setOrderId(id);
        List<OmsOrderService> orderServiceList = omsOrderServiceMapper.selectListBySql(omsOrderService);

        if (CollectionUtils.isEmpty(orderServiceList)){
            return null;
        }

        //TODO fix
        return orderServiceList;
    }

    /**
     * 查询预约订单服务详细信息记录表列表
     * 
     * @param omsOrderService 预约订单服务详细信息记录表
     * @return 预约订单服务详细信息记录表集合
     */
    public List<OmsOrderService> selectOmsOrderServiceList(OmsOrderService omsOrderService){
        return omsOrderServiceMapper.selectListBySql(omsOrderService);
    }

    /**
     * 新增预约订单服务详细信息记录表
     * 
     * @param omsOrderService 预约订单服务详细信息记录表
     * @return 结果
     */
    public int insertOmsOrderService(OmsOrderService omsOrderService){
        return omsOrderServiceMapper.insert(omsOrderService);
    }

    /**
     * 修改预约订单服务详细信息记录表
     * 
     * @param omsOrderService 预约订单服务详细信息记录表
     * @return 结果
     */
    public int updateOmsOrderService(OmsOrderService omsOrderService){
        return omsOrderServiceMapper.update(omsOrderService);
    }

    /**
     * 批量删除预约订单服务详细信息记录表
     * 
     * @param ids 需要删除的预约订单服务详细信息记录表主键集合
     * @return 结果
     */
    public int deleteOmsOrderServiceByIds(Long[] ids){
        return omsOrderServiceMapper.deleteByIds(ids);
    }

    /**
     * 删除预约订单服务详细信息记录表信息
     * 
     * @param id 预约订单服务详细信息记录表主键
     * @return 结果
     */
    public int deleteOmsOrderServiceById(Long id){
        return omsOrderServiceMapper.deleteById(id);
    }
}
