This commit is contained in:
@@ -75,7 +75,7 @@ public class HandlerConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Map<Integer, RequestHandler> internalHandlers(
|
public Map<Integer, RequestHandler> internalInfoHandler(
|
||||||
StatisticComplaintHandler statisticComplaintHandler,
|
StatisticComplaintHandler statisticComplaintHandler,
|
||||||
StatisticUserFilesHandler statisticUserHandler,
|
StatisticUserFilesHandler statisticUserHandler,
|
||||||
StatisticTariffInfoFileHandler statisticTariffInfoFileHandler,
|
StatisticTariffInfoFileHandler statisticTariffInfoFileHandler,
|
||||||
@@ -86,7 +86,6 @@ public class HandlerConfig {
|
|||||||
StatisticTokenHandler statisticTokenHandler,
|
StatisticTokenHandler statisticTokenHandler,
|
||||||
StatisticIncomeHandler statisticIncomeHandler,
|
StatisticIncomeHandler statisticIncomeHandler,
|
||||||
MonitoringStatisticHandler monitoringStatisticHandler,
|
MonitoringStatisticHandler monitoringStatisticHandler,
|
||||||
ControlComplaintHandler controlComplaintHandler,
|
|
||||||
UserInfoHandler userInfoHandler
|
UserInfoHandler userInfoHandler
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -102,6 +101,18 @@ public class HandlerConfig {
|
|||||||
map.put(30026, statisticIncomeHandler);
|
map.put(30026, statisticIncomeHandler);
|
||||||
map.put(30027, monitoringStatisticHandler);
|
map.put(30027, monitoringStatisticHandler);
|
||||||
map.put(30029, statisticComplaintHandler);
|
map.put(30029, statisticComplaintHandler);
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Map<Integer, RequestHandler> internalControlHandler(
|
||||||
|
ControlComplaintHandler controlComplaintHandler,
|
||||||
|
UserInfoHandler userInfoHandler
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Map<Integer, RequestHandler> map = new HashMap<>();
|
||||||
|
map.put(30014, userInfoHandler);
|
||||||
map.put(30030, controlComplaintHandler);
|
map.put(30030, controlComplaintHandler);
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ public class ApiController {
|
|||||||
|
|
||||||
private final Map<Integer, RequestHandler> handlers;
|
private final Map<Integer, RequestHandler> handlers;
|
||||||
|
|
||||||
private final Map<Integer, RequestHandler> internalHandlers;
|
private final Map<Integer, RequestHandler> internalInfoHandler;
|
||||||
|
|
||||||
|
private final Map<Integer, RequestHandler> internalControlHandler;
|
||||||
|
|
||||||
private final FileEntityService fileEntityService;
|
private final FileEntityService fileEntityService;
|
||||||
|
|
||||||
@@ -128,11 +130,40 @@ public class ApiController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/internal/data")
|
@PostMapping("/internal/data-info")
|
||||||
public ResponseEntity<?> handleInternalPostRequest(@RequestBody BaseRequest request) {
|
public ResponseEntity<?> handleInternalInfoPostRequest(@RequestBody BaseRequest request) {
|
||||||
Integer msgId = request.getMsgId();
|
Integer msgId = request.getMsgId();
|
||||||
BaseResponse response;
|
BaseResponse response;
|
||||||
RequestHandler internalHandler = internalHandlers.get(msgId);
|
RequestHandler internalHandler = internalInfoHandler.get(msgId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (internalHandler == null) {
|
||||||
|
response = new BaseResponse(msgId,
|
||||||
|
MessageCode.MSG_ID_NOT_FOUND.getCode(),
|
||||||
|
MessageCode.MSG_ID_NOT_FOUND.getDescription(),
|
||||||
|
new HashMap<>());
|
||||||
|
} else {
|
||||||
|
response = internalHandler.handle(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.ok().body(response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Handler execution failed for msgId: {}", msgId, e);
|
||||||
|
|
||||||
|
BaseResponse errorResponse = new BaseResponse(msgId,
|
||||||
|
MessageCode.INVALID_JSON_BODY.getCode(),
|
||||||
|
MessageCode.INVALID_JSON_BODY.getDescription(),
|
||||||
|
new HashMap<>());
|
||||||
|
|
||||||
|
return ResponseEntity.ok().body(errorResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/internal/data-control")
|
||||||
|
public ResponseEntity<?> handleInternalControlPostRequest(@RequestBody BaseRequest request) {
|
||||||
|
Integer msgId = request.getMsgId();
|
||||||
|
BaseResponse response;
|
||||||
|
RequestHandler internalHandler = internalControlHandler.get(msgId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (internalHandler == null) {
|
if (internalHandler == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user