/***文档注释***********************************************
 * 作者               :                   易鑫
 * 创建日期      :                   2018.2.5
 * 描述               :        			取样码与产品名称
 * 注意事项      :                   无
 * 遗留BUG :                   无
 * 修改日期      :                   
 * 修改人员      :                   
 * 修改内容      :                   
***********************************************************/
package market.Com.impl;

import market.Com.mapper.ComBaseSampleRProductMapper;
import market.Com.service.ComBaseSampleRProductService;
import market.Com.vo.ComBaseSampleRProduct;
import market.Com.vo.CommonPage;
import market.Com.vo.ResultModel;

import org.springframework.transaction.annotation.Transactional;

import com.hnshituo.basic.service.impl.BaseServiceImpl;
import com.hnshituo.basic.spring.remoting.annotation.RemoteService;

@RemoteService(path="ComBaseSampleRProductService")
public class ComBaseSampleRProductServiceImpl extends BaseServiceImpl<ComBaseSampleRProduct,Object> implements ComBaseSampleRProductService {


	/**
	 * 保存取样码与产品名称关系
	 * @param sum
	 * @return
	 */
	@Transactional(value="tm", rollbackFor=Exception.class)
	public ResultModel doAddProduct(CommonPage<ComBaseSampleRProduct> sum) {
		ResultModel rm =new ResultModel();
		ComBaseSampleRProduct prodduct = sum.getObject();
		prodduct.setValidflag("1");
		ComBaseSampleRProduct duct =this.getMapper(ComBaseSampleRProductMapper.class).findById(prodduct.getSmp_index());
		if (duct!=null) {
			this.getMapper(ComBaseSampleRProductMapper.class).delete(duct.getSmp_index());
		}
		this.getMapper(ComBaseSampleRProductMapper.class).insert(prodduct);
		return rm;
	}

}
