-
Notifications
You must be signed in to change notification settings - Fork 0
/
InvokeController.java
312 lines (289 loc) · 12.3 KB
/
InvokeController.java
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
package icu.qimuu.qiapisdkdemo.controller;
import com.qimuu.easyweb.common.BaseResponse;
import com.qimuu.easyweb.common.ResultUtils;
import com.qimuu.easyweb.exception.BusinessException;
import icu.qimuu.qiapisdk.client.QiApiClient;
import icu.qimuu.qiapisdk.exception.ApiException;
import icu.qimuu.qiapisdk.model.params.HoroscopeParams;
import icu.qimuu.qiapisdk.model.params.IpInfoParams;
import icu.qimuu.qiapisdk.model.params.RandomWallpaperParams;
import icu.qimuu.qiapisdk.model.params.WeatherParams;
import icu.qimuu.qiapisdk.model.request.HoroscopeRequest;
import icu.qimuu.qiapisdk.model.request.IpInfoRequest;
import icu.qimuu.qiapisdk.model.request.RandomWallpaperRequest;
import icu.qimuu.qiapisdk.model.request.WeatherRequest;
import icu.qimuu.qiapisdk.model.response.LoveResponse;
import icu.qimuu.qiapisdk.model.response.PoisonousChickenSoupResponse;
import icu.qimuu.qiapisdk.model.response.RandomWallpaperResponse;
import icu.qimuu.qiapisdk.model.response.ResultResponse;
import icu.qimuu.qiapisdk.service.ApiService;
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.RestController;
import javax.annotation.Resource;
/**
* @Author: QiMu
* @Date: 2023年09月17日 23:30
* @Version: 1.0
* @Description:
*/
@RequestMapping("/invoke")
@RestController
@Slf4j
public class InvokeController {
@Resource
private ApiService apiService;
/**
* 随机毒鸡汤
*
* @return {@link PoisonousChickenSoupResponse}
*/
@GetMapping("/getPoisonousChickenSoup")
public PoisonousChickenSoupResponse getPoisonousChickenSoup() {
QiApiClient qiApiClient = new QiApiClient("7052a8594339a519e0ba5eb04a267a60", "d8d6df60ab209385a09ac796f1dfe3e1");
PoisonousChickenSoupResponse poisonousChickenSoup = null;
try {
poisonousChickenSoup = apiService.getPoisonousChickenSoup(qiApiClient);
System.out.println("poisonousChickenSoup = " + poisonousChickenSoup);
} catch (ApiException e) {
log.error(e.getMessage());
}
return poisonousChickenSoup;
}
/**
* 随机毒鸡汤
*
* @return {@link PoisonousChickenSoupResponse}
*/
@GetMapping("/getPoisonousChickenSoupKey")
public PoisonousChickenSoupResponse getPoisonousChickenSoupKey(QiApiClient qiApiClient) {
PoisonousChickenSoupResponse poisonousChickenSoup = null;
try {
poisonousChickenSoup = apiService.getPoisonousChickenSoup(qiApiClient);
System.out.println("poisonousChickenSoup = " + poisonousChickenSoup);
} catch (ApiException e) {
log.error(e.getMessage());
}
return poisonousChickenSoup;
}
/**
* 获取毒鸡汤未设置密钥
*
* @return {@link BaseResponse}<{@link PoisonousChickenSoupResponse}>
*/
@GetMapping("/getPoisonousChickenSoupNotSetKey")
public BaseResponse<PoisonousChickenSoupResponse> getPoisonousChickenSoupNotSetKey() {
PoisonousChickenSoupResponse poisonousChickenSoup = null;
try {
poisonousChickenSoup = apiService.getPoisonousChickenSoup();
System.out.println("poisonousChickenSoup = " + poisonousChickenSoup);
} catch (ApiException e) {
throw new com.qimuu.easyweb.exception.BusinessException(e.getCode(), e.getMessage());
}
return ResultUtils.success(poisonousChickenSoup);
}
/**
* 随机情话
*
* @return {@link BaseResponse}<{@link LoveResponse}>
*/
@GetMapping("/loveTalk/easyWeb")
public BaseResponse<LoveResponse> getLoveTalkEasyWeb() {
LoveResponse loveResponse;
try {
loveResponse = apiService.randomLoveTalk();
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return ResultUtils.success(loveResponse);
}
@GetMapping("/loveTalk")
public LoveResponse getLoveTalk() {
LoveResponse loveResponse;
try {
loveResponse = apiService.randomLoveTalk();
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return loveResponse;
}
@GetMapping("/loveTalk/setKey")
public LoveResponse getLoveTalkSetKey() {
LoveResponse loveResponse;
try {
QiApiClient qiApiClient = new QiApiClient("7052a8594339a519e0ba5eb04a267a60", "d8d6df60ab209385a09ac796f1dfe3e1");
loveResponse = apiService.randomLoveTalk(qiApiClient);
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return loveResponse;
}
/**
* 获取星座运势
*
* @param horoscopeParams 星座参数
* @return {@link BaseResponse}<{@link ResultResponse}>
*/
@GetMapping("/getHoroscopeEasyWeb")
public BaseResponse<ResultResponse> getHoroscopeEasyWeb(HoroscopeParams horoscopeParams) {
ResultResponse horoscope;
try {
HoroscopeRequest horoscopeRequest = new HoroscopeRequest();
horoscopeRequest.setRequestParams(horoscopeParams);
horoscope = apiService.horoscope(horoscopeRequest);
} catch (ApiException e) {
throw new com.qimuu.easyweb.exception.BusinessException(e.getCode(), e.getMessage());
}
return ResultUtils.success(horoscope);
}
@GetMapping("/getHoroscope")
public ResultResponse getHoroscope(HoroscopeParams horoscopeParams) {
ResultResponse horoscope;
try {
HoroscopeRequest horoscopeRequest = new HoroscopeRequest();
horoscopeRequest.setRequestParams(horoscopeParams);
horoscope = apiService.horoscope(horoscopeRequest);
} catch (ApiException e) {
throw new com.qimuu.easyweb.exception.BusinessException(e.getCode(), e.getMessage());
}
return horoscope;
}
@GetMapping("/getHoroscope/setKey")
public ResultResponse getHoroscopeSetKey(HoroscopeParams horoscopeParams) {
ResultResponse horoscope;
QiApiClient qiApiClient = new QiApiClient("7052a8594339a519e0ba5eb04a267a60", "d8d6df60ab209385a09ac796f1dfe3e1");
try {
HoroscopeRequest horoscopeRequest = new HoroscopeRequest();
horoscopeRequest.setRequestParams(horoscopeParams);
horoscope = apiService.horoscope(qiApiClient, horoscopeRequest);
} catch (ApiException e) {
throw new com.qimuu.easyweb.exception.BusinessException(e.getCode(), e.getMessage());
}
return horoscope;
}
/**
* 获取ip信息
* <p>
* // * @param ipInfoParams ip信息参数
*
* @return {@link BaseResponse}<{@link ResultResponse}>
*/
@GetMapping("/ipInfo/easyWeb")
public BaseResponse<ResultResponse> getIpInfoEasyWeb(QiApiClient qiApiClient, IpInfoParams ipInfoParams) {
ResultResponse resultResponse;
try {
IpInfoRequest ipInfoRequest = new IpInfoRequest();
ipInfoRequest.setRequestParams(ipInfoParams);
resultResponse = apiService.getIpInfo(qiApiClient, ipInfoRequest);
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return ResultUtils.success(resultResponse);
}
@GetMapping("/ipInfo/toEasyWeb")
public BaseResponse<ResultResponse> getIpInfoEasyWeb(IpInfoParams ipInfoParams) {
ResultResponse resultResponse;
try {
IpInfoRequest ipInfoRequest = new IpInfoRequest();
ipInfoRequest.setRequestParams(ipInfoParams);
resultResponse = apiService.getIpInfo(ipInfoRequest);
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return ResultUtils.success(resultResponse);
}
@GetMapping("/ipInfo")
public ResultResponse getIpInfo(IpInfoParams ipInfoParams) {
QiApiClient qiApiClient = new QiApiClient("7052a8594339a519e0ba5eb04a267a60", "d8d6df60ab209385a09ac796f1dfe3e1");
ResultResponse resultResponse;
try {
IpInfoRequest ipInfoRequest = new IpInfoRequest();
ipInfoRequest.setRequestParams(ipInfoParams);
resultResponse = apiService.getIpInfo(qiApiClient, ipInfoRequest);
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return resultResponse;
}
/**
* 获取天气信息
*
* @param weatherParams ip信息参数
* @return {@link BaseResponse}<{@link ResultResponse}>
*/
@GetMapping("/weatherInfo/EasyWeb")
public BaseResponse<ResultResponse> getWeatherInfoEasyWeb(WeatherParams weatherParams) {
ResultResponse resultResponse;
try {
WeatherRequest weatherRequest = new WeatherRequest();
weatherRequest.setRequestParams(weatherParams);
resultResponse = apiService.getWeatherInfo(weatherRequest);
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return ResultUtils.success(resultResponse);
}
@GetMapping("/weatherInfo")
public ResultResponse getWeatherInfo(WeatherParams weatherParams) {
ResultResponse resultResponse;
try {
WeatherRequest weatherRequest = new WeatherRequest();
weatherRequest.setRequestParams(weatherParams);
resultResponse = apiService.getWeatherInfo(weatherRequest);
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return resultResponse;
}
@GetMapping("/weatherInfo/setKey")
public ResultResponse getWeatherInfoSetKey(WeatherParams weatherParams) {
ResultResponse resultResponse;
QiApiClient qiApiClient = new QiApiClient("7052a8594339a519e0ba5eb04a267a60", "d8d6df60ab209385a09ac796f1dfe3e1");
try {
WeatherRequest weatherRequest = new WeatherRequest();
weatherRequest.setRequestParams(weatherParams);
resultResponse = apiService.getWeatherInfo(qiApiClient, weatherRequest);
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return resultResponse;
}
@GetMapping("/randomWallpaper/setKey")
public RandomWallpaperResponse getRandomWallpaperSetKey(RandomWallpaperParams randomWallpaperParams) {
RandomWallpaperResponse resultResponse;
QiApiClient qiApiClient = new QiApiClient("7052a8594339a519e0ba5eb04a267a60", "d8d6df60ab209385a09ac796f1dfe3e1");
try {
RandomWallpaperRequest randomWallpaperRequest = new RandomWallpaperRequest();
randomWallpaperRequest.setRequestParams(randomWallpaperParams);
resultResponse = apiService.getRandomWallpaper(qiApiClient, randomWallpaperRequest);
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return resultResponse;
}
@GetMapping("/randomWallpaper")
public RandomWallpaperResponse getRandomWallpaper(RandomWallpaperParams randomWallpaperParams) {
RandomWallpaperResponse resultResponse;
try {
RandomWallpaperRequest randomWallpaperRequest = new RandomWallpaperRequest();
randomWallpaperRequest.setRequestParams(randomWallpaperParams);
resultResponse = apiService.getRandomWallpaper(randomWallpaperRequest);
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return resultResponse;
}
@GetMapping("/randomWallpaper/easyWeb")
public BaseResponse<RandomWallpaperResponse> getRandomWallpaperEasyWeb(RandomWallpaperParams randomWallpaperParams) {
RandomWallpaperResponse resultResponse;
try {
RandomWallpaperRequest randomWallpaperRequest = new RandomWallpaperRequest();
randomWallpaperRequest.setRequestParams(randomWallpaperParams);
resultResponse = apiService.getRandomWallpaper(randomWallpaperRequest);
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return ResultUtils.success(resultResponse);
}
}