package com.ruoyi.web.controller.business;

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.UseGuide;
import com.ruoyi.system.service.IUseGuideService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 使用指南Controller
 * 
 * @author ruoyi
 * @date 2022-07-14
 */
@RestController
@RequestMapping("/system/use")
public class UseGuideController extends BaseController
{
    @Autowired
    private IUseGuideService useGuideService;

    /**
     * 查询使用指南列表
     */
    @GetMapping("/list")
    public TableDataInfo list(UseGuide useGuide)
    {
        startPage();
        List<UseGuide> list = useGuideService.selectUseGuideList(useGuide);
        return getDataTable(list);
    }

    /**
     * 导出使用指南列表
     */
    @Log(title = "使用指南", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UseGuide useGuide)
    {
        List<UseGuide> list = useGuideService.selectUseGuideList(useGuide);
        ExcelUtil<UseGuide> util = new ExcelUtil<UseGuide>(UseGuide.class);
        util.exportExcel(response, list, "使用指南数据");
    }

    /**
     * 获取使用指南详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(useGuideService.selectUseGuideById(id));
    }

    /**
     * 新增使用指南
     */
    @Log(title = "使用指南", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UseGuide useGuide)
    {
        return toAjax(useGuideService.insertUseGuide(useGuide));
    }

    /**
     * 修改使用指南
     */
    @Log(title = "使用指南", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UseGuide useGuide)
    {
        return toAjax(useGuideService.updateUseGuide(useGuide));
    }

    /**
     * 删除使用指南
     */
    @Log(title = "使用指南", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(useGuideService.deleteUseGuideByIds(ids));
    }

    /**
     * 获取最新的使用指南详细信息
     */
    @GetMapping(value = "/new")
    public AjaxResult getInfoNew()
    {
        return useGuideService.getInfoNew();
    }

}
