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.base.Vehicle;
import com.dev.swms.server.service.base.VehicleManager;
 
public class DefaultVehicleManager extends DefaultBaseManager implements VehicleManager{

	//添加车辆
	@Override
	public void saveVehicle(Vehicle v) {
		
		v.setBeDisabled(false);//默认否
		v.setCreatDate(new Date());
		v.setCreatPeople(UserHolder.getUser().getName());
		commonDao.store(v);
		
	}
	
	//删除车辆
	@Override
	public void deleteVehicle(List<Long> ids) {
		for (Long id : ids) {
			Vehicle v = this.load(Vehicle.class, id);
			this.delete(v);
		}
		
	}
	
	//失效
	@Override
	public void vehicleInvalid(List<Long> ids) {
		for (Long id : ids) {
			Vehicle v = this.load(Vehicle.class, id);
			v.setBeDisabled(true);
		}
		
	}
	
	//恢復
	@Override
	public void vehiclerestore(List<Long> ids) {
		for (Long id : ids) {
			Vehicle v = this.load(Vehicle.class, id);
			v.setBeDisabled(false);
		}
		
	}

}
