10 12 25
Переименовал классы в один стиль
This commit is contained in:
parent
7072882b0b
commit
7f91c60d26
@ -5,10 +5,10 @@ import server.logic.ws_protocol.JSON.entyties.Auth.Net_AuthChallenge_Request;
|
||||
import server.logic.ws_protocol.JSON.entyties.Auth.Net_CreateAuthSession_Request;
|
||||
import server.logic.ws_protocol.JSON.entyties.Auth.Net_RefreshSession_Request;
|
||||
import server.logic.ws_protocol.JSON.handlers.*;
|
||||
import server.logic.ws_protocol.JSON.entyties.tempToTest.NetAddUserRequest;
|
||||
import server.logic.ws_protocol.JSON.entyties.tempToTest.Net_AddUser_Request;
|
||||
import server.logic.ws_protocol.JSON.handlers.auth.Net_CreateAuthSession__Handler;
|
||||
import server.logic.ws_protocol.JSON.handlers.auth.Net_RefreshSession_Handler;
|
||||
import server.logic.ws_protocol.JSON.handlers.tempToTest.NetAddUserHandler;
|
||||
import server.logic.ws_protocol.JSON.handlers.tempToTest.Net_AddUser_Handler;
|
||||
import server.logic.ws_protocol.JSON.handlers.auth.Net_AuthChallenge_Handler;
|
||||
|
||||
import java.util.Map;
|
||||
@ -26,15 +26,15 @@ public final class JsonHandlerRegistry {
|
||||
|
||||
private static final Map<String, JsonMessageHandler> HANDLERS = Map.of(
|
||||
"RefreshSession", new Net_RefreshSession_Handler(),
|
||||
"AddUser", new NetAddUserHandler(),
|
||||
"AddUser", new Net_AddUser_Handler(),
|
||||
"AuthChallenge", new Net_AuthChallenge_Handler(),
|
||||
"CreateAuthSession", new Net_CreateAuthSession__Handler()
|
||||
// сюда потом добавишь другие операции
|
||||
);
|
||||
|
||||
private static final Map<String, Class<? extends NetRequest>> REQUEST_TYPES = Map.of(
|
||||
private static final Map<String, Class<? extends Net_Request>> REQUEST_TYPES = Map.of(
|
||||
"RefreshSession", Net_RefreshSession_Request.class,
|
||||
"AddUser", NetAddUserRequest.class,
|
||||
"AddUser", Net_AddUser_Request.class,
|
||||
"AuthChallenge", Net_AuthChallenge_Request.class,
|
||||
"CreateAuthSession", Net_CreateAuthSession_Request.class
|
||||
);
|
||||
@ -47,7 +47,7 @@ public final class JsonHandlerRegistry {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static Map<String, Class<? extends NetRequest>> getRequestTypes() {
|
||||
public static Map<String, Class<? extends Net_Request>> getRequestTypes() {
|
||||
return REQUEST_TYPES;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,9 +6,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.logic.ws_protocol.JSON.entyties.NetExceptionResponse;
|
||||
import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
import server.logic.ws_protocol.JSON.entyties.NetResponse;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Exception_Response;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Request;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Response;
|
||||
import server.logic.ws_protocol.JSON.handlers.JsonMessageHandler;
|
||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||
import server.logic.ws_protocol.WireCodes;
|
||||
@ -40,7 +40,7 @@ public final class JsonInboundProcessor {
|
||||
private static final Map<String, JsonMessageHandler> JSON_HANDLERS =
|
||||
JsonHandlerRegistry.getHandlers();
|
||||
|
||||
private static final Map<String, Class<? extends NetRequest>> JSON_REQUEST_TYPES =
|
||||
private static final Map<String, Class<? extends Net_Request>> JSON_REQUEST_TYPES =
|
||||
JsonHandlerRegistry.getRequestTypes();
|
||||
|
||||
private JsonInboundProcessor() {
|
||||
@ -53,7 +53,7 @@ public final class JsonInboundProcessor {
|
||||
|
||||
try {
|
||||
if (json == null || json.isBlank()) {
|
||||
NetExceptionResponse err = NetExceptionResponseFactory.error(
|
||||
Net_Exception_Response err = NetExceptionResponseFactory.error(
|
||||
null,
|
||||
null,
|
||||
WireCodes.Status.BAD_REQUEST,
|
||||
@ -71,7 +71,7 @@ public final class JsonInboundProcessor {
|
||||
requestId = getTextOrNull(root, "requestId");
|
||||
|
||||
if (op == null || op.isEmpty()) {
|
||||
NetExceptionResponse err = NetExceptionResponseFactory.error(
|
||||
Net_Exception_Response err = NetExceptionResponseFactory.error(
|
||||
null,
|
||||
requestId,
|
||||
WireCodes.Status.BAD_REQUEST,
|
||||
@ -82,10 +82,10 @@ public final class JsonInboundProcessor {
|
||||
}
|
||||
|
||||
JsonMessageHandler handler = JSON_HANDLERS.get(op);
|
||||
Class<? extends NetRequest> reqClass = JSON_REQUEST_TYPES.get(op);
|
||||
Class<? extends Net_Request> reqClass = JSON_REQUEST_TYPES.get(op);
|
||||
|
||||
if (handler == null || reqClass == null) {
|
||||
NetExceptionResponse err = NetExceptionResponseFactory.error(
|
||||
Net_Exception_Response err = NetExceptionResponseFactory.error(
|
||||
op,
|
||||
requestId,
|
||||
WireCodes.Status.BAD_REQUEST,
|
||||
@ -98,7 +98,7 @@ public final class JsonInboundProcessor {
|
||||
// 3. Берём payload
|
||||
JsonNode payloadNode = root.get("payload");
|
||||
if (payloadNode == null || payloadNode.isNull()) {
|
||||
NetExceptionResponse err = NetExceptionResponseFactory.error(
|
||||
Net_Exception_Response err = NetExceptionResponseFactory.error(
|
||||
op,
|
||||
requestId,
|
||||
WireCodes.Status.BAD_REQUEST,
|
||||
@ -108,7 +108,7 @@ public final class JsonInboundProcessor {
|
||||
return writeResponse(err);
|
||||
}
|
||||
if (!payloadNode.isObject()) {
|
||||
NetExceptionResponse err = NetExceptionResponseFactory.error(
|
||||
Net_Exception_Response err = NetExceptionResponseFactory.error(
|
||||
op,
|
||||
requestId,
|
||||
WireCodes.Status.BAD_REQUEST,
|
||||
@ -134,16 +134,16 @@ public final class JsonInboundProcessor {
|
||||
merged.setAll((ObjectNode) payloadNode);
|
||||
|
||||
// 4. Маппим в конкретный класс NetRequest
|
||||
NetRequest request = JSON_MAPPER.treeToValue(merged, reqClass);
|
||||
Net_Request request = JSON_MAPPER.treeToValue(merged, reqClass);
|
||||
|
||||
NetResponse response;
|
||||
Net_Response response;
|
||||
|
||||
// 5. Вызываем хэндлер
|
||||
try {
|
||||
response = handler.handle(request, ctx);
|
||||
} catch (Exception handlerError) {
|
||||
log.error("💥 Ошибка внутри хэндлера '{}'", op, handlerError);
|
||||
NetExceptionResponse err = NetExceptionResponseFactory.error(
|
||||
Net_Exception_Response err = NetExceptionResponseFactory.error(
|
||||
op,
|
||||
requestId,
|
||||
WireCodes.Status.INTERNAL_ERROR,
|
||||
@ -162,7 +162,7 @@ public final class JsonInboundProcessor {
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Ошибка при обработке JSON-сообщения", e);
|
||||
NetExceptionResponse err = NetExceptionResponseFactory.error(
|
||||
Net_Exception_Response err = NetExceptionResponseFactory.error(
|
||||
op != null ? op : "Unknown",
|
||||
requestId,
|
||||
WireCodes.Status.INTERNAL_ERROR,
|
||||
@ -189,7 +189,7 @@ public final class JsonInboundProcessor {
|
||||
* "payload": { ... }
|
||||
* }
|
||||
*/
|
||||
private static String writeResponse(NetResponse response) {
|
||||
private static String writeResponse(Net_Response response) {
|
||||
try {
|
||||
// Конвертируем полный объект ответа в ObjectNode
|
||||
ObjectNode full = JSON_MAPPER.convertValue(response, ObjectNode.class);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package server.logic.ws_protocol.JSON.entyties.Auth;
|
||||
|
||||
import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Request;
|
||||
|
||||
/**
|
||||
* Шаг 1 авторизации: запрос выдачи временного пароля сессии (sessionPwd).
|
||||
@ -27,7 +27,7 @@ import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
public class Net_AuthChallenge_Request extends NetRequest {
|
||||
public class Net_AuthChallenge_Request extends Net_Request {
|
||||
|
||||
/**
|
||||
* Логин пользователя, для которого запускается авторизация.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package server.logic.ws_protocol.JSON.entyties.Auth;
|
||||
|
||||
import server.logic.ws_protocol.JSON.entyties.NetResponse;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Response;
|
||||
|
||||
/**
|
||||
* Ответ на AuthChallenge.
|
||||
@ -19,7 +19,7 @@ import server.logic.ws_protocol.JSON.entyties.NetResponse;
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
public class Net_AuthChallenge_Response extends NetResponse {
|
||||
public class Net_AuthChallenge_Response extends Net_Response {
|
||||
|
||||
/**
|
||||
* Одноразовый nonce для авторификации.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package server.logic.ws_protocol.JSON.entyties.Auth;
|
||||
|
||||
import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Request;
|
||||
|
||||
/**
|
||||
* Шаг 2 авторизации: подтверждение владения ключом и установка сессии.
|
||||
@ -28,7 +28,7 @@ import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
public class Net_CreateAuthSession_Request extends NetRequest {
|
||||
public class Net_CreateAuthSession_Request extends Net_Request {
|
||||
|
||||
/** Клиентский пароль для хранения данных (base64 от 32 байт). */
|
||||
private String storagePwd;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package server.logic.ws_protocol.JSON.entyties.Auth;
|
||||
|
||||
import server.logic.ws_protocol.JSON.entyties.NetResponse;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Response;
|
||||
|
||||
/**
|
||||
* Ответ на CreateAuthSession.
|
||||
@ -19,7 +19,7 @@ import server.logic.ws_protocol.JSON.entyties.NetResponse;
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
public class Net_CreateAuthSession_Response extends NetResponse {
|
||||
public class Net_CreateAuthSession_Response extends Net_Response {
|
||||
|
||||
/** Идентификатор сессии, base64 от 32 байт. */
|
||||
private String sessionId;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package server.logic.ws_protocol.JSON.entyties.Auth;
|
||||
|
||||
import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Request;
|
||||
|
||||
/**
|
||||
* Запрос RefreshSession.
|
||||
@ -15,7 +15,7 @@ import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
* "clientInfo": "до 50 символов, краткая строка об устройстве"
|
||||
* }
|
||||
*/
|
||||
public class Net_RefreshSession_Request extends NetRequest {
|
||||
public class Net_RefreshSession_Request extends Net_Request {
|
||||
|
||||
private String sessionId;
|
||||
private String sessionPwd;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package server.logic.ws_protocol.JSON.entyties.Auth;
|
||||
|
||||
import server.logic.ws_protocol.JSON.entyties.NetResponse;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Response;
|
||||
|
||||
/**
|
||||
* Успешный ответ на RefreshSession.
|
||||
@ -18,7 +18,7 @@ import server.logic.ws_protocol.JSON.entyties.NetResponse;
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
public class Net_RefreshSession_Response extends NetResponse {
|
||||
public class Net_RefreshSession_Response extends Net_Response {
|
||||
|
||||
/** Пароль хранилища, сохранённый в сессии (storagePwd). */
|
||||
private String storagePwd;
|
||||
|
||||
@ -33,8 +33,7 @@ Net_RefreshSession_Request — обновление / продление
|
||||
|
||||
план что сделать
|
||||
|
||||
Додумать названия что бы было общее новое приветствие ( и поле назвать число для проверки а не пароль )
|
||||
или от него или новая сессия (и плюс в ней новый пароль передавать)
|
||||
или получить список сесссий
|
||||
или удалить сессию
|
||||
И добавить хранимую инфу по сессии
|
||||
получить список сесссий
|
||||
и удалить сессию
|
||||
|
||||
при новом подключении или при активной сесии
|
||||
|
||||
@ -10,7 +10,7 @@ package server.logic.ws_protocol.JSON.entyties;
|
||||
* "payload": { ... }
|
||||
* }
|
||||
*/
|
||||
public abstract class NetEvent {
|
||||
public abstract class Net_Event {
|
||||
|
||||
/** Имя операции / события (op). */
|
||||
private String op;
|
||||
@ -9,7 +9,7 @@ package server.logic.ws_protocol.JSON.entyties;
|
||||
* "message": "..."
|
||||
* }
|
||||
*/
|
||||
public class NetExceptionResponse extends NetResponse {
|
||||
public class Net_Exception_Response extends Net_Response {
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
@ -12,7 +12,7 @@ package server.logic.ws_protocol.JSON.entyties;
|
||||
* "payload": { ... }
|
||||
* }
|
||||
*/
|
||||
public abstract class NetRequest extends NetEvent {
|
||||
public abstract class Net_Request extends Net_Event {
|
||||
|
||||
/** Идентификатор запроса, чтобы связать запрос и ответ. */
|
||||
private String requestId;
|
||||
@ -13,7 +13,7 @@ package server.logic.ws_protocol.JSON.entyties;
|
||||
* "payload": { ... } // и для успеха, и для ошибки
|
||||
* }
|
||||
*/
|
||||
public abstract class NetResponse extends NetRequest {
|
||||
public abstract class Net_Response extends Net_Request {
|
||||
|
||||
/** Статус результата (200 — успех, любое другое значение — ошибка). */
|
||||
private int status;
|
||||
@ -1,6 +1,6 @@
|
||||
package server.logic.ws_protocol.JSON.entyties.tempToTest;
|
||||
|
||||
import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Request;
|
||||
|
||||
/**
|
||||
* Запрос AddUser — временная/тестовая регистрация локального пользователя.
|
||||
@ -22,7 +22,7 @@ import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
*
|
||||
* Все поля лежат внутри payload.
|
||||
*/
|
||||
public class NetAddUserRequest extends NetRequest {
|
||||
public class Net_AddUser_Request extends Net_Request {
|
||||
|
||||
private String login;
|
||||
private long loginId;
|
||||
@ -1,6 +1,6 @@
|
||||
package server.logic.ws_protocol.JSON.entyties.tempToTest;
|
||||
|
||||
import server.logic.ws_protocol.JSON.entyties.NetResponse;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Response;
|
||||
|
||||
/**
|
||||
* Успешный ответ на AddUser.
|
||||
@ -15,6 +15,6 @@ import server.logic.ws_protocol.JSON.entyties.NetResponse;
|
||||
* "payload": { }
|
||||
* }
|
||||
*/
|
||||
public class NetAddUserResponse extends NetResponse {
|
||||
public class Net_AddUser_Response extends Net_Response {
|
||||
// При необходимости сюда можно добавить, например, флаг created/updated и т.п.
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
package server.logic.ws_protocol.JSON.handlers;
|
||||
|
||||
import server.logic.ws_protocol.JSON.ConnectionContext;
|
||||
import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
import server.logic.ws_protocol.JSON.entyties.NetResponse;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Request;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Response;
|
||||
|
||||
/**
|
||||
* Общий интерфейс для всех JSON-хэндлеров.
|
||||
@ -15,5 +15,5 @@ public interface JsonMessageHandler {
|
||||
* @param request распарсенный запрос
|
||||
* @param ctx контекст текущего WebSocket-соединения
|
||||
*/
|
||||
NetResponse handle(NetRequest request, ConnectionContext ctx) throws Exception;
|
||||
Net_Response handle(Net_Request request, ConnectionContext ctx) throws Exception;
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ public class Net_AuthChallenge_Handler implements JsonMessageHandler {
|
||||
private static final SecureRandom RANDOM = new SecureRandom();
|
||||
|
||||
@Override
|
||||
public NetResponse handle(NetRequest baseReq, ConnectionContext ctx) throws Exception {
|
||||
public Net_Response handle(Net_Request baseReq, ConnectionContext ctx) throws Exception {
|
||||
|
||||
Net_AuthChallenge_Request req = (Net_AuthChallenge_Request) baseReq;
|
||||
|
||||
|
||||
@ -5,8 +5,8 @@ import org.slf4j.LoggerFactory;
|
||||
import server.logic.ws_protocol.JSON.ActiveConnectionsRegistry;
|
||||
import server.logic.ws_protocol.JSON.ConnectionContext;
|
||||
import server.logic.ws_protocol.JSON.entyties.Auth.Net_CreateAuthSession_Response;
|
||||
import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
import server.logic.ws_protocol.JSON.entyties.NetResponse;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Request;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Response;
|
||||
import server.logic.ws_protocol.JSON.entyties.Auth.Net_CreateAuthSession_Request;
|
||||
import server.logic.ws_protocol.JSON.handlers.JsonMessageHandler;
|
||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||
@ -53,7 +53,7 @@ public class Net_CreateAuthSession__Handler implements JsonMessageHandler {
|
||||
private static final long ALLOWED_SKEW_MS = 30_000L;
|
||||
|
||||
@Override
|
||||
public NetResponse handle(NetRequest baseReq, ConnectionContext ctx) throws Exception {
|
||||
public Net_Response handle(Net_Request baseReq, ConnectionContext ctx) throws Exception {
|
||||
Net_CreateAuthSession_Request req = (Net_CreateAuthSession_Request) baseReq;
|
||||
|
||||
// --- базовые проверки контекста ---
|
||||
|
||||
@ -6,8 +6,8 @@ import server.logic.ws_protocol.JSON.ActiveConnectionsRegistry;
|
||||
import server.logic.ws_protocol.JSON.ConnectionContext;
|
||||
import server.logic.ws_protocol.JSON.entyties.Auth.Net_RefreshSession_Request;
|
||||
import server.logic.ws_protocol.JSON.entyties.Auth.Net_RefreshSession_Response;
|
||||
import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
import server.logic.ws_protocol.JSON.entyties.NetResponse;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Request;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Response;
|
||||
import server.logic.ws_protocol.JSON.handlers.JsonMessageHandler;
|
||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||
import server.logic.ws_protocol.WireCodes;
|
||||
@ -37,7 +37,7 @@ public class Net_RefreshSession_Handler implements JsonMessageHandler {
|
||||
private static final int CLIENT_INFO_MAX_LEN = 50;
|
||||
|
||||
@Override
|
||||
public NetResponse handle(NetRequest request, ConnectionContext ctx) throws Exception {
|
||||
public Net_Response handle(Net_Request request, ConnectionContext ctx) throws Exception {
|
||||
Net_RefreshSession_Request req = (Net_RefreshSession_Request) request;
|
||||
|
||||
String sessionId = req.getSessionId();
|
||||
|
||||
@ -3,10 +3,10 @@ package server.logic.ws_protocol.JSON.handlers.tempToTest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.logic.ws_protocol.JSON.ConnectionContext;
|
||||
import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
import server.logic.ws_protocol.JSON.entyties.NetResponse;
|
||||
import server.logic.ws_protocol.JSON.entyties.tempToTest.NetAddUserRequest;
|
||||
import server.logic.ws_protocol.JSON.entyties.tempToTest.NetAddUserResponse;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Request;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Response;
|
||||
import server.logic.ws_protocol.JSON.entyties.tempToTest.Net_AddUser_Request;
|
||||
import server.logic.ws_protocol.JSON.entyties.tempToTest.Net_AddUser_Response;
|
||||
import server.logic.ws_protocol.JSON.handlers.JsonMessageHandler;
|
||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||
import server.logic.ws_protocol.WireCodes;
|
||||
@ -36,13 +36,13 @@ import java.sql.SQLException;
|
||||
* - пользователь сохраняется в таблицу solana_users;
|
||||
* - возвращается status=200 и пустой payload.
|
||||
*/
|
||||
public class NetAddUserHandler implements JsonMessageHandler {
|
||||
public class Net_AddUser_Handler implements JsonMessageHandler {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(NetAddUserHandler.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(Net_AddUser_Handler.class);
|
||||
|
||||
@Override
|
||||
public NetResponse handle(NetRequest baseRequest, ConnectionContext ctx) throws Exception {
|
||||
NetAddUserRequest req = (NetAddUserRequest) baseRequest;
|
||||
public Net_Response handle(Net_Request baseRequest, ConnectionContext ctx) throws Exception {
|
||||
Net_AddUser_Request req = (Net_AddUser_Request) baseRequest;
|
||||
|
||||
// Одна общая проверка всех ключевых полей
|
||||
if (req.getLogin() == null || req.getLogin().isBlank()
|
||||
@ -72,7 +72,7 @@ public class NetAddUserHandler implements JsonMessageHandler {
|
||||
|
||||
dao.insert(user);
|
||||
|
||||
NetAddUserResponse resp = new NetAddUserResponse();
|
||||
Net_AddUser_Response resp = new Net_AddUser_Response();
|
||||
resp.setOp(req.getOp());
|
||||
resp.setRequestId(req.getRequestId());
|
||||
resp.setStatus(WireCodes.Status.OK);
|
||||
@ -1,7 +1,7 @@
|
||||
package server.logic.ws_protocol.JSON.utils;
|
||||
|
||||
import server.logic.ws_protocol.JSON.entyties.NetExceptionResponse;
|
||||
import server.logic.ws_protocol.JSON.entyties.NetRequest;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Exception_Response;
|
||||
import server.logic.ws_protocol.JSON.entyties.Net_Request;
|
||||
|
||||
/**
|
||||
* Фабрика ошибок для JSON-протокола.
|
||||
@ -13,12 +13,12 @@ public final class NetExceptionResponseFactory {
|
||||
// запрет на создание объектов
|
||||
}
|
||||
|
||||
public static NetExceptionResponse error(NetRequest req,
|
||||
int status,
|
||||
String code,
|
||||
String message) {
|
||||
public static Net_Exception_Response error(Net_Request req,
|
||||
int status,
|
||||
String code,
|
||||
String message) {
|
||||
|
||||
NetExceptionResponse resp = new NetExceptionResponse();
|
||||
Net_Exception_Response resp = new Net_Exception_Response();
|
||||
resp.setOp(req.getOp());
|
||||
resp.setRequestId(req.getRequestId());
|
||||
resp.setStatus(status);
|
||||
@ -31,13 +31,13 @@ public final class NetExceptionResponseFactory {
|
||||
* Вариант для случаев, когда NetRequest ещё не распарсен,
|
||||
* но мы уже знаем op и requestId (или они null).
|
||||
*/
|
||||
public static NetExceptionResponse error(String op,
|
||||
String requestId,
|
||||
int status,
|
||||
String code,
|
||||
String message) {
|
||||
public static Net_Exception_Response error(String op,
|
||||
String requestId,
|
||||
int status,
|
||||
String code,
|
||||
String message) {
|
||||
|
||||
NetExceptionResponse resp = new NetExceptionResponse();
|
||||
Net_Exception_Response resp = new Net_Exception_Response();
|
||||
resp.setOp(op);
|
||||
resp.setRequestId(requestId);
|
||||
resp.setStatus(status);
|
||||
|
||||
@ -46,8 +46,8 @@ public class Test_AddUser_and_Authorification {
|
||||
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
|
||||
|
||||
// Тестовые данные пользователя
|
||||
private static final String TEST_LOGIN = "anya2";
|
||||
private static final long TEST_LOGIN_ID = 100120L;
|
||||
private static final String TEST_LOGIN = "anya24";
|
||||
private static final long TEST_LOGIN_ID = 1030120L;
|
||||
private static final long TEST_BCH_ID = 4222L;
|
||||
private static final int TEST_BCH_LIMIT = 1_000_000;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user