| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.BasePage; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.system.model.TAdvertisement; |
| | | import com.ruoyi.system.service.TAdvertisementService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author xiaochen |
| | | * @since 2025-11-06 |
| | | */ |
| | | @Api(tags = "广告管理") |
| | | @RestController |
| | | @RequestMapping("/t-advertisement") |
| | | public class TAdvertisementController { |
| | | |
| | | private final TAdvertisementService advertisementService; |
| | | @Autowired |
| | | public TAdvertisementController(TAdvertisementService advertisementService) { |
| | | this.advertisementService = advertisementService; |
| | | } |
| | | |
| | | /** |
| | | * 获取广告管理管理列表 |
| | | */ |
| | | @ApiOperation(value = "获取广告管理分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<TAdvertisement>> pageList(@RequestBody BasePage query) { |
| | | return R.ok(advertisementService.pageList(query)); |
| | | } |
| | | |
| | | /** |
| | | * 获取广告管理管理列表 |
| | | */ |
| | | @ApiOperation(value = "获取广告管理列表") |
| | | @PostMapping(value = "/list") |
| | | public R<List<TAdvertisement>> list() { |
| | | return R.ok(advertisementService.list(Wrappers.lambdaQuery(TAdvertisement.class).orderByDesc(TAdvertisement::getCreateTime))); |
| | | } |
| | | |
| | | /** |
| | | * 添加广告管理管理 |
| | | */ |
| | | @Log(title = "广告管理信息-新增广告管理", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "添加广告管理") |
| | | @PostMapping(value = "/add") |
| | | public R<Boolean> add(@Validated @RequestBody TAdvertisement dto) { |
| | | if (advertisementService.isExit(dto)) { |
| | | return R.fail("广告名称已存在"); |
| | | } |
| | | return R.ok(advertisementService.save(dto)); |
| | | } |
| | | |
| | | /** |
| | | * 修改广告管理 |
| | | */ |
| | | @Log(title = "广告管理信息-修改广告管理", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "修改广告管理") |
| | | @PostMapping(value = "/update") |
| | | public R<Boolean> update(@Validated @RequestBody TAdvertisement dto) { |
| | | if (advertisementService.isExit(dto)) { |
| | | return R.fail("广告名称已存在"); |
| | | } |
| | | return R.ok(advertisementService.updateById(dto)); |
| | | } |
| | | |
| | | /** |
| | | * 查看广告管理详情 |
| | | */ |
| | | @ApiOperation(value = "查看广告管理详情") |
| | | @GetMapping(value = "/getDetailById") |
| | | public R<TAdvertisement> getDetailById(@RequestParam String id) { |
| | | return R.ok(advertisementService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 删除广告管理 |
| | | */ |
| | | @Log(title = "广告管理信息-删除广告管理", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "删除广告管理") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public R<Boolean> deleteById(@RequestParam String id) { |
| | | return R.ok(advertisementService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除广告管理 |
| | | */ |
| | | @Log(title = "广告管理信息-删除广告管理", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "批量删除广告管理") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public R<Boolean> deleteByIds(@RequestBody List<String> ids) { |
| | | return R.ok(advertisementService.removeByIds(ids)); |
| | | } |
| | | |
| | | } |
| | | |