package com.willalp.yiqing.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.willalp.common.exception.base.BaseException;
import com.willalp.common.utils.StringUtils;
import com.willalp.yiqing.domain.HsOrdersLog;
import com.willalp.yiqing.domain.HsOrdersLogData;
import com.willalp.yiqing.mapper.HsOrdersLogMapper;
import com.willalp.yiqing.service.IHsOrdersLogDataService;
import com.willalp.yiqing.service.IHsOrdersLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 派单记录Service业务层处理
 *
 * @author willalp
 * @date 2022-05-24
 */
@Service
public class
HsOrdersLogServiceImpl extends ServiceImpl<HsOrdersLogMapper, HsOrdersLog> implements IHsOrdersLogService {
    @Resource
    private HsOrdersLogMapper hsOrdersLogMapper;

    @Resource
    private IHsOrdersLogDataService ordersLogDataService;

    /**
     * 查询派单记录列表
     *
     * @param hsOrdersLog 派单记录
     * @return 派单记录
     */
    @Override
    public List<HsOrdersLog> selectHsOrdersLogList(HsOrdersLog hsOrdersLog) {
        return hsOrdersLogMapper.selectHsOrdersLogList(hsOrdersLog);
    }

    @Override
    public List<HsOrdersLogData> exportOrderResult(HsOrdersLog hsOrdersLog) {
        String id = hsOrdersLog.getId();
        if (StringUtils.isBlank(id)) {
            throw new BaseException("未选择记录");
        }
        List<HsOrdersLogData> hsOrdersLogData = ordersLogDataService.getBaseMapper()
                .selectList(new QueryWrapper<HsOrdersLogData>()
                        .eq("log_id", id));
        return hsOrdersLogData;
    }
}
