package com.bonus.sgzb.material.controller;

import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import com.bonus.sgzb.common.security.annotation.RequiresPermissions;
import com.bonus.sgzb.material.domain.LeaseRecord;
import com.bonus.sgzb.material.service.LeaseRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
* @description 综合查询--领料记录查询
* @author hay
* @date   2024/2/26 14:15
*/
@Api(tags = "综合查询--领料记录查询")
@RestController
@RequestMapping("/leaseRecord")
public class LeaseRecordController extends BaseController {
    @Autowired
    private LeaseRecordService leaseRecordService;

    /**
     * 领料记录列表
     */
    @ApiOperation(value = "综合查询--领料记录列表")
    @GetMapping("/getLeaseRecordList")
    @RequiresPermissions("picking:list:query")
    public AjaxResult getLeaseRecordList(LeaseRecord bean) {
        startPage();
        List<LeaseRecord> list = leaseRecordService.getLeaseRecordList(bean);
        return AjaxResult.success(getDataTable(list));
    }

    /**
     * 导出综合查询领料记录列表
     */
    @ApiOperation("导出综合查询领料记录列表")
    @Log(title = "导出综合查询领料记录列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @RequiresPermissions("picking:list:export")
    public void export(HttpServletResponse response, LeaseRecord bean)
    {
        List<LeaseRecord> list = leaseRecordService.getLeaseRecordList(bean);
        ExcelUtil<LeaseRecord> util = new ExcelUtil<LeaseRecord>(LeaseRecord.class);
        util.exportExcel(response, list, "综合查询--领料记录");
    }

}
