package com.dayou.controller;

import com.dayou.annotation.DataPermission;
import com.dayou.vo.BrokerageSequenceDetailVO;
import com.dayou.vo.BrokerageSequenceVO;
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.IItemBrokerageSequenceDetailService;
import com.dayou.entity.ItemBrokerageSequenceDetail;
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.io.IOException;
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;

import javax.servlet.http.HttpServletResponse;

/**
 * 提成流水明细表
 *
 * @author wucl
 * @since 2023-03-03
 */
@RestController
@RequestMapping("itemBrokerageSequenceDetail")
@Slf4j
public class ItemBrokerageSequenceDetailController extends BaseController {
    @Autowired
    private IItemBrokerageSequenceDetailService itemBrokerageSequenceDetailService;

    /**
    * 提成流水明细表列表
    */
    @DataPermission
    @GetMapping("")
    public RestResponse<Page<BrokerageSequenceDetailVO>> page(BrokerageSequenceDetailVO brokerageSequenceDetailVO, Page page){
        Page<BrokerageSequenceDetailVO> pages=itemBrokerageSequenceDetailService.selectPage(page,brokerageSequenceDetailVO);
        return RestResponse.data(pages);
    }

    /**
     * 提成流水明细导出
     */
    @DataPermission
    @GetMapping("/export")
    public void exportData(BrokerageSequenceDetailVO brokerageSequenceDetailVO, HttpServletResponse response) throws IOException {
        List<BrokerageSequenceDetailVO> list = itemBrokerageSequenceDetailService.xList(brokerageSequenceDetailVO);
        exportPlus(response,"提成结算明细",list,BrokerageSequenceDetailVO.class);
    }
    /**
     * 提成流水明细表详情
     */
    @GetMapping("/{id}")
    public RestResponse<ItemBrokerageSequenceDetail> detail(@PathVariable Long id){
        ItemBrokerageSequenceDetail xItemBrokerageSequenceDetail =itemBrokerageSequenceDetailService.detail(id);
        return RestResponse.data(xItemBrokerageSequenceDetail);
     }

    /**
     * 提成流水明细表新增
     */
    @PostMapping("")
    public RestResponse<Boolean> save(@RequestBody ItemBrokerageSequenceDetail itemBrokerageSequenceDetail) {
        Boolean ret = itemBrokerageSequenceDetailService.add(itemBrokerageSequenceDetail);
        return RestResponse.data(ret);
    }

    /**
     * 提成流水明细表更新
     */
    @PutMapping("")
    public RestResponse<Boolean> update(@RequestBody ItemBrokerageSequenceDetail itemBrokerageSequenceDetail) {
        Boolean ret = itemBrokerageSequenceDetailService.update(itemBrokerageSequenceDetail);
        return RestResponse.data(ret);
    }

    /**
     * 提成流水明细表删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = itemBrokerageSequenceDetailService.delete(id);
        return RestResponse.data(ret);
    }


}

