package cn.iselab.mooctest.user.service.impl;

import cn.iselab.mooctest.user.mapper.BankAccountInfoDao;
import cn.iselab.mooctest.user.model.BankAccountInfo;
import cn.iselab.mooctest.user.service.BankAccountInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: xuexb
 * @Date: 2019.2.26 14:57
 */
@Service
public class BankAccountInfoServiceImpl implements BankAccountInfoService {

    @Autowired
    BankAccountInfoDao bankAccountInfoDao;

    @Override
    public BankAccountInfo setBankAccountInfo(BankAccountInfo info) {
        BankAccountInfo bankAccountInfo = bankAccountInfoDao.findBankAccountInfoByUserId(info.getUserId());
        if(bankAccountInfo!=null){
            info.setId(bankAccountInfo.getId());
            return bankAccountInfoDao.save(info);
        }else{
            return bankAccountInfoDao.save(info);
        }
    }
}
