package com.kxs.product.biz.controller.admin;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kxs.common.core.util.R;
import com.kxs.product.api.model.KxsMachineDeduct;
import com.kxs.product.api.vo.kxsapp.excel.MachineDeductExcelVo;
import com.kxs.product.biz.service.KxsMachineDeductService;
import com.pig4cloud.plugin.excel.annotation.RequestExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;
import java.util.List;

/**
 * 产品模块(SysMachineDeduct)控制层
 *
 * @author 系统
 * @since 2024-03-07 15:29:10
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("sysMachineDeduct")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SysMachineDeductController {

    /**
     * 服务对象
     */
    private final KxsMachineDeductService kxsMachineDeductService;



    /**
     * 机具管理-循环机已扣款-列表
     *
     * @param page 分页对象
     * @param param 查询实体
     * @return 机具管理-循环机已扣款-列表
     */
    @GetMapping("/list")
    public R list(Page<KxsMachineDeduct> page, KxsMachineDeduct param) {
        return R.ok(kxsMachineDeductService.page(page, new QueryWrapper<>(param)));
    }


    /**
     * 机具管理-循环机已扣款-导入
     *
     * @param machineDeductExcelVos 实体对象
     * @return 机具管理-循环机已扣款-导入
     */
    @PostMapping("/import")
//    @PreAuthorize("@pms.hasPermission('sys_machine_deduct_import')")
    public R importData(@RequestExcel List<MachineDeductExcelVo> machineDeductExcelVos, BindingResult bindingResult) {

        return kxsMachineDeductService.importData(machineDeductExcelVos, bindingResult);
    }

    /**
     * 机具管理-循环机已扣款-删除
     *
     * @param idsList 实体对象
     * @return 机具管理-循环机已扣款-删除
     */
    @PostMapping("/remove")
//    @PreAuthorize("@pms.hasPermission('sys_machine_deduct_del')")
    public R remove(@RequestBody List<Integer> idsList) {
        return R.ok(kxsMachineDeductService.removeBatchByIds(idsList));
    }





}

