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

k.e.book.ddh.controller.CcBoxController 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.CcBoxAddDTO;
import k.e.book.ddh.entity.CcBoxDO;
import k.e.book.ddh.entity.CcBoxQueryDTO;
import k.e.book.ddh.entity.CcBoxVO;
import k.e.book.ddh.service.CcBoxService;
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 = "CcBox相关文档")
@RestController
@RequestMapping("/ccBox")
public class CcBoxController {
    @Resource
    private CcBoxService ccBoxService;

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

    @ApiOperation("根据 id 查询CcBox信息")
    @GetMapping(value = "/get")
    public Result getCcBoxById(@RequestParam("id") @ApiParam(value = "ccBoxD") Long id) {
        return Result.success(CcBoxDO.toVO(ccBoxService.getById(id)));
    }

    @ApiOperation("新增CcBox")
    @PostMapping("/add")
    public Result addCcBox(@RequestBody @Valid CcBoxAddDTO dto) {
        CcBoxDO entity = CcBoxDO.toDO(dto);
        ccBoxService.save(entity);
        return getCcBoxById(entity.getId());
    }

    @ApiOperation("删除CcBox")
    @DeleteMapping("/delete")
    public Result deleteCcBoxById(@RequestParam("id") @ApiParam(value = "ccBoxID") Long id) {
        ccBoxService.removeById(id);
        return Result.success();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy