k.e.book.ddh.controller.CcAdszoneZoneController 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.CcAdszoneZoneAddDTO;
import k.e.book.ddh.entity.CcAdszoneZoneDO;
import k.e.book.ddh.entity.CcAdszoneZoneQueryDTO;
import k.e.book.ddh.entity.CcAdszoneZoneVO;
import k.e.book.ddh.service.CcAdszoneZoneService;
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 = "CcAdszoneZone相关文档")
@RestController
@RequestMapping("/ccAdszoneZone")
public class CcAdszoneZoneController {
@Resource
private CcAdszoneZoneService ccAdszoneZoneService;
@ApiOperation("分页查询CcAdszoneZone信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcAdszoneZoneQueryDTO dto) {
IPage page = ccAdszoneZoneService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcAdszoneZoneDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcAdszoneZone信息")
@GetMapping(value = "/get")
public Result getCcAdszoneZoneById(@RequestParam("id") @ApiParam(value = "ccAdszoneZoneD") Long id) {
return Result.success(CcAdszoneZoneDO.toVO(ccAdszoneZoneService.getById(id)));
}
@ApiOperation("新增CcAdszoneZone")
@PostMapping("/add")
public Result addCcAdszoneZone(@RequestBody @Valid CcAdszoneZoneAddDTO dto) {
CcAdszoneZoneDO entity = CcAdszoneZoneDO.toDO(dto);
ccAdszoneZoneService.save(entity);
return getCcAdszoneZoneById(entity.getId());
}
@ApiOperation("删除CcAdszoneZone")
@DeleteMapping("/delete")
public Result deleteCcAdszoneZoneById(@RequestParam("id") @ApiParam(value = "ccAdszoneZoneID") Long id) {
ccAdszoneZoneService.removeById(id);
return Result.success();
}
}