k.e.book.ddh.controller.CcRechargeOrderController 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.CcRechargeOrderAddDTO;
import k.e.book.ddh.entity.CcRechargeOrderDO;
import k.e.book.ddh.entity.CcRechargeOrderQueryDTO;
import k.e.book.ddh.entity.CcRechargeOrderVO;
import k.e.book.ddh.service.CcRechargeOrderService;
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 = "CcRechargeOrder相关文档")
@RestController
@RequestMapping("/ccRechargeOrder")
public class CcRechargeOrderController {
@Resource
private CcRechargeOrderService ccRechargeOrderService;
@ApiOperation("分页查询CcRechargeOrder信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcRechargeOrderQueryDTO dto) {
IPage page = ccRechargeOrderService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcRechargeOrderDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcRechargeOrder信息")
@GetMapping(value = "/get")
public Result getCcRechargeOrderById(@RequestParam("id") @ApiParam(value = "ccRechargeOrderD") Long id) {
return Result.success(CcRechargeOrderDO.toVO(ccRechargeOrderService.getById(id)));
}
@ApiOperation("新增CcRechargeOrder")
@PostMapping("/add")
public Result addCcRechargeOrder(@RequestBody @Valid CcRechargeOrderAddDTO dto) {
CcRechargeOrderDO entity = CcRechargeOrderDO.toDO(dto);
ccRechargeOrderService.save(entity);
return getCcRechargeOrderById(entity.getId());
}
@ApiOperation("删除CcRechargeOrder")
@DeleteMapping("/delete")
public Result deleteCcRechargeOrderById(@RequestParam("id") @ApiParam(value = "ccRechargeOrderID") Long id) {
ccRechargeOrderService.removeById(id);
return Result.success();
}
}