k.e.book.ddh.controller.CcUserBoxEggController 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.CcUserBoxEggAddDTO;
import k.e.book.ddh.entity.CcUserBoxEggDO;
import k.e.book.ddh.entity.CcUserBoxEggQueryDTO;
import k.e.book.ddh.entity.CcUserBoxEggVO;
import k.e.book.ddh.service.CcUserBoxEggService;
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 = "CcUserBoxEgg相关文档")
@RestController
@RequestMapping("/ccUserBoxEgg")
public class CcUserBoxEggController {
@Resource
private CcUserBoxEggService ccUserBoxEggService;
@ApiOperation("分页查询CcUserBoxEgg信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcUserBoxEggQueryDTO dto) {
IPage page = ccUserBoxEggService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcUserBoxEggDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcUserBoxEgg信息")
@GetMapping(value = "/get")
public Result getCcUserBoxEggById(@RequestParam("id") @ApiParam(value = "ccUserBoxEggD") Long id) {
return Result.success(CcUserBoxEggDO.toVO(ccUserBoxEggService.getById(id)));
}
@ApiOperation("新增CcUserBoxEgg")
@PostMapping("/add")
public Result addCcUserBoxEgg(@RequestBody @Valid CcUserBoxEggAddDTO dto) {
CcUserBoxEggDO entity = CcUserBoxEggDO.toDO(dto);
ccUserBoxEggService.save(entity);
return getCcUserBoxEggById(entity.getId());
}
@ApiOperation("删除CcUserBoxEgg")
@DeleteMapping("/delete")
public Result deleteCcUserBoxEggById(@RequestParam("id") @ApiParam(value = "ccUserBoxEggID") Long id) {
ccUserBoxEggService.removeById(id);
return Result.success();
}
}