package com.goldenwater.web.controller.yjjt;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.goldenwater.common.annotation.Log;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import com.goldenwater.common.enums.BusinessType;
import com.goldenwater.yjjt.domain.YjjtFile;
import com.goldenwater.yjjt.service.IYjjtFileService;

/**
 * 引江济太文件Controller
 */
@RestController
@RequestMapping("/yjjt/file")
public class YjjtFileController extends BaseController
{
    @Autowired
    private IYjjtFileService yjjtFileService;

    /**
     * 查询文件列表
     */
    @PreAuthorize("@ss.hasPermi('yjjt:file:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjjtFile file)
    {
        startPage();
        List<YjjtFile> list = yjjtFileService.selectYjjtFileList(file);
        return getDataTable(list);
    }

    /**
     * 获取文件详细信息
     */
    @PreAuthorize("@ss.hasPermi('yjjt:file:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return success(yjjtFileService.selectYjjtFileById(id));
    }

    /**
     * 新增文件记录
     */
    @PreAuthorize("@ss.hasPermi('yjjt:file:add')")
    @Log(title = "引江济太文件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjjtFile file)
    {
        file.setUserName(getUsername());
        return toAjax(yjjtFileService.insertYjjtFile(file));
    }

    /**
     * 删除文件
     */
    @PreAuthorize("@ss.hasPermi('yjjt:file:remove')")
    @Log(title = "引江济太文件", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yjjtFileService.deleteYjjtFileByIds(ids));
    }
}
