LogUsualController.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
  3. * <p>
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. * <p>
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. * <p>
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.springblade.modules.system.controller;
  17. import com.baomidou.mybatisplus.core.metadata.IPage;
  18. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  19. import lombok.AllArgsConstructor;
  20. import org.springblade.core.log.model.LogUsual;
  21. import org.springblade.core.log.model.LogUsualVo;
  22. import org.springblade.core.mp.support.Condition;
  23. import org.springblade.core.mp.support.Query;
  24. import org.springblade.core.tool.api.R;
  25. import org.springblade.core.tool.utils.BeanUtil;
  26. import org.springblade.core.tool.utils.Func;
  27. import org.springblade.modules.system.service.ILogUsualService;
  28. import org.springframework.web.bind.annotation.GetMapping;
  29. import org.springframework.web.bind.annotation.RequestMapping;
  30. import org.springframework.web.bind.annotation.RequestParam;
  31. import org.springframework.web.bind.annotation.RestController;
  32. import springfox.documentation.annotations.ApiIgnore;
  33. import java.util.List;
  34. import java.util.Map;
  35. import java.util.stream.Collectors;
  36. /**
  37. * 控制器
  38. *
  39. * @author Chill
  40. * @since 2018-10-12
  41. */
  42. @ApiIgnore
  43. @RestController
  44. @AllArgsConstructor
  45. @RequestMapping("/blade-log/usual")
  46. public class LogUsualController {
  47. private ILogUsualService logService;
  48. /**
  49. * 查询单条
  50. */
  51. @GetMapping("/detail")
  52. public R<LogUsual> detail(LogUsual log) {
  53. return R.data(logService.getOne(Condition.getQueryWrapper(log)));
  54. }
  55. /**
  56. * 查询多条(分页)
  57. */
  58. @GetMapping("/list")
  59. public R<IPage<LogUsualVo>> list(@ApiIgnore @RequestParam Map<String, Object> log, Query query) {
  60. IPage<LogUsual> pages = logService.page(Condition.getPage(query), Condition.getQueryWrapper(log, LogUsual.class));
  61. List<LogUsualVo> records = pages.getRecords().stream().map(logApi -> {
  62. LogUsualVo vo = BeanUtil.copy(logApi, LogUsualVo.class);
  63. vo.setStrId(Func.toStr(logApi.getId()));
  64. return vo;
  65. }).collect(Collectors.toList());
  66. IPage<LogUsualVo> pageVo = new Page<>(pages.getCurrent(), pages.getSize(), pages.getTotal());
  67. pageVo.setRecords(records);
  68. return R.data(pageVo);
  69. }
  70. }