package com.uas.finance.service.Impl;

import com.uas.finance.dao.UpdowncastDao;
import com.uas.finance.model.Updowncast;
import com.uas.finance.service.UpdowncastService;
import com.uas.finance.dao.UpdowncastDao;
import com.uas.finance.model.Updowncast;
import com.uas.finance.service.UpdowncastService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 上下游接口路实现类
 * created by shicr on 2017/12/21
 **/
@Service
public class UpdowncastServiceImpl implements UpdowncastService {

    @Autowired
    private UpdowncastDao dao;

    /**
     * 上下游保存
     *
     * @param updowncast
     * @return
     */
    public Updowncast save(Updowncast updowncast) {
        return dao.save(updowncast);
    }

    /**
     * 上下游更新
     *
     * @param updowncastList
     */
    @Override
    public List<Map<String, Long>> update(List<Updowncast> updowncastList) {
        List<Map<String, Long>> list = new ArrayList<Map<String, Long>>();
        for (Updowncast updowncast : updowncastList) {
            Map<String, Long> map = new HashMap<String, Long>();
            Updowncast updowncast1 = dao.save(updowncast);
            map.put("id", updowncast1.getId());
            map.put("udc_id", updowncast1.getErpId());
            list.add(map);
        }
        return list;
    }
}
