99 lines
3.4 KiB
Java
99 lines
3.4 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.JcskSlBPageSo;
|
|
import com.gunshi.project.hsz.entity.vo.HomeJcskSlBVo;
|
|
import com.gunshi.project.hsz.model.JcskSlB;
|
|
import com.gunshi.project.hsz.service.JcskSlBService;
|
|
import com.gunshi.project.hsz.validate.markers.Insert;
|
|
import com.gunshi.project.hsz.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.Date;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
|
|
@Tag(name = "渗压测力点-设备基础信息")
|
|
@RestController
|
|
@RequestMapping(value="/osmoticFlowDevice")
|
|
public class JcskSlBController {
|
|
@Autowired
|
|
private JcskSlBService service;
|
|
|
|
@Operation(summary = "分页")
|
|
@PostMapping("/page")
|
|
public R<Page<JcskSlB>> page(@RequestBody @Validated JcskSlBPageSo page) {
|
|
return R.ok(service.pageQuery(page));
|
|
}
|
|
|
|
@Operation(summary = "新增")
|
|
@PostMapping("/insert")
|
|
public R<JcskSlB> insert(@Validated(Insert.class) @RequestBody JcskSlB dto) {
|
|
if (Objects.nonNull(service.getById(dto.getMpcd()))) {
|
|
throw new IllegalArgumentException("当前编号已存在");
|
|
}
|
|
|
|
dto.setDtuptm(new Date());
|
|
boolean result = service.save(dto);
|
|
// if (result){
|
|
// fileService.saveFile(dto.getFiles(), getGroupId(), dto.getStationCode());
|
|
// }
|
|
return R.ok(result ? dto : null);
|
|
}
|
|
|
|
@Operation(summary = "修改")
|
|
@PostMapping("/update")
|
|
public R<JcskSlB> update(@Validated(Update.class) @RequestBody JcskSlB dto) {
|
|
if (Objects.isNull(service.getById(dto.getMpcd()))) {
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
}
|
|
dto.setDtuptm(null);
|
|
boolean result = service.updateById(dto);
|
|
// if (result){
|
|
// fileService.saveFile(dto.getFiles(), getGroupId(), dto.getStationCode());
|
|
// }
|
|
return R.ok(result ? dto : null);
|
|
}
|
|
|
|
@Operation(summary = "删除")
|
|
@GetMapping("/del/{id}")
|
|
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
|
if (Objects.isNull(service.getById(id))) {
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
}
|
|
return R.ok(service.removeById(id));
|
|
}
|
|
|
|
@Operation(summary = "列表")
|
|
@PostMapping("/list")
|
|
public R<List<JcskSlB>> list() {
|
|
List<JcskSlB> list = service.lambdaQuery().list();
|
|
list.stream().forEach(o ->{
|
|
o.setStationCode(o.getDvcd());
|
|
});
|
|
return R.ok(list);
|
|
}
|
|
|
|
|
|
@Operation(summary = "详情和监测数据查询")
|
|
@PostMapping("/getDetailsAndMonitoringDataList")
|
|
public R<List<HomeJcskSlBVo>> getDetailsAndMonitoringDataList() {
|
|
return R.ok(service.getDetailsAndMonitoringDataList());
|
|
}
|
|
|
|
@Operation(summary = "根据id查询详细数据")
|
|
@GetMapping("/getDetailsById")
|
|
public R<HomeJcskSlBVo> getDetailsById(@RequestParam(name = "id") String id) {
|
|
HomeJcskSlBVo byId = service.getDetailsById(id.toString());
|
|
return R.ok(byId);
|
|
}
|
|
}
|