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

k.e.book.ddh.controller.CcUserBoxController 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.CcUserBoxAddDTO;
import k.e.book.ddh.entity.CcUserBoxDO;
import k.e.book.ddh.entity.CcUserBoxQueryDTO;
import k.e.book.ddh.entity.CcUserBoxVO;
import k.e.book.ddh.service.CcUserBoxService;
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 = "CcUserBox相关文档")
@RestController
@RequestMapping("/ccUserBox")
public class CcUserBoxController {
    @Resource
    private CcUserBoxService ccUserBoxService;

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

    @ApiOperation("根据 id 查询CcUserBox信息")
    @GetMapping(value = "/get")
    public Result getCcUserBoxById(@RequestParam("id") @ApiParam(value = "ccUserBoxD") Long id) {
        return Result.success(CcUserBoxDO.toVO(ccUserBoxService.getById(id)));
    }

    @ApiOperation("新增CcUserBox")
    @PostMapping("/add")
    public Result addCcUserBox(@RequestBody @Valid CcUserBoxAddDTO dto) {
        CcUserBoxDO entity = CcUserBoxDO.toDO(dto);
        ccUserBoxService.save(entity);
        return getCcUserBoxById(entity.getId());
    }

    @ApiOperation("删除CcUserBox")
    @DeleteMapping("/delete")
    public Result deleteCcUserBoxById(@RequestParam("id") @ApiParam(value = "ccUserBoxID") Long id) {
        ccUserBoxService.removeById(id);
        return Result.success();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy