package com.ruoyi.hezhi.controller; 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.hezhi.domain.TbNews; import com.ruoyi.hezhi.service.ITbNewsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.List; /** * 新闻咨询Controller * * @author ruoyi * @date 2024-09-14 */ @RestController @RequestMapping("/hezhi/news") public class TbNewsController extends BaseController { @Autowired private ITbNewsService tbNewsService; /** * 查询新闻咨询列表 */ @PreAuthorize("@ss.hasPermi('hezhi:news:list')") @GetMapping("/list") public TableDataInfo list(TbNews tbNews) { startPage(); List list = tbNewsService.selectTbNewsList(tbNews); return getDataTable(list); } /** * 导出新闻咨询列表 */ @PreAuthorize("@ss.hasPermi('hezhi:news:export')") @Log(title = "新闻咨询", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, TbNews tbNews) { List list = tbNewsService.selectTbNewsList(tbNews); ExcelUtil util = new ExcelUtil(TbNews.class); util.exportExcel(response, list, "新闻咨询数据"); } /** * 获取新闻咨询详细信息 */ @PreAuthorize("@ss.hasPermi('hezhi:news:query')") @GetMapping(value = "/{newsId}") public AjaxResult getInfo(@PathVariable("newsId") Long newsId) { return success(tbNewsService.selectTbNewsByNewsId(newsId)); } /** * 新增新闻咨询 */ @PreAuthorize("@ss.hasPermi('hezhi:news:add')") @Log(title = "新闻咨询", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody TbNews tbNews) { return toAjax(tbNewsService.insertTbNews(tbNews)); } /** * 修改新闻咨询 */ @PreAuthorize("@ss.hasPermi('hezhi:news:edit')") @Log(title = "新闻咨询", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody TbNews tbNews) { return toAjax(tbNewsService.updateTbNews(tbNews)); } /** * 删除新闻咨询 */ @PreAuthorize("@ss.hasPermi('hezhi:news:remove')") @Log(title = "新闻咨询", businessType = BusinessType.DELETE) @DeleteMapping("/{newsIds}") public AjaxResult remove(@PathVariable Long[] newsIds) { return toAjax(tbNewsService.deleteTbNewsByNewsIds(newsIds)); } }