92 lines
3.3 KiB
Java
92 lines
3.3 KiB
Java
package com.gunshi.project.hsz.controller;
|
|
|
|
import com.gunshi.core.result.R;
|
|
import com.gunshi.project.hsz.model.AttResBuilding;
|
|
import com.gunshi.project.hsz.model.FileAssociations;
|
|
import com.gunshi.project.hsz.service.AttResBuildingService;
|
|
import com.gunshi.project.hsz.service.FileAssociationsService;
|
|
import com.gunshi.project.hsz.validate.markers.Update;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* 描述: 水库基本信息表
|
|
* author: xusan
|
|
* date: 2024-07-08 17:40:37
|
|
*/
|
|
@Tag(name = "水库基本信息表")
|
|
@RestController
|
|
@RequestMapping(value="/attResBuilding")
|
|
public class AttResBuildingController extends AbstractCommonFileController {
|
|
|
|
@Autowired
|
|
private AttResBuildingService attResBuildingService;
|
|
|
|
@Autowired
|
|
private FileAssociationsService fileService;
|
|
|
|
|
|
@Operation(summary = "修改")
|
|
@PostMapping("/update")
|
|
public R<AttResBuilding> update(@Validated(Update.class) @RequestBody AttResBuilding dto) {
|
|
// if (Objects.isNull(attResBuildingService.getById(dto.getId()))) {
|
|
// throw new IllegalArgumentException("当前数据不存在");
|
|
// }
|
|
boolean result = attResBuildingService.updateById(dto);
|
|
// if (result){
|
|
// fileService.saveFile(dto.getFiles(), getGroupId(), dto.getResCode());
|
|
// }
|
|
return R.ok(result ? dto : null);
|
|
}
|
|
|
|
@Operation(summary = "修改")
|
|
@GetMapping("/info")
|
|
public R<AttResBuilding> info() {
|
|
List<AttResBuilding> list = attResBuildingService.list();
|
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
}
|
|
AttResBuilding byId = list.stream().findFirst().orElse(null);
|
|
//boolean result = attResBuildingService.updateById(dto);
|
|
// if (result){
|
|
// fileService.saveFile(dto.getFiles(), getGroupId(), dto.getResCode());
|
|
// }
|
|
return R.ok(byId);
|
|
}
|
|
|
|
// @Operation(summary = "设计图纸和资料文件上传")
|
|
// @PostMapping("/updateFile")
|
|
// public R<AttResBase> updateFile(@Validated(Update.class) @RequestBody AttResBase dto) {
|
|
// if (Objects.isNull(service.getById(dto.getResCode()))) {
|
|
// throw new IllegalArgumentException("当前数据不存在");
|
|
// }
|
|
// List<FileAssociations> files = dto.getFiles();
|
|
// fileService.saveFileNotDel(files, getGroupId(), dto.getResCode(),"1");
|
|
// return R.ok(dto);
|
|
// }
|
|
|
|
@Operation(summary = "设计图纸和资料列表")
|
|
@GetMapping("/fileList/{resCode}")
|
|
public R<List<FileAssociations>> list(@PathVariable("resCode") String resCode) {
|
|
List<FileAssociations> files = fileService.getFiles(getGroupId(), resCode);
|
|
if (CollectionUtils.isEmpty(files)){
|
|
return R.ok(files);
|
|
}
|
|
List<FileAssociations> datas = files.stream().filter(o -> "1".equals(o.getType()))
|
|
.collect(Collectors.toList());
|
|
return R.ok(datas);
|
|
}
|
|
|
|
@Override
|
|
public String getGroupId() {
|
|
return "attResBase";
|
|
}
|
|
} |