Commit 49bf1f7f by 刘鑫

替换资源文件读取方式

1 parent 6f4ae460
......@@ -13,6 +13,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.RequiredArgsConstructor;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.format.annotation.DateTimeFormat;
......@@ -113,8 +114,8 @@ public class PeaApiController {
//查询日期起止参数限制为一月
Resource resource = resourceLoader.getResource("classpath:/json/capacity.json");
String jsonStr = FileUtil.readString(resource.getFile(), StandardCharsets.UTF_8);
ClassPathResource classPathResource = new ClassPathResource("json/capacity.json");
String jsonStr = FileUtil.readString(classPathResource.getFile(), StandardCharsets.UTF_8);
CapacityQueryDTO.Result result = JsonUtil.parse(jsonStr, CapacityQueryDTO.Result.class).get();
result.setParams(reqDTO);
return Result.success(result);
......@@ -139,8 +140,8 @@ public class PeaApiController {
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@RequestParam("endDate") Date endDate) throws IOException {
Resource resource = resourceLoader.getResource("classpath:/json/capacity.json");
String jsonStr = FileUtil.readString(resource.getFile(), StandardCharsets.UTF_8);
ClassPathResource classPathResource = new ClassPathResource("json/capacity.json");
String jsonStr = FileUtil.readString(classPathResource.getFile(), StandardCharsets.UTF_8);
CapacityQueryDTO.Result resultTemp = JsonUtil.parse(jsonStr, CapacityQueryDTO.Result.class).get();
CapacityQueryDTO.PersonalResult result = new CapacityQueryDTO.PersonalResult();
......@@ -189,8 +190,8 @@ public class PeaApiController {
@GetMapping("/order/stage/query")
public Result<OrderDTO.StageResult> orderStage(@NotBlank @RequestParam("orderId") String orderId) throws IOException {
Resource resource = resourceLoader.getResource("classpath:/json/stage.json");
String jsonStr = FileUtil.readString(resource.getFile(), StandardCharsets.UTF_8);
ClassPathResource classPathResource = new ClassPathResource("json/stage.json");
String jsonStr = FileUtil.readString(classPathResource.getFile(), StandardCharsets.UTF_8);
OrderDTO.StageResult stageResult = JsonUtil.parse(jsonStr, OrderDTO.StageResult.class).get();
stageResult.setOrderId(orderId);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!