신규 db 추가

This commit is contained in:
김판돌 2023-11-30 22:14:43 +09:00
parent df9af17fc3
commit b340dfdc12
11 changed files with 162 additions and 2 deletions

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore;
using Npgsql.EntityFrameworkCore.PostgreSQL;
using System.ComponentModel.DataAnnotations.Schema;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Server.SQL
{
[Table("deck_unit_info", Schema = "gamedb")]
public class DeckUnitInfo
{
public int id { get; set; }
public string uuid { get; set; }
public string mail { get; set; }
public string nickname { get; set; }
}
public class DeckUnitInfoSQL : SQL<DeckUnitInfo>
{
public override DbSet<DeckUnitInfo> table { get; set; }
public override string tablename { get { return "deck_unit_info"; } }
}
}

22
Server/SQL/LeaderInfo.cs Normal file
View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore;
using Npgsql.EntityFrameworkCore.PostgreSQL;
using System.ComponentModel.DataAnnotations.Schema;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Server.SQL
{
[Table("leader_info", Schema = "gamedb")]
public class LeaderInfo
{
public int id { get; set; }
public string uuid { get; set; }
public string mail { get; set; }
public string nickname { get; set; }
}
public class LeaderInfoSQL : SQL<LeaderInfo>
{
public override DbSet<LeaderInfo> table { get; set; }
public override string tablename { get { return "leader_info"; } }
}
}

32
Server/SQL/User.cs Normal file
View File

@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore;
using Npgsql.EntityFrameworkCore.PostgreSQL;
using System.ComponentModel.DataAnnotations.Schema;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Server.SQL
{
[Table("user", Schema = "gamedb")]
public class User
{
public int id { get; set; }
public string uuid { get; set; }
public string mail { get; set; }
public string nickname { get; set; }
}
public class UserSQL : SQL<User>
{
public override DbSet<User> table { get; set; }
public override string tablename { get { return "user"; } }
public User SelectUuid(string uuid)
{
return table.SingleOrDefault(data => data.uuid == uuid);
}
public User SelectMail(string mail)
{
return table.SingleOrDefault(data => data.mail == mail);
}
}
}

83
Server/Service/Login.cs Normal file
View File

@ -0,0 +1,83 @@
using Server.System;
using Newtonsoft.Json;
using Server.SQL;
namespace Server.Service
{
public class Login : AbstractService
{
private LoginReq req;
public override string Process()
{
UserSQL userSql = new UserSQL();
User user;
if (req.uuid == null)
{
//최초 메일 로그인
//게스트 로그인은 허용하지 않고 무조건 구글로그인 혹은 마스토돈 로그인만 가능하게 처리하기
user = userSql.SelectMail(req.mail);
}
else
{
user = userSql.SelectUuid(req.uuid);
}
if(user == null)
{
#region
user = new User();
user.mail = req.mail;
user.uuid = Guid.NewGuid().ToString();
userSql.Insert(user);
#endregion
#region ,
#endregion
}
SaveQurry(userSql, user);
return makeResp(user);
}
public void SaveQurry(UserSQL userSql, User user)
{
userSql.Insert(user);
}
public override Protocol ProtocolValue() => Protocol.Login;
public override Req Requst(string json)
{
req = JsonConvert.DeserializeObject<LoginReq>(json);
return req;
}
private string makeResp(User user)
{
LoginResp resp = new LoginResp();
resp.nickname = user.nickname;
resp.uuid = user.uuid;
resp.status = 200;
return resp.ToJson();
}
}
public class LoginReq : Req
{
public string mail;
public string uuid;
public override bool IsReceivedAllField()
{
if(mail == null && uuid == null)
return false;
return true;
}
}
public class LoginResp : Resp
{
public string uuid;
public string nickname;
}
}

View File

@ -9,6 +9,7 @@
Downlode = 100,//기획 데이터 다운로드
Login = 101,//기획 데이터 다운로드
}
public enum Error

View File

@ -1 +1 @@
a8963fa66f05382597e3668fc4d7b87af57a54943eab383a2b7c8418ec1b6073
dd557d62badea6ea383f22ecfcd791495e975b22b1c7b07715ed4657eabd5e04

Binary file not shown.

View File

@ -1 +1 @@
51569073025ff8d42d413f4a9e547cbb8da5c9713f87cb390a23e4fd403de519
f07a5d637b9aa528bca131b13fc576f71d7e7a53b21695ee30255e0137559728

Binary file not shown.