package com.ruoyi.web.controller.back;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.syzy.domain.BWwwNews;
import com.ruoyi.syzy.service.IBWwwNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * bWwwNewsController
 * 
 * @author mingxue
 * @date 2022-07-17
 */
@RestController
@RequestMapping("/back/bWwwNews")
public class BackBWwwNewsController extends BaseController
{
    @Autowired
    private IBWwwNewsService bWwwNewsService;

    /**
     * 查询bWwwNews列表
     */
    @PreAuthorize("@ss.hasPermi('back:bWwwNews:list')")
    @GetMapping("/list")
    public TableDataInfo list(BWwwNews bWwwNews)
    {
        startPage();
        List<BWwwNews> list = bWwwNewsService.selectBWwwNewsList(bWwwNews);
        return getDataTable(list);
    }

    /**
     * 导出bWwwNews列表
     */
    @PreAuthorize("@ss.hasPermi('back:bWwwNews:export')")
    @Log(title = "资讯导出", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BWwwNews bWwwNews)
    {
        List<BWwwNews> list = bWwwNewsService.selectBWwwNewsList(bWwwNews);
        ExcelUtil<BWwwNews> util = new ExcelUtil<BWwwNews>(BWwwNews.class);
        return util.exportExcel(list, "bWwwNews数据");
    }

    /**
     * 获取bWwwNews详细信息
     */
    @PreAuthorize("@ss.hasPermi('back:bWwwNews:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bWwwNewsService.selectBWwwNewsById(id));
    }

    /**
     * 新增bWwwNews
     */
    @PreAuthorize("@ss.hasPermi('back:bWwwNews:add')")
    @Log(title = "资讯新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BWwwNews bWwwNews)
    {
        return toAjax(bWwwNewsService.insertBWwwNews(bWwwNews));
    }

    /**
     * 修改bWwwNews
     */
    @PreAuthorize("@ss.hasPermi('back:bWwwNews:edit')")
    @Log(title = "资讯修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BWwwNews bWwwNews)
    {
        return toAjax(bWwwNewsService.updateBWwwNews(bWwwNews));
    }

    /**
     * 删除bWwwNews
     */
    @PreAuthorize("@ss.hasPermi('back:bWwwNews:remove')")
    @Log(title = "资讯删除", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bWwwNewsService.deleteBWwwNewsByIds(ids));
    }
}
