package com.uas.finance.controller;

import com.uas.finance.service.MFCustInfoDetailService;
import com.uas.finance.model.MFCustInfoDetail;
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/24
 **/
@Controller
@RequestMapping("/mfcustinfodetail")
public class MFCustInfoDetailController {

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

    @Autowired
    private MFCustInfoDetailService service;

    /**
     * 买方客户信息详情保存
     *
     * @param mfCustInfoDetails
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public List<MFCustInfoDetail> save(@RequestBody MFCustInfoDetail[] mfCustInfoDetails) {

        ArrayList<MFCustInfoDetail> arrayList = new ArrayList<MFCustInfoDetail>();
        logger.info("买方客户信息详情保存", "success");
        for (MFCustInfoDetail mfCustInfoDetail : mfCustInfoDetails) {
            MFCustInfoDetail mfCustInfoDetail1 = service.save(mfCustInfoDetail);
            arrayList.add(mfCustInfoDetail1);
        }
        return arrayList;
    }
}
