package com.dayou.controller;

import com.dayou.vo.DeductionTechStatVO;
import com.dayou.vo.TechDeductionVO;
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.IItemBrokerageTechnicistDeductionService;
import com.dayou.entity.ItemBrokerageTechnicistDeduction;
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-06-06
 */
@RestController
@RequestMapping("itemBrokerageTechnicistDeduction")
@Slf4j
public class ItemBrokerageTechnicistDeductionController extends BaseController {
    @Autowired
    private IItemBrokerageTechnicistDeductionService itemBrokerageTechnicistDeductionService;

    /**
    * 技术人员提成抵扣记录列表
    */
    @GetMapping("")
    public RestResponse<Page<TechDeductionVO>> page(TechDeductionVO techDeductionVO, Page page){
        Page<TechDeductionVO> pages=itemBrokerageTechnicistDeductionService.selectPage(page,techDeductionVO);
        return RestResponse.data(pages);
    }

    /**
     * 技术人员提成抵扣记录详情
     */
    @GetMapping("/{id}")
    public RestResponse<ItemBrokerageTechnicistDeduction> detail(@PathVariable Long id){
        ItemBrokerageTechnicistDeduction xItemBrokerageTechnicistDeduction =itemBrokerageTechnicistDeductionService.detail(id);
        return RestResponse.data(xItemBrokerageTechnicistDeduction);
     }

    /**
     * 技术人员提成抵扣记录新增
     */
    @PostMapping("")
    public RestResponse<Boolean> save(@RequestBody ItemBrokerageTechnicistDeduction itemBrokerageTechnicistDeduction) {
        Boolean ret = itemBrokerageTechnicistDeductionService.add(itemBrokerageTechnicistDeduction);
        return RestResponse.data(ret);
    }

    /**
     * 技术人员提成抵扣记录更新
     */
    @PutMapping("")
    public RestResponse<Boolean> update(@RequestBody ItemBrokerageTechnicistDeduction itemBrokerageTechnicistDeduction) {
        Boolean ret = itemBrokerageTechnicistDeductionService.update(itemBrokerageTechnicistDeduction);
        return RestResponse.data(ret);
    }

    /**
     * 技术人员提成抵扣记录删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = itemBrokerageTechnicistDeductionService.delete(id);
        return RestResponse.data(ret);
    }


    /**
     * 统计技术人员提成奖金池剩余金额
     * @return
     */
    @GetMapping("/stat")
    public RestResponse<DeductionTechStatVO> stat(){
        DeductionTechStatVO vo = itemBrokerageTechnicistDeductionService.stat();
        return RestResponse.data(vo);
    }

}

