All Downloads are FREE. Search and download functionalities are using the official Maven repository.

k.e.book.ddh.controller.CcIntegralCouponController 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.CcIntegralCouponAddDTO;
import k.e.book.ddh.entity.CcIntegralCouponDO;
import k.e.book.ddh.entity.CcIntegralCouponQueryDTO;
import k.e.book.ddh.entity.CcIntegralCouponVO;
import k.e.book.ddh.service.CcIntegralCouponService;
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 = "CcIntegralCoupon相关文档")
@RestController
@RequestMapping("/ccIntegralCoupon")
public class CcIntegralCouponController {
    @Resource
    private CcIntegralCouponService ccIntegralCouponService;

    @ApiOperation("分页查询CcIntegralCoupon信息")
    @PostMapping(value = "/page")
    public Result> queryPage(@RequestBody @Valid  CcIntegralCouponQueryDTO dto) {
        IPage page = ccIntegralCouponService.selectProductPage(dto);
        List records = page.getRecords();
        return Result.success(records.stream().map(CcIntegralCouponDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
    }

    @ApiOperation("根据 id 查询CcIntegralCoupon信息")
    @GetMapping(value = "/get")
    public Result getCcIntegralCouponById(@RequestParam("id") @ApiParam(value = "ccIntegralCouponD") Long id) {
        return Result.success(CcIntegralCouponDO.toVO(ccIntegralCouponService.getById(id)));
    }

    @ApiOperation("新增CcIntegralCoupon")
    @PostMapping("/add")
    public Result addCcIntegralCoupon(@RequestBody @Valid CcIntegralCouponAddDTO dto) {
        CcIntegralCouponDO entity = CcIntegralCouponDO.toDO(dto);
        ccIntegralCouponService.save(entity);
        return getCcIntegralCouponById(entity.getId());
    }

    @ApiOperation("删除CcIntegralCoupon")
    @DeleteMapping("/delete")
    public Result deleteCcIntegralCouponById(@RequestParam("id") @ApiParam(value = "ccIntegralCouponID") Long id) {
        ccIntegralCouponService.removeById(id);
        return Result.success();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy