package com.jeethink.save.controller;

import java.util.List;

import com.jeethink.bean.domain.ArchivesMaster;
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.save.service.IPutinService;
import com.jeethink.common.utils.poi.ExcelUtil;
import com.jeethink.common.core.page.TableDataInfo;

/**
 * 档案入库Controller
 * 
 * @author sh
 * @date 2022-11-11
 */
@RestController
@RequestMapping("/save/putin")
public class PutinController extends BaseController
{
    @Autowired
    private IPutinService service;

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

    @PreAuthorize("@ss.hasPermi('save:archiveIn:query')")
    @GetMapping("/archives")
    public AjaxResult getInfo(@RequestParam String archivesId)
    {
        return AjaxResult.success(service.selectArchivesById(archivesId));
    }
    /**
     * 导出档案入库列表
     */
    @PreAuthorize("@ss.hasPermi('save:archiveIn:export')")
    @Log(title = "档案入库", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ArchivesMaster archives)
    {
        List<ArchivesMaster> list = service.selectPutinList(archives);
        ExcelUtil<ArchivesMaster> util = new ExcelUtil<ArchivesMaster>(ArchivesMaster.class);
        return util.exportExcel(list, "archiveIn");
    }

    @PreAuthorize("@ss.hasPermi('save:archiveIn:confirm')")
    @GetMapping
    public AjaxResult confirm(@RequestParam String archivesId) {

        service.confirmPutin(archivesId);
        return AjaxResult.success();
    }
}
