Merge branch 'furion' of https://gitee.com/ccnetcore/Yi into furion

This commit is contained in:
橙子
2023-08-13 21:27:55 +08:00
16 changed files with 250 additions and 10 deletions

View File

@@ -0,0 +1,23 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "YI",
"classifications": [ "Common", "Code" ],
"identity": "yi",
"name": "YI",
"shortName": "yi",
"sourceName": "Yi.Furion",
"tags": {
"language": "C#",
"type": "item"
},
"sources": [
{
"modifiers": [
{
"exclude": [ "Server.Bin/**/*", "obj/**/*", "*.user", "*.vspscc", "*.vssscc", "*.cache",".git/**/*",".vs/**/*" ]
}
]
}
]
}

View File

@@ -13,7 +13,7 @@ using Yi.Framework.Infrastructure.Data.Entities;
namespace Yi.Framework.Infrastructure.Sqlsugar
{
public class SqlSugarDbContext
public class SqlSugarDbContext
{
/// <summary>
/// SqlSugar 客户端
@@ -109,7 +109,11 @@ namespace Yi.Framework.Infrastructure.Sqlsugar
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModificationTime)))
{
entityInfo.SetValue(DateTime.Now);
//为空或者为默认最小值
if (oldValue is null || DateTime.MinValue.Equals((DateTime)oldValue))
{
entityInfo.SetValue(DateTime.Now);
}
}
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModifierId)))
{
@@ -122,7 +126,11 @@ namespace Yi.Framework.Infrastructure.Sqlsugar
case DataFilterType.InsertByObject:
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreationTime)))
{
entityInfo.SetValue(DateTime.Now);
//为空或者为默认最小值
if (oldValue is null || DateTime.MinValue.Equals((DateTime)oldValue))
{
entityInfo.SetValue(DateTime.Now);
}
}
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreatorId)))
{

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Module.WebFirstManager.Dtos
{
public class WebFirstGetOutputDto
{
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using Yi.Framework.Infrastructure.Data.Auditing;
using Yi.Framework.Infrastructure.Ddd.Entities;
namespace Yi.Framework.Module.WebFirstManager.Entities
{
public class TemplateEntity : IEntity<long>, ICreationAuditedObject
{
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// 模板字符串
/// </summary>
public string TemplateStr { get; set; } = string.Empty;
public long? CreatorId { get; set; }
public DateTime CreationTime { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Module.WebFirstManager.Entities
{
public class TemplateVarEntity
{
/// <summary>
/// 变量名称
/// </summary>
public string Name { get; set; }=string.Empty;
/// <summary>
/// 变量值
/// </summary>
public string Value { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Module.WebFirstManager
{
public interface ITemplateService
{
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Module.WebFirstManager
{
public interface ITemplateVarService
{
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Module.WebFirstManager
{
public interface IWebFirstService
{
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Module.WebFirstManager.Impl
{
public class TemplateService: ITemplateService
{
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Module.WebFirstManager.Impl
{
public class TemplateVarService: ITemplateVarService
{
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mapster;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Yi.Framework.Infrastructure.Ddd.Repositories;
using Yi.Framework.Infrastructure.Ddd.Services;
using Yi.Framework.Module.WebFirstManager.Dtos;
using Yi.Framework.Module.WebFirstManager.Entities;
namespace Yi.Framework.Module.WebFirstManager.Impl
{
public class WebFirstService : ApplicationService, IWebFirstService
{
private IRepository<TemplateEntity> _repository;
public WebFirstService(IRepository<TemplateEntity> repository) { _repository = repository; }
/// <summary>
/// 根据模板id生成对应的结果
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<WebFirstGetOutputDto> GetAsync(Guid id)
{
var entity = await _repository.GetByIdAsync(id);
return entity.Adapt<WebFirstGetOutputDto>();
}
}
}

View File

@@ -346,7 +346,7 @@ namespace Yi.Furion.Application.Rbac.Services.Impl
[HttpPut]
public async Task<bool> RestPasswordAsync(long userId, RestPasswordDto input)
{
if (!string.IsNullOrEmpty(input.Password))
if (string.IsNullOrEmpty(input.Password))
{
throw new UserFriendlyException("重置密码不能为空!");
}

View File

@@ -0,0 +1,57 @@
using SqlSugar;
using Yi.Framework.Infrastructure.Data.DataSeeds;
using Yi.Framework.Infrastructure.Ddd.Repositories;
using Yi.Framework.Module.DictionaryManager.Entities;
using Yi.Furion.Core.Rbac.Entities;
namespace Yi.Furion.Core.Bbs.DataSeeds
{
public class ConfigDataSeed : AbstractDataSeed<ConfigEntity>, ITransient
{
public ConfigDataSeed(IRepository<ConfigEntity> repository) : base(repository)
{
}
public override List<ConfigEntity> GetSeedData()
{
List<ConfigEntity> entities = new List<ConfigEntity>();
ConfigEntity config1 = new ConfigEntity()
{
Id = SnowFlakeSingle.Instance.NextId(),
ConfigKey= "bbs.site.name",
ConfigName="站点名称",
ConfigValue="意社区"
};
entities.Add(config1);
ConfigEntity config2 = new ConfigEntity()
{
Id = SnowFlakeSingle.Instance.NextId(),
ConfigKey = "bbs.site.author",
ConfigName = "站点作者",
ConfigValue = "橙子"
};
entities.Add(config2);
ConfigEntity config3 = new ConfigEntity()
{
Id = SnowFlakeSingle.Instance.NextId(),
ConfigKey = "bbs.site.icp",
ConfigName = "站点Icp备案",
ConfigValue = "赣ICP备20008025号"
};
entities.Add(config3);
ConfigEntity config4 = new ConfigEntity()
{
Id = SnowFlakeSingle.Instance.NextId(),
ConfigKey = "bbs.site.bottom",
ConfigName = "站点底部信息",
ConfigValue = "你好世界"
};
entities.Add(config4);
return entities;
}
}
}

View File

@@ -24,7 +24,7 @@ public class Startup : AppStartup
services.AddCorsAccessor();
services.AddControllers().AddInjectWithUnifyResult().AddJsonOptions(x => {
//x.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
x.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
x.JsonSerializerOptions.Converters.Add(new LongToStringConverter());
});
@@ -36,7 +36,7 @@ public class Startup : AppStartup
services.AddSchedule(options =>
{
// 注册作业,并配置作业触发器
options.AddJob<TestJob>(Triggers.Period(10000));
//options.AddJob<TestJob>(Triggers.Period(10000));
options.AddJob<SystemDataJob>(Triggers.Cron("0 0 0,12 ? * ?",CronStringFormat.WithSeconds)); // 表示每天凌晨与12点
});
services.AddFileLogging("log/application-{0:yyyy}-{0:MM}-{0:dd}.log", options =>