package com.jeethink.save.controller;

import java.util.HashMap;
import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.jeethink.common.annotation.Log;
import com.jeethink.common.core.controller.BaseController;
import com.jeethink.common.core.domain.AjaxResult;
import com.jeethink.common.enums.BusinessType;
import com.jeethink.bean.domain.ArchivesMaster;
import com.jeethink.save.service.IPutoutService;
import com.jeethink.common.utils.poi.ExcelUtil;
import com.jeethink.common.core.page.TableDataInfo;

/**
 * 档案出库Controller
 * 
 * @author sh
 * @date 2022-11-11
 */
@RestController
@RequestMapping("/save/putout")
public class PutoutController extends BaseController
{
    @Autowired
    private IPutoutService service;

    /**
     * 查询档案出库列表
     */
    @PreAuthorize("@ss.hasPermi('save:archiveOut:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchivesMaster archives)
    {
        startPage();
        List<ArchivesMaster> list = service.selectPutoutList(archives);
        return getDataTable(list);
    }

    /**
     * 导出档案出库列表
     */
    @PreAuthorize("@ss.hasPermi('save:archiveOut:export')")
    @Log(title = "档案出库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public AjaxResult export(ArchivesMaster archives)
    {
        List<ArchivesMaster> list = service.selectPutoutList(archives);
        ExcelUtil<ArchivesMaster> util = new ExcelUtil<ArchivesMaster>(ArchivesMaster.class);
        return util.exportExcel(list, "archiveOut");
    }

    /**
     * 确认出库
     */
    @PreAuthorize("@ss.hasPermi('save:archiveOut:confirm')")
    @Log(title = "档案出库", businessType = BusinessType.OTHER)
    @GetMapping
    public AjaxResult confirm(@RequestParam String archivesId)
    {
        service.confirmPutout(archivesId);
        return AjaxResult.success();
    }
}