k.e.book.ddh.controller.CcUserInfoLogController 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.CcUserInfoLogAddDTO;
import k.e.book.ddh.entity.CcUserInfoLogDO;
import k.e.book.ddh.entity.CcUserInfoLogQueryDTO;
import k.e.book.ddh.entity.CcUserInfoLogVO;
import k.e.book.ddh.service.CcUserInfoLogService;
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 = "CcUserInfoLog相关文档")
@RestController
@RequestMapping("/ccUserInfoLog")
public class CcUserInfoLogController {
@Resource
private CcUserInfoLogService ccUserInfoLogService;
@ApiOperation("分页查询CcUserInfoLog信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcUserInfoLogQueryDTO dto) {
IPage page = ccUserInfoLogService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcUserInfoLogDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcUserInfoLog信息")
@GetMapping(value = "/get")
public Result getCcUserInfoLogById(@RequestParam("id") @ApiParam(value = "ccUserInfoLogD") Long id) {
return Result.success(CcUserInfoLogDO.toVO(ccUserInfoLogService.getById(id)));
}
@ApiOperation("新增CcUserInfoLog")
@PostMapping("/add")
public Result addCcUserInfoLog(@RequestBody @Valid CcUserInfoLogAddDTO dto) {
CcUserInfoLogDO entity = CcUserInfoLogDO.toDO(dto);
ccUserInfoLogService.save(entity);
return getCcUserInfoLogById(entity.getId());
}
@ApiOperation("删除CcUserInfoLog")
@DeleteMapping("/delete")
public Result deleteCcUserInfoLogById(@RequestParam("id") @ApiParam(value = "ccUserInfoLogID") Long id) {
ccUserInfoLogService.removeById(id);
return Result.success();
}
}