diff --git a/Api/Utility/Factory.cs b/Api/Utility/Factory.cs index 2a3fdfd..1949dc9 100644 --- a/Api/Utility/Factory.cs +++ b/Api/Utility/Factory.cs @@ -415,7 +415,7 @@ namespace Milimoe.FunGame.Core.Api.Utility if (drRoom != null) { long id = (long)drRoom[RoomQuery.Column_ID]; - string roomid = (string)drRoom[RoomQuery.Column_RoomID]; + string roomid = (string)drRoom[RoomQuery.Column_Roomid]; if (!DateTime.TryParse(drRoom[RoomQuery.Column_CreateTime].ToString(), out DateTime createTime)) { createTime = General.DefaultTime; @@ -450,7 +450,7 @@ namespace Milimoe.FunGame.Core.Api.Utility foreach (DataRow drRoom in dsRoom.Tables[0].Rows) { long Id = (long)drRoom[RoomQuery.Column_ID]; - string Roomid = (string)drRoom[RoomQuery.Column_RoomID]; + string Roomid = (string)drRoom[RoomQuery.Column_Roomid]; if (!DateTime.TryParse(drRoom[RoomQuery.Column_CreateTime].ToString(), out DateTime createTime)) { createTime = General.DefaultTime; diff --git a/Entity/User/UserProfile.cs b/Entity/User/UserProfile.cs index 6c34e27..0b9c0e4 100644 --- a/Entity/User/UserProfile.cs +++ b/Entity/User/UserProfile.cs @@ -42,6 +42,6 @@ namespace Milimoe.FunGame.Core.Entity /// /// 用户组 /// - public string Group { get; set; } = ""; + public string UserGroup { get; set; } = ""; } } diff --git a/Library/Common/JsonConverter/RoomConverter.cs b/Library/Common/JsonConverter/RoomConverter.cs index 1534f3c..c2d6c9c 100644 --- a/Library/Common/JsonConverter/RoomConverter.cs +++ b/Library/Common/JsonConverter/RoomConverter.cs @@ -21,7 +21,7 @@ namespace Milimoe.FunGame.Core.Library.Common.JsonConverter case RoomQuery.Column_ID: result.Id = reader.GetInt64(); break; - case RoomQuery.Column_RoomID: + case RoomQuery.Column_Roomid: result.Roomid = reader.GetString() ?? ""; break; case RoomQuery.Column_CreateTime: @@ -60,7 +60,7 @@ namespace Milimoe.FunGame.Core.Library.Common.JsonConverter { writer.WriteStartObject(); writer.WriteNumber(RoomQuery.Column_ID, value.Id); - writer.WriteString(RoomQuery.Column_RoomID, value.Roomid); + writer.WriteString(RoomQuery.Column_Roomid, value.Roomid); writer.WriteString(RoomQuery.Column_CreateTime, value.CreateTime.ToString(General.GeneralDateTimeFormat)); writer.WritePropertyName(RoomQuery.Column_RoomMaster); JsonSerializer.Serialize(writer, value.RoomMaster, options); diff --git a/Library/Constant/ConstantSet.cs b/Library/Constant/ConstantSet.cs index 6b89770..3807ff1 100644 --- a/Library/Constant/ConstantSet.cs +++ b/Library/Constant/ConstantSet.cs @@ -151,8 +151,6 @@ namespace Milimoe.FunGame.Core.Library.Constant /** * UserCenter */ - public const string UserCenter_GetUserProfile = "UserCenter::GetUserProfile"; - public const string UserCenter_GetUserStatistics = "UserCenter::GetUserStatistics"; public const string UserCenter_UpdateUser = "UserCenter::UpdateUser"; public const string UserCenter_UpdatePassword = "UserCenter::UpdatePassword"; public const string UserCenter_DailySignIn = "UserCenter::DailySignIn"; @@ -163,7 +161,7 @@ namespace Milimoe.FunGame.Core.Library.Constant public const string Inventory_GetMarket = "Inventory::GetMarket"; public const string Inventory_StoreBuy = "Inventory::StoreBuy"; public const string Inventory_MarketBuy = "Inventory::MarketBuy"; - public const string Inventory_GetInventory = "Inventory::GetInventory"; + public const string Inventory_UpdateInventory = "Inventory::UpdateInventory"; public const string Inventory_Use = "Inventory::Use"; public const string Inventory_StoreSell = "Inventory::StoreSell"; public const string Inventory_MarketSell = "Inventory::MarketSell"; @@ -200,8 +198,6 @@ namespace Milimoe.FunGame.Core.Library.Constant DataRequestType.Room_UpdateRoomSettings => Room_UpdateRoomSettings, DataRequestType.Room_GetRoomPlayerCount => Room_GetRoomPlayerCount, DataRequestType.Room_UpdateRoomMaster => Room_UpdateRoomMaster, - DataRequestType.UserCenter_GetUserProfile => UserCenter_GetUserProfile, - DataRequestType.UserCenter_GetUserStatistics => UserCenter_GetUserStatistics, DataRequestType.UserCenter_UpdateUser => UserCenter_UpdateUser, DataRequestType.UserCenter_UpdatePassword => UserCenter_UpdatePassword, DataRequestType.UserCenter_DailySignIn => UserCenter_DailySignIn, @@ -209,7 +205,7 @@ namespace Milimoe.FunGame.Core.Library.Constant DataRequestType.Inventory_GetMarket => Inventory_GetMarket, DataRequestType.Inventory_StoreBuy => Inventory_StoreBuy, DataRequestType.Inventory_MarketBuy => Inventory_MarketBuy, - DataRequestType.Inventory_GetInventory => Inventory_GetInventory, + DataRequestType.Inventory_UpdateInventory => Inventory_UpdateInventory, DataRequestType.Inventory_Use => Inventory_Use, DataRequestType.Inventory_StoreSell => Inventory_StoreSell, DataRequestType.Inventory_MarketSell => Inventory_MarketSell, diff --git a/Library/Constant/TypeEnum.cs b/Library/Constant/TypeEnum.cs index f9936f4..875a570 100644 --- a/Library/Constant/TypeEnum.cs +++ b/Library/Constant/TypeEnum.cs @@ -105,8 +105,6 @@ namespace Milimoe.FunGame.Core.Library.Constant Room_UpdateRoomSettings, Room_GetRoomPlayerCount, Room_UpdateRoomMaster, - UserCenter_GetUserProfile, - UserCenter_GetUserStatistics, UserCenter_UpdateUser, UserCenter_UpdatePassword, UserCenter_DailySignIn, @@ -114,7 +112,7 @@ namespace Milimoe.FunGame.Core.Library.Constant Inventory_GetMarket, Inventory_StoreBuy, Inventory_MarketBuy, - Inventory_GetInventory, + Inventory_UpdateInventory, Inventory_Use, Inventory_StoreSell, Inventory_MarketSell, diff --git a/Library/SQLScript/Entity/RoomQuery.cs b/Library/SQLScript/Entity/RoomQuery.cs index cef0b24..7ca520d 100644 --- a/Library/SQLScript/Entity/RoomQuery.cs +++ b/Library/SQLScript/Entity/RoomQuery.cs @@ -8,7 +8,7 @@ namespace Milimoe.FunGame.Core.Library.SQLScript.Entity { public const string TableName = "Rooms"; public const string Column_ID = "Id"; - public const string Column_RoomID = "Roomid"; + public const string Column_Roomid = "Roomid"; public const string Column_CreateTime = "CreateTime"; public const string Column_RoomMaster = "RoomMaster"; public const string Column_RoomMasterName = "RoomMasterName"; @@ -26,7 +26,7 @@ namespace Milimoe.FunGame.Core.Library.SQLScript.Entity public static string Select_IsExistRoom(SQLHelper SQLHelper, string Roomid) { SQLHelper.Parameters["@Roomid"] = Roomid; - return $"{Command_Select} {Command_All} {Command_From} {TableName} {Command_Where} {Column_RoomID} = @Roomid"; + return $"{Command_Select} {Command_All} {Command_From} {TableName} {Command_Where} {Column_Roomid} = @Roomid"; } public static string Select_RoomsByRoomState(SQLHelper SQLHelper, params RoomState[] States) @@ -83,7 +83,7 @@ namespace Milimoe.FunGame.Core.Library.SQLScript.Entity public static string Insert_CreateRoom(SQLHelper SQLHelper, string Roomid, long RoomMaster, RoomType RoomType, string GameModule, string GameMap, bool IsRank, string Password, int MaxUsers) { - Library.Constant.RoomState RoomState = Library.Constant.RoomState.Created; + RoomState RoomState = RoomState.Created; DateTime NowTime = DateTime.Now; bool HasPass = Password.Trim() != ""; @@ -99,24 +99,24 @@ namespace Milimoe.FunGame.Core.Library.SQLScript.Entity SQLHelper.Parameters["@Password"] = Password; SQLHelper.Parameters["@MaxUsers"] = MaxUsers; - return $"{Command_Insert} {Command_Into} {TableName} ({Column_RoomID}, {Column_CreateTime}, {Column_RoomMaster}, {Column_RoomType}, {Column_GameModule}, {Column_GameMap}, {Column_RoomState}, {Column_IsRank}, {Column_HasPass}, {Column_Password}, {Column_MaxUsers})" + + return $"{Command_Insert} {Command_Into} {TableName} ({Column_Roomid}, {Column_CreateTime}, {Column_RoomMaster}, {Column_RoomType}, {Column_GameModule}, {Column_GameMap}, {Column_RoomState}, {Column_IsRank}, {Column_HasPass}, {Column_Password}, {Column_MaxUsers})" + $" {Command_Values} (@Roomid, @CreateTime, @RoomMaster, @RoomType, @GameModule, @GameMap, @RoomState, @IsRank, @HasPass, @Password, @MaxUsers)"; } - public static string Delete_Rooms(SQLHelper SQLHelper, params string[] RoomIDs) + public static string Delete_Rooms(SQLHelper SQLHelper, params string[] Roomids) { - if (RoomIDs.Length != 0) + if (Roomids.Length != 0) { - string[] roomids = [.. RoomIDs.Distinct()]; - if (roomids.Length > 0) + Roomids = [.. Roomids.Distinct()]; + if (Roomids.Length > 0) { StringBuilder builder = new(); builder.Append($"{Command_Where} {Column_RoomState} {Command_In} ("); - for (int i = 0; i < roomids.Length; i++) + for (int i = 0; i < Roomids.Length; i++) { if (i > 0) builder.Append(", "); builder.Append($"@room{i}"); - SQLHelper.Parameters[$"@room{i}"] = roomids[i]; + SQLHelper.Parameters[$"@room{i}"] = Roomids[i]; } builder.AppendLine(")"); return $"{Command_Delete} {Command_From} {TableName} {builder}"; @@ -125,26 +125,26 @@ namespace Milimoe.FunGame.Core.Library.SQLScript.Entity return $"{Command_Delete} {Command_From} {TableName} {Command_Where} 1 = 0"; } - public static string Delete_QuitRoom(SQLHelper SQLHelper, string RoomID, long RoomMaster) + public static string Delete_QuitRoom(SQLHelper SQLHelper, string Roomid, long RoomMaster) { - SQLHelper.Parameters["@RoomID"] = RoomID; + SQLHelper.Parameters["@Roomid"] = Roomid; SQLHelper.Parameters["@RoomMaster"] = RoomMaster; - return $"{Command_Delete} {Command_From} {TableName} {Command_Where} {Column_RoomID} = @RoomID {Command_And} {Column_RoomMaster} = @RoomMaster"; + return $"{Command_Delete} {Command_From} {TableName} {Command_Where} {Column_Roomid} = @Roomid {Command_And} {Column_RoomMaster} = @RoomMaster"; } - public static string Update_QuitRoom(SQLHelper SQLHelper, string RoomID, long OldRoomMaster, long NewRoomMaster) + public static string Update_QuitRoom(SQLHelper SQLHelper, string Roomid, long OldRoomMaster, long NewRoomMaster) { - SQLHelper.Parameters["@RoomID"] = RoomID; + SQLHelper.Parameters["@Roomid"] = Roomid; SQLHelper.Parameters["@OldRoomMaster"] = OldRoomMaster; SQLHelper.Parameters["@NewRoomMaster"] = NewRoomMaster; - return $"{Command_Update} {TableName} {Command_Set} {Column_RoomMaster} = @NewRoomMaster {Command_Where} {Column_RoomID} = @Roomid {Command_And} {Column_RoomMaster} = @OldRoomMaster"; + return $"{Command_Update} {TableName} {Command_Set} {Column_RoomMaster} = @NewRoomMaster {Command_Where} {Column_Roomid} = @Roomid {Command_And} {Column_RoomMaster} = @OldRoomMaster"; } - public static string Update_UpdateRoomMaster(SQLHelper SQLHelper, string RoomID, long NewRoomMaster) + public static string Update_UpdateRoomMaster(SQLHelper SQLHelper, string Roomid, long NewRoomMaster) { - SQLHelper.Parameters["@RoomID"] = RoomID; + SQLHelper.Parameters["@Roomid"] = Roomid; SQLHelper.Parameters["@NewRoomMaster"] = NewRoomMaster; - return $"{Command_Update} {TableName} {Command_Set} {Column_RoomMaster} = @NewRoomMaster {Command_Where} {Column_RoomID} = @RoomID"; + return $"{Command_Update} {TableName} {Command_Set} {Column_RoomMaster} = @NewRoomMaster {Command_Where} {Column_Roomid} = @Roomid"; } } } diff --git a/Library/SQLScript/Entity/UserProfilesQuery.cs b/Library/SQLScript/Entity/UserProfilesQuery.cs new file mode 100644 index 0000000..8d81401 --- /dev/null +++ b/Library/SQLScript/Entity/UserProfilesQuery.cs @@ -0,0 +1,114 @@ +using Milimoe.FunGame.Core.Api.Transmittal; +using Milimoe.FunGame.Core.Library.Constant; + +namespace Milimoe.FunGame.Core.Library.SQLScript.Entity +{ + public class UserProfilesQuery : Constant + { + public const string TableName = "UserProfiles"; + public const string Column_UserId = "UserId"; + public const string Column_AvatarUrl = "AvatarUrl"; + public const string Column_Signature = "Signature"; + public const string Column_Gender = "Gender"; + public const string Column_BirthDay = "BirthDay"; + public const string Column_Followers = "Followers"; + public const string Column_Following = "Following"; + public const string Column_Title = "Title"; + public const string Column_UserGroup = "UserGroup"; + + public const string Select_UserProfiles = $"{Command_Select} {Command_All} {Command_From} {TableName}"; + + public static string Select_UserProfileByUserId(SQLHelper SQLHelper, long UserId) + { + SQLHelper.Parameters["@UserId"] = UserId; + return $"{Select_UserProfiles} {Command_Where} {Column_UserId} = @UserId"; + } + + public static string Insert_UserProfile(SQLHelper SQLHelper, long UserId) + { + SQLHelper.Parameters["@UserId"] = UserId; + SQLHelper.Parameters["@BirthDay"] = General.DefaultTime; + + return $"{Command_Insert} {Command_Into} {TableName} ({Column_UserId}, {Column_BirthDay}) " + + $"{Command_Values} (@UserId, @BirthDay)"; + } + + public static string Update_UserProfile(SQLHelper SQLHelper, long UserId, string AvatarUrl, string Signature, string Gender, DateTime BirthDay, int Followers, int Following, string Title, string UserGroup) + { + SQLHelper.Parameters["@UserId"] = UserId; + SQLHelper.Parameters["@AvatarUrl"] = AvatarUrl; + SQLHelper.Parameters["@Signature"] = Signature; + SQLHelper.Parameters["@Gender"] = Gender; + SQLHelper.Parameters["@BirthDay"] = BirthDay; + SQLHelper.Parameters["@Followers"] = Followers; + SQLHelper.Parameters["@Following"] = Following; + SQLHelper.Parameters["@Title"] = Title; + SQLHelper.Parameters["@UserGroup"] = UserGroup; + + return $"{Command_Update} {TableName} {Command_Set} {Column_AvatarUrl} = @AvatarUrl, {Column_Signature} = @Signature, {Column_Gender} = @Gender, {Column_BirthDay} = @BirthDay, " + + $"{Column_Followers} = @Followers, {Column_Following} = @Following, {Column_Title} = @Title, {Column_UserGroup} = @UserGroup {Command_Where} {Column_UserId} = @UserId"; + } + + public static string Update_UserProfileAvatarUrl(SQLHelper SQLHelper, long UserId, string AvatarUrl) + { + SQLHelper.Parameters["@UserId"] = UserId; + SQLHelper.Parameters["@AvatarUrl"] = AvatarUrl; + return $"{Command_Update} {TableName} {Command_Set} {Column_AvatarUrl} = @AvatarUrl {Command_Where} {Column_UserId} = @UserId"; + } + + public static string Update_UserProfileSignature(SQLHelper SQLHelper, long UserId, string Signature) + { + SQLHelper.Parameters["@UserId"] = UserId; + SQLHelper.Parameters["@Signature"] = Signature; + return $"{Command_Update} {TableName} {Command_Set} {Column_Signature} = @Signature {Command_Where} {Column_UserId} = @UserId"; + } + + public static string Update_UserProfileGender(SQLHelper SQLHelper, long UserId, string Gender) + { + SQLHelper.Parameters["@UserId"] = UserId; + SQLHelper.Parameters["@Gender"] = Gender; + return $"{Command_Update} {TableName} {Command_Set} {Column_Gender} = @Gender {Command_Where} {Column_UserId} = @UserId"; + } + + public static string Update_UserProfileBirthDay(SQLHelper SQLHelper, long UserId, DateTime BirthDay) + { + SQLHelper.Parameters["@UserId"] = UserId; + SQLHelper.Parameters["@BirthDay"] = BirthDay; + return $"{Command_Update} {TableName} {Command_Set} {Column_BirthDay} = @BirthDay {Command_Where} {Column_UserId} = @UserId"; + } + + public static string Update_UserProfileFollowers(SQLHelper SQLHelper, long UserId, int Followers) + { + SQLHelper.Parameters["@UserId"] = UserId; + SQLHelper.Parameters["@Followers"] = Followers; + return $"{Command_Update} {TableName} {Command_Set} {Column_Followers} = @Followers {Command_Where} {Column_UserId} = @UserId"; + } + + public static string Update_UserProfileFollowing(SQLHelper SQLHelper, long UserId, int Following) + { + SQLHelper.Parameters["@UserId"] = UserId; + SQLHelper.Parameters["@Following"] = Following; + return $"{Command_Update} {TableName} {Command_Set} {Column_Following} = @Following {Command_Where} {Column_UserId} = @UserId"; + } + + public static string Update_UserProfileTitle(SQLHelper SQLHelper, long UserId, string Title) + { + SQLHelper.Parameters["@UserId"] = UserId; + SQLHelper.Parameters["@Title"] = Title; + return $"{Command_Update} {TableName} {Command_Set} {Column_Title} = @Title {Command_Where} {Column_UserId} = @UserId"; + } + + public static string Update_UserProfileUserGroup(SQLHelper SQLHelper, long UserId, string UserGroup) + { + SQLHelper.Parameters["@UserId"] = UserId; + SQLHelper.Parameters["@UserGroup"] = UserGroup; + return $"{Command_Update} {TableName} {Command_Set} {Column_UserGroup} = @UserGroup {Command_Where} {Column_UserId} = @UserId"; + } + + public static string Delete_UserProfile(SQLHelper SQLHelper, long UserId) + { + SQLHelper.Parameters["@UserId"] = UserId; + return $"{Command_Delete} {Command_From} {TableName} {Command_Where} {Column_UserId} = @UserId"; + } + } +} diff --git a/Library/SQLScript/fungame.sql b/Library/SQLScript/fungame.sql index f7438bb..a0cd079 100644 --- a/Library/SQLScript/fungame.sql +++ b/Library/SQLScript/fungame.sql @@ -272,6 +272,23 @@ CREATE TABLE `UserLogs` ( PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +-- ---------------------------- +-- Table structure for UserProfiles +-- ---------------------------- +DROP TABLE IF EXISTS `UserProfiles`; +CREATE TABLE `UserProfiles` ( + `UserId` bigint(20) NOT NULL DEFAULT '0', + `AvatarUrl` varchar(255) NOT NULL DEFAULT '', + `Signature` varchar(255) NOT NULL DEFAULT '', + `Gender` varchar(255) NOT NULL DEFAULT '', + `BirthDay` datetime DEFAULT NULL, + `Followers` int(11) NOT NULL DEFAULT '0', + `Following` int(11) NOT NULL DEFAULT '0', + `Title` varchar(255) NOT NULL DEFAULT '', + `UserGroup` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`UserId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + -- ---------------------------- -- Table structure for Users -- ---------------------------- diff --git a/Library/SQLScript/fungame_sqlite.sql b/Library/SQLScript/fungame_sqlite.sql index f6793bb..4397135 100644 --- a/Library/SQLScript/fungame_sqlite.sql +++ b/Library/SQLScript/fungame_sqlite.sql @@ -259,6 +259,23 @@ CREATE TABLE UserLogs ( CreateTime DATETIME NOT NULL DEFAULT (DATETIME('now')) ); +-- ---------------------------- +-- Table structure for UserProfiles +-- ---------------------------- +DROP TABLE IF EXISTS "main"."UserProfiles"; +CREATE TABLE UserProfiles ( + UserId INTEGER NOT NULL DEFAULT 0, + AvatarUrl TEXT NOT NULL DEFAULT '', + Signature TEXT NOT NULL DEFAULT '', + Gender TEXT NOT NULL DEFAULT '', + BirthDay DATETIME DEFAULT NULL, + Followers INTEGER NOT NULL DEFAULT 0, + Following INTEGER NOT NULL DEFAULT 0, + Title TEXT NOT NULL DEFAULT '', + UserGroup TEXT NOT NULL DEFAULT '', + PRIMARY KEY (UserId) +); + -- ---------------------------- -- Table structure for Users -- ---------------------------- diff --git a/Model/Gaming.cs b/Model/Gaming.cs index 845aae9..ce82438 100644 --- a/Model/Gaming.cs +++ b/Model/Gaming.cs @@ -49,8 +49,8 @@ namespace Milimoe.FunGame.Core.Model Gaming instance = new(module, room, user, users); // 读取模组的依赖集合 module.GameModuleDepend.GetDependencies(loader); - // 新建线程来启动模组的界面 - TaskUtility.NewTask(() => module.StartUI()); + // 启动模组的界面 + module.StartUI(); // 启动模组主线程 module.StartGame(instance, args); return instance;