k.e.book.ddh.controller.CcUserBoxDetailController 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.CcUserBoxDetailAddDTO;
import k.e.book.ddh.entity.CcUserBoxDetailDO;
import k.e.book.ddh.entity.CcUserBoxDetailQueryDTO;
import k.e.book.ddh.entity.CcUserBoxDetailVO;
import k.e.book.ddh.service.CcUserBoxDetailService;
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 = "CcUserBoxDetail相关文档")
@RestController
@RequestMapping("/ccUserBoxDetail")
public class CcUserBoxDetailController {
@Resource
private CcUserBoxDetailService ccUserBoxDetailService;
@ApiOperation("分页查询CcUserBoxDetail信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcUserBoxDetailQueryDTO dto) {
IPage page = ccUserBoxDetailService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcUserBoxDetailDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcUserBoxDetail信息")
@GetMapping(value = "/get")
public Result getCcUserBoxDetailById(@RequestParam("id") @ApiParam(value = "ccUserBoxDetailD") Long id) {
return Result.success(CcUserBoxDetailDO.toVO(ccUserBoxDetailService.getById(id)));
}
@ApiOperation("新增CcUserBoxDetail")
@PostMapping("/add")
public Result addCcUserBoxDetail(@RequestBody @Valid CcUserBoxDetailAddDTO dto) {
CcUserBoxDetailDO entity = CcUserBoxDetailDO.toDO(dto);
ccUserBoxDetailService.save(entity);
return getCcUserBoxDetailById(entity.getId());
}
@ApiOperation("删除CcUserBoxDetail")
@DeleteMapping("/delete")
public Result deleteCcUserBoxDetailById(@RequestParam("id") @ApiParam(value = "ccUserBoxDetailID") Long id) {
ccUserBoxDetailService.removeById(id);
return Result.success();
}
}