k.e.book.ddh.controller.CcIntegralOrderGoodsController 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.CcIntegralOrderGoodsAddDTO;
import k.e.book.ddh.entity.CcIntegralOrderGoodsDO;
import k.e.book.ddh.entity.CcIntegralOrderGoodsQueryDTO;
import k.e.book.ddh.entity.CcIntegralOrderGoodsVO;
import k.e.book.ddh.service.CcIntegralOrderGoodsService;
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 = "CcIntegralOrderGoods相关文档")
@RestController
@RequestMapping("/ccIntegralOrderGoods")
public class CcIntegralOrderGoodsController {
@Resource
private CcIntegralOrderGoodsService ccIntegralOrderGoodsService;
@ApiOperation("分页查询CcIntegralOrderGoods信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcIntegralOrderGoodsQueryDTO dto) {
IPage page = ccIntegralOrderGoodsService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcIntegralOrderGoodsDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcIntegralOrderGoods信息")
@GetMapping(value = "/get")
public Result getCcIntegralOrderGoodsById(@RequestParam("id") @ApiParam(value = "ccIntegralOrderGoodsD") Long id) {
return Result.success(CcIntegralOrderGoodsDO.toVO(ccIntegralOrderGoodsService.getById(id)));
}
@ApiOperation("新增CcIntegralOrderGoods")
@PostMapping("/add")
public Result addCcIntegralOrderGoods(@RequestBody @Valid CcIntegralOrderGoodsAddDTO dto) {
CcIntegralOrderGoodsDO entity = CcIntegralOrderGoodsDO.toDO(dto);
ccIntegralOrderGoodsService.save(entity);
return getCcIntegralOrderGoodsById(entity.getId());
}
@ApiOperation("删除CcIntegralOrderGoods")
@DeleteMapping("/delete")
public Result deleteCcIntegralOrderGoodsById(@RequestParam("id") @ApiParam(value = "ccIntegralOrderGoodsID") Long id) {
ccIntegralOrderGoodsService.removeById(id);
return Result.success();
}
}