package com.jiayue.biz.controller; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.jiayue.biz.domain.*; import com.jiayue.biz.service.TunnelInfoService; import com.jiayue.common.annotation.Log; import com.jiayue.common.core.controller.BaseController; import com.jiayue.common.core.domain.AjaxResult; import com.jiayue.common.core.page.TableDataInfo; import com.jiayue.common.enums.BusinessType; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import java.util.*; /** * 通道信息Controller * * @author L.ym * @date 2022-05-11 */ @RequiredArgsConstructor(onConstructor_ = @Autowired) @RestController @RequestMapping("/dataQuery/tunnelInfo") public class TunnelInfoController extends BaseController { private final TunnelInfoService tunnelInfoService; /** * 查询通道信息列表 */ @PreAuthorize("@ss.hasPermi('dataQuery:windTowerStatusInfo:list')") @GetMapping("/list") public TableDataInfo list(TunnelInfo tunnelInfo) { startPage(); LambdaQueryWrapper queryWrapper = this.buildQueryParams(tunnelInfo); List list = tunnelInfoService.list(queryWrapper); return getDataTable(list); } /** * 查询通道信息列表 */ @PreAuthorize("@ss.hasPermi('dataQuery:windTowerStatusInfo:list')") @GetMapping("/listAll") public TableDataInfo listAll() { List list = tunnelInfoService.lambdaQuery().orderByAsc(TunnelInfo::getId).list(); return getDataTable(list); } /** * 新增通道信息 */ @PreAuthorize("@ss.hasPermi('dataQuery:windTowerStatusInfo:add')") @Log(title = "通道信息", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody TunnelInfo tunnelInfo) { return toAjax(tunnelInfoService.save(tunnelInfo)); } /** * 修改通道信息 */ @PreAuthorize("@ss.hasPermi('dataQuery:windTowerStatusInfo:edit')") @Log(title = "通道信息", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody TunnelInfo tunnelInfo) { return toAjax(tunnelInfoService.updateById(tunnelInfo) ? 1 : 0); } /** * 删除通道信息 */ @PreAuthorize("@ss.hasPermi('dataQuery:windTowerStatusInfo:remove')") @Log(title = "通道信息", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable String[] ids) { return toAjax(tunnelInfoService.removeByIds(Arrays.asList(ids)) ? 1 : 0); } /** * 构建查询条件 **/ private LambdaQueryWrapper buildQueryParams(TunnelInfo tunnelInfo) { LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); if (StrUtil.isNotBlank(tunnelInfo.getTunnelName())) { queryWrapper.eq(TunnelInfo::getTunnelName, tunnelInfo.getTunnelName()); } if (ObjectUtil.isNotNull(tunnelInfo.getEquipmentNo())) { queryWrapper.eq(TunnelInfo::getEquipmentNo, tunnelInfo.getEquipmentNo()); } if (ObjectUtil.isNotNull(tunnelInfo.getStationId())) { queryWrapper.eq(TunnelInfo::getStationId, tunnelInfo.getStationId()); } return queryWrapper; } }