package com.uas.finance.service.Impl;

import com.uas.finance.model.Shareholders;import com.uas.finance.service.ShareholdersService;import com.uas.finance.dao.ShareholdersDao;
import com.uas.finance.model.Shareholders;
import com.uas.finance.service.ShareholdersService;
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/19
 **/
@Service
public class ShareholdersServiceImpl implements ShareholdersService {

    @Autowired
    private ShareholdersDao shareholdersDao;

    /**
     * 股东信息保存
     * @param shareholders
     * @return
     */
    public Shareholders save(Shareholders shareholders) {
        return shareholdersDao.save(shareholders);
    }

    /**
     * 更新股东信息资料
     * @param shareholders
     */
    public List<Map<String,Long>> update(List<Shareholders> shareholders){
        List<Map<String, Long>> list = new ArrayList<Map<String, Long>>();
        for(Shareholders shareholders1 : shareholders){
            Map<String, Long> map = new HashMap<String, Long>();
            Shareholders shareholders2 = shareholdersDao.save(shareholders1);
            map.put("id",shareholders2.getId());
            map.put("cs_id",shareholders2.getErpId());
            list.add(map);
        }
        return list;
    }
}
