package com.ruoyi.web.controller.system;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.system.domain.Banner;
|
import com.ruoyi.system.pojo.dto.AddBannerDTO;
|
import com.ruoyi.system.pojo.dto.EditBannerDTO;
|
import com.ruoyi.system.pojo.vo.BannerPageVO;
|
import com.ruoyi.system.service.BannerService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import javax.validation.Valid;
|
|
@Slf4j
|
@RestController
|
@RequestMapping("/system/banner")
|
@Api( tags = "后台-系统设置-banner管理")
|
public class BannerController {
|
|
@Resource
|
private BannerService bannerService;
|
|
/**
|
* banner分页
|
*/
|
@GetMapping("/getBannerPage")
|
@ApiOperation(value = "banner分页")
|
public R<IPage<BannerPageVO>> getBannerPage(
|
@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
|
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
|
@RequestParam(value = "name",required = false) String name) {
|
return R.ok(bannerService.getBannerPage(pageNum,pageSize,name));
|
}
|
/**
|
* banner添加
|
*/
|
@PostMapping("/add")
|
@ApiOperation(value = "banner添加")
|
public R<Void> add(@RequestBody AddBannerDTO dto) {
|
bannerService.add(dto);
|
return R.ok();
|
}
|
/**
|
* 根据类型查看
|
*/
|
@GetMapping("/getBannerByType/{id}")
|
@ApiOperation(value = "根据类型查看")
|
public R<Banner> getBannerByType(@PathVariable("jumpType")Integer jumpType) {
|
Banner banner = bannerService.getOne(new LambdaQueryWrapper<Banner>().eq(Banner::getJumpType, jumpType).eq(Banner::getDelFlag, 0));
|
return R.ok(banner);
|
}
|
/**
|
* 根据id查看
|
*/
|
@GetMapping("/getBannerById/{id}")
|
@ApiOperation(value = "根据id查看")
|
public R<Banner> getBannerById(@PathVariable("id")Integer id) {
|
Banner banner = bannerService.getById(id);
|
return R.ok(banner);
|
}
|
/**
|
* 编辑
|
*/
|
@PutMapping("/edit")
|
@ApiOperation(value = "banner编辑")
|
public R<Void> edit(@RequestBody @Valid EditBannerDTO dto) {
|
bannerService.edit(dto);
|
return R.ok();
|
}
|
/**
|
* 删除
|
*/
|
@DeleteMapping("/delete/{id}")
|
@ApiOperation(value = "banner删除")
|
public R<Void> delete(@PathVariable("id")Integer id) {
|
bannerService.delete(id);
|
return R.ok();
|
}
|
}
|