package com.dev.swms.server.service.base.pojo;

import java.util.Date;
import java.util.List;

import com.dev.energy.server.service.pojo.DefaultBaseManager;
import com.dev.energy.server.web.security.UserHolder;
import com.dev.swms.server.model.abstractEntity.DesignList;
import com.dev.swms.server.model.base.City;
import com.dev.swms.server.service.base.CityManager;

public class DefaultCityManager extends DefaultBaseManager implements CityManager{

	@Override
	public void saveCity(City c) {
		if(c.isNew()) {
			c.setDisabled(false);//默认否
			c.setCreatDate(new Date());
			c.setCreatPeople(UserHolder.getUser().getName());
		}
		
		commonDao.store(c);
		
	}

	@Override
	public void deleteCity(List<Long> ids) {
		for(Long id : ids) {
			City c = this.load(City.class, id);
			this.delete(c);
		}
		
	}
	
	//失效
	@Override
	public void CityInvalid(List<Long> ids) {
		for(Long id : ids) {
			City c = this.load(City.class, id);
			c.setDisabled(true);
		}
		
	}
	
	//恢复
	@Override
	public void Cityrestore(List<Long> ids) {
		for(Long id : ids) {
			City c = this.load(City.class, id);
			c.setDisabled(false);
		}
		
	}
	
	@Override
	public void deleteDesignList(List<Long> ids) {
		for(Long id : ids) {
			DesignList c = this.load(DesignList.class, id);
			this.delete(c);
		}
		
	}

}
