Commit 416a6476 authored by keita.onoguchi's avatar keita.onoguchi

ウォレット機能途中

parent c363330c
...@@ -5,18 +5,14 @@ import java.util.List; ...@@ -5,18 +5,14 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.example.domain.BadRequestException;
import com.example.domain.Wallets; import com.example.domain.Wallets;
import com.example.repository.WalletsRepository; import com.example.repository.WalletsRepository;
import com.example.web.EcsiteController;
//ユーザウォレットのサービス //ユーザウォレットのサービス
@Service @Service
public class WalletsService { public class WalletsService {
@Autowired @Autowired
WalletsRepository walletsRepository; WalletsRepository walletsRepository;
@Autowired
Wallets wallet;
public List<Wallets> findAll(){ public List<Wallets> findAll(){
return walletsRepository.findAll(); return walletsRepository.findAll();
...@@ -37,6 +33,7 @@ public class WalletsService { ...@@ -37,6 +33,7 @@ public class WalletsService {
//支払い処理 //支払い処理
public Wallets pay(Integer id, Integer amount){ public Wallets pay(Integer id, Integer amount){
//対象の財布情報を取得 //対象の財布情報を取得
Wallets wallet = new Wallets();
wallet = this.findOne(id); wallet = this.findOne(id);
wallet.setAmount(wallet.getAmount() - amount); wallet.setAmount(wallet.getAmount() - amount);
return walletsRepository.save(wallet); return walletsRepository.save(wallet);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment