k.e.book.ddh.controller.CcIntegralOrderController 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.CcIntegralOrderAddDTO;
import k.e.book.ddh.entity.CcIntegralOrderDO;
import k.e.book.ddh.entity.CcIntegralOrderQueryDTO;
import k.e.book.ddh.entity.CcIntegralOrderVO;
import k.e.book.ddh.service.CcIntegralOrderService;
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 = "CcIntegralOrder相关文档")
@RestController
@RequestMapping("/ccIntegralOrder")
public class CcIntegralOrderController {
@Resource
private CcIntegralOrderService ccIntegralOrderService;
@ApiOperation("分页查询CcIntegralOrder信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcIntegralOrderQueryDTO dto) {
IPage page = ccIntegralOrderService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcIntegralOrderDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcIntegralOrder信息")
@GetMapping(value = "/get")
public Result getCcIntegralOrderById(@RequestParam("id") @ApiParam(value = "ccIntegralOrderD") Long id) {
return Result.success(CcIntegralOrderDO.toVO(ccIntegralOrderService.getById(id)));
}
@ApiOperation("新增CcIntegralOrder")
@PostMapping("/add")
public Result addCcIntegralOrder(@RequestBody @Valid CcIntegralOrderAddDTO dto) {
CcIntegralOrderDO entity = CcIntegralOrderDO.toDO(dto);
ccIntegralOrderService.save(entity);
return getCcIntegralOrderById(entity.getId());
}
@ApiOperation("删除CcIntegralOrder")
@DeleteMapping("/delete")
public Result deleteCcIntegralOrderById(@RequestParam("id") @ApiParam(value = "ccIntegralOrderID") Long id) {
ccIntegralOrderService.removeById(id);
return Result.success();
}
}