package com.dayou.controller;

import com.dayou.vo.BaseAmountVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.RestController;
import com.dayou.service.IBrokerageBaseAmountService;
import com.dayou.entity.BrokerageBaseAmount;
import com.dayou.common.RestResponse;
import org.springframework.web.bind.annotation.*;

/**
 * 自定义提成基数
 *
 * @author wucl
 * @since 2023-03-10
 */
@RestController
@RequestMapping("brokerageBaseAmount")
@Slf4j
public class BrokerageBaseAmountController extends BaseController {
    @Autowired
    private IBrokerageBaseAmountService brokerageBaseAmountService;

    /**
    * 自定义提成基数列表
    */
    @GetMapping("")
    public RestResponse<Page<BaseAmountVO>> page(BaseAmountVO baseAmountVO, Page page){
        Page<BaseAmountVO> pages=brokerageBaseAmountService.selectPage(page,baseAmountVO);
        return RestResponse.data(pages);
    }

    /**
     * 自定义提成基数详情
     */
    @GetMapping("/{id}")
    public RestResponse<BrokerageBaseAmount> detail(@PathVariable Long id){
        BrokerageBaseAmount xBrokerageBaseAmount =brokerageBaseAmountService.detail(id);
        return RestResponse.data(xBrokerageBaseAmount);
     }

    /**
     * 自定义提成基数新增
     */
    @PostMapping("")
    public RestResponse<Boolean> save(@RequestBody BrokerageBaseAmount brokerageBaseAmount) {
        Boolean ret = brokerageBaseAmountService.add(brokerageBaseAmount);
        return RestResponse.data(ret);
    }

    /**
     * 自定义提成基数更新
     */
    @PutMapping("")
    public RestResponse<Boolean> update(@RequestBody BrokerageBaseAmount brokerageBaseAmount) {
        Boolean ret = brokerageBaseAmountService.update(brokerageBaseAmount);
        return RestResponse.data(ret);
    }

    /**
     * 自定义提成基数删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = brokerageBaseAmountService.delete(id);
        return RestResponse.data(ret);
    }


}

