k.e.book.ddh.controller.CcItemOpLogController 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.CcItemOpLogAddDTO;
import k.e.book.ddh.entity.CcItemOpLogDO;
import k.e.book.ddh.entity.CcItemOpLogQueryDTO;
import k.e.book.ddh.entity.CcItemOpLogVO;
import k.e.book.ddh.service.CcItemOpLogService;
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 = "CcItemOpLog相关文档")
@RestController
@RequestMapping("/ccItemOpLog")
public class CcItemOpLogController {
@Resource
private CcItemOpLogService ccItemOpLogService;
@ApiOperation("分页查询CcItemOpLog信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcItemOpLogQueryDTO dto) {
IPage page = ccItemOpLogService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcItemOpLogDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcItemOpLog信息")
@GetMapping(value = "/get")
public Result getCcItemOpLogById(@RequestParam("id") @ApiParam(value = "ccItemOpLogD") Long id) {
return Result.success(CcItemOpLogDO.toVO(ccItemOpLogService.getById(id)));
}
@ApiOperation("新增CcItemOpLog")
@PostMapping("/add")
public Result addCcItemOpLog(@RequestBody @Valid CcItemOpLogAddDTO dto) {
CcItemOpLogDO entity = CcItemOpLogDO.toDO(dto);
ccItemOpLogService.save(entity);
return getCcItemOpLogById(entity.getId());
}
@ApiOperation("删除CcItemOpLog")
@DeleteMapping("/delete")
public Result deleteCcItemOpLogById(@RequestParam("id") @ApiParam(value = "ccItemOpLogID") Long id) {
ccItemOpLogService.removeById(id);
return Result.success();
}
}