123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- 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<TunnelInfo> queryWrapper = this.buildQueryParams(tunnelInfo);
- List<TunnelInfo> list = tunnelInfoService.list(queryWrapper);
- return getDataTable(list);
- }
- /**
- * 查询通道信息列表
- */
- @PreAuthorize("@ss.hasPermi('dataQuery:windTowerStatusInfo:list')")
- @GetMapping("/listAll")
- public TableDataInfo listAll() {
- List<TunnelInfo> 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<TunnelInfo> buildQueryParams(TunnelInfo tunnelInfo) {
- LambdaQueryWrapper<TunnelInfo> 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;
- }
- }
|