fork from 1.3

This commit is contained in:
moux23333
2024-01-27 21:06:07 +08:00
commit 22fc0b0848
1507 changed files with 24139 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
namespace FreeSR.Dispatch.Util
{
using FreeSR.Database.Account.Model;
using Newtonsoft.Json.Linq;
internal static class DispatchHelper
{
public static JObject ToLoginResponseData(this AccountModel model)
{
return new JObject
{
{"uid", model.Uid},
{"name", model.Name},
{"email", ""},
{"mobile", ""},
{"is_email_verify", "0"},
{"realname", ""},
{"identity_card", ""},
{"safe_mobile", ""},
{"facebook_name", ""},
{"google_name", ""},
{"twitter_name", ""},
{"game_center_name", ""},
{"apple_name", ""},
{"sony_name", ""},
{"tap_name", ""},
{"country", "CN"},
{"reactivate_ticket", ""},
{"area_code", "**"},
{"device_grant_ticket", ""},
{"steam_name", ""},
{"unmasked_email", ""},
{"unmasked_email_type", 0},
{"token", model.Token}
};
}
}
}

View File

@@ -0,0 +1,69 @@
namespace FreeSR.Dispatch.Util
{
using Newtonsoft.Json.Linq;
internal class DispatchResponseBuilder
{
private readonly JObject _jsonObject;
private DispatchResponseBuilder()
{
_jsonObject = new JObject();
}
public string Build()
{
return _jsonObject.ToString();
}
public DispatchResponseBuilder Code(int code)
{
_jsonObject["code"] = code;
return this;
}
public DispatchResponseBuilder Retcode(int retcode)
{
_jsonObject["retcode"] = retcode;
return this;
}
public DispatchResponseBuilder Message(string message)
{
_jsonObject["message"] = message;
return this;
}
public DispatchResponseBuilder Boolean(string field, bool value)
{
_jsonObject[field] = value;
return this;
}
public DispatchResponseBuilder String(string field, string value)
{
_jsonObject[field] = value;
return this;
}
public DispatchResponseBuilder Int(string field, int value)
{
_jsonObject[field] = value;
return this;
}
public DispatchResponseBuilder Array(string field, JArray array)
{
_jsonObject[field] = array;
return this;
}
public DispatchResponseBuilder Object(string field, JObject jsonObject)
{
_jsonObject[field] = jsonObject;
return this;
}
public static DispatchResponseBuilder Create() => new DispatchResponseBuilder();
}
}

View File

@@ -0,0 +1,15 @@
namespace FreeSR.Dispatch.Util
{
using ProtoBuf;
internal static class ProtobufUtil
{
public static byte[] Serialize<T>(T obj) where T : class
{
var stream = new MemoryStream();
Serializer.Serialize(stream, obj);
return stream.ToArray();
}
}
}