package com.ruoyi.web.controller.system.count;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TdFileProvide;
import com.ruoyi.system.domain.TdFileReceive;
import com.ruoyi.system.domain.TdPropertyNetinfo;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ITdFileProvideService;
import com.ruoyi.system.service.ITdFileReceiveService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 涉密文件统计
 */
@Controller
@RequestMapping("/system/filenum")
public class SysFilenumController extends BaseController {
    private String prefix = "system/fileprovide/filenum";

    @Autowired
    private ITdFileProvideService tdFileProvideService;
    @Autowired
    private ITdFileReceiveService tdFileReceiveService;

    @RequiresPermissions("system:filenum:view")
    @GetMapping()
    public String fileprovide()
    {
        return prefix + "/filenum";
    }

    /**
     * 查询文件下发列表
     */
    @RequiresPermissions("system:filenum:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TdFileProvide tdFileProvide)
    {
        startPage();
        List<TdFileProvide> list = tdFileProvideService.selectTdFileProvideList(tdFileProvide);
        return getDataTable(list);
    }

    /**
     * 打印界面，根据文件编号区分
     */
    @RequiresPermissions("system:filenum:print")
    @GetMapping("/print/{fileId}")
    @Log(title = "文件统计", businessType = BusinessType.PRINT)
    public String print(@PathVariable("fileId") String fileId, ModelMap mmap)
    {
        List<TdFileReceive> tdFileReceives = tdFileReceiveService.selectTdFileReceiveByFileId(fileId);
        TdFileProvide tdFileProvide = tdFileProvideService.selectTdFileProvideByFileId(fileId);
        mmap.put("tdFileReceives", tdFileReceives);
        mmap.put("tdFileProvide", tdFileProvide);
        mmap.put("sysuser", getSysUser());
        return prefix + "/print";
    }
}
