You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.6 KiB
77 lines
2.6 KiB
package com.iflytop.gd.app.controller;
|
|
|
|
import com.iflytop.gd.app.model.entity.DeviceParamConfig;
|
|
import com.iflytop.gd.app.model.vo.DeviceParamGroupVO;
|
|
import com.iflytop.gd.app.model.vo.ModuleIdVO;
|
|
import com.iflytop.gd.app.model.vo.RegIndexVO;
|
|
import com.iflytop.gd.app.service.DeviceParamConfigService;
|
|
import com.iflytop.gd.common.result.Result;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import jakarta.validation.Valid;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 设备参数配置
|
|
*/
|
|
@Tag(name = "设备参数配置")
|
|
@RestController
|
|
@RequestMapping("/api/device-param")
|
|
@RequiredArgsConstructor
|
|
@Slf4j
|
|
public class DeviceParamController {
|
|
|
|
private final DeviceParamConfigService deviceParamConfigService;
|
|
|
|
@Operation(summary = "获取所有设备配置")
|
|
@GetMapping("/list")
|
|
public Result<List<DeviceParamGroupVO>> listGroupedParams() {
|
|
List<DeviceParamGroupVO> vos = deviceParamConfigService.listGroupedByModule();
|
|
return Result.success(vos);
|
|
}
|
|
|
|
@Operation(summary = "获取所有设备模块")
|
|
@GetMapping("/modules")
|
|
public Result<List<ModuleIdVO>> listAllModules() {
|
|
List<ModuleIdVO> vos = deviceParamConfigService.listAllModuleIds();
|
|
return Result.success(vos);
|
|
}
|
|
|
|
@Operation(summary = "获取所有设备模块配置项")
|
|
@GetMapping("/reg-indices")
|
|
public Result<List<RegIndexVO>> listAllRegIndices() {
|
|
List<RegIndexVO> vos = deviceParamConfigService.listAllRegIndices();
|
|
return Result.success(vos);
|
|
}
|
|
|
|
|
|
@Operation(summary = "添加新配置")
|
|
@PostMapping("")
|
|
public Result<String> add(@Valid @RequestBody DeviceParamConfig deviceParamConfig) {
|
|
deviceParamConfigService.save(deviceParamConfig);
|
|
return Result.success();
|
|
}
|
|
|
|
@Operation(summary = "修改配置")
|
|
@PutMapping("")
|
|
public Result<String> update(@Valid @RequestBody DeviceParamConfig deviceParamConfig) {
|
|
deviceParamConfigService.updateById(deviceParamConfig);
|
|
return Result.success();
|
|
}
|
|
|
|
@Operation(summary = "删除配置")
|
|
@DeleteMapping("/{ids}")
|
|
public Result<String> deleteOres(@Parameter(description = "矿石ID,多个以英文逗号(,)分割") @PathVariable String ids) {
|
|
boolean isSuccess = deviceParamConfigService.deleteDeviceParam(ids);
|
|
if (isSuccess) {
|
|
return Result.success();
|
|
}
|
|
return Result.failed();
|
|
}
|
|
|
|
}
|