56 lines
1.7 KiB
Java
56 lines
1.7 KiB
Java
|
|
package com.ruoyi.loanpricing.controller;
|
||
|
|
|
||
|
|
|
||
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||
|
|
import com.ruoyi.common.annotation.Anonymous;
|
||
|
|
import com.ruoyi.common.core.controller.BaseController;
|
||
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||
|
|
|
||
|
|
import com.ruoyi.loanpricing.domain.dto.ModelInvokeDTO;
|
||
|
|
import io.swagger.v3.oas.annotations.Operation;
|
||
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||
|
|
import org.springframework.core.io.ClassPathResource;
|
||
|
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
|
||
|
|
|
||
|
|
import java.io.InputStream;
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @Author 吴凯程
|
||
|
|
* @Date 2025/11/10
|
||
|
|
**/
|
||
|
|
@Tag(name = "测算测试接口")
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/rate/pricing/mock")
|
||
|
|
public class LoanRatePricingMockController extends BaseController {
|
||
|
|
|
||
|
|
@Anonymous
|
||
|
|
@Operation(summary = "调用模型获取测算利率")
|
||
|
|
@PostMapping("/invokeModel")
|
||
|
|
public AjaxResult invokeModel( ModelInvokeDTO modelInvokeDTO) {
|
||
|
|
ObjectNode jsonNodes;
|
||
|
|
if (modelInvokeDTO.getCustType().equals("个人")) {
|
||
|
|
jsonNodes = loadJsonFromResource("data/retail_output.json");
|
||
|
|
} else {
|
||
|
|
jsonNodes = loadJsonFromResource("data/corp_output.json");
|
||
|
|
}
|
||
|
|
|
||
|
|
return new AjaxResult(10000, "success", jsonNodes);
|
||
|
|
}
|
||
|
|
|
||
|
|
private ObjectNode loadJsonFromResource(String resourcePath){
|
||
|
|
ClassPathResource classPathResource = new ClassPathResource(resourcePath);
|
||
|
|
try (InputStream inputStream = classPathResource.getInputStream();){
|
||
|
|
|
||
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
||
|
|
return objectMapper.readValue(inputStream, ObjectNode.class);
|
||
|
|
} catch (Exception e) {
|
||
|
|
throw new RuntimeException(e);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|