package com.uas.finance.controller;

import com.uas.finance.service.CustomerExcutiveService;
import com.uas.finance.model.CustomerExcutive;
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("/customerexcutive")
public class CustomerExcutiveController {

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


    @Autowired
    private CustomerExcutiveService excutiveService;


    /**
     * 管理层信息保存
     *
     * @param customerExcutive
     * @return
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseBody
    public List<CustomerExcutive> save(@RequestBody CustomerExcutive[] customerExcutive) {
        ArrayList<CustomerExcutive> arrayList = new ArrayList<CustomerExcutive>();
        logger.info("管理层信息保存", "success");
        for (CustomerExcutive excutive : customerExcutive) {
            CustomerExcutive excutive1 = excutiveService.save(excutive);
            arrayList.add(excutive1);
        }

        return arrayList;
    }

}
