All Downloads are FREE. Search and download functionalities are using the official Maven repository.

k.e.book.ddh.controller.CcVersionController 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.CcVersionAddDTO;
import k.e.book.ddh.entity.CcVersionDO;
import k.e.book.ddh.entity.CcVersionQueryDTO;
import k.e.book.ddh.entity.CcVersionVO;
import k.e.book.ddh.service.CcVersionService;
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 = "CcVersion相关文档")
@RestController
@RequestMapping("/ccVersion")
public class CcVersionController {
    @Resource
    private CcVersionService ccVersionService;

    @ApiOperation("分页查询CcVersion信息")
    @PostMapping(value = "/page")
    public Result> queryPage(@RequestBody @Valid  CcVersionQueryDTO dto) {
        IPage page = ccVersionService.selectProductPage(dto);
        List records = page.getRecords();
        return Result.success(records.stream().map(CcVersionDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
    }

    @ApiOperation("根据 id 查询CcVersion信息")
    @GetMapping(value = "/get")
    public Result getCcVersionById(@RequestParam("id") @ApiParam(value = "ccVersionD") Long id) {
        return Result.success(CcVersionDO.toVO(ccVersionService.getById(id)));
    }

    @ApiOperation("新增CcVersion")
    @PostMapping("/add")
    public Result addCcVersion(@RequestBody @Valid CcVersionAddDTO dto) {
        CcVersionDO entity = CcVersionDO.toDO(dto);
        ccVersionService.save(entity);
        return getCcVersionById(entity.getId());
    }

    @ApiOperation("删除CcVersion")
    @DeleteMapping("/delete")
    public Result deleteCcVersionById(@RequestParam("id") @ApiParam(value = "ccVersionID") Long id) {
        ccVersionService.removeById(id);
        return Result.success();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy