mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-04 13:47:04 -04:00
Removed NioTSO client and server
- NioTSO client isn't needed because we're using RayLib - Added FreeSO's API server to handle most backend operations
This commit is contained in:
parent
f12ba1502b
commit
22191ce648
591 changed files with 53264 additions and 3362 deletions
19
server/FSO.Server.Database/DA/Inbox/DbInboxMsg.cs
Executable file
19
server/FSO.Server.Database/DA/Inbox/DbInboxMsg.cs
Executable file
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
|
||||
namespace FSO.Server.Database.DA.Inbox
|
||||
{
|
||||
public class DbInboxMsg
|
||||
{
|
||||
public int message_id { get; set; }
|
||||
public uint sender_id { get; set; }
|
||||
public uint target_id { get; set; }
|
||||
public string subject { get; set; }
|
||||
public string body { get; set; }
|
||||
public string sender_name { get; set; }
|
||||
public DateTime time { get; set; }
|
||||
public int msg_type { get; set; }
|
||||
public int msg_subtype { get; set; }
|
||||
public int read_state { get; set; }
|
||||
public int? reply_id { get; set; }
|
||||
}
|
||||
}
|
15
server/FSO.Server.Database/DA/Inbox/IInbox.cs
Executable file
15
server/FSO.Server.Database/DA/Inbox/IInbox.cs
Executable file
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FSO.Server.Database.DA.Inbox
|
||||
{
|
||||
public interface IInbox
|
||||
{
|
||||
List<DbInboxMsg> GetMessages(uint avatarID);
|
||||
List<DbInboxMsg> GetMessagesAfter(uint avatarID, DateTime after);
|
||||
DbInboxMsg Get(int msgID);
|
||||
int CreateMessage(DbInboxMsg msg);
|
||||
bool DeleteMessage(int msgID, uint avatarID);
|
||||
bool DeleteMessage(int msgID);
|
||||
}
|
||||
}
|
47
server/FSO.Server.Database/DA/Inbox/SqlInbox.cs
Executable file
47
server/FSO.Server.Database/DA/Inbox/SqlInbox.cs
Executable file
|
@ -0,0 +1,47 @@
|
|||
using Dapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace FSO.Server.Database.DA.Inbox
|
||||
{
|
||||
public class SqlInbox : AbstractSqlDA, IInbox
|
||||
{
|
||||
public SqlInbox(ISqlContext context) : base(context){
|
||||
}
|
||||
|
||||
public int CreateMessage(DbInboxMsg msg)
|
||||
{
|
||||
var result = Context.Connection.Query<int>("INSERT INTO fso_inbox (sender_id, target_id, subject, " +
|
||||
"body, sender_name, time, msg_type, msg_subtype, read_state) " +
|
||||
" VALUES (@sender_id, @target_id, @subject, @body, @sender_name, " +
|
||||
" @time, @msg_type, @msg_subtype, @read_state); SELECT LAST_INSERT_ID();", msg).First();
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool DeleteMessage(int msgID)
|
||||
{
|
||||
return Context.Connection.Execute("DELETE FROM fso_inbox WHERE message_id = @id", new { id = msgID }) > 0;
|
||||
}
|
||||
|
||||
public bool DeleteMessage(int msgID, uint avatarID)
|
||||
{
|
||||
return Context.Connection.Execute("DELETE FROM fso_inbox WHERE message_id = @id AND target_id = @aid", new { id = msgID, aid = avatarID }) > 0;
|
||||
}
|
||||
|
||||
public DbInboxMsg Get(int msgID)
|
||||
{
|
||||
return Context.Connection.Query<DbInboxMsg>("SELECT * FROM fso_inbox WHERE message_id = @id", new { id = msgID }).FirstOrDefault();
|
||||
}
|
||||
|
||||
public List<DbInboxMsg> GetMessages(uint avatarID)
|
||||
{
|
||||
return Context.Connection.Query<DbInboxMsg>("SELECT * FROM fso_inbox WHERE target_id = @id", new { id = avatarID }).ToList();
|
||||
}
|
||||
|
||||
public List<DbInboxMsg> GetMessagesAfter(uint avatarID, DateTime after)
|
||||
{
|
||||
return Context.Connection.Query<DbInboxMsg>("SELECT * FROM fso_inbox WHERE target_id = @id AND time > @after", new { id = avatarID, after = after }).ToList();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue