billserviceimpl.java

来自「自己做的关于spring框架的使用」· Java 代码 · 共 37 行

JAVA
37
字号
package myspring.v3.ts;

import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataIntegrityViolationException;

public class BillServiceImpl implements BillService {

	private AccountDao accountDao;
	
	private BillDao billDao;

	public void setAccountDao(AccountDao accountDao) {
		this.accountDao = accountDao;
	}

	public void setBillDao(BillDao billDao) {
		this.billDao = billDao;
	}
	
	public boolean buy(int accountId, int billId, float sum) {
		// TODO Auto-generated method stub
				
		if (billDao.addBill(billId, sum)){
			if (accountDao.pay(accountId, sum)){
				return true;
			} else {
				//throw new DataIntegrityViolationException("扣款失败,生成订单无效");
				//throw new Exception("扣款失败,生成订单无效");
				return false;
			}
		} else {
			return false;
		}
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?