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

k.e.book.ddh.controller.CcCreatorController 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.CcCreatorAddDTO;
import k.e.book.ddh.entity.CcCreatorDO;
import k.e.book.ddh.entity.CcCreatorQueryDTO;
import k.e.book.ddh.entity.CcCreatorVO;
import k.e.book.ddh.service.CcCreatorService;
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 = "CcCreator相关文档")
@RestController
@RequestMapping("/ccCreator")
public class CcCreatorController {
    @Resource
    private CcCreatorService ccCreatorService;

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

    @ApiOperation("根据 id 查询CcCreator信息")
    @GetMapping(value = "/get")
    public Result getCcCreatorById(@RequestParam("id") @ApiParam(value = "ccCreatorD") Long id) {
        return Result.success(CcCreatorDO.toVO(ccCreatorService.getById(id)));
    }

    @ApiOperation("新增CcCreator")
    @PostMapping("/add")
    public Result addCcCreator(@RequestBody @Valid CcCreatorAddDTO dto) {
        CcCreatorDO entity = CcCreatorDO.toDO(dto);
        ccCreatorService.save(entity);
        return getCcCreatorById(entity.getId());
    }

    @ApiOperation("删除CcCreator")
    @DeleteMapping("/delete")
    public Result deleteCcCreatorById(@RequestParam("id") @ApiParam(value = "ccCreatorID") Long id) {
        ccCreatorService.removeById(id);
        return Result.success();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy