opt:地图编辑设备组件接口修改

This commit is contained in:
zhangzq
2026-02-24 16:55:06 +08:00
parent 3f83b1735c
commit 2e2b36ddf8
6 changed files with 62 additions and 30 deletions

View File

@@ -12,18 +12,24 @@
*/
package org.nl.module.device.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.page.PageQuery;
import org.nl.common.pojo.CommonResult;
import org.nl.module.device.dto.BaseDeviceQuery;
import org.nl.module.device.entity.BaseDataDevice;
import org.nl.module.device.service.BaseDataDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
* 设备信息表Controller
*/
@@ -41,32 +47,8 @@ public class BaseDataDeviceController {
*/
@Operation(summary = "获取设备列表")
@GetMapping("/list")
public CommonResult list(@RequestParam(required = false) String searchKey,
@RequestParam(required = false) String region,
@RequestParam(defaultValue = "1") Integer current,
@RequestParam(defaultValue = "10") Integer size) {
LambdaQueryWrapper<BaseDataDevice> queryWrapper = new LambdaQueryWrapper<>();
// 关键词搜索(设备名称或编码)
if (StringUtils.isNotBlank(searchKey)) {
queryWrapper.and(wrapper -> wrapper
.like(BaseDataDevice::getName, searchKey)
.or()
.like(BaseDataDevice::getCode, searchKey)
);
}
// 区域搜索
if (StringUtils.isNotBlank(region)) {
queryWrapper.like(BaseDataDevice::getRegion, region);
}
// 按创建时间倒序
queryWrapper.orderByDesc(BaseDataDevice::getCreateTime);
Page<BaseDataDevice> page = new Page<>(current, size);
Page<BaseDataDevice> result = baseDataDeviceService.page(page, queryWrapper);
public CommonResult list(BaseDeviceQuery query,PageQuery page) {
Page<BaseDataDevice> result = baseDataDeviceService.page(page.build(), query.build());
return CommonResult.data(result);
}
@@ -99,4 +81,9 @@ public class BaseDataDeviceController {
baseDataDeviceService.removeById(id);
return CommonResult.ok();
}
@Operation(summary = "设备组件列表")
@GetMapping("compentList")
public CommonResult<List> compentList() {
return CommonResult.data(baseDataDeviceService.list());
}
}

View File

@@ -0,0 +1,11 @@
package org.nl.module.device.dto;
import org.nl.common.page.BaseQuery;
import org.nl.module.device.entity.BaseDataDevice;
public class BaseDeviceQuery extends BaseQuery<BaseDataDevice> {
@Override
protected Class<BaseDataDevice> getEntityClass() {
return BaseDataDevice.class;
}
}

View File

@@ -33,8 +33,16 @@ public class BaseDataDevice implements Serializable {
@Schema(description = "设备名称")
private String name;
@Schema(description = "所属区域")
private String region;
@Schema(description = "类型")
private String type;
@Schema(description = "描述")
private String description;
@Schema(description = "扩展参数")
private String editParam;
@Schema(description = "吃否启用")
private Boolean isUsed;
@Schema(description = "x坐标")
private Integer x;
@@ -51,6 +59,9 @@ public class BaseDataDevice implements Serializable {
@Schema(description = "图标地址")
private String icon;
@Schema(description = "图标路径地址")
private String path;
@Schema(description = "创建时间")
private Date createTime;

View File

@@ -220,7 +220,7 @@ export default {
methods: {
async loadDeviceList() {
try {
const response = await fetch('http://localhost:8081/api/device/list', {
const response = await fetch('http://localhost:8081/api/baseData/device/compentList', {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})

View File

@@ -29,6 +29,12 @@
<a-form-item label="所属区域:" name="region">
<a-input v-model:value="formData.region" placeholder="请输入所属区域" allow-clear />
</a-form-item>
<a-form-item label="设备类型:" name="type">
<a-input v-model:value="formData.type" placeholder="请输入设备类型" allow-clear />
</a-form-item>
<a-form-item label="设备描述:" name="description">
<a-input v-model:value="formData.description" placeholder="请输入设备描述" allow-clear />
</a-form-item>
<a-form-item label="设备图片:" name="icon">
<a-upload
v-model:file-list="fileList"
@@ -185,6 +191,7 @@
// 保存文件ID到表单数据
const fileId = res.id || res
formData.value.icon = fileId
formData.value.path = res.storagePath
message.success('上传成功')
// 加载新上传的图片预览

View File

@@ -91,12 +91,28 @@
title: '设备名称',
dataIndex: 'name'
},
{
title: '设备类型',
dataIndex: 'type'
},
{
title: '描述',
dataIndex: 'description'
},
{
title: '扩展参数',
dataIndex: 'editParam'
},
{
title: '图片路径',
dataIndex: 'path'
},
{
title: '所属区域',
dataIndex: 'region'
},
{
title: '设备图片',
title: '设备图片ID',
dataIndex: 'icon'
},
{