k.e.book.ddh.controller.CcSnapshotConfigController 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.CcSnapshotConfigAddDTO;
import k.e.book.ddh.entity.CcSnapshotConfigDO;
import k.e.book.ddh.entity.CcSnapshotConfigQueryDTO;
import k.e.book.ddh.entity.CcSnapshotConfigVO;
import k.e.book.ddh.service.CcSnapshotConfigService;
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 = "CcSnapshotConfig相关文档")
@RestController
@RequestMapping("/ccSnapshotConfig")
public class CcSnapshotConfigController {
@Resource
private CcSnapshotConfigService ccSnapshotConfigService;
@ApiOperation("分页查询CcSnapshotConfig信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcSnapshotConfigQueryDTO dto) {
IPage page = ccSnapshotConfigService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcSnapshotConfigDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcSnapshotConfig信息")
@GetMapping(value = "/get")
public Result getCcSnapshotConfigById(@RequestParam("id") @ApiParam(value = "ccSnapshotConfigD") Long id) {
return Result.success(CcSnapshotConfigDO.toVO(ccSnapshotConfigService.getById(id)));
}
@ApiOperation("新增CcSnapshotConfig")
@PostMapping("/add")
public Result addCcSnapshotConfig(@RequestBody @Valid CcSnapshotConfigAddDTO dto) {
CcSnapshotConfigDO entity = CcSnapshotConfigDO.toDO(dto);
ccSnapshotConfigService.save(entity);
return getCcSnapshotConfigById(entity.getId());
}
@ApiOperation("删除CcSnapshotConfig")
@DeleteMapping("/delete")
public Result deleteCcSnapshotConfigById(@RequestParam("id") @ApiParam(value = "ccSnapshotConfigID") Long id) {
ccSnapshotConfigService.removeById(id);
return Result.success();
}
}