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

k.e.book.ddh.controller.CcItemMarketController 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.CcItemMarketAddDTO;
import k.e.book.ddh.entity.CcItemMarketDO;
import k.e.book.ddh.entity.CcItemMarketQueryDTO;
import k.e.book.ddh.entity.CcItemMarketVO;
import k.e.book.ddh.service.CcItemMarketService;
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 = "CcItemMarket相关文档")
@RestController
@RequestMapping("/ccItemMarket")
public class CcItemMarketController {
    @Resource
    private CcItemMarketService ccItemMarketService;

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

    @ApiOperation("根据 id 查询CcItemMarket信息")
    @GetMapping(value = "/get")
    public Result getCcItemMarketById(@RequestParam("id") @ApiParam(value = "ccItemMarketD") Long id) {
        return Result.success(CcItemMarketDO.toVO(ccItemMarketService.getById(id)));
    }

    @ApiOperation("新增CcItemMarket")
    @PostMapping("/add")
    public Result addCcItemMarket(@RequestBody @Valid CcItemMarketAddDTO dto) {
        CcItemMarketDO entity = CcItemMarketDO.toDO(dto);
        ccItemMarketService.save(entity);
        return getCcItemMarketById(entity.getId());
    }

    @ApiOperation("删除CcItemMarket")
    @DeleteMapping("/delete")
    public Result deleteCcItemMarketById(@RequestParam("id") @ApiParam(value = "ccItemMarketID") Long id) {
        ccItemMarketService.removeById(id);
        return Result.success();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy