FunGame-Core/Library/SQLScript/Entity/InventoriesQuery.cs
milimoe 2827c53d14
补全数据库表、查询常量类 (#118)
* 补充数据库表

* 更新sqlite

* 添加商店相关的数据库常量类

* add Update_UpdateRoomMaster

* 修改常量类

* 添加  NOTICE 文件

* 添加市场、报价、库存的数据库常量类

* 优化表结构和查询常量类

* 添加 UserCenter 和 Inventory 相关枚举;数据表和 Query 常量类修改

* 添加报价的核心操作

* 涉及库存的物品获取应该使用 Guid 而不是 ItemId

---------

Co-authored-by: yeziuku <yezi@wrss.org>
2025-04-04 23:39:49 +08:00

79 lines
3.9 KiB
C#

using Milimoe.FunGame.Core.Api.Transmittal;
namespace Milimoe.FunGame.Core.Library.SQLScript.Entity
{
public class InventoriesQuery : Constant
{
public const string TableName = "Inventories";
public const string Column_UserId = "UserId";
public const string Column_Name = "Name";
public const string Column_Credits = "Credits";
public const string Column_Materials = "Materials";
public const string Column_MainCharacter = "MainCharacter";
public const string Select_Inventories = $"{Command_Select} {Command_All} {Command_From} {TableName}";
public static string Select_InventoryByUserId(SQLHelper SQLHelper, long UserId)
{
SQLHelper.Parameters["@UserId"] = UserId;
return $"{Select_Inventories} {Command_Where} {Column_UserId} = @UserId";
}
public static string Select_MainCharacterByUserId(SQLHelper SQLHelper, long UserId)
{
SQLHelper.Parameters["@UserId"] = UserId;
return $"{Command_Select} {Column_MainCharacter} {Command_From} {TableName} {Command_Where} {Column_UserId} = @UserId";
}
public static string Insert_Inventory(SQLHelper SQLHelper, long UserId, string Name, double Credits, double Materials, long MainCharacter)
{
SQLHelper.Parameters["@UserId"] = UserId;
SQLHelper.Parameters["@Name"] = Name;
SQLHelper.Parameters["@Credits"] = Credits;
SQLHelper.Parameters["@Materials"] = Materials;
SQLHelper.Parameters["@MainCharacter"] = MainCharacter;
return $"{Command_Insert} {Command_Into} {TableName} ({Column_UserId}, {Column_Name}, {Column_Credits}, {Column_Materials}, {Column_MainCharacter}) " +
$"{Command_Values} (@UserId, @Name, @Credits, @Materials, @MainCharacter)";
}
public static string Update_Inventory(SQLHelper SQLHelper, long UserId, string Name, double Credits, double Materials, long MainCharacter)
{
SQLHelper.Parameters["@UserId"] = UserId;
SQLHelper.Parameters["@Name"] = Name;
SQLHelper.Parameters["@Credits"] = Credits;
SQLHelper.Parameters["@Materials"] = Materials;
SQLHelper.Parameters["@MainCharacter"] = MainCharacter;
return $"{Command_Update} {TableName} {Command_Set} {Column_Name} = @Name, {Column_Credits} = @Credits, {Column_Materials} = @Materials, {Column_MainCharacter} = @MainCharacter {Command_Where} {Column_UserId} = @UserId";
}
public static string Update_InventoryCredits(SQLHelper SQLHelper, long UserId, double Credits)
{
SQLHelper.Parameters["@UserId"] = UserId;
SQLHelper.Parameters["@Credits"] = Credits;
return $"{Command_Update} {TableName} {Command_Set} {Column_Credits} = @Credits {Command_Where} {Column_UserId} = @UserId";
}
public static string Update_InventoryMaterials(SQLHelper SQLHelper, long UserId, double Materials)
{
SQLHelper.Parameters["@UserId"] = UserId;
SQLHelper.Parameters["@Materials"] = Materials;
return $"{Command_Update} {TableName} {Command_Set} {Column_Materials} = @Materials {Command_Where} {Column_UserId} = @UserId";
}
public static string Update_InventoryMainCharacter(SQLHelper SQLHelper, long UserId, long MainCharacter)
{
SQLHelper.Parameters["@UserId"] = UserId;
SQLHelper.Parameters["@MainCharacter"] = MainCharacter;
return $"{Command_Update} {TableName} {Command_Set} {Column_MainCharacter} = @MainCharacter {Command_Where} {Column_UserId} = @UserId";
}
public static string Delete_Inventory(SQLHelper SQLHelper, long UserId)
{
SQLHelper.Parameters["@UserId"] = UserId;
return $"{Command_Delete} {Command_From} {TableName} {Command_Where} {Column_UserId} = @UserId";
}
}
}