초기커밋
This commit is contained in:
282
UGQApiServer/Converter/UGQConveter.cs
Normal file
282
UGQApiServer/Converter/UGQConveter.cs
Normal file
@@ -0,0 +1,282 @@
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
using UGQDataAccess.Repository.Models;
|
||||
using UGQApiServer.Models;
|
||||
using UGQDatabase.Models;
|
||||
using UGQApiServer.Storage;
|
||||
using UGQApiServer.UGQData;
|
||||
using UGQDataAccess.Service;
|
||||
|
||||
|
||||
namespace UGQApiServer.Converter;
|
||||
|
||||
|
||||
public static class UGQConverter
|
||||
{
|
||||
static IStorageService _storageService = null!;
|
||||
static UGQMetaData _ugqMetadata = null!;
|
||||
|
||||
public static void init(IStorageService storageService, UGQMetaData ugqMetadata)
|
||||
{
|
||||
_storageService = storageService;
|
||||
_ugqMetadata = ugqMetadata;
|
||||
}
|
||||
|
||||
public static UGQText ToDTO(this TextEntity entity)
|
||||
{
|
||||
return new UGQText
|
||||
{
|
||||
Kr = entity.Kr,
|
||||
En = entity.En,
|
||||
Jp = entity.Jp,
|
||||
};
|
||||
}
|
||||
|
||||
public static UGQTask ToDTO(this TaskEntity entity, LangEnum langEnum)
|
||||
{
|
||||
return new UGQTask
|
||||
{
|
||||
GoalText = entity.GoalText.ToDTO(),
|
||||
ActionId = entity.ActionId,
|
||||
ActionValue = entity.ActionValue,
|
||||
IsShowNpcLocation = entity.IsShowNpcLocation,
|
||||
UgcActionValueGuid = entity.UgcActionValueGuid,
|
||||
UgcActionValueName = entity.UgcActionValueName,
|
||||
DialogId = entity.DialogId,
|
||||
|
||||
ActionName = _ugqMetadata.getTaskActionName(entity.ActionId, langEnum),
|
||||
ActionValueName = _ugqMetadata.getTaskActionValueName(entity.ActionId, entity.ActionValue, langEnum),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static UGQAccount ToDTO(this AccountEntity entity)
|
||||
{
|
||||
return new UGQAccount
|
||||
{
|
||||
UserGuid = entity.UserGuid,
|
||||
Nickname = entity.Nickname,
|
||||
AccountId = entity.AccountId ?? "",
|
||||
SlotCount = (MetaHelper.GameConfigMeta.UGQDefaultSlot + entity.AdditionalSlotCount),
|
||||
GradeType = entity.GradeType,
|
||||
CreatorPoint = entity.CreatorPoint,
|
||||
};
|
||||
}
|
||||
|
||||
public static UGQAccountItem ToDTO(this AccountItemResult entity)
|
||||
{
|
||||
return new UGQAccountItem
|
||||
{
|
||||
UserGuid = entity.UserGuid,
|
||||
Nickname = entity.Nickname,
|
||||
AccountId = entity.AccountId ?? "",
|
||||
SlotCount = (MetaHelper.GameConfigMeta.UGQDefaultSlot + entity.AdditionalSlotCount),
|
||||
GradeType = entity.GradeType,
|
||||
CreatorPoint = entity.CreatorPoint,
|
||||
QuestCount = entity.QuestCount,
|
||||
CreatedAt = entity.CreatedAt,
|
||||
};
|
||||
}
|
||||
|
||||
public static UGQQuestProfitStats ToDTO(this QuestProfitStatsItemResult result, LangEnum langEnum)
|
||||
{
|
||||
return new UGQQuestProfitStats
|
||||
{
|
||||
QuestContentId = result.QuestContentId,
|
||||
QuestId = result.QuestId,
|
||||
Revision = result.Revision,
|
||||
Title = result.Title.GetLangText(langEnum),
|
||||
TitleImagePath = _storageService.fileUrl(result.TitleImagePath),
|
||||
BannerImagePath = _storageService.fileUrl(result.BannerImagePath),
|
||||
Completed = result.CompletedCount,
|
||||
TotalProfit = result.TotalProfit,
|
||||
};
|
||||
}
|
||||
|
||||
public static UGQDialogSequenceAction ToDTO(this DialogSequenceActionEntity entity, LangEnum langEnum)
|
||||
{
|
||||
return new UGQDialogSequenceAction
|
||||
{
|
||||
Talker = entity.Talker,
|
||||
Type = entity.Type,
|
||||
Talk = entity.Talk.ToDTO(),
|
||||
Condition = entity.Condition,
|
||||
ConditionValue = entity.ConditionValue,
|
||||
NextSequence = entity.NextSequence,
|
||||
NpcAction = entity.NpcAction,
|
||||
|
||||
TypeName = _ugqMetadata.getDialogTypeName(entity.Type, langEnum),
|
||||
ConditioneName = _ugqMetadata.getDialogConditionName(entity.Type, entity.Condition, langEnum),
|
||||
ConditioneValueName = _ugqMetadata.getDialogConditionValueName(entity.Type, entity.Condition, entity.ConditionValue, langEnum),
|
||||
};
|
||||
}
|
||||
|
||||
public static UGQDialogSequence ToDTO(this DialogSequenceEntity entity, LangEnum langEnum)
|
||||
{
|
||||
return new UGQDialogSequence
|
||||
{
|
||||
SequenceId = entity.SequenceId,
|
||||
Actions = entity.Actions.Select(x => x.ToDTO(langEnum)).ToList(),
|
||||
};
|
||||
}
|
||||
|
||||
public static UGQPresetImage ToDTO(this UGQPresetImageMetaData data)
|
||||
{
|
||||
return new UGQPresetImage
|
||||
{
|
||||
Id = data.Id,
|
||||
ImagePath = _storageService.fileUrl(data.FileName),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static UGQSummary ToDTO(this SummaryItemResult result, LangEnum langEnum)
|
||||
{
|
||||
string beaconName = "";
|
||||
|
||||
if (result.BeaconId != 0)
|
||||
beaconName = _ugqMetadata.getBeaconName(result.BeaconId, langEnum);
|
||||
else if (result.UgcBeaconNickname != null)
|
||||
beaconName = result.UgcBeaconNickname;
|
||||
|
||||
return new UGQSummary
|
||||
{
|
||||
QuestContentId = result.QuestContentId,
|
||||
QuestId = result.QuestId,
|
||||
Revision = result.Revision,
|
||||
|
||||
UserGuid = result.UserGuid,
|
||||
Author = result.Author,
|
||||
|
||||
BeaconId = result.BeaconId,
|
||||
UgcBeaconGuid = result.UgcBeaconGuid,
|
||||
|
||||
GradeType = result.GradeType,
|
||||
|
||||
Title = result.Title.GetLangText(Culture.ToLangEnum(result.Savelanguage)),
|
||||
Languages = ConverterCommon.buildLanguages(result.Title),
|
||||
TitleImagePath = _storageService.fileUrl(result.TitleImagePath),
|
||||
BannerImagePath = _storageService.fileUrl(result.BannerImagePath),
|
||||
Description = result.Description.GetLangText(Culture.ToLangEnum(result.Savelanguage)),
|
||||
State = result.State,
|
||||
Cost = result.Cost,
|
||||
UpdatedAt = result.UpdatedAt,
|
||||
CreatedAt = result.CreatedAt,
|
||||
Savelanguage = result.Savelanguage,
|
||||
|
||||
Stats = new UGQStats
|
||||
{
|
||||
Accepted = result.AcceptedCount,
|
||||
Completed = result.CompletedCount,
|
||||
Like = result.LikeCount,
|
||||
Bookmark = result.BookmarkCount,
|
||||
Report = result.ReportCount,
|
||||
TotalProfit = result.TotalProfit,
|
||||
},
|
||||
|
||||
BeaconName = beaconName,
|
||||
};
|
||||
}
|
||||
|
||||
public static UGQContent ToDTO(this QuestContentEntity entity, LangEnum langEnum)
|
||||
{
|
||||
string beaconName = "";
|
||||
|
||||
if (entity.BeaconId != 0)
|
||||
beaconName = _ugqMetadata.getBeaconName(entity.BeaconId, langEnum);
|
||||
else if (entity.UgcBeaconNickname != null)
|
||||
beaconName = entity.UgcBeaconNickname;
|
||||
|
||||
return new UGQContent
|
||||
{
|
||||
QuestContentId = entity.Id,
|
||||
QuestId = entity.QuestId,
|
||||
Revision = entity.Revision,
|
||||
BeaconId = entity.BeaconId,
|
||||
UgcBeaconGuid = entity.UgcBeaconGuid,
|
||||
|
||||
GradeType = entity.GradeType,
|
||||
Title = entity.Title.ToDTO(),
|
||||
Languages = ConverterCommon.buildLanguages(entity.Title),
|
||||
TitleImagePath = _storageService.fileUrl(entity.TitleImagePath),
|
||||
BannerImagePath = _storageService.fileUrl(entity.BannerImagePath),
|
||||
Description = entity.Description.ToDTO(),
|
||||
State = entity.State,
|
||||
Cost = entity.Cost,
|
||||
Tasks = entity.Tasks.Select(x => x.ToDTO(langEnum)).ToList(),
|
||||
LastUpdated = entity.UpdatedAt,
|
||||
|
||||
BeaconName = beaconName,
|
||||
};
|
||||
}
|
||||
|
||||
public static UGQDialog ToDTO(this QuestDialogEntity entity, LangEnum langEnum)
|
||||
{
|
||||
return new UGQDialog
|
||||
{
|
||||
DialogId = entity.Id,
|
||||
Sequences = entity.Sequences.Select(x => x.ToDTO(langEnum)).ToList(),
|
||||
};
|
||||
}
|
||||
|
||||
public static UGQCreatorPointHistory ToDTO(this CreatorPointHistoryEntity entity, LangEnum langEnum)
|
||||
{
|
||||
return new UGQCreatorPointHistory
|
||||
{
|
||||
Kind = entity.Kind,
|
||||
Amount = entity.Amount,
|
||||
TotalAmount = entity.TotalAmount,
|
||||
CreatedAt = entity.CreatedAt,
|
||||
};
|
||||
}
|
||||
|
||||
public static UGQCreatorPointHistoryResult ToDTO(this CreatorPointHistoryQueryResult result, LangEnum langEnum)
|
||||
{
|
||||
return new UGQCreatorPointHistoryResult
|
||||
{
|
||||
PageNumber = result.PageNumber,
|
||||
PageSize = result.PageSize,
|
||||
TotalPages = result.TotalPages,
|
||||
Items = result.Items.Select(x => x.ToDTO(langEnum)).ToList(),
|
||||
};
|
||||
}
|
||||
|
||||
public static UGQReserveAccountGradeResult ToDTO(this ReserveAccountGradeEntity entity)
|
||||
{
|
||||
return new UGQReserveAccountGradeResult
|
||||
{
|
||||
ReserveId = entity.Id.ToString(),
|
||||
UserGuid = entity.UserGuid,
|
||||
CurrentGradeType = entity.BeforeGradeType,
|
||||
ReserveGradeType = entity.ReserveGradeType,
|
||||
ReserveTime = entity.ReserveTime,
|
||||
UpdatedAt = entity.UpdatedAt,
|
||||
IsCompleted = entity.IsCompleted,
|
||||
};
|
||||
}
|
||||
|
||||
public static UGQReserveAccountGradeResult ToDTO(this ReserveAccountGradeItemResult entity)
|
||||
{
|
||||
return new UGQReserveAccountGradeResult
|
||||
{
|
||||
ReserveId = entity.ReserveId,
|
||||
UserGuid = entity.UserGuid,
|
||||
AccountId = entity.AccountId,
|
||||
CurrentGradeType = entity.CurrentGradeType,
|
||||
ReserveGradeType = entity.ReserveGradeType,
|
||||
ReserveTime = entity.ReserveTime,
|
||||
UpdatedAt = entity.UpdatedAt,
|
||||
IsCompleted = entity.IsCompleted,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user