Protocol: Echelon_List

This commit is contained in:
game4353 2024-05-28 21:28:13 +08:00
parent 1da6abb46f
commit c8a1d72e2a
1 changed files with 14 additions and 19 deletions

View File

@ -6,37 +6,32 @@ using SCHALE.GameServer.Services;
namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{ {
public class Echelon : ProtocolHandlerBase public class Echelon(
IProtocolHandlerFactory protocolHandlerFactory,
ISessionKeyService _sessionKeyService,
SCHALEContext _context,
ExcelTableService _excelTableService
) : ProtocolHandlerBase(protocolHandlerFactory)
{ {
private readonly ISessionKeyService sessionKeyService; private readonly ISessionKeyService sessionKeyService = _sessionKeyService;
private readonly SCHALEContext context; private readonly SCHALEContext context = _context;
private readonly ExcelTableService excelTableService; private readonly ExcelTableService excelTableService = _excelTableService;
public Echelon(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context, ExcelTableService _excelTableService) : base(protocolHandlerFactory)
{
sessionKeyService = _sessionKeyService;
context = _context;
excelTableService = _excelTableService;
}
[ProtocolHandler(Protocol.Echelon_List)] [ProtocolHandler(Protocol.Echelon_List)]
public ResponsePacket ListHandler(EchelonListRequest req) public ResponsePacket ListHandler(EchelonListRequest req)
{ {
var account = sessionKeyService.GetAccount(req.SessionKey); var account = sessionKeyService.GetAccount(req.SessionKey);
return new EchelonListResponse() return new EchelonListResponse() { EchelonDBs = [.. account.Echelons] };
{
EchelonDBs = account.Echelons.ToList()
};
} }
[ProtocolHandler(Protocol.Echelon_Save)] [ProtocolHandler(Protocol.Echelon_Save)]
public ResponsePacket SaveHandler(EchelonSaveRequest req) public ResponsePacket SaveHandler(EchelonSaveRequest req)
{ {
return new EchelonSaveResponse() var db = req.EchelonDB;
{ context.Echelons.Add(db);
EchelonDB = req.EchelonDB, context.SaveChanges();
}; return new EchelonSaveResponse() { EchelonDB = db, };
} }
} }
} }