package com.buy507.mall.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.buy507.mall.dto.ExpressOptions;
import com.buy507.mall.mapper.OmsExpressCompanyMapper;
import com.buy507.mall.model.EnableStatus;
import com.buy507.mall.model.OmsExpressCompany;
import com.buy507.mall.service.OmsExpressCompanyService;

@Service
public class OmsExpressCompanyServiceImpl implements OmsExpressCompanyService {
	
	@Autowired
	private OmsExpressCompanyMapper mapper;

	@Override
	public List<ExpressOptions> getExpressOptions() {
		List<OmsExpressCompany> list = mapper.selectAll();
		
		List<ExpressOptions> result = new ArrayList<>();
		ExpressOptions option = null;
		for(OmsExpressCompany express : list) {
			if(EnableStatus.Enable.equals(express.getStatus())) {
				option = new ExpressOptions();
				option.setValue(String.valueOf(express.getId()));
				option.setLabel(express.getName());
				result.add(option);
			}
		}
		return result;
	}

}
