package com.hwrj.cloud.admin.service.impl;

import com.hwrj.cloud.admin.dto.param.SelectNewVo;
import com.hwrj.cloud.admin.mapper.OmsOrderExpressMapper;
import com.hwrj.cloud.admin.model.OmsOrderExpress;
import com.hwrj.cloud.admin.model.OmsOrderExpressExample;
import com.hwrj.cloud.admin.service.OmsOrderExpressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class OmsOrderExpressServiceImpl implements OmsOrderExpressService {


    @Autowired
    private OmsOrderExpressMapper omsOrderExpressMapper;


    @Override
    public List<SelectNewVo> select() {
        OmsOrderExpressExample example=new OmsOrderExpressExample();
        OmsOrderExpressExample.Criteria criteria = example.createCriteria();
        criteria.andStatusEqualTo(1);
        List<OmsOrderExpress> omsOrderExpresses = omsOrderExpressMapper.selectByExample(example);
        List<SelectNewVo> collect = omsOrderExpresses.stream().map(x -> {
            String expressName = x.getExpressName();
            SelectNewVo selectNewVo = new SelectNewVo();
            selectNewVo.setLabel(expressName);
            selectNewVo.setValue(expressName);
            return selectNewVo;
        }).collect(Collectors.toList());
        return collect;
    }
}
