TunnelInfoController.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package com.jiayue.biz.controller;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import cn.hutool.core.util.StrUtil;
  4. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  5. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  6. import com.jiayue.biz.domain.*;
  7. import com.jiayue.biz.service.TunnelInfoService;
  8. import com.jiayue.common.annotation.Log;
  9. import com.jiayue.common.core.controller.BaseController;
  10. import com.jiayue.common.core.domain.AjaxResult;
  11. import com.jiayue.common.core.page.TableDataInfo;
  12. import com.jiayue.common.enums.BusinessType;
  13. import lombok.RequiredArgsConstructor;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.security.access.prepost.PreAuthorize;
  16. import org.springframework.web.bind.annotation.*;
  17. import java.util.*;
  18. /**
  19. * 通道信息Controller
  20. *
  21. * @author L.ym
  22. * @date 2022-05-11
  23. */
  24. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  25. @RestController
  26. @RequestMapping("/dataQuery/tunnelInfo")
  27. public class TunnelInfoController extends BaseController {
  28. private final TunnelInfoService tunnelInfoService;
  29. /**
  30. * 查询通道信息列表
  31. */
  32. @PreAuthorize("@ss.hasPermi('dataQuery:windTowerStatusInfo:list')")
  33. @GetMapping("/list")
  34. public TableDataInfo list(TunnelInfo tunnelInfo) {
  35. startPage();
  36. LambdaQueryWrapper<TunnelInfo> queryWrapper = this.buildQueryParams(tunnelInfo);
  37. List<TunnelInfo> list = tunnelInfoService.list(queryWrapper);
  38. return getDataTable(list);
  39. }
  40. /**
  41. * 查询通道信息列表
  42. */
  43. @PreAuthorize("@ss.hasPermi('dataQuery:windTowerStatusInfo:list')")
  44. @GetMapping("/listAll")
  45. public TableDataInfo listAll() {
  46. List<TunnelInfo> list = tunnelInfoService.lambdaQuery().orderByAsc(TunnelInfo::getId).list();
  47. return getDataTable(list);
  48. }
  49. /**
  50. * 新增通道信息
  51. */
  52. @PreAuthorize("@ss.hasPermi('dataQuery:windTowerStatusInfo:add')")
  53. @Log(title = "通道信息", businessType = BusinessType.INSERT)
  54. @PostMapping
  55. public AjaxResult add(@RequestBody TunnelInfo tunnelInfo) {
  56. return toAjax(tunnelInfoService.save(tunnelInfo));
  57. }
  58. /**
  59. * 修改通道信息
  60. */
  61. @PreAuthorize("@ss.hasPermi('dataQuery:windTowerStatusInfo:edit')")
  62. @Log(title = "通道信息", businessType = BusinessType.UPDATE)
  63. @PutMapping
  64. public AjaxResult edit(@RequestBody TunnelInfo tunnelInfo) {
  65. return toAjax(tunnelInfoService.updateById(tunnelInfo) ? 1 : 0);
  66. }
  67. /**
  68. * 删除通道信息
  69. */
  70. @PreAuthorize("@ss.hasPermi('dataQuery:windTowerStatusInfo:remove')")
  71. @Log(title = "通道信息", businessType = BusinessType.DELETE)
  72. @DeleteMapping("/{ids}")
  73. public AjaxResult remove(@PathVariable String[] ids) {
  74. return toAjax(tunnelInfoService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
  75. }
  76. /**
  77. * 构建查询条件
  78. **/
  79. private LambdaQueryWrapper<TunnelInfo> buildQueryParams(TunnelInfo tunnelInfo) {
  80. LambdaQueryWrapper<TunnelInfo> queryWrapper = Wrappers.lambdaQuery();
  81. if (StrUtil.isNotBlank(tunnelInfo.getTunnelName())) {
  82. queryWrapper.eq(TunnelInfo::getTunnelName, tunnelInfo.getTunnelName());
  83. }
  84. if (ObjectUtil.isNotNull(tunnelInfo.getEquipmentNo())) {
  85. queryWrapper.eq(TunnelInfo::getEquipmentNo, tunnelInfo.getEquipmentNo());
  86. }
  87. if (ObjectUtil.isNotNull(tunnelInfo.getStationId())) {
  88. queryWrapper.eq(TunnelInfo::getStationId, tunnelInfo.getStationId());
  89. }
  90. return queryWrapper;
  91. }
  92. }