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

k.e.book.ddh.controller.CcUserController 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.CcUserAddDTO;
import k.e.book.ddh.entity.CcUserDO;
import k.e.book.ddh.entity.CcUserQueryDTO;
import k.e.book.ddh.entity.CcUserVO;
import k.e.book.ddh.service.CcUserService;
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 = "CcUser相关文档")
@RestController
@RequestMapping("/ccUser")
public class CcUserController {
    @Resource
    private CcUserService ccUserService;

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

    @ApiOperation("根据 id 查询CcUser信息")
    @GetMapping(value = "/get")
    public Result getCcUserById(@RequestParam("id") @ApiParam(value = "ccUserD") Long id) {
        return Result.success(CcUserDO.toVO(ccUserService.getById(id)));
    }

    @ApiOperation("新增CcUser")
    @PostMapping("/add")
    public Result addCcUser(@RequestBody @Valid CcUserAddDTO dto) {
        CcUserDO entity = CcUserDO.toDO(dto);
        ccUserService.save(entity);
        return getCcUserById(entity.getId());
    }

    @ApiOperation("删除CcUser")
    @DeleteMapping("/delete")
    public Result deleteCcUserById(@RequestParam("id") @ApiParam(value = "ccUserID") Long id) {
        ccUserService.removeById(id);
        return Result.success();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy