|
|
@ -1,8 +1,11 @@ |
|
|
|
package com.iflytop.nuclear.controller; |
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.iflytop.nuclear.model.Account; |
|
|
|
import com.iflytop.nuclear.model.NuclearCore; |
|
|
|
import com.iflytop.nuclear.model.NuclearStation; |
|
|
|
import com.iflytop.nuclear.service.NuclearCoreService; |
|
|
|
import com.iflytop.nuclear.service.NuclearStationService; |
|
|
|
import com.iflytop.nuclear.utils.ResponseData; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -26,6 +29,8 @@ public class NuclearStationController { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
NuclearStationService nuclearStationService; |
|
|
|
@Autowired |
|
|
|
NuclearCoreService nuclearCoreService; |
|
|
|
|
|
|
|
@GetMapping("/list") |
|
|
|
public ResponseData list() { |
|
|
@ -53,6 +58,13 @@ public class NuclearStationController { |
|
|
|
|
|
|
|
@PostMapping("/delete/{id}") |
|
|
|
public ResponseData delete(@PathVariable(name="id") String stationId) { |
|
|
|
// 根据id查询底下是否有核芯堆 |
|
|
|
QueryWrapper<NuclearCore> nuclearCoreQueryWrapper = new QueryWrapper<>(); |
|
|
|
nuclearCoreQueryWrapper.eq("station_id", stationId); |
|
|
|
List<NuclearCore> list = nuclearCoreService.list(nuclearCoreQueryWrapper); |
|
|
|
if (list.size() > 0){ |
|
|
|
return ResponseData.fail("当前核电站下拥有核芯堆,禁止删除"); |
|
|
|
} |
|
|
|
boolean b = nuclearStationService.removeById(stationId); |
|
|
|
JSONObject res = new JSONObject(); |
|
|
|
res.put("result", b); |
|
|
@ -60,7 +72,7 @@ public class NuclearStationController { |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/update/{id}") |
|
|
|
public ResponseData update(@PathVariable(name="id") Long stationId, @RequestBody Map<String,String> stationInfo) { |
|
|
|
public ResponseData update(@PathVariable(name="id") int stationId, @RequestBody Map<String,String> stationInfo) { |
|
|
|
NuclearStation nuclearStation = NuclearStation.builder() |
|
|
|
.name(stationInfo.get("name")) |
|
|
|
.address(stationInfo.get("address")) |
|
|
|