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

k.e.book.ddh.controller.CcOrderAttributeController 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.CcOrderAttributeAddDTO;
import k.e.book.ddh.entity.CcOrderAttributeDO;
import k.e.book.ddh.entity.CcOrderAttributeQueryDTO;
import k.e.book.ddh.entity.CcOrderAttributeVO;
import k.e.book.ddh.service.CcOrderAttributeService;
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 = "CcOrderAttribute相关文档")
@RestController
@RequestMapping("/ccOrderAttribute")
public class CcOrderAttributeController {
    @Resource
    private CcOrderAttributeService ccOrderAttributeService;

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

    @ApiOperation("根据 id 查询CcOrderAttribute信息")
    @GetMapping(value = "/get")
    public Result getCcOrderAttributeById(@RequestParam("id") @ApiParam(value = "ccOrderAttributeD") Long id) {
        return Result.success(CcOrderAttributeDO.toVO(ccOrderAttributeService.getById(id)));
    }

    @ApiOperation("新增CcOrderAttribute")
    @PostMapping("/add")
    public Result addCcOrderAttribute(@RequestBody @Valid CcOrderAttributeAddDTO dto) {
        CcOrderAttributeDO entity = CcOrderAttributeDO.toDO(dto);
        ccOrderAttributeService.save(entity);
        return getCcOrderAttributeById(entity.getId());
    }

    @ApiOperation("删除CcOrderAttribute")
    @DeleteMapping("/delete")
    public Result deleteCcOrderAttributeById(@RequestParam("id") @ApiParam(value = "ccOrderAttributeID") Long id) {
        ccOrderAttributeService.removeById(id);
        return Result.success();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy