k.e.book.ddh.controller.CcSnapshotOwnerController 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.CcSnapshotOwnerAddDTO;
import k.e.book.ddh.entity.CcSnapshotOwnerDO;
import k.e.book.ddh.entity.CcSnapshotOwnerQueryDTO;
import k.e.book.ddh.entity.CcSnapshotOwnerVO;
import k.e.book.ddh.service.CcSnapshotOwnerService;
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 = "CcSnapshotOwner相关文档")
@RestController
@RequestMapping("/ccSnapshotOwner")
public class CcSnapshotOwnerController {
@Resource
private CcSnapshotOwnerService ccSnapshotOwnerService;
@ApiOperation("分页查询CcSnapshotOwner信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcSnapshotOwnerQueryDTO dto) {
IPage page = ccSnapshotOwnerService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcSnapshotOwnerDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcSnapshotOwner信息")
@GetMapping(value = "/get")
public Result getCcSnapshotOwnerById(@RequestParam("id") @ApiParam(value = "ccSnapshotOwnerD") Long id) {
return Result.success(CcSnapshotOwnerDO.toVO(ccSnapshotOwnerService.getById(id)));
}
@ApiOperation("新增CcSnapshotOwner")
@PostMapping("/add")
public Result addCcSnapshotOwner(@RequestBody @Valid CcSnapshotOwnerAddDTO dto) {
CcSnapshotOwnerDO entity = CcSnapshotOwnerDO.toDO(dto);
ccSnapshotOwnerService.save(entity);
return getCcSnapshotOwnerById(entity.getId());
}
@ApiOperation("删除CcSnapshotOwner")
@DeleteMapping("/delete")
public Result deleteCcSnapshotOwnerById(@RequestParam("id") @ApiParam(value = "ccSnapshotOwnerID") Long id) {
ccSnapshotOwnerService.removeById(id);
return Result.success();
}
}