package com.qmth.qrzk.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.qmth.qrzk.dao.repositories.SupplyConfigRepo;
import com.qmth.qrzk.supplypaper.model.SupplyConfig;

/**
 * 供卷设置
 * @author zhengmin
 *
 */
@RestController
@RequestMapping("supplyconfig")
public class SupplyConfigController {

	@Autowired private SupplyConfigRepo supplyConfigRepo;
	
	@RequestMapping(method=RequestMethod.GET)
	public SupplyConfig get(@RequestParam int batchId){
		SupplyConfig result = new SupplyConfig();
		result.setBatchId(batchId);
		List<SupplyConfig> list = supplyConfigRepo.findByBatchId(batchId);
		if(list.size() > 0){
			result = list.get(0);
		}
		return result;
	}
	
	@RequestMapping(method=RequestMethod.PUT)
	public AjaxResponse save(@RequestBody SupplyConfig supplyConfig){
		supplyConfigRepo.save(supplyConfig);
		return new AjaxResponse(true);
	}
}
