package com.dayou.controller;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;
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 com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RestController;
import com.dayou.controller.BaseController;
import com.dayou.service.IBrokerageVariableService;
import com.dayou.entity.BrokerageVariable;
import com.dayou.common.RestResponse;
import org.springframework.web.bind.annotation.*;
import com.dayou.utils.ConvertUtil;
import com.dayou.utils.HttpKit;
import com.dayou.exception.ErrorCode;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.http.MediaType;
import org.springframework.web.multipart.MultipartFile;
/**
 * 浮动提成
 *
 * @author wucl
 * @since 2023-04-14
 */
@RestController
@RequestMapping("brokerageVariable")
@Slf4j
public class BrokerageVariableController extends BaseController {
    @Autowired
    private IBrokerageVariableService brokerageVariableService;

    /**
    * 浮动提成列表
    */
    @GetMapping("")
    public RestResponse<Page<BrokerageVariable>> page(BrokerageVariable brokerageVariable, Page page){
        Page<BrokerageVariable> pages=brokerageVariableService.selectPage(page,brokerageVariable);
        return RestResponse.data(pages);
    }

    /**
     * 浮动提成详情
     */
    @GetMapping("/{id}")
    public RestResponse<BrokerageVariable> detail(@PathVariable Long id){
        BrokerageVariable xBrokerageVariable =brokerageVariableService.detail(id);
        return RestResponse.data(xBrokerageVariable);
     }

    /**
     * 浮动提成新增
     */
    @PostMapping("")
    public RestResponse<Boolean> save(@RequestBody BrokerageVariable brokerageVariable) {
        Boolean ret = brokerageVariableService.add(brokerageVariable);
        return RestResponse.data(ret);
    }

    /**
     * 浮动提成更新
     */
    @PutMapping("")
    public RestResponse<Boolean> update(@RequestBody BrokerageVariable brokerageVariable) {
        Boolean ret = brokerageVariableService.update(brokerageVariable);
        return RestResponse.data(ret);
    }

    /**
     * 浮动提成删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = brokerageVariableService.delete(id);
        return RestResponse.data(ret);
    }


}

