k.e.book.ddh.controller.CcAdszoneAdsController Maven / Gradle / Ivy
package k.e.book.ddh.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import k.e.book.common.model.Result;
import k.e.book.ddh.entity.CcAdszoneAdsAddDTO;
import k.e.book.ddh.entity.CcAdszoneAdsDO;
import k.e.book.ddh.entity.CcAdszoneAdsQueryDTO;
import k.e.book.ddh.entity.CcAdszoneAdsVO;
import k.e.book.ddh.service.CcAdszoneAdsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author kk
* @date 2023-05-21 11:13
*/
@Api(tags = "CcAdszoneAds相关文档")
@RestController
@RequestMapping("/ccAdszoneAds")
public class CcAdszoneAdsController {
@Resource
private CcAdszoneAdsService ccAdszoneAdsService;
@ApiOperation("分页查询CcAdszoneAds信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcAdszoneAdsQueryDTO dto) {
IPage page = ccAdszoneAdsService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcAdszoneAdsDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcAdszoneAds信息")
@GetMapping(value = "/get")
public Result getCcAdszoneAdsById(@RequestParam("id") @ApiParam(value = "ccAdszoneAdsD") Long id) {
return Result.success(CcAdszoneAdsDO.toVO(ccAdszoneAdsService.getById(id)));
}
@ApiOperation("新增CcAdszoneAds")
@PostMapping("/add")
public Result addCcAdszoneAds(@RequestBody @Valid CcAdszoneAdsAddDTO dto) {
CcAdszoneAdsDO entity = CcAdszoneAdsDO.toDO(dto);
ccAdszoneAdsService.save(entity);
return getCcAdszoneAdsById(entity.getId());
}
@ApiOperation("删除CcAdszoneAds")
@DeleteMapping("/delete")
public Result deleteCcAdszoneAdsById(@RequestParam("id") @ApiParam(value = "ccAdszoneAdsID") Long id) {
ccAdszoneAdsService.removeById(id);
return Result.success();
}
}