k.e.book.ddh.controller.CccConfigController 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.CccConfigAddDTO;
import k.e.book.ddh.entity.CccConfigDO;
import k.e.book.ddh.entity.CccConfigQueryDTO;
import k.e.book.ddh.entity.CccConfigVO;
import k.e.book.ddh.service.CccConfigService;
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 = "CccConfig相关文档")
@RestController
@RequestMapping("/cccConfig")
public class CccConfigController {
@Resource
private CccConfigService cccConfigService;
@ApiOperation("分页查询CccConfig信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CccConfigQueryDTO dto) {
IPage page = cccConfigService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CccConfigDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CccConfig信息")
@GetMapping(value = "/get")
public Result getCccConfigById(@RequestParam("id") @ApiParam(value = "cccConfigD") Long id) {
return Result.success(CccConfigDO.toVO(cccConfigService.getById(id)));
}
@ApiOperation("新增CccConfig")
@PostMapping("/add")
public Result addCccConfig(@RequestBody @Valid CccConfigAddDTO dto) {
CccConfigDO entity = CccConfigDO.toDO(dto);
cccConfigService.save(entity);
return getCccConfigById(entity.getId());
}
@ApiOperation("删除CccConfig")
@DeleteMapping("/delete")
public Result deleteCccConfigById(@RequestParam("id") @ApiParam(value = "cccConfigID") Long id) {
cccConfigService.removeById(id);
return Result.success();
}
}