package com.jeethink.manage.controller;

import java.util.HashMap;
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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.manage.service.ISearchService;
import com.jeethink.common.utils.poi.ExcelUtil;
import com.jeethink.common.core.page.TableDataInfo;

/**
 * 档案检索Controller
 * 
 * @author sh
 * @date 2022-11-10
 */
@RestController
@RequestMapping("/manage/search")
public class SearchController extends BaseController
{
    @Autowired
    private ISearchService service;

    /**
     * 查询档案检索列表
     */
    @PreAuthorize("@ss.hasPermi('manage:search:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchivesMaster archives)
    {
        startPage();
        List<ArchivesMaster> list = service.selectSearchList(archives);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('manage:search:query')")
    @GetMapping("/{archivesId}")
    public AjaxResult getInfo(@PathVariable("archivesId") String archivesId) {

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

    //查询附件
    @GetMapping("/exportFile/{archivesId}")
    public AjaxResult getFileInfo(@PathVariable("archivesId") String archivesId) {

        return AjaxResult.success(service.selectArchivesFileById(archivesId));
    }
    /**
     * 导出档案检索列表
     */
    @PreAuthorize("@ss.hasPermi('manage:search:export')")
    @Log(title = "档案检索", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ArchivesMaster archives)
    {
        List<ArchivesMaster> list = service.selectSearchList(archives);
        ExcelUtil<ArchivesMaster> util = new ExcelUtil<ArchivesMaster>(ArchivesMaster.class);
        return util.exportExcel(list, "search");
    }
}
