package com.ruoyi.web.project.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.yanzhu.jh.work.domain.WorkFile;
import com.yanzhu.jh.work.service.IWorkFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @version : V1.0
 * @ClassName: ProjectFilesController
 * @Description: 文件传达
 * @Auther: JiangYuQi
 * @Date: 2020/7/7 18:03
 */
@RestController
@RequestMapping("/wechat/projectFiles")
public class ProjectFilesController extends BaseController {

    @Autowired
    private IWorkFileService workFileService;

    /**
     * 查询文件传达列表
     * workFile
     */
    @GetMapping("/list")
    public TableDataInfo list(WorkFile workFile)
    {
        startPage();
        List<WorkFile> list = workFileService.selectWorkFileList(workFile);
        return getDataTable(list);
    }

    /**
     * 根据条件统计项目文件传达
     * @param workFile
     * @return
     */
    @GetMapping("/findCountByType")
    public AjaxResult findCountByType(WorkFile workFile){
        clearPage();
        return success(workFileService.findCountByType(workFile));
    }

    /**
     * 打开文件
     * @return
     */
    @GetMapping("/readFile/{id}")
    public AjaxResult workFileRead(@PathVariable("id") Long id){
        return success(workFileService.openWorkFile(id));
    }

}
