RopApiController.java
3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.glsx.usedcar.controller;
import com.alibaba.fastjson2.JSON;
import com.glsx.usedcar.gsc.GscApiInvoker;
import com.glsx.usedcar.gsc.vo.CarBrandCompleteRespVO;
import com.glsx.usedcar.gsc.vo.CarTypeListRespVO;
import com.glsx.usedcar.gsc.vo.GscApiResponse;
import com.glsx.usedcar.resp.BaseResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* rop api
* @author yangwei
* @version 1.0
* @since 2026/03/24 11:05
*/
@Slf4j
@RestController
@RequestMapping("/rest/ropApi")
@RequiredArgsConstructor
@Tag(name = "rop-api调用前端控制器", description = "各类rop-api调用处理")
public class RopApiController {
private final GscApiInvoker gscApiInvoker;
@Operation(summary = "根据车系ID查询车型列表", description = "根据车系ID查询车型列表")
@GetMapping("getCarTypeList")
public BaseResp<CarTypeListRespVO> getCarTypeList(
@Parameter(description = "车系ID")
@RequestParam(value = "csId", required = false) String csId) {
String jsonResult = gscApiInvoker.getCarTypeList(csId);
if (jsonResult == null) {
return BaseResp.fail("获取车型列表失败");
}
try {
GscApiResponse<CarTypeListRespVO> response = JSON.parseObject(jsonResult,
new com.alibaba.fastjson2.TypeReference<GscApiResponse<CarTypeListRespVO>>() {});
if ("0".equals(response.getCode())) {
return BaseResp.success(response.getData());
} else {
return BaseResp.fail(response.getCode(), response.getMessage());
}
} catch (Exception e) {
log.error("解析车型列表响应失败: {}", e.getMessage());
return BaseResp.fail("解析响应数据失败");
}
}
@Operation(summary = "查询车品牌全称", description = "查询车品牌全称(品牌-车系-车型树形结构)")
@GetMapping("getCarBrandComplete")
public BaseResp<CarBrandCompleteRespVO> getCarBrandComplete() {
String jsonResult = gscApiInvoker.getCarBrandComplete();
if (jsonResult == null) {
return BaseResp.fail("获取车品牌信息失败");
}
try {
GscApiResponse<CarBrandCompleteRespVO> response = JSON.parseObject(jsonResult,
new com.alibaba.fastjson2.TypeReference<GscApiResponse<CarBrandCompleteRespVO>>() {});
if ("0".equals(response.getCode())) {
return BaseResp.success(response.getData());
} else {
return BaseResp.fail(response.getCode(), response.getMessage());
}
} catch (Exception e) {
log.error("解析车品牌响应失败: {}", e.getMessage());
return BaseResp.fail("解析响应数据失败");
}
}
}