package com.uas.finance.controller;

import com.uas.finance.service.AccountInfoService;
import com.uas.finance.model.AccountInfo;
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.ResponseBody;

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

/**
 * created by shicr on 2017/12/21
 * 财务数据表
 **/
@Controller
@RequestMapping("/accountinfo")
public class AccountInfoController {

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

    @Autowired
    private AccountInfoService accountInfoService;

    /**
     * 财务数据保存
     *
     * @param accountInfos
     * @return
     */
    @ResponseBody
    @RequestMapping("/save")
    public List<AccountInfo> save(@RequestBody AccountInfo[] accountInfos) {
        logger.info("财务数据保存", "success");
        ArrayList<AccountInfo> arrayList = new ArrayList<AccountInfo>();
        for (AccountInfo a : accountInfos) {
            AccountInfo accountInfo = accountInfoService.save(a);
            arrayList.add(accountInfo);
        }
        /*Long time = new Date().getTime();*/
        Long time = System.currentTimeMillis();
        return arrayList;
    }
}
