k.e.book.ddh.controller.CcQueueLogController 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.CcQueueLogAddDTO;
import k.e.book.ddh.entity.CcQueueLogDO;
import k.e.book.ddh.entity.CcQueueLogQueryDTO;
import k.e.book.ddh.entity.CcQueueLogVO;
import k.e.book.ddh.service.CcQueueLogService;
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 = "CcQueueLog相关文档")
@RestController
@RequestMapping("/ccQueueLog")
public class CcQueueLogController {
@Resource
private CcQueueLogService ccQueueLogService;
@ApiOperation("分页查询CcQueueLog信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcQueueLogQueryDTO dto) {
IPage page = ccQueueLogService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcQueueLogDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcQueueLog信息")
@GetMapping(value = "/get")
public Result getCcQueueLogById(@RequestParam("id") @ApiParam(value = "ccQueueLogD") Long id) {
return Result.success(CcQueueLogDO.toVO(ccQueueLogService.getById(id)));
}
@ApiOperation("新增CcQueueLog")
@PostMapping("/add")
public Result addCcQueueLog(@RequestBody @Valid CcQueueLogAddDTO dto) {
CcQueueLogDO entity = CcQueueLogDO.toDO(dto);
ccQueueLogService.save(entity);
return getCcQueueLogById(entity.getId());
}
@ApiOperation("删除CcQueueLog")
@DeleteMapping("/delete")
public Result deleteCcQueueLogById(@RequestParam("id") @ApiParam(value = "ccQueueLogID") Long id) {
ccQueueLogService.removeById(id);
return Result.success();
}
}