package com.ylx.web.controller.massage;

import com.ylx.common.core.controller.BaseController;
import com.ylx.common.core.domain.R;
import com.ylx.common.core.domain.model.WxLoginUser;
import com.ylx.massage.domain.TBankUser;
import com.ylx.massage.domain.vo.BankVo;
import com.ylx.massage.service.TBankService;
import com.ylx.massage.service.TBankUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 银行卡号(TBankUser)表控制层
 *
 * @author makejava
 * @since 2024-12-31 09:58:19
 */
@Api(tags = {"App我的银行卡"})
@RestController
@RequestMapping("tBankUser")
public class TBankUserController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private TBankUserService tBankUserService;

    /**
     * 服务对象
     */
    @Resource
    private TBankService tBankService;
    /**
     * 通过主键查询单条数据
     *
     * @param
     * @return 单条数据
     */

    @ApiOperation("我的银行卡")
    @GetMapping("myBank")
    public R selectOne() {
        WxLoginUser wxLoginUser = getWxLoginUser();
        List<BankVo> list = tBankUserService.myBank(wxLoginUser);
        return R.ok(list);
    }

    /**
     * 新增数据
     *
     * @param tBankUser 实体对象
     * @return 新增结果
     */
    @ApiOperation("新增/绑定银行卡")
    @PostMapping("save")
    public R insert(@RequestBody TBankUser tBankUser) {
        return R.ok(this.tBankUserService.save(tBankUser));
    }

    /**
     * 新增数据
     *
     * @param tBankUser 实体对象
     * @return 新增结果
     */
    @ApiOperation("删除银行卡")
    @PostMapping("delete")
    public R deleteBank(@RequestBody TBankUser tBankUser) {
        return R.ok(this.tBankUserService.deleteBank(tBankUser));
    }

    @ApiOperation("银行配置列表")
    @GetMapping("bankList")
    public R selectAll() {
        return R.ok(this.tBankService.list());
    }
}

