LogApiController.java 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the dreamlu.net developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: Chill 庄骞 (smallchill@163.com)
  16. */
  17. package org.springblade.modules.system.controller;
  18. import com.baomidou.mybatisplus.core.metadata.IPage;
  19. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  20. import lombok.AllArgsConstructor;
  21. import org.springblade.core.log.model.LogApi;
  22. import org.springblade.core.log.model.LogApiVo;
  23. import org.springblade.core.mp.support.Condition;
  24. import org.springblade.core.mp.support.Query;
  25. import org.springblade.core.tool.api.R;
  26. import org.springblade.core.tool.utils.BeanUtil;
  27. import org.springblade.core.tool.utils.Func;
  28. import org.springblade.modules.system.service.ILogApiService;
  29. import org.springframework.web.bind.annotation.GetMapping;
  30. import org.springframework.web.bind.annotation.RequestMapping;
  31. import org.springframework.web.bind.annotation.RequestParam;
  32. import org.springframework.web.bind.annotation.RestController;
  33. import springfox.documentation.annotations.ApiIgnore;
  34. import java.util.List;
  35. import java.util.Map;
  36. import java.util.stream.Collectors;
  37. /**
  38. * 控制器
  39. *
  40. * @author Chill
  41. * @since 2018-09-26
  42. */
  43. @ApiIgnore
  44. @RestController
  45. @AllArgsConstructor
  46. @RequestMapping("/blade-log/api")
  47. public class LogApiController {
  48. private ILogApiService logService;
  49. /**
  50. * 查询单条
  51. */
  52. @GetMapping("/detail")
  53. public R<LogApi> detail(LogApi log) {
  54. return R.data(logService.getOne(Condition.getQueryWrapper(log)));
  55. }
  56. /**
  57. * 查询多条(分页)
  58. */
  59. @GetMapping("/list")
  60. public R<IPage<LogApiVo>> list(@ApiIgnore @RequestParam Map<String, Object> log, Query query) {
  61. IPage<LogApi> pages = logService.page(Condition.getPage(query.setDescs("create_time")), Condition.getQueryWrapper(log, LogApi.class));
  62. List<LogApiVo> records = pages.getRecords().stream().map(logApi -> {
  63. LogApiVo vo = BeanUtil.copy(logApi, LogApiVo.class);
  64. vo.setStrId(Func.toStr(logApi.getId()));
  65. return vo;
  66. }).collect(Collectors.toList());
  67. IPage<LogApiVo> pageVo = new Page<>(pages.getCurrent(), pages.getSize(), pages.getTotal());
  68. pageVo.setRecords(records);
  69. return R.data(pageVo);
  70. }
  71. }