package com.cloudcross.ssp.back.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cloudcross.ssp.back.model.Zone;
import com.cloudcross.ssp.back.service.IZoneService;
import com.cloudcross.ssp.base.dao.GenericIBatisDao;
import com.cloudcross.ssp.common.utils.Assert;
import com.cloudcross.ssp.common.utils.MapBuilder;
import com.cloudcross.ssp.common.utils.Pager;
import com.cloudcross.ssp.web.widget.SelectorController.ISelector;
import com.cloudcross.ssp.web.widget.SelectorController.ISelectorProvider;


@Service
public class ZoneService implements IZoneService, ISelectorProvider {
	@Autowired
	private GenericIBatisDao myBatisDao;

	@Override
	public Zone findById(Long id) {
		return myBatisDao.get("back.zoneSqlMapper.selectById", id);
	}

	@Override
	public int countByParams(Map<String, Object> paramMap) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<Zone> findByParams(Map<String, Object> paramMap, Pager pager) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean add(Zone t) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean edit(Zone t) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean updateStatus(List<Long> idList, int status) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Map<String, List<? extends ISelector>> provideData(String[] parentId) {
		Assert.isTrue(ArrayUtils.isNotEmpty(parentId));
		Long operatorId = Long.parseLong(parentId[0]);
		List<Zone> zoneList = findByOperatorId(operatorId);
		return MapBuilder.create(HashMap.class).add("zoneList", zoneList).map();
	}

	@Override
	public List<Zone> findByOperatorId(Long operatorId) {
		return myBatisDao.getList("back.zoneSqlMapper.findByOperatorId", operatorId);
	}

}
