k.e.book.ddh.controller.CcDrawConfigController 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.CcDrawConfigAddDTO;
import k.e.book.ddh.entity.CcDrawConfigDO;
import k.e.book.ddh.entity.CcDrawConfigQueryDTO;
import k.e.book.ddh.entity.CcDrawConfigVO;
import k.e.book.ddh.service.CcDrawConfigService;
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 = "CcDrawConfig相关文档")
@RestController
@RequestMapping("/ccDrawConfig")
public class CcDrawConfigController {
@Resource
private CcDrawConfigService ccDrawConfigService;
@ApiOperation("分页查询CcDrawConfig信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcDrawConfigQueryDTO dto) {
IPage page = ccDrawConfigService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcDrawConfigDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcDrawConfig信息")
@GetMapping(value = "/get")
public Result getCcDrawConfigById(@RequestParam("id") @ApiParam(value = "ccDrawConfigD") Long id) {
return Result.success(CcDrawConfigDO.toVO(ccDrawConfigService.getById(id)));
}
@ApiOperation("新增CcDrawConfig")
@PostMapping("/add")
public Result addCcDrawConfig(@RequestBody @Valid CcDrawConfigAddDTO dto) {
CcDrawConfigDO entity = CcDrawConfigDO.toDO(dto);
ccDrawConfigService.save(entity);
return getCcDrawConfigById(entity.getId());
}
@ApiOperation("删除CcDrawConfig")
@DeleteMapping("/delete")
public Result deleteCcDrawConfigById(@RequestParam("id") @ApiParam(value = "ccDrawConfigID") Long id) {
ccDrawConfigService.removeById(id);
return Result.success();
}
}