k.e.book.ddh.controller.CcOrderProfitSharingController 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.CcOrderProfitSharingAddDTO;
import k.e.book.ddh.entity.CcOrderProfitSharingDO;
import k.e.book.ddh.entity.CcOrderProfitSharingQueryDTO;
import k.e.book.ddh.entity.CcOrderProfitSharingVO;
import k.e.book.ddh.service.CcOrderProfitSharingService;
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 = "CcOrderProfitSharing相关文档")
@RestController
@RequestMapping("/ccOrderProfitSharing")
public class CcOrderProfitSharingController {
@Resource
private CcOrderProfitSharingService ccOrderProfitSharingService;
@ApiOperation("分页查询CcOrderProfitSharing信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcOrderProfitSharingQueryDTO dto) {
IPage page = ccOrderProfitSharingService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcOrderProfitSharingDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcOrderProfitSharing信息")
@GetMapping(value = "/get")
public Result getCcOrderProfitSharingById(@RequestParam("id") @ApiParam(value = "ccOrderProfitSharingD") Long id) {
return Result.success(CcOrderProfitSharingDO.toVO(ccOrderProfitSharingService.getById(id)));
}
@ApiOperation("新增CcOrderProfitSharing")
@PostMapping("/add")
public Result addCcOrderProfitSharing(@RequestBody @Valid CcOrderProfitSharingAddDTO dto) {
CcOrderProfitSharingDO entity = CcOrderProfitSharingDO.toDO(dto);
ccOrderProfitSharingService.save(entity);
return getCcOrderProfitSharingById(entity.getId());
}
@ApiOperation("删除CcOrderProfitSharing")
@DeleteMapping("/delete")
public Result deleteCcOrderProfitSharingById(@RequestParam("id") @ApiParam(value = "ccOrderProfitSharingID") Long id) {
ccOrderProfitSharingService.removeById(id);
return Result.success();
}
}