package com.ajb.web.metadata.impl;


import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ajb.car.entity.meta.AgMdVehicleBrand;
import com.ajb.car.metadata.service.AgMdVehicleBrandService;
import com.ajb.car.vo.common.CommonResult;
import com.ajb.car.vo.meta.AgMdVehicleBrandRequestVO;
import com.ajb.car.vo.meta.AgMdVehicleBrandResponseVO;
import com.ajb.web.metadata.AgMdVehicleBrandWebService;

@Service("agMdVehicleBrandWebService")
public class AgMdVehicleBrandWebServiceImpl implements AgMdVehicleBrandWebService {

	@Autowired
	private AgMdVehicleBrandService agMdVehicleBrandService;
	
	@Transactional
	@Override
	public AgMdVehicleBrandResponseVO agMdVehicleBrandSave(AgMdVehicleBrandRequestVO agMdVehicleBrandRequestVO) throws Exception {
		AgMdVehicleBrandResponseVO result =  new AgMdVehicleBrandResponseVO();
    	//TODO validate the user inputs
		AgMdVehicleBrand tempEntity =  new AgMdVehicleBrand();      
	    
        //TODO validate the user inputs
        BeanUtils.copyProperties(tempEntity,agMdVehicleBrandRequestVO);
        
		//data persistence        
    	tempEntity = agMdVehicleBrandService.save(tempEntity);
    	
        //fetch the sequence id the database returned
    	Long sequence = tempEntity.getId();
    	agMdVehicleBrandRequestVO.setId(sequence);
        
        //return success info
		Boolean success = true;
		String message = "save success!";
		
		result.setCommonResult(new CommonResult(success,message));
		result.setRequestVO(agMdVehicleBrandRequestVO);
        
        return result;
	}
    
    @Transactional
	@Override
	public  AgMdVehicleBrandResponseVO agMdVehicleBrandUpdate(AgMdVehicleBrandRequestVO agMdVehicleBrandRequestVO) {
		// TODO Auto-generated method stub
				Boolean success = true;
		String message = "save success!";
		
		AgMdVehicleBrandResponseVO result = new AgMdVehicleBrandResponseVO();
		result.setCommonResult(new CommonResult(success,message));
		
        return result;
	}

	@Transactional
	@Override
	public  AgMdVehicleBrandResponseVO agMdVehicleBrandQuery(AgMdVehicleBrandRequestVO agMdVehicleBrandRequestVO) {
		// TODO Auto-generated method stub
		Boolean success = true;
		String message = "save success!";
		
		AgMdVehicleBrandResponseVO result = new AgMdVehicleBrandResponseVO();
		result.setCommonResult(new CommonResult(success,message));
		
        return result;
	}

}