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.BackRecord;
import com.bonus.sgzb.material.domain.ProjUsingRecord;
import com.bonus.sgzb.material.service.BackRecordService;
import com.bonus.sgzb.material.service.ProjUsingRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
* @description 综合查询--工程机具使用查询
* @author hay
* @date   2024/2/26 14:15
*/
@Api(tags = "综合查询--工程机具使用查询")
@RestController
@RequestMapping("/projUsingRecord")
public class ProjUsingRecordController extends BaseController {
    @Autowired
    private ProjUsingRecordService projUsingRecordService;

    /**
     * 工程机具使用列表
     */
    @ApiOperation(value = "综合查询--工程机具使用列表")
    @GetMapping("/getProjUsingRecordList")
    @RequiresPermissions("stquery:projUsingRecord:list")
    public AjaxResult getProjUsingRecordList(ProjUsingRecord bean) {
        startPage();
        List<ProjUsingRecord> list = projUsingRecordService.getProjUsingRecordList(bean);
        return AjaxResult.success(getDataTable(list));
    }

    /**
     * 导出综合查询工程机具使用列表
     */
    @ApiOperation("导出综合查询工程机具使用列表")
    @Log(title = "导出综合查询工程机具使用列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjUsingRecord bean)
    {
        List<ProjUsingRecord> list = projUsingRecordService.getProjUsingRecordList(bean);
        ExcelUtil<ProjUsingRecord> util = new ExcelUtil<ProjUsingRecord>(ProjUsingRecord.class);
        util.exportExcel(response, list, "综合查询--工程机具使用");
    }

}
