k.e.book.ddh.controller.CcIntegralLuckController 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.CcIntegralLuckAddDTO;
import k.e.book.ddh.entity.CcIntegralLuckDO;
import k.e.book.ddh.entity.CcIntegralLuckQueryDTO;
import k.e.book.ddh.entity.CcIntegralLuckVO;
import k.e.book.ddh.service.CcIntegralLuckService;
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 = "CcIntegralLuck相关文档")
@RestController
@RequestMapping("/ccIntegralLuck")
public class CcIntegralLuckController {
@Resource
private CcIntegralLuckService ccIntegralLuckService;
@ApiOperation("分页查询CcIntegralLuck信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcIntegralLuckQueryDTO dto) {
IPage page = ccIntegralLuckService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcIntegralLuckDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcIntegralLuck信息")
@GetMapping(value = "/get")
public Result getCcIntegralLuckById(@RequestParam("id") @ApiParam(value = "ccIntegralLuckD") Long id) {
return Result.success(CcIntegralLuckDO.toVO(ccIntegralLuckService.getById(id)));
}
@ApiOperation("新增CcIntegralLuck")
@PostMapping("/add")
public Result addCcIntegralLuck(@RequestBody @Valid CcIntegralLuckAddDTO dto) {
CcIntegralLuckDO entity = CcIntegralLuckDO.toDO(dto);
ccIntegralLuckService.save(entity);
return getCcIntegralLuckById(entity.getId());
}
@ApiOperation("删除CcIntegralLuck")
@DeleteMapping("/delete")
public Result deleteCcIntegralLuckById(@RequestParam("id") @ApiParam(value = "ccIntegralLuckID") Long id) {
ccIntegralLuckService.removeById(id);
return Result.success();
}
}