package com.ruoyi.web.controller.applicationCase;

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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysApplicationCase;
import com.ruoyi.system.service.ISysApplicationCaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

@RestController
@RequestMapping("/applicationCase")
public class SysApplicationCaseController extends BaseController
{
    @Autowired
    private ISysApplicationCaseService sysApplicationCaseService;

    @PreAuthorize("@ss.hasPermi('applicationCase:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysApplicationCase sysApplicationCase)
    {
        startPage();
        List<SysApplicationCase> list = sysApplicationCaseService.selectSysApplicationCaseList(sysApplicationCase);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('applicationCase:export')")
    @Log(title = "应用案例", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysApplicationCase sysApplicationCase)
    {
        List<SysApplicationCase> list = sysApplicationCaseService.selectSysApplicationCaseList(sysApplicationCase);
        ExcelUtil<SysApplicationCase> util = new ExcelUtil<SysApplicationCase>(SysApplicationCase.class);
        util.exportExcel(response, list, "应用案例数据");
    }

    @PreAuthorize("@ss.hasPermi('applicationCase:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysApplicationCaseService.selectSysApplicationCaseById(id));
    }

    @PreAuthorize("@ss.hasPermi('applicationCase:add')")
    @Log(title = "应用案例", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysApplicationCase sysApplicationCase)
    {
        return toAjax(sysApplicationCaseService.insertSysApplicationCase(sysApplicationCase));
    }

    @PreAuthorize("@ss.hasPermi('applicationCase:edit')")
    @Log(title = "应用案例", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysApplicationCase sysApplicationCase)
    {
        return toAjax(sysApplicationCaseService.updateSysApplicationCase(sysApplicationCase));
    }

    @PreAuthorize("@ss.hasPermi('applicationCase:remove')")
    @Log(title = "应用案例", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysApplicationCaseService.deleteSysApplicationCaseByIds(ids));
    }
}
