k.e.book.ddh.controller.CcAdminLogController 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.CcAdminLogAddDTO;
import k.e.book.ddh.entity.CcAdminLogDO;
import k.e.book.ddh.entity.CcAdminLogQueryDTO;
import k.e.book.ddh.entity.CcAdminLogVO;
import k.e.book.ddh.service.CcAdminLogService;
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 = "CcAdminLog相关文档")
@RestController
@RequestMapping("/ccAdminLog")
public class CcAdminLogController {
@Resource
private CcAdminLogService ccAdminLogService;
@ApiOperation("分页查询CcAdminLog信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcAdminLogQueryDTO dto) {
IPage page = ccAdminLogService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcAdminLogDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcAdminLog信息")
@GetMapping(value = "/get")
public Result getCcAdminLogById(@RequestParam("id") @ApiParam(value = "ccAdminLogD") Long id) {
return Result.success(CcAdminLogDO.toVO(ccAdminLogService.getById(id)));
}
@ApiOperation("新增CcAdminLog")
@PostMapping("/add")
public Result addCcAdminLog(@RequestBody @Valid CcAdminLogAddDTO dto) {
CcAdminLogDO entity = CcAdminLogDO.toDO(dto);
ccAdminLogService.save(entity);
return getCcAdminLogById(entity.getId());
}
@ApiOperation("删除CcAdminLog")
@DeleteMapping("/delete")
public Result deleteCcAdminLogById(@RequestParam("id") @ApiParam(value = "ccAdminLogID") Long id) {
ccAdminLogService.removeById(id);
return Result.success();
}
}