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.TbBanner; import com.ruoyi.hezhi.service.ITbBannerService; 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 CC * @date 2024-03-12 */ @RestController @RequestMapping("/hezhi/banner") public class TbBannerController extends BaseController { @Autowired private ITbBannerService tbBannerService; /** * 查询轮播图列表 */ @PreAuthorize("@ss.hasPermi('hezhi:banner:list')") @GetMapping("/list") public TableDataInfo list(TbBanner tbBanner) { startPage(); List list = tbBannerService.selectTbBannerList(tbBanner); return getDataTable(list); } /** * 导出轮播图列表 */ @PreAuthorize("@ss.hasPermi('hezhi:banner:export')") @Log(title = "轮播图", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, TbBanner tbBanner) { List list = tbBannerService.selectTbBannerList(tbBanner); ExcelUtil util = new ExcelUtil(TbBanner.class); util.exportExcel(response, list, "轮播图数据"); } /** * 获取轮播图详细信息 */ @PreAuthorize("@ss.hasPermi('hezhi:banner:query')") @GetMapping(value = "/{bannerId}") public AjaxResult getInfo(@PathVariable("bannerId") String bannerId) { return success(tbBannerService.selectTbBannerByBannerId(bannerId)); } /** * 新增轮播图 */ @PreAuthorize("@ss.hasPermi('hezhi:banner:add')") @Log(title = "轮播图", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody TbBanner tbBanner) { return toAjax(tbBannerService.insertTbBanner(tbBanner)); } /** * 修改轮播图 */ @PreAuthorize("@ss.hasPermi('hezhi:banner:edit')") @Log(title = "轮播图", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody TbBanner tbBanner) { return toAjax(tbBannerService.updateTbBanner(tbBanner)); } /** * 删除轮播图 */ @PreAuthorize("@ss.hasPermi('hezhi:banner:remove')") @Log(title = "轮播图", businessType = BusinessType.DELETE) @DeleteMapping("/{bannerIds}") public AjaxResult remove(@PathVariable String[] bannerIds) { return toAjax(tbBannerService.deleteTbBannerByBannerIds(bannerIds)); } }