package com.gree.mall.miniapp.controller.material.withdrawal;

import com.gree.mall.miniapp.exception.RemoteServiceException;
import com.gree.mall.miniapp.helper.ResponseHelper;
import com.gree.mall.miniapp.logic.material.withdrawal.WorkerBankLogic;
import com.gree.mall.miniapp.plus.entity.WorkerBank;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Slf4j
@RestController
@Api(value = "师傅银行卡", tags ={"师傅银行卡"} )
@RequestMapping(value = "/worker/bank", produces = "application/json; charset=utf-8")
public class WorkerBankController {

    @Autowired
    WorkerBankLogic workerBankLogic;

    @PostMapping("list")
    @ApiOperation("银行卡-列表")
    public ResponseHelper<List<WorkerBank>> list(){
        List<WorkerBank> list = workerBankLogic.list();
        return ResponseHelper.success(list);
    }

    @PostMapping("/save")
    @ApiOperation(value = "银行卡-保存")
    public ResponseHelper save(
            @RequestBody WorkerBank workerBank
    ) throws RemoteServiceException {
        workerBankLogic.save(workerBank);
        return ResponseHelper.success();
    }

    @PostMapping("/detail")
    @ApiOperation(value = "银行卡-详情")
    public ResponseHelper<WorkerBank> detail(
            @ApiParam(value = "id",required = true) @RequestParam String id
    ) throws RemoteServiceException {
        WorkerBank workerBank = workerBankLogic.detail(id);
        return ResponseHelper.success(workerBank);
    }

    @PostMapping("/delete")
    @ApiOperation(value = "银行卡-删除")
    public ResponseHelper delete(
            @ApiParam(value = "id",required = true) @RequestParam String id
    ){
        workerBankLogic.delete(id);
        return ResponseHelper.success();
    }

}
