k.e.book.ddh.controller.CcInviteLogController 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.CcInviteLogAddDTO;
import k.e.book.ddh.entity.CcInviteLogDO;
import k.e.book.ddh.entity.CcInviteLogQueryDTO;
import k.e.book.ddh.entity.CcInviteLogVO;
import k.e.book.ddh.service.CcInviteLogService;
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 = "CcInviteLog相关文档")
@RestController
@RequestMapping("/ccInviteLog")
public class CcInviteLogController {
@Resource
private CcInviteLogService ccInviteLogService;
@ApiOperation("分页查询CcInviteLog信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcInviteLogQueryDTO dto) {
IPage page = ccInviteLogService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcInviteLogDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcInviteLog信息")
@GetMapping(value = "/get")
public Result getCcInviteLogById(@RequestParam("id") @ApiParam(value = "ccInviteLogD") Long id) {
return Result.success(CcInviteLogDO.toVO(ccInviteLogService.getById(id)));
}
@ApiOperation("新增CcInviteLog")
@PostMapping("/add")
public Result addCcInviteLog(@RequestBody @Valid CcInviteLogAddDTO dto) {
CcInviteLogDO entity = CcInviteLogDO.toDO(dto);
ccInviteLogService.save(entity);
return getCcInviteLogById(entity.getId());
}
@ApiOperation("删除CcInviteLog")
@DeleteMapping("/delete")
public Result deleteCcInviteLogById(@RequestParam("id") @ApiParam(value = "ccInviteLogID") Long id) {
ccInviteLogService.removeById(id);
return Result.success();
}
}