102 lines
2.7 KiB
Java
102 lines
2.7 KiB
Java
![]() |
package com.ruoyi.web.bst;
|
||
|
|
||
|
import com.ruoyi.bst.ad.domain.Ad;
|
||
|
import com.ruoyi.bst.ad.domain.AdQuery;
|
||
|
import com.ruoyi.bst.ad.domain.AdVO;
|
||
|
import com.ruoyi.bst.ad.service.AdService;
|
||
|
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 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 2025-04-01
|
||
|
*/
|
||
|
@RestController
|
||
|
@RequestMapping("/bst/ad")
|
||
|
public class AdController extends BaseController
|
||
|
{
|
||
|
@Autowired
|
||
|
private AdService adService;
|
||
|
|
||
|
/**
|
||
|
* 查询广告列表
|
||
|
*/
|
||
|
@PreAuthorize("@ss.hasPermi('bst:ad:list')")
|
||
|
@GetMapping("/list")
|
||
|
public TableDataInfo list(AdQuery query)
|
||
|
{
|
||
|
startPage();
|
||
|
startOrderBy();
|
||
|
List<AdVO> list = adService.selectAdList(query);
|
||
|
return getDataTable(list);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 导出广告列表
|
||
|
*/
|
||
|
@PreAuthorize("@ss.hasPermi('bst:ad:export')")
|
||
|
@Log(title = "广告", businessType = BusinessType.EXPORT)
|
||
|
@PostMapping("/export")
|
||
|
public void export(HttpServletResponse response, AdQuery query)
|
||
|
{
|
||
|
List<AdVO> list = adService.selectAdList(query);
|
||
|
ExcelUtil<AdVO> util = new ExcelUtil<AdVO>(AdVO.class);
|
||
|
util.exportExcel(response, list, "广告数据");
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 获取广告详细信息
|
||
|
*/
|
||
|
@PreAuthorize("@ss.hasPermi('bst:ad:query')")
|
||
|
@GetMapping(value = "/{adId}")
|
||
|
public AjaxResult getInfo(@PathVariable("adId") Long adId)
|
||
|
{
|
||
|
return success(adService.selectAdByAdId(adId));
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 新增广告
|
||
|
*/
|
||
|
@PreAuthorize("@ss.hasPermi('bst:ad:add')")
|
||
|
@Log(title = "广告", businessType = BusinessType.INSERT)
|
||
|
@PostMapping
|
||
|
public AjaxResult add(@RequestBody Ad ad)
|
||
|
{
|
||
|
return toAjax(adService.insertAd(ad));
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 修改广告
|
||
|
*/
|
||
|
@PreAuthorize("@ss.hasPermi('bst:ad:edit')")
|
||
|
@Log(title = "广告", businessType = BusinessType.UPDATE)
|
||
|
@PutMapping
|
||
|
public AjaxResult edit(@RequestBody Ad ad)
|
||
|
{
|
||
|
return toAjax(adService.updateAd(ad));
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 删除广告
|
||
|
*/
|
||
|
@PreAuthorize("@ss.hasPermi('bst:ad:remove')")
|
||
|
@Log(title = "广告", businessType = BusinessType.DELETE)
|
||
|
@DeleteMapping("/{adIds}")
|
||
|
public AjaxResult remove(@PathVariable Long[] adIds)
|
||
|
{
|
||
|
return toAjax(adService.deleteAdByAdIds(adIds));
|
||
|
}
|
||
|
}
|