99 lines
3.3 KiB
Java
99 lines
3.3 KiB
Java
package com.gunshi.project.hsz.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.gunshi.core.result.R;
|
|
import com.gunshi.project.hsz.entity.so.JcskGnssBPageSo;
|
|
import com.gunshi.project.hsz.entity.vo.HomeJcskGnssBVo;
|
|
import com.gunshi.project.hsz.model.JcskGnssB;
|
|
import com.gunshi.project.hsz.service.JcskGnssBService;
|
|
import com.gunshi.project.hsz.common.validate.markers.Insert;
|
|
import com.gunshi.project.hsz.common.validate.markers.Update;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
|
|
@Tag(name = "位移设备Controller")
|
|
@RestController
|
|
@RequestMapping(value="/osmoticShiftDevice")
|
|
public class JcskGnssBController {
|
|
|
|
@Autowired
|
|
private JcskGnssBService service;
|
|
|
|
|
|
@Operation(summary = "新增")
|
|
@PostMapping("/insert")
|
|
public R<JcskGnssB> insert(@Validated(Insert.class) @RequestBody JcskGnssB dto) {
|
|
if (Objects.nonNull(service.getById(dto.getCd()))) {
|
|
throw new IllegalArgumentException("当前编号已存在");
|
|
}
|
|
boolean result = service.save(dto);
|
|
return R.ok(result ? dto : null);
|
|
}
|
|
|
|
@Operation(summary = "修改")
|
|
@PostMapping("/update")
|
|
public R<JcskGnssB> update(@Validated(Update.class) @RequestBody JcskGnssB dto) {
|
|
if (Objects.isNull(service.getById(dto.getCd()))) {
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
}
|
|
boolean result = service.updateById(dto);
|
|
return R.ok(result ? dto : null);
|
|
}
|
|
|
|
@Operation(summary = "删除")
|
|
@GetMapping("/del/{id}")
|
|
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
|
return R.ok(service.removeById(id));
|
|
}
|
|
|
|
@Operation(summary = "分页")
|
|
@PostMapping("/page")
|
|
public R<Page<JcskGnssB>> page(@RequestBody @Validated JcskGnssBPageSo page) {
|
|
return R.ok(service.pageQuery(page));
|
|
}
|
|
|
|
|
|
@Operation(summary = "详情和监测数据查询(暂无设备表,无法使用)")
|
|
@PostMapping("/getDetailsAndMonitoringDataList")
|
|
public R<List<HomeJcskGnssBVo>> getDetailsAndMonitoringDataList() {
|
|
return R.ok(service.getDetailsAndMonitoringDataList());
|
|
}
|
|
|
|
@Operation(summary = "根据id查询详细数据")
|
|
@GetMapping("/getDetailsById")
|
|
public R<HomeJcskGnssBVo> getDetailsById(@RequestParam(name = "id") String id) {
|
|
HomeJcskGnssBVo byId = service.getDetailsById(id);
|
|
return R.ok(byId);
|
|
}
|
|
|
|
@Operation(summary = "列表")
|
|
@PostMapping("/list")
|
|
public R<List<JcskGnssB>> list() {
|
|
List<JcskGnssB> list = service.lambdaQuery()
|
|
.orderByAsc(JcskGnssB::getCd)
|
|
.list();
|
|
list.stream().forEach(o ->{
|
|
o.setStationCode(o.getCd());
|
|
});
|
|
return R.ok(list);
|
|
}
|
|
|
|
@Operation(summary = "获取位移的断面数据")
|
|
@GetMapping("/list/dm")
|
|
public R<List<String>> listDm(){
|
|
|
|
List<String> res = service.listDms();
|
|
return R.ok(res);
|
|
}
|
|
|
|
}
|