package com.transaction_anno.service.impl;

import com.transaction_anno.service.AccountTwoService;
import com.transaction_anno.dao.AccountDao;
import com.transaction_anno.entity.AccountEntity;
import com.transaction_anno.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("account_anno")
public class AccountServiceImpl implements AccountService {
    @Autowired
    AccountDao accountDao;
    @Override
    public void initAccount() {
        AccountEntity accountEntity = new AccountEntity();
        accountEntity.setUserName("李四");
        accountEntity.setBalance(300.0);
        int i = accountDao.saveAccount(accountEntity);
    }
    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
    @Override
    public int reduceAccount(AccountEntity toEntity) {
        int in = accountDao.incomeAccount(toEntity, "to");
        return 0;
    }
}
