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

/**
 * 档案移交Controller
 * 
 * @author sh
 * @date 2022-11-11
 */
@RestController
@RequestMapping("/save/handOver")
public class archiveHandOverController extends BaseController
{
    @Autowired
    private IarchiveHandOverService archiveHandOverService;
    /*@Autowired
    private IRsArchiveService rsArchiveService;*/

    /**
     * 查询档案移交列表
     */
    @PreAuthorize("@ss.hasPermi('save:handOver:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchivesMaster archiveHandOver)
    {
        startPage();
        List<ArchivesMaster> list = archiveHandOverService.selectarchiveHandOverList(archiveHandOver);
        return getDataTable(list);
    }

    /**
     * 导出档案移交列表
     */
    @PreAuthorize("@ss.hasPermi('save:handOver:export')")
    @Log(title = "档案移交", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ArchivesMaster archiveHandOver)
    {
        List<ArchivesMaster> list = archiveHandOverService.selectarchiveHandOverList(archiveHandOver);
        ExcelUtil<ArchivesMaster> util = new ExcelUtil<ArchivesMaster>(ArchivesMaster.class);
        return util.exportExcel(list, "handOver");
    }

    /**
     * 获取档案移交详细信息
     */
    @PreAuthorize("@ss.hasPermi('save:handOver:query')")
    @GetMapping(value = "/{archivesId}")
    public AjaxResult getInfo(@PathVariable("archivesId") String archivesId)
    {
        HashMap hashMap = new HashMap();
        ArchivesMaster archivesMaster = archiveHandOverService.selectarchiveHandOverById(archivesId);
        hashMap.put("form",archivesMaster);
        //hashMap.put("fileInfo",rsArchiveService.selectRsArchivesFileList(archivesMaster));
        return AjaxResult.success(hashMap);
    }

    /**
     * 新增档案移交
     */
    @PreAuthorize("@ss.hasPermi('save:handOver:add')")
    @Log(title = "档案移交", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchivesMaster archiveHandOver)
    {
        return toAjax(archiveHandOverService.insertarchiveHandOver(archiveHandOver));
    }

    /**
     * 修改档案移交
     */
    @PreAuthorize("@ss.hasPermi('save:handOver:edit')")
    @Log(title = "档案移交", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchivesMaster archiveHandOver)
    {
        return toAjax(archiveHandOverService.updatearchiveHandOver(archiveHandOver));
    }

    /**
     * 删除档案移交
     */
    @PreAuthorize("@ss.hasPermi('save:handOver:remove')")
    @Log(title = "档案移交", businessType = BusinessType.DELETE)
	@DeleteMapping("/{archivesIds}")
    public AjaxResult remove(@PathVariable String[] archivesIds)
    {
        return toAjax(archiveHandOverService.deletearchiveHandOverByIds(archivesIds));
    }
}
