Compare commits

...
4 Commits
Author SHA1 Message Date
xrain 47a48d0103 增加了model默认字段 2024-03-23 07:12:25 +08:00
xrain 4c50acc309 增加了model默认字段 2024-03-23 07:10:17 +08:00
xrain be9092bf3c fix rpc client error 2023-10-30 03:45:15 +08:00
xrain 345aaa261e fix readme 2023-10-23 17:42:37 +08:00
7 changed files with 24 additions and 16 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: "7.0.100"
dotnet-version: "8.0.200"
- name: Publish
run: |
version=`git describe --tags`
+3 -3
View File
@@ -61,14 +61,14 @@ namespace SimApi.Configs
/// <summary>
/// Swagger文档相关配置,需要启用 EnableSimApiDoc
/// </summary>
public SimApiDocOptions SimApiDocOptions { get; set; } = new SimApiDocOptions();
public SimApiDocOptions SimApiDocOptions { get; set; } = new();
/// <summary>
/// S3兼容的存储系统配置,需要启用 EnableSimApiStorage
/// </summary>
public SimApiStorageOptions SimApiStorageOptions { get; set; } = new SimApiStorageOptions();
public SimApiStorageOptions SimApiStorageOptions { get; set; } = new();
public SimApiSynapseOptions SimApiSynapseOptions { get; set; } = new SimApiSynapseOptions();
public SimApiSynapseOptions SimApiSynapseOptions { get; set; } = new();
public void ConfigureSimApiSynapse(Action<SimApiSynapseOptions> options = null)
{
+11 -4
View File
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text.Json;
using SimApi.Helpers;
@@ -7,10 +8,16 @@ namespace SimApi.Models
{
public class SimApiBaseModel
{
protected virtual string[] MapperIgnoreField { get; set; } =
{
"Id", "CreatedAt", "UpdatedAt"
};
[Column(Order = 1)]
public string Id { get; set; } = Guid.NewGuid().ToString();
[Column(Order = 9998)]
public DateTime UpdatedAt { get; set; } = SimApiUtil.CstNow;
[Column(Order = 9999)]
public DateTime CreatedAt { get; set; } = SimApiUtil.CstNow;
protected virtual string[] MapperIgnoreField { get; set; } = { "Id", "CreatedAt", "UpdatedAt" };
protected virtual string UpdatedTimeField { get; set; } = "UpdatedAt";
+2 -1
View File
@@ -1,4 +1,4 @@
# YYApi 基于Asp.net Core 3/5的一个基础辅助包
# SimApi 基于.Net的一个基础辅助包
[![PublishNugetPackage](https://github.com/simcu/simapi-net/actions/workflows/nuget-publish.yml/badge.svg)](https://github.com/simcu/simapi-net/actions/workflows/nuget-publish.yml)
### 包含了以下组件:
@@ -52,3 +52,4 @@ services.AddSimApi(options =>
options.SimApiStorageOptions = Configuration.GetSection("S3").Get<SimApiStorageOptions>();
});
```
基于S3的存储,基于RabbitMq的事件RPC调用,自定义Logger格式,自定义响应格式
+1 -1
View File
@@ -14,7 +14,7 @@
<SynchReleaseVersion>false</SynchReleaseVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>5.0.2</PackageVersion>
<TargetFramework>net7.0</TargetFramework>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
+4 -5
View File
@@ -36,11 +36,11 @@ public partial class Synapse
RpcClientChannel.BasicConsume(queue, false, "", false, false, null, consumer);
}
private object FireRpc(string app, string action, object param)
private string FireRpc(string app, string action, object param)
{
var paramJson = JsonSerializer.Serialize(param, SimApiUtil.JsonOption);
var router = $"server.{app}";
SimApiBaseResponse response;
string response;
var props = RpcClientChannel.CreateBasicProperties();
props.AppId = Options.AppId;
props.MessageId = Guid.NewGuid().ToString();
@@ -55,13 +55,12 @@ public partial class Synapse
{
if (SimApiUtil.TimestampNow - ts > Options.RpcTimeout)
{
response = new SimApiBaseResponse(502, "timeout");
response = JsonSerializer.Serialize(new SimApiBaseResponse(502, "timeout"), SimApiUtil.JsonOption);
break;
}
if (ResponseCache.TryGetValue(props.MessageId, out var value))
{
response = JsonSerializer.Deserialize<SimApiBaseResponse<object>>(
Encoding.UTF8.GetString(value), SimApiUtil.JsonOption);
response = Encoding.UTF8.GetString(value);
ResponseCache.Remove(props.MessageId);
break;
}
+2 -1
View File
@@ -96,7 +96,8 @@ public partial class Synapse
}
else
{
res = FireRpc(appName, method, param);
var data = FireRpc(appName, method, param);
res = JsonSerializer.Deserialize<SimApiBaseResponse<T>>(data, SimApiUtil.JsonOption);
}
return res as SimApiBaseResponse<T>;
}