package com.ruoyi.web.controller.sdgsat1;

import com.ruoyi.common.annotation.Anonymous;
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.SysSdgsat1Case;
import com.ruoyi.system.service.ISysSdgsat1CaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * SDGSAT-1 应用案例管理
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/sdgsat1/case")
public class Sdgsat1CaseController extends BaseController
{
    @Autowired
    private ISysSdgsat1CaseService sysSdgsat1CaseService;

    /**
     * 查询应用案例列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(SysSdgsat1Case sysSdgsat1Case)
    {
        startPage();
        List<SysSdgsat1Case> list = sysSdgsat1CaseService.selectSysSdgsat1CaseList(sysSdgsat1Case);
        return getDataTable(list);
    }

    /**
     * 导出应用案例列表
     */
    @PreAuthorize("@ss.hasPermi('sdgsat1:case:export')")
    @Log(title = "应用案例", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysSdgsat1Case sysSdgsat1Case)
    {
        List<SysSdgsat1Case> list = sysSdgsat1CaseService.selectSysSdgsat1CaseList(sysSdgsat1Case);
        ExcelUtil<SysSdgsat1Case> util = new ExcelUtil<SysSdgsat1Case>(SysSdgsat1Case.class);
        util.exportExcel(response, list, "应用案例数据");
    }

    /**
     * 获取应用案例详细信息
     */
    @Anonymous
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysSdgsat1CaseService.selectSysSdgsat1CaseById(id));
    }

    /**
     * 新增应用案例
     */
    @PreAuthorize("@ss.hasPermi('sdgsat1:case:add')")
    @Log(title = "应用案例", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSdgsat1Case sysSdgsat1Case)
    {
        return toAjax(sysSdgsat1CaseService.insertSysSdgsat1Case(sysSdgsat1Case));
    }

    /**
     * 修改应用案例
     */
    @PreAuthorize("@ss.hasPermi('sdgsat1:case:edit')")
    @Log(title = "应用案例", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSdgsat1Case sysSdgsat1Case)
    {
        return toAjax(sysSdgsat1CaseService.updateSysSdgsat1Case(sysSdgsat1Case));
    }

    /**
     * 删除应用案例
     */
    @PreAuthorize("@ss.hasPermi('sdgsat1:case:remove')")
    @Log(title = "应用案例", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysSdgsat1CaseService.deleteSysSdgsat1CaseByIds(ids));
    }
}
