我正在开发一个API(只是为了学习),当我尝试使用端点列出保存在我的DB(本地)上的文件时,我收到了这个:
[
{
"nome": null,
"url": null,
"type": null,
"size": 0,
"paciente": null,
"medico": null
}
字符串
]
这是我的终点:
@GetMapping("/files")
public ResponseEntity<List<ResponseFile>> getListFiles() {
List<ResponseFile> files = resultadosExamesService.listarTodosArquivos().map(dbFile -> {
String fileDownloadUri = ServletUriComponentsBuilder
.fromCurrentContextPath()
.path("/exames/files/")
.path(dbFile.getIdExame().toString())
.toUriString();
return new ResponseFile(
dbFile.getNomeArquivo(),
fileDownloadUri,
dbFile.getTipoExame(),
dbFile.getArquivoExame().length);
}).collect(Collectors.toList());
return ResponseEntity.status(HttpStatus.OK).body(files);
}
型
我的ResponseFile:
public class ResponseFile {
private String nome;
private String url;
private String type;
private long size;
private Paciente paciente;
private PacientesDTO pacienteDTO;
private Medico medico;
public ResponseFile(String nomeArquivo, String fileDownloadUri, String tipoExame, int length) {
this.nome = nome;
this.url = url;
this.type = type;
this.size = size;
}
//get and set...
型
我期待收到这样的JSON:(这个端点列出了来自DB的医生预约)
[
{
"idConsulta": 2,
"nomeMedico": "Camila Bernardo",
"nomePaciente": "João",
"motivoConsulta": "fortes dores de cabeça",
"dataConsulta": "2023-12-12T14:00:00"
},
{
"idConsulta": 3,
"nomeMedico": "Camila Bernardo",
"nomePaciente": "João",
"motivoConsulta": "fortes dores de cabeça",
"dataConsulta": "2023-12-12T16:00:00"
}
型
]
1条答案
按热度按时间kxkpmulp1#
如果我没有错的话,你的问题是由于ResponseFile而发生的。我认为ResponseFile不应该是这样的,它应该更像这样。
字符串