k.e.book.ddh.controller.CcDrawLogController 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.CcDrawLogAddDTO;
import k.e.book.ddh.entity.CcDrawLogDO;
import k.e.book.ddh.entity.CcDrawLogQueryDTO;
import k.e.book.ddh.entity.CcDrawLogVO;
import k.e.book.ddh.service.CcDrawLogService;
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 = "CcDrawLog相关文档")
@RestController
@RequestMapping("/ccDrawLog")
public class CcDrawLogController {
@Resource
private CcDrawLogService ccDrawLogService;
@ApiOperation("分页查询CcDrawLog信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcDrawLogQueryDTO dto) {
IPage page = ccDrawLogService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcDrawLogDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcDrawLog信息")
@GetMapping(value = "/get")
public Result getCcDrawLogById(@RequestParam("id") @ApiParam(value = "ccDrawLogD") Long id) {
return Result.success(CcDrawLogDO.toVO(ccDrawLogService.getById(id)));
}
@ApiOperation("新增CcDrawLog")
@PostMapping("/add")
public Result addCcDrawLog(@RequestBody @Valid CcDrawLogAddDTO dto) {
CcDrawLogDO entity = CcDrawLogDO.toDO(dto);
ccDrawLogService.save(entity);
return getCcDrawLogById(entity.getId());
}
@ApiOperation("删除CcDrawLog")
@DeleteMapping("/delete")
public Result deleteCcDrawLogById(@RequestParam("id") @ApiParam(value = "ccDrawLogID") Long id) {
ccDrawLogService.removeById(id);
return Result.success();
}
}