package com.uas.finance.controller;

import com.uas.finance.service.ProductMixService;
import com.uas.finance.model.ProductMix;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * 经营情况表单
 * created by shicr on 2017/12/21
 **/
@Controller
@RequestMapping("/productmix")
public class ProductMixController {

    private final static Logger logger = LoggerFactory.getLogger(ProductMixController.class);

    @Autowired
    private ProductMixService productMixService;

    /**
     * 经营情况表单保存
     *
     * @param productMixes
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    List<ProductMix> save(@RequestBody ProductMix[] productMixes) {

        ArrayList<ProductMix> arrayList = new ArrayList<ProductMix>();
        logger.info("经营情况表单保存", "success");
        for (ProductMix productMix : productMixes) {
            ProductMix productMix1 = productMixService.save(productMix);
            arrayList.add(productMix1);
        }
        return arrayList;
    }
}
