package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.entity.SysUserBankCard;
import com.ym.mec.biz.service.SysUserBankCardService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.page.QueryInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RequestMapping("userBankCard")
@Api(tags = "银行卡信息服务")
@RestController
public class SysUserBankCardController extends BaseController {

    @Autowired
    private SysUserBankCardService sysUserBankCardService;

    @ApiOperation(value = "新增银行卡信息")
    @PostMapping("/add")
    public Object add(SysUserBankCard sysUserBankCard) {
        sysUserBankCardService.insert(sysUserBankCard);
        return succeed();
    }

    @ApiOperation(value = "删除银行卡信息")
    @PostMapping("/del/{id}")
    public Object del(@ApiParam(value = "银行卡信息编号", required = true) @PathVariable("id") Long id) {
        sysUserBankCardService.delete(id);
        return succeed();
    }

    @ApiOperation(value = "修改银行卡信息")
    @PutMapping("/update")
    public Object update(SysUserBankCard sysUserBankCard) {
        sysUserBankCard.setModifyOn(new Date());
        sysUserBankCardService.update(sysUserBankCard);
        return succeed();
    }

    @ApiOperation(value = "分页查询银行卡信息列表")
    @GetMapping("/queryPage")
    public Object queryPage(QueryInfo queryInfo) {
        return succeed(sysUserBankCardService.queryPage(queryInfo));
    }
}
