package com.srs.web.controller.comprehensive;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.srs.common.annotation.Log;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.enums.BusinessType;
import com.srs.comprehensive.domain.CphFile;
import com.srs.comprehensive.service.ICphFileService;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.core.page.TableDataInfo;

/**
 * 综合素质系统文档Controller
 * 
 * @author srs
 * @date 2023-07-03
 */
@RestController
@RequestMapping("/cph/file")
public class CphFileController extends BaseController
{
    @Autowired
    private ICphFileService cphFileService;

    /**
     * 查询综合素质系统文档列表
     */
//    @PreAuthorize("@ss.hasPermi('comprehensive:file:list')")
    @GetMapping("/list")
    public TableDataInfo list(CphFile cphFile)
    {
        startPage();
        List<CphFile> list = cphFileService.selectCphFileList(cphFile);
        return getDataTable(list);
    }

    /**
     * 导出综合素质系统文档列表
     */
//    @PreAuthorize("@ss.hasPermi('comprehensive:file:export')")
    @Log(title = "综合素质系统文档", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CphFile cphFile)
    {
        List<CphFile> list = cphFileService.selectCphFileList(cphFile);
        ExcelUtil<CphFile> util = new ExcelUtil<CphFile>(CphFile.class);
        util.exportExcel(response, list, "综合素质系统文档数据");
    }

    /**
     * 获取综合素质系统文档详细信息
     */
//    @PreAuthorize("@ss.hasPermi('comprehensive:file:query')")
    @GetMapping(value = "/{fileName}")
    public AjaxResult getInfo(@PathVariable("fileName") String fileName)
    {
        return success(cphFileService.selectCphFileByFileName(fileName));
    }

    /**
     * 新增综合素质系统文档
     */
//    @PreAuthorize("@ss.hasPermi('comprehensive:file:add')")
    @Log(title = "综合素质系统文档", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CphFile cphFile)
    {
        return toAjax(cphFileService.insertCphFile(cphFile));
    }

    /**
     * 修改综合素质系统文档
     */
//    @PreAuthorize("@ss.hasPermi('comprehensive:file:edit')")
    @Log(title = "综合素质系统文档", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody CphFile cphFile)
    {
        return toAjax(cphFileService.updateCphFile(cphFile));
    }

    /**
     * 删除综合素质系统文档
     */
//    @PreAuthorize("@ss.hasPermi('comprehensive:file:remove')")
    @Log(title = "综合素质系统文档", businessType = BusinessType.DELETE)
	@PostMapping("/delete/{fileNames}")
    public AjaxResult remove(@PathVariable String[] fileNames)
    {
        return toAjax(cphFileService.deleteCphFileByFileNames(fileNames));
    }
}
