From a2cb96b9a7edb6c0829c4fc40b7b7b897c8a43bf Mon Sep 17 00:00:00 2001 From: wenyongda Date: Fri, 13 Jun 2025 16:40:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=90=AFhttps=EF=BC=8C=E6=8E=A5?= =?UTF-8?q?=E5=85=A5grpc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + ZR.Admin.Grpc/Protos/my_diary.proto | 35 +++ ZR.Admin.Grpc/Services/GreeterService.cs | 37 +++ ZR.Admin.Grpc/Services/MyDiaryService.cs | 76 ++++++ ZR.Admin.Grpc/ZR.Admin.Grpc.csproj | 9 +- ZR.Admin.WebApi/Program.cs | 46 ++-- .../Properties/launchSettings.json | 14 +- ZR.Admin.WebApi/appsettings.Production.json | 20 ++ ZR.Admin.WebApi/appsettings.json | 248 +++++++++--------- ZR.Model/MyDiary.cs | 23 ++ ZR.Service/IService/IMyDiaryService.cs | 14 + ZR.Service/MyDiaryService.cs | 15 ++ 12 files changed, 387 insertions(+), 151 deletions(-) create mode 100644 ZR.Admin.Grpc/Protos/my_diary.proto create mode 100644 ZR.Admin.Grpc/Services/GreeterService.cs create mode 100644 ZR.Admin.Grpc/Services/MyDiaryService.cs create mode 100644 ZR.Admin.WebApi/appsettings.Production.json create mode 100644 ZR.Model/MyDiary.cs create mode 100644 ZR.Service/IService/IMyDiaryService.cs create mode 100644 ZR.Service/MyDiaryService.cs diff --git a/.gitignore b/.gitignore index e62663f..845c17c 100644 --- a/.gitignore +++ b/.gitignore @@ -286,3 +286,4 @@ __pycache__/ /ZRAdmin-vue/deploy.js /ZR.Admin.WebApi/ZRModel.xml ZRAdmin-vue/dist.zip +**/.vshistory/ \ No newline at end of file diff --git a/ZR.Admin.Grpc/Protos/my_diary.proto b/ZR.Admin.Grpc/Protos/my_diary.proto new file mode 100644 index 0000000..a2c9919 --- /dev/null +++ b/ZR.Admin.Grpc/Protos/my_diary.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; + +option csharp_namespace = "ZR.Admin.Grpc"; + +package my.diary; + +import "google/protobuf/timestamp.proto"; + +// The greeting service definition. +service MyDiary { + // Sends a greeting + rpc Edit (EditRequest) returns (EditReply); + rpc Query (QueryRequest) returns (QueryReply); +} + +// The request message containing the user's name. +message EditRequest { + string content = 1; + int64 user_id = 2; + google.protobuf.Timestamp create_time = 3; // 字段名仍然建议使用 snake_case +} + +// The response message containing the greetings. +message EditReply { + string result_message = 1; +} + +message QueryRequest { + int64 user_id = 1; + google.protobuf.Timestamp create_time = 2; +} + +message QueryReply { + string content = 1; +} \ No newline at end of file diff --git a/ZR.Admin.Grpc/Services/GreeterService.cs b/ZR.Admin.Grpc/Services/GreeterService.cs new file mode 100644 index 0000000..c893ded --- /dev/null +++ b/ZR.Admin.Grpc/Services/GreeterService.cs @@ -0,0 +1,37 @@ +using Grpc.Core; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZR.Admin.Grpc.Services +{ + public class GreeterService : Greeter.GreeterBase + { + private readonly ILogger _logger; + + public GreeterService(ILogger logger) + { + _logger = logger; + } + + // 实现 SayHello 方法 + // 第一个参数是请求消息 (HelloRequest) + // 第二个参数是服务器上下文 (ServerCallContext),提供关于当前调用的信息 + public override Task SayHello(HelloRequest request, ServerCallContext context) + { + _logger.LogInformation($"接收到来自 {request.Name} 的请求"); + + // 构建并返回回复消息 + var reply = new HelloReply + { + Message = $"你好,{request.Name} 来自 gRPC 服务器!" + }; + + // 返回一个 Task + return Task.FromResult(reply); + } + } +} diff --git a/ZR.Admin.Grpc/Services/MyDiaryService.cs b/ZR.Admin.Grpc/Services/MyDiaryService.cs new file mode 100644 index 0000000..861a5d8 --- /dev/null +++ b/ZR.Admin.Grpc/Services/MyDiaryService.cs @@ -0,0 +1,76 @@ +using Grpc.Core; +using Microsoft.Extensions.Logging; +using ZR.Service.IService; + +namespace ZR.Admin.Grpc.Services +{ + public class MyDiaryService(ILogger logger, IMyDiaryService myDiaryService) : MyDiary.MyDiaryBase + { + public override async Task Edit(EditRequest request, ServerCallContext context) + { + logger.LogInformation($"接收到来自 {request.UserId} 的请求"); + + var myDiary = new Model.MyDiary() + { + Content = request.Content, + CreateTime = request.CreateTime.ToDateTime().ToLocalTime(), + UserId = request.UserId + }; + + var myDiaryToday = await myDiaryService.Queryable() + .Where(it => it.CreateTime.Date == myDiary.CreateTime.Date && it.UserId == myDiary.UserId) + .FirstAsync(); + if (myDiaryToday != null) + { + myDiaryToday.Content = myDiary.Content; + await myDiaryService.Updateable(myDiaryToday) + .ExecuteCommandAsync(); + } + else + { + await myDiaryService.Insertable(myDiary).ExecuteReturnSnowflakeIdAsync(); + } + + + + // 构建并返回回复消息 + var reply = new EditReply() + { + ResultMessage = $"日记已记录 来自 gRPC 服务器!" + }; + + logger.LogInformation($"日记已记录"); + + // 返回一个 Task + return reply; + } + + public override async Task Query(QueryRequest request, ServerCallContext context) + { + logger.LogInformation($"接收到来自 {request.UserId} 的请求"); + + var myDiary = new Model.MyDiary() + { + CreateTime = request.CreateTime.ToDateTime().ToLocalTime(), + UserId = request.UserId + }; + + var myDiaryToday = await myDiaryService.Queryable() + .Where(it => it.CreateTime.Date == myDiary.CreateTime.Date && it.UserId == myDiary.UserId) + .FirstAsync(); + + if (myDiaryToday != null) + { + myDiary.Content = myDiaryToday.Content; + } + + // 构建并返回回复消息 + var reply = new QueryReply() + { + Content = myDiary.Content ?? "" + }; + + return reply; + } + } +} diff --git a/ZR.Admin.Grpc/ZR.Admin.Grpc.csproj b/ZR.Admin.Grpc/ZR.Admin.Grpc.csproj index 5d38906..27c5eef 100644 --- a/ZR.Admin.Grpc/ZR.Admin.Grpc.csproj +++ b/ZR.Admin.Grpc/ZR.Admin.Grpc.csproj @@ -7,16 +7,17 @@ - - + + + - + - + diff --git a/ZR.Admin.WebApi/Program.cs b/ZR.Admin.WebApi/Program.cs index d6fba37..f585f87 100644 --- a/ZR.Admin.WebApi/Program.cs +++ b/ZR.Admin.WebApi/Program.cs @@ -1,14 +1,15 @@ using AspNetCoreRateLimit; using Infrastructure.Converter; using Microsoft.AspNetCore.DataProtection; -using NLog.Web; -using System.Text.Json; using Microsoft.AspNetCore.RateLimiting; +using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Caching.Redis; using Microsoft.Extensions.Options; +using NLog.Web; +using System.Text.Json; using ZR.Admin.Grpc; -using ZR.Admin.Grpc.Extensions; +using ZR.Admin.Grpc.Services; using ZR.Admin.WebApi.Extensions; using ZR.Infrastructure.Cache; using ZR.Infrastructure.WebExtensions; @@ -99,15 +100,27 @@ builder.Services.AddSignalR() options.PayloadSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; }); builder.Services.AddSwaggerConfig(); -// using var channel = GrpcChannel.ForAddress("https://localhost:7025"); -// var client = new Greeter.GreeterClient(channel); -// var reply = await client.SayHelloAsync(new HelloRequest { Name = "GreeterClient" }); -// Console.WriteLine("Greeting: " + reply.Message); +//using var channel = GrpcChannel.ForAddress("https://localhost:7025"); +//var client = new Greeter.GreeterClient(channel); +//var reply = await client.SayHelloAsync(new HelloRequest { Name = "GreeterClient" }); +//Console.WriteLine("Greeting: " + reply.Message); // // var blockClient = new Block.BlockClient(channel); // var blockReply = await blockClient.GetBlockAsync(new BlockRequest { In = "asads" }); // Console.WriteLine("BlockReply: " + blockReply.Out); -builder.Services.AddGrpcServiceConfiguration(builder.Configuration); +//builder.Services.AddGrpcServiceConfiguration(builder.Configuration); + +// 配置 Kestrel 监听 HTTP/2 的非加密流量 +//builder.WebHost.ConfigureKestrel(options => +//{ +// // 如果你只想监听一个端口,只保留其中一个 Listen +// options.ListenLocalhost(8888, o => +// { +// o.Protocols = HttpProtocols.Http2; // 明确设置为 Http2 +// }); + +//}); + var app = builder.Build(); InternalApp.ServiceProvider = app.Services; InternalApp.Configuration = builder.Configuration; @@ -140,7 +153,7 @@ app.UseStaticFiles(); //开启路由访问 app.UseRouting(); app.UseCors("Policy");//要放在app.UseEndpoints前。 -//app.UseHttpsRedirection(); +app.UseHttpsRedirection(); app.UseAuthentication(); app.UseAuthorization(); @@ -187,12 +200,15 @@ using (var serviceScope = app.Services.CreateScope()) pol.IpRules.AddRange(ipRateLimitPolicies.Adapt>()); await ipPolicyStore.SetAsync(optionsAccessor.Value.IpPolicyPrefix, pol); - // var greeterClient = services.GetRequiredService(); - // var helloReply = await greeterClient.SayHelloAsync(new HelloRequest - // { - // Name = "gree" - // }); - // Console.WriteLine(helloReply); + //var greeterClient = services.GetRequiredService(); + //var helloReply = await greeterClient.SayHelloAsync(new HelloRequest + //{ + // Name = "gree" + //}); + //Console.WriteLine(helloReply); } +app.MapGrpcService(); +app.MapGrpcService(); + app.Run(); \ No newline at end of file diff --git a/ZR.Admin.WebApi/Properties/launchSettings.json b/ZR.Admin.WebApi/Properties/launchSettings.json index 8ba95da..fe57f62 100644 --- a/ZR.Admin.WebApi/Properties/launchSettings.json +++ b/ZR.Admin.WebApi/Properties/launchSettings.json @@ -10,13 +10,13 @@ }, "profiles": { "ZR.Admin.WebApi": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchUrl": "", - "applicationUrl": "http://localhost:8888", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } + "commandName": "Project", + "dotnetRunMessages": true, + "launchUrl": "", + "applicationUrl": "https://localhost:8888", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } } } } diff --git a/ZR.Admin.WebApi/appsettings.Production.json b/ZR.Admin.WebApi/appsettings.Production.json new file mode 100644 index 0000000..9150b10 --- /dev/null +++ b/ZR.Admin.WebApi/appsettings.Production.json @@ -0,0 +1,20 @@ +{ + "urls": "http://[*]:8888", //项目启动url,如果改动端口前端对应devServer也需要进行修改 + "dbConfigs": [ + { + "Conn": "server=8.140.174.251;user=admin;pwd=admin123;database=ZrAdmin", + "DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4 + "ConfigId": "0", //多租户唯一标识 + "IsAutoCloseConnection": true + } + //...下面添加更多的数据库源 + ], + //redis服务配置 + "RedisServer": { + "open": 1, //是否启用redis + "Cache": "8.140.174.251:6379,password=Wyd210213,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=cache:", + // "Cache": "127.0.0.1:6379,password=Wyd210213,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=cache:", + "Session": "8.140.174.251:6379,password=Wyd210213,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=session:" + // "Session": "127.0.0.1:6379,password=Wyd210213,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=session:" + }, +} \ No newline at end of file diff --git a/ZR.Admin.WebApi/appsettings.json b/ZR.Admin.WebApi/appsettings.json index 7c4f607..244121b 100644 --- a/ZR.Admin.WebApi/appsettings.json +++ b/ZR.Admin.WebApi/appsettings.json @@ -1,128 +1,126 @@ { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "dbConfigs": [ + { + "Conn": "server=127.0.0.1;user=admin;pwd=admin123;database=ZrAdmin;port=3306", + "DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4 + "ConfigId": "0", //多租户唯一标识 + "IsAutoCloseConnection": true + } + //...下面添加更多的数据库源 + ], + //代码生成数据库配置 + "CodeGenDbConfig": { + //代码生成连接字符串,注意{dbName}为固定格式,不要填写数据库名 + "Conn": "Data Source=127.0.0.1;user=admin;pwd=admin123;database=ZrAdmin;port=3306", + "DbType": 0, + "IsAutoCloseConnection": true, + "DbName": "ZrAdmin" //代码生成默认连接数据库,Oracle库是实例的名称 + }, + "urls": "https://localhost:8888", //项目启动url,如果改动端口前端对应devServer也需要进行修改 + "corsUrls": [ "http://localhost:8887", "http://localhost:8886" ], //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开 + "JwtSettings": { + "Issuer": "ZRAdmin.NET", //即token的签发者。 + "Audience": "ZRAdmin.NET", //指该token是服务于哪个群体的(群体范围) + "SecretKey": "SecretKey-ZRADMIN.NET-20210101", + "Expire": 1440, //jwt登录过期时间(分) + "RefreshTokenTime": 5, //分钟 + "TokenType": "Bearer" + }, + "InjectClass": [ "ZR.Repository", "ZR.Service", "ZR.Tasks", "ZR.ServiceCore" ], //自动注入类 + "ShowDbLog": true, //是否打印db日志 + "InitDb": false, //是否初始化db + "DemoMode": false, //是否演示模式 + "SingleLogin": false, //是否单点登录 + "Upload": { + "uploadUrl": "http://localhost:8888", //本地存储资源访问路径 + "localSavePath": "", //本地上传默认文件存储目录 wwwroot + "maxSize": 15, //上传文件大小限制 15M + "notAllowedExt": [ ".bat", ".exe", ".jar", ".js" ] + }, + //阿里云存储配置 + "ALIYUN_OSS": { + "REGIONID": "oss-cn-hangzhou.aliyuncs.com", //eg:cn-hangzhou + "KEY": "LTAI5tBjDZatWWunAhxLAAFR", + "SECRET": "Klcm77KdpkIROAl2ffPemK5I1yDshM", + "bucketName": "markdownhexo", + "domainUrl": "https://markdownhexo.oss-cn-hangzhou.aliyuncs.com", //访问资源域名 + "maxSize": 1000 //上传文件大小限制 1000M + }, + //企业微信通知配置 + "WxCorp": { + "AgentID": "", + "CorpID": "", + "CorpSecret": "", + "SendUser": "@all" + }, + //微信公众号设置 + "WxOpen": { + "AppID": "", + "AppSecret": "" + }, + //代码生成配置 + "gen": { + //是否显示移动端代码生成 + "showApp": false, + //自动去除表前缀 + "autoPre": true, + "author": "admin", + "tablePrefix": "sys_", //"表前缀(生成类名不会包含表前缀,多个用逗号分隔)", + "vuePath": "", //前端代码存储路径eg:D:\Work\ZRAdmin-Vue3 + "csharpTypeArr": { + "string": [ "varchar", "nvarchar", "text", "longtext" ], + "int": [ "int", "integer", "smallint", "int4", "int8", "int2" ], + "long": [ "bigint", "number" ], + "float": [ "numeric", "real", "float" ], + "decimal": [ "money", "decimal", "smallmoney" ], + "dateTime": [ "date", "datetime", "datetime2", "smalldatetime", "timestamp" ], + "byte": [ "tinyint" ], + "bool": [ "bit" ] + } + }, + //邮箱配置信息 + "MailOptions": { + //发件人名称 + "FromName": "文永达", + //发送人邮箱 + "FromEmail": "1224169330@qq.com", //eg:xxxx@qq.com + //发送人邮箱密码 + "Password": "wbctsfvdazchibdh", + //协议 + "Smtp": "smtp.qq.com", + "Port": 465, + "Signature": "系统邮件,请勿回复!", + "UseSsl": true + }, + //redis服务配置 + "RedisServer": { + "open": 1, //是否启用redis + "Cache": "127.0.0.1:6379,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=cache:", + "Session": "127.0.0.1:6379,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=session:" + }, + //验证码配置 + "CaptchaOptions": { + "CaptchaType": 10, + "IgnoreCase": true, // 比较时是否忽略大小写 + "ImageOption": { + "FontSize": 36, // 字体大小 + "Animation": true, // 是否启用动画 + "TextBold": true, // 是否启用粗体 + "InterferenceLineCount": 4, // 干扰线数量 + "BubbleMinRadius": 5, // 气泡最小半径 + "BubbleMaxRadius": 10, // 气泡最大半径 + "BubbleCount": 3, // 气泡数量 + "BubbleThickness": 1.0 // 气泡边沿厚度 + } + }, + "GrpcUrls": { + "FindTeacher": "http://localhost:5212" } - }, - "dbConfigs": [ - { - "Conn": "server=8.140.174.251;user=admin;pwd=admin123;database=ZrAdmin;port=33060", - "DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4 - "ConfigId": "0", //多租户唯一标识 - "IsAutoCloseConnection": true - } - //...下面添加更多的数据库源 - ], - //代码生成数据库配置 - "CodeGenDbConfig": { - //代码生成连接字符串,注意{dbName}为固定格式,不要填写数据库名 - "Conn": "Data Source=LAPTOP-STKF2M8H\\SQLEXPRESS;User ID=admin;Password=admin123;Initial Catalog={dbName};", - "DbType": 1, - "IsAutoCloseConnection": true, - "DbName": "ZrAdmin" //代码生成默认连接数据库,Oracle库是实例的名称 - }, - "urls": "http://localhost:8888", //项目启动url,如果改动端口前端对应devServer也需要进行修改 - "corsUrls": [ "http://localhost:8887", "http://localhost:8886" ], //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开 - "JwtSettings": { - "Issuer": "ZRAdmin.NET", //即token的签发者。 - "Audience": "ZRAdmin.NET", //指该token是服务于哪个群体的(群体范围) - "SecretKey": "SecretKey-ZRADMIN.NET-20210101", - "Expire": 1440, //jwt登录过期时间(分) - "RefreshTokenTime": 5,//分钟 - "TokenType": "Bearer" - }, - "InjectClass": [ "ZR.Repository", "ZR.Service", "ZR.Tasks", "ZR.ServiceCore" ], //自动注入类 - "ShowDbLog": true, //是否打印db日志 - "InitDb": false, //是否初始化db - "DemoMode": false, //是否演示模式 - "SingleLogin": false,//是否单点登录 - "Upload": { - "uploadUrl": "http://localhost:8888", //本地存储资源访问路径 - "localSavePath": "", //本地上传默认文件存储目录 wwwroot - "maxSize": 15, //上传文件大小限制 15M - "notAllowedExt": [ ".bat", ".exe", ".jar", ".js" ] - }, - //阿里云存储配置 - "ALIYUN_OSS": { - "REGIONID": "oss-cn-hangzhou.aliyuncs.com", //eg:cn-hangzhou - "KEY": "LTAI5tBjDZatWWunAhxLAAFR", - "SECRET": "Klcm77KdpkIROAl2ffPemK5I1yDshM", - "bucketName": "markdownhexo", - "domainUrl": "https://markdownhexo.oss-cn-hangzhou.aliyuncs.com", //访问资源域名 - "maxSize": 1000 //上传文件大小限制 1000M - }, - //企业微信通知配置 - "WxCorp": { - "AgentID": "", - "CorpID": "", - "CorpSecret": "", - "SendUser": "@all" - }, - //微信公众号设置 - "WxOpen": { - "AppID": "", - "AppSecret": "" - }, - //代码生成配置 - "gen": { - //是否显示移动端代码生成 - "showApp": false, - //自动去除表前缀 - "autoPre": true, - "author": "admin", - "tablePrefix": "sys_", //"表前缀(生成类名不会包含表前缀,多个用逗号分隔)", - "vuePath": "", //前端代码存储路径eg:D:\Work\ZRAdmin-Vue3 - "csharpTypeArr": { - "string": [ "varchar", "nvarchar", "text", "longtext" ], - "int": [ "int", "integer", "smallint", "int4", "int8", "int2" ], - "long": [ "bigint", "number" ], - "float": [ "numeric", "real", "float" ], - "decimal": [ "money", "decimal", "smallmoney" ], - "dateTime": [ "date", "datetime", "datetime2", "smalldatetime", "timestamp" ], - "byte": [ "tinyint" ], - "bool": [ "bit" ] - } - }, - //邮箱配置信息 - "MailOptions": { - //发件人名称 - "FromName": "文永达", - //发送人邮箱 - "FromEmail": "1224169330@qq.com", //eg:xxxx@qq.com - //发送人邮箱密码 - "Password": "wbctsfvdazchibdh", - //协议 - "Smtp": "smtp.qq.com", - "Port": 465, - "Signature": "系统邮件,请勿回复!", - "UseSsl": true - }, - //redis服务配置 - "RedisServer": { - "open": 1, //是否启用redis - "Cache": "8.140.174.251:6379,password=Wyd210213,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=cache:", -// "Cache": "127.0.0.1:6379,password=Wyd210213,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=cache:", - "Session": "8.140.174.251:6379,password=Wyd210213,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=session:" -// "Session": "127.0.0.1:6379,password=Wyd210213,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=session:" - }, - //验证码配置 - "CaptchaOptions": { - "CaptchaType": 10, - "IgnoreCase": true, // 比较时是否忽略大小写 - "ImageOption": { - "FontSize": 36, // 字体大小 - "Animation": true, // 是否启用动画 - "TextBold": true, // 是否启用粗体 - "InterferenceLineCount": 4, // 干扰线数量 - "BubbleMinRadius": 5, // 气泡最小半径 - "BubbleMaxRadius": 10, // 气泡最大半径 - "BubbleCount": 3, // 气泡数量 - "BubbleThickness": 1.0 // 气泡边沿厚度 - } - }, - "GrpcUrls": { - "FindTeacher": "http://localhost:5212" - } } diff --git a/ZR.Model/MyDiary.cs b/ZR.Model/MyDiary.cs new file mode 100644 index 0000000..c64100c --- /dev/null +++ b/ZR.Model/MyDiary.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZR.Model +{ + [SugarTable("my_diary")] + public class MyDiary + { + [SugarColumn(IsPrimaryKey = true)] + [JsonConverter(typeof(ValueToStringConverter))] + public long Id { get; set; } + + public string Content { get; set; } + + [JsonConverter(typeof(ValueToStringConverter))] + public long UserId { get; set; } + + public DateTime CreateTime { get; set; } + } +} diff --git a/ZR.Service/IService/IMyDiaryService.cs b/ZR.Service/IService/IMyDiaryService.cs new file mode 100644 index 0000000..ffa9afb --- /dev/null +++ b/ZR.Service/IService/IMyDiaryService.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZR.Model; + +namespace ZR.Service.IService +{ + public interface IMyDiaryService : IBaseService + { + + } +} diff --git a/ZR.Service/MyDiaryService.cs b/ZR.Service/MyDiaryService.cs new file mode 100644 index 0000000..4b2ef4d --- /dev/null +++ b/ZR.Service/MyDiaryService.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZR.Model; +using ZR.Service.IService; + +namespace ZR.Service +{ + [AppService(ServiceType = typeof(IMyDiaryService), ServiceLifetime = LifeTime.Transient)] + public class MyDiaryService : BaseService, IMyDiaryService + { + } +}