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

k.e.book.ddh.controller.CcIntegralGoodsController 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.CcIntegralGoodsAddDTO;
import k.e.book.ddh.entity.CcIntegralGoodsDO;
import k.e.book.ddh.entity.CcIntegralGoodsQueryDTO;
import k.e.book.ddh.entity.CcIntegralGoodsVO;
import k.e.book.ddh.service.CcIntegralGoodsService;
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 = "CcIntegralGoods相关文档")
@RestController
@RequestMapping("/ccIntegralGoods")
public class CcIntegralGoodsController {
    @Resource
    private CcIntegralGoodsService ccIntegralGoodsService;

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

    @ApiOperation("根据 id 查询CcIntegralGoods信息")
    @GetMapping(value = "/get")
    public Result getCcIntegralGoodsById(@RequestParam("id") @ApiParam(value = "ccIntegralGoodsD") Long id) {
        return Result.success(CcIntegralGoodsDO.toVO(ccIntegralGoodsService.getById(id)));
    }

    @ApiOperation("新增CcIntegralGoods")
    @PostMapping("/add")
    public Result addCcIntegralGoods(@RequestBody @Valid CcIntegralGoodsAddDTO dto) {
        CcIntegralGoodsDO entity = CcIntegralGoodsDO.toDO(dto);
        ccIntegralGoodsService.save(entity);
        return getCcIntegralGoodsById(entity.getId());
    }

    @ApiOperation("删除CcIntegralGoods")
    @DeleteMapping("/delete")
    public Result deleteCcIntegralGoodsById(@RequestParam("id") @ApiParam(value = "ccIntegralGoodsID") Long id) {
        ccIntegralGoodsService.removeById(id);
        return Result.success();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy