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

k.e.book.ddh.controller.CcInviteController 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.CcInviteAddDTO;
import k.e.book.ddh.entity.CcInviteDO;
import k.e.book.ddh.entity.CcInviteQueryDTO;
import k.e.book.ddh.entity.CcInviteVO;
import k.e.book.ddh.service.CcInviteService;
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 = "CcInvite相关文档")
@RestController
@RequestMapping("/ccInvite")
public class CcInviteController {
    @Resource
    private CcInviteService ccInviteService;

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

    @ApiOperation("根据 id 查询CcInvite信息")
    @GetMapping(value = "/get")
    public Result getCcInviteById(@RequestParam("id") @ApiParam(value = "ccInviteD") Long id) {
        return Result.success(CcInviteDO.toVO(ccInviteService.getById(id)));
    }

    @ApiOperation("新增CcInvite")
    @PostMapping("/add")
    public Result addCcInvite(@RequestBody @Valid CcInviteAddDTO dto) {
        CcInviteDO entity = CcInviteDO.toDO(dto);
        ccInviteService.save(entity);
        return getCcInviteById(entity.getId());
    }

    @ApiOperation("删除CcInvite")
    @DeleteMapping("/delete")
    public Result deleteCcInviteById(@RequestParam("id") @ApiParam(value = "ccInviteID") Long id) {
        ccInviteService.removeById(id);
        return Result.success();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy