Now supports saving card groups, this is probably the ugliest code ive ever written but anything to avoid 20 cardgroup properties. we should see if there's a better way, it could probably be a lot cleaner
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -6,6 +7,7 @@ using System.Net.Http;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
using AutoMapper.QueryableExtensions;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@@ -47,18 +49,64 @@ namespace TOOHUCardAPI.Controllers
|
|||||||
return await InvokeEndpointHandlerForMethod<PlayerDataController>(this, method, body);
|
return await InvokeEndpointHandlerForMethod<PlayerDataController>(this, method, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[EndpointHandler("save_card_group")]
|
||||||
|
private async Task<object> SaveCardGroup(string body)
|
||||||
|
{
|
||||||
|
PlayerDataSaveCardGroupRequestObject request =
|
||||||
|
JsonConvert.DeserializeObject<PlayerDataSaveCardGroupRequestObject>(body);
|
||||||
|
User user = _userRepository.GetUser(request.SteamId);
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return new PlayerDataSaveCardGroupResponseObject()
|
||||||
|
{
|
||||||
|
Code = "0001",
|
||||||
|
Message = "Invalid player"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
EncodedCardGroup group = user.EncodedCardGroups.FirstOrDefault(group => group.GroupKey == request.GroupKey) ?? new EncodedCardGroup()
|
||||||
|
{
|
||||||
|
GroupKey = request.GroupKey
|
||||||
|
};
|
||||||
|
group.EncodedString = request.GroupData;
|
||||||
|
user.EncodedCardGroups = user.EncodedCardGroups.Where(group2 => group.Id != group2.Id).Append(group).ToList();
|
||||||
|
_userRepository.UpdateUser(user);
|
||||||
|
return new PlayerDataSaveCardGroupResponseObject();
|
||||||
|
}
|
||||||
|
|
||||||
[EndpointHandler("get")]
|
[EndpointHandler("get")]
|
||||||
private async Task<object> Get(string body)
|
private async Task<object> Get(string body)
|
||||||
{
|
{
|
||||||
PlayerDataGetRequestObject requestObject = JsonConvert.DeserializeObject<PlayerDataGetRequestObject>(body);
|
PlayerDataGetRequestObject requestObject = JsonConvert.DeserializeObject<PlayerDataGetRequestObject>(body);
|
||||||
Dictionary<string, User> users = requestObject.Ids.Aggregate(new Dictionary<string, User>(),
|
IEnumerable<User> users = requestObject.Ids.Values.Select(val => _userRepository.GetOrCreateUser(val));
|
||||||
(dictionary, pair) =>
|
IEnumerable<string> queriedUserSteamIds = requestObject.Ids.Select(i => i.Value);
|
||||||
|
IEnumerable<PlayerDataGetResponseObjectPlayer> responsePlayers = users
|
||||||
|
.Where(user => queriedUserSteamIds.Contains(user.SteamId))
|
||||||
|
.Select(user => _mapper.Map<PlayerDataGetResponseObjectPlayer>(user));
|
||||||
|
Dictionary<string, PlayerDataGetResponseObjectPlayer> playersStatic = requestObject.Ids
|
||||||
|
.Select(pair =>
|
||||||
|
KeyValuePair.Create(pair.Key, responsePlayers.FirstOrDefault(resp => resp.SteamId == pair.Value)))
|
||||||
|
.ToDictionary(kv => kv.Key, kv => kv.Value);
|
||||||
|
Dictionary<string, Dictionary<string, object>> dynamicResponses = playersStatic
|
||||||
|
.Select(kv =>
|
||||||
|
{
|
||||||
|
var obj = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(kv.Value));
|
||||||
|
return KeyValuePair.Create(kv.Key, obj);
|
||||||
|
})
|
||||||
|
.ToDictionary(kv => kv.Key, kv => kv.Value);
|
||||||
|
foreach (var kv in dynamicResponses)
|
||||||
|
{
|
||||||
|
var props = kv.Value;
|
||||||
|
var user = users.FirstOrDefault(user1 => user1.SteamId == requestObject.Ids[kv.Key]);
|
||||||
|
foreach (var cardgroup in user.EncodedCardGroups ?? new List<EncodedCardGroup>())
|
||||||
{
|
{
|
||||||
User user = _userRepository.GetOrCreateUser(pair.Value);
|
props[$"{cardgroup.GroupKey}"] = cardgroup.EncodedString;
|
||||||
dictionary[pair.Key] = user;
|
}
|
||||||
return dictionary;
|
}
|
||||||
});
|
PlayerDataGetResponseObject response = new PlayerDataGetResponseObject()
|
||||||
PlayerDataGetResponseObject response = new PlayerDataGetResponseObject(users, _mapper);
|
{
|
||||||
|
Players = dynamicResponses
|
||||||
|
};
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
10
TOOHUCardAPI/DTO/AbstractRequest.cs
Normal file
10
TOOHUCardAPI/DTO/AbstractRequest.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace TOOHUCardAPI.DTO
|
||||||
|
{
|
||||||
|
public abstract class AbstractRequest
|
||||||
|
{
|
||||||
|
[JsonProperty("method")]
|
||||||
|
public string Method { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
14
TOOHUCardAPI/DTO/AbstractResponse.cs
Normal file
14
TOOHUCardAPI/DTO/AbstractResponse.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace TOOHUCardAPI.DTO
|
||||||
|
{
|
||||||
|
public abstract class AbstractResponse
|
||||||
|
{
|
||||||
|
public static string SUCCESS_CODE = "0000";
|
||||||
|
[JsonProperty("code")]
|
||||||
|
public string Code { get; set; } = SUCCESS_CODE;
|
||||||
|
[JsonProperty("msg")]
|
||||||
|
public string Message { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,20 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace TOOHUCardAPI.DTO
|
namespace TOOHUCardAPI.DTO
|
||||||
{
|
{
|
||||||
public class PlayerDataGetRequestObject
|
public class PlayerDataGetRequestObject : AbstractRequest
|
||||||
{
|
{
|
||||||
public string Method { get; set; }
|
|
||||||
public Dictionary<string, string> Ids;
|
public Dictionary<string, string> Ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PlayerDataSaveCardGroupRequestObject: AbstractRequest
|
||||||
|
{
|
||||||
|
public string SteamId { get; set; }
|
||||||
|
public string UserId { get; set; }
|
||||||
|
[JsonProperty("group_key")]
|
||||||
|
public string GroupKey { get; set; }
|
||||||
|
[JsonProperty("group_data")]
|
||||||
|
public string GroupData { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Dynamic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using TOOHUCardAPI.Data.Models;
|
using TOOHUCardAPI.Data.Models;
|
||||||
@@ -9,30 +11,17 @@ namespace TOOHUCardAPI.DTO
|
|||||||
public class PlayerDataGetResponseObject
|
public class PlayerDataGetResponseObject
|
||||||
{
|
{
|
||||||
[JsonProperty("bo")]
|
[JsonProperty("bo")]
|
||||||
public Dictionary<string, PlayerDataGetResponseObjectPlayer> Players { get; set; }
|
public Dictionary<string, Dictionary<string, object>> Players { get; set; }
|
||||||
|
|
||||||
public PlayerDataGetResponseObject(Dictionary<string, User> users, IMapper mapper)
|
|
||||||
{
|
|
||||||
this.Players = users.Aggregate(new Dictionary<string, PlayerDataGetResponseObjectPlayer>(),
|
|
||||||
(players, pair) =>
|
|
||||||
{
|
|
||||||
User user = pair.Value;
|
|
||||||
players[pair.Key] = mapper.Map<PlayerDataGetResponseObjectPlayer>(user);
|
|
||||||
return players;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Fields pulled from the game code
|
* Fields pulled from the game code
|
||||||
* Looking up Gamerules.Playerdata
|
* Looking up Gamerules.Playerdata
|
||||||
*/
|
*/
|
||||||
public class PlayerDataGetResponseObjectPlayer
|
public class PlayerDataGetResponseObjectPlayer: AbstractResponse
|
||||||
{
|
{
|
||||||
[JsonProperty("code")] public string Code { get; set; } = "0000";
|
[JsonProperty("steamid")]
|
||||||
|
public string SteamId { get; set; }
|
||||||
[JsonProperty("msg")] public string Message { get; set; } = string.Empty;
|
|
||||||
//[JsonProperty("steamid")]
|
|
||||||
//public string SteamId { get; set; }
|
|
||||||
[JsonProperty("max_wave")] public int MaxWave { get; set; } = 0;
|
[JsonProperty("max_wave")] public int MaxWave { get; set; } = 0;
|
||||||
[JsonProperty("max_team_wave")] public int MaxTeamWave { get; set; } = 0;
|
[JsonProperty("max_team_wave")] public int MaxTeamWave { get; set; } = 0;
|
||||||
[JsonProperty("pet_level")] public int PetLevel { get; set; } = 1;
|
[JsonProperty("pet_level")] public int PetLevel { get; set; } = 1;
|
||||||
@@ -42,5 +31,16 @@ namespace TOOHUCardAPI.DTO
|
|||||||
[JsonProperty("vip")] public int Vip { get; set; } = 1;
|
[JsonProperty("vip")] public int Vip { get; set; } = 1;
|
||||||
[JsonProperty("point")] public int Point { get; set; } = 10000;
|
[JsonProperty("point")] public int Point { get; set; } = 10000;
|
||||||
[JsonProperty("level_list")] public string LevelList { get; set; } = string.Empty;
|
[JsonProperty("level_list")] public string LevelList { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public Dictionary<string, object> ToDynamicProperties()
|
||||||
|
{
|
||||||
|
return GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||||
|
.ToDictionary(prop => prop.Name, prop => prop.GetValue(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PlayerDataSaveCardGroupResponseObject : AbstractResponse
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,6 @@ namespace TOOHUCardAPI.Data
|
|||||||
public AutomapProfile()
|
public AutomapProfile()
|
||||||
{
|
{
|
||||||
CreateMap<User, PlayerDataGetResponseObjectPlayer>();
|
CreateMap<User, PlayerDataGetResponseObjectPlayer>();
|
||||||
CreateMap<User, User>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace TOOHUCardAPI.Data.Models
|
namespace TOOHUCardAPI.Data.Models
|
||||||
{
|
{
|
||||||
public class EncodedCardGroup
|
public class EncodedCardGroup
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int CardGroupNumber { get; set; }
|
public string GroupKey { get; set; }
|
||||||
public string EncodedString { get; set; }
|
public string EncodedString { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ namespace TOOHUCardAPI.Data.Models
|
|||||||
public int KeyTotal { get; set; }
|
public int KeyTotal { get; set; }
|
||||||
public DateTime KeySaveDate { get; set; }
|
public DateTime KeySaveDate { get; set; }
|
||||||
public bool Vip { get; set; }
|
public bool Vip { get; set; }
|
||||||
|
public bool Ban { get; set; }
|
||||||
public int Point { get; set; }
|
public int Point { get; set; }
|
||||||
public string LevelList { get; set; }
|
public string LevelList { get; set; }
|
||||||
public List<EncodedCardGroup> EncodedCardGroups { get; set; }
|
public List<EncodedCardGroup> EncodedCardGroups { get; set; }
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using TOOHUCardAPI.Data.Models;
|
using TOOHUCardAPI.Data.Models;
|
||||||
|
|
||||||
namespace TOOHUCardAPI.Data.Repositories
|
namespace TOOHUCardAPI.Data.Repositories
|
||||||
@@ -16,9 +18,14 @@ namespace TOOHUCardAPI.Data.Repositories
|
|||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IQueryable<User> GetAllUsersQuery()
|
||||||
|
{
|
||||||
|
return _appDbContext.Users.Include(u => u.EncodedCardGroups).AsQueryable();
|
||||||
|
}
|
||||||
|
|
||||||
public User GetUser(string steamId)
|
public User GetUser(string steamId)
|
||||||
{
|
{
|
||||||
return _appDbContext.Users.Where((user => user.SteamId.Equals(steamId))).FirstOrDefault();
|
return GetAllUsersQuery().FirstOrDefault(user => user.SteamId.Equals(steamId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public User CreateUser(string steamId)
|
public User CreateUser(string steamId)
|
||||||
@@ -29,7 +36,8 @@ namespace TOOHUCardAPI.Data.Repositories
|
|||||||
Vip = true,
|
Vip = true,
|
||||||
EndTime = DateTime.MaxValue,
|
EndTime = DateTime.MaxValue,
|
||||||
LevelList = string.Empty,
|
LevelList = string.Empty,
|
||||||
PetLevel = 1
|
PetLevel = 1,
|
||||||
|
EncodedCardGroups = new List<EncodedCardGroup>()
|
||||||
};
|
};
|
||||||
_appDbContext.Users.Add(user);
|
_appDbContext.Users.Add(user);
|
||||||
_appDbContext.SaveChanges();
|
_appDbContext.SaveChanges();
|
||||||
@@ -38,7 +46,7 @@ namespace TOOHUCardAPI.Data.Repositories
|
|||||||
|
|
||||||
public User UpdateUser(User user)
|
public User UpdateUser(User user)
|
||||||
{
|
{
|
||||||
var trackedUser = _appDbContext.Users.FirstOrDefault(u => u.SteamId == user.SteamId);
|
var trackedUser = GetAllUsersQuery().FirstOrDefault(u => u.SteamId == user.SteamId);
|
||||||
if (trackedUser == default)
|
if (trackedUser == default)
|
||||||
{
|
{
|
||||||
return trackedUser;
|
return trackedUser;
|
||||||
|
|||||||
97
TOOHUCardAPI/Migrations/20211029035809_groupid for encoded card group.Designer.cs
generated
Normal file
97
TOOHUCardAPI/Migrations/20211029035809_groupid for encoded card group.Designer.cs
generated
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using TOOHUCardAPI.Data;
|
||||||
|
|
||||||
|
namespace TOOHUCardAPI.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20211029035809_groupid for encoded card group")]
|
||||||
|
partial class groupidforencodedcardgroup
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "5.0.11");
|
||||||
|
|
||||||
|
modelBuilder.Entity("TOOHUCardAPI.Data.Models.EncodedCardGroup", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("CardGroupNumber")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("EncodedString")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("UserSteamId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserSteamId");
|
||||||
|
|
||||||
|
b.ToTable("EncodedCardGroup");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TOOHUCardAPI.Data.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("SteamId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("Ban")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTime>("EndTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("KeySaveDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("KeyTotal")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("LevelList")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("MaxTeamWave")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("MaxWave")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("PetLevel")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Point")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("Vip")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("SteamId");
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TOOHUCardAPI.Data.Models.EncodedCardGroup", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("TOOHUCardAPI.Data.Models.User", null)
|
||||||
|
.WithMany("EncodedCardGroups")
|
||||||
|
.HasForeignKey("UserSteamId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TOOHUCardAPI.Data.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("EncodedCardGroups");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace TOOHUCardAPI.Migrations
|
||||||
|
{
|
||||||
|
public partial class groupidforencodedcardgroup : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "Ban",
|
||||||
|
table: "Users",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "CardGroupNumber",
|
||||||
|
table: "EncodedCardGroup",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Ban",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "CardGroupNumber",
|
||||||
|
table: "EncodedCardGroup");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
97
TOOHUCardAPI/Migrations/20211029043842_fix groupkey, they send full string.Designer.cs
generated
Normal file
97
TOOHUCardAPI/Migrations/20211029043842_fix groupkey, they send full string.Designer.cs
generated
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using TOOHUCardAPI.Data;
|
||||||
|
|
||||||
|
namespace TOOHUCardAPI.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20211029043842_fix groupkey, they send full string")]
|
||||||
|
partial class fixgroupkeytheysendfullstring
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "5.0.11");
|
||||||
|
|
||||||
|
modelBuilder.Entity("TOOHUCardAPI.Data.Models.EncodedCardGroup", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("EncodedString")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("GroupKey")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("UserSteamId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserSteamId");
|
||||||
|
|
||||||
|
b.ToTable("EncodedCardGroup");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TOOHUCardAPI.Data.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("SteamId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("Ban")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTime>("EndTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("KeySaveDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("KeyTotal")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("LevelList")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("MaxTeamWave")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("MaxWave")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("PetLevel")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Point")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("Vip")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("SteamId");
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TOOHUCardAPI.Data.Models.EncodedCardGroup", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("TOOHUCardAPI.Data.Models.User", null)
|
||||||
|
.WithMany("EncodedCardGroups")
|
||||||
|
.HasForeignKey("UserSteamId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TOOHUCardAPI.Data.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("EncodedCardGroups");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace TOOHUCardAPI.Migrations
|
||||||
|
{
|
||||||
|
public partial class fixgroupkeytheysendfullstring : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "CardGroupNumber",
|
||||||
|
table: "EncodedCardGroup");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "GroupKey",
|
||||||
|
table: "EncodedCardGroup",
|
||||||
|
type: "TEXT",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "GroupKey",
|
||||||
|
table: "EncodedCardGroup");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "CardGroupNumber",
|
||||||
|
table: "EncodedCardGroup",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,9 @@ namespace TOOHUCardAPI.Migrations
|
|||||||
b.Property<string>("EncodedString")
|
b.Property<string>("EncodedString")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("GroupKey")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("UserSteamId")
|
b.Property<string>("UserSteamId")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
@@ -40,6 +43,9 @@ namespace TOOHUCardAPI.Migrations
|
|||||||
b.Property<string>("SteamId")
|
b.Property<string>("SteamId")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("Ban")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<DateTime>("EndTime")
|
b.Property<DateTime>("EndTime")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user