package com.buy507.mall.portal.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.buy507.mall.common.api.CommonResult;
import com.buy507.mall.portal.domain.MemberBankAccount;
import com.buy507.mall.portal.service.MemberBankAccountService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 会员银行信息管理Controller
 */
@RestController
@Api(tags = "MemberBankAccountController", description = "会员银行信息管理")
@RequestMapping("/member/bankAccount")
public class MemberBankAccountController {

	@Autowired
	private MemberBankAccountService service;

	@ApiOperation("添加会员银行信息")
	@RequestMapping(value = "/add", method = RequestMethod.POST)
    public CommonResult<String> add(@RequestBody MemberBankAccount bankAccount) {
    	return service.add(bankAccount);
    }
	
	@ApiOperation("删除会员银行信息")
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
    public CommonResult<String> delete(@PathVariable Long id) {
        return service.delete(id);
    }

    @ApiOperation("修改会员银行信息")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public CommonResult<String> update(@RequestBody MemberBankAccount bankAccount) {
    	return service.update(bankAccount);
    }

    @ApiOperation("显示会员的所有银行信息")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public CommonResult<List<MemberBankAccount>> list() {
        return service.list();
    }
    
    @ApiOperation("获取会员默认银行信息")
    @RequestMapping(value = "/getDefaultBankAccount", method = RequestMethod.GET)
    public CommonResult<MemberBankAccount> getDefaultBankAccount() {
        return service.getDefaultBankAccount();
    }
    
    @ApiOperation("获取单个会员银行信息")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public CommonResult<MemberBankAccount> get(@PathVariable Long id) {
        return service.get(id);
    }

}
