Former-commit-id: b9429ff5591f58712e5526aecb7522073feb5708
Former-commit-id: 71546c05bce88eee78f3195ce18a05a3dc41e04b
1.0
wanggang 4 years ago
parent 39c3e04196
commit e505540062

@ -128,6 +128,7 @@ namespace Platform.Data
}
});
db.SaveChanges();
db.Set<DictionaryCategory>().Add(new DictionaryCategory
{
Key = "OrganType",
@ -142,6 +143,7 @@ namespace Platform.Data
}
});
db.SaveChanges();
db.Set<DictionaryCategory>().Add(new DictionaryCategory
{
Key = "BuildingType",
@ -154,6 +156,7 @@ namespace Platform.Data
}
});
db.SaveChanges();
db.Set<DictionaryCategory>().Add(new DictionaryCategory
{
Key = "DepartmentType",
@ -166,6 +169,7 @@ namespace Platform.Data
}
});
db.SaveChanges();
db.Set<DictionaryCategory>().Add(new DictionaryCategory
{
Key = "DepartmentUserType",
@ -177,6 +181,7 @@ namespace Platform.Data
}
});
db.SaveChanges();
db.Set<DictionaryCategory>().Add(new DictionaryCategory
{
Key = "OrganUserType",
@ -189,6 +194,7 @@ namespace Platform.Data
}
});
db.SaveChanges();
var order = 0;
var root = db.Set<IoTProductCategory>().Add(new IoTProductCategory
{
@ -493,7 +499,8 @@ namespace Platform.Data
var superRole = new Role { OrganId = platformOrganId, Number = "super", Name = "超级管理员", IsReadOnly = true };
var adminRole = new Role { OrganId = platformOrganId, Number = "admin", Name = "管理员" };
var organRole = new Role { OrganId = platformOrganId, Number = "organ", Name = "机构管理员" };
db.Set<Role>().AddRange(superRole, adminRole, organRole);
db.SaveChanges();
//初始化角色
var skips = new string[] {
//"添加Api", "修改Api", "添加分类", "修改分类", "添加参数", "修改参数", "添加产品", "修改产品", "添加节点", "添加权限", "修改权限", "添加权限分类", "修改权限分类", "添加设备"
@ -501,18 +508,17 @@ namespace Platform.Data
foreach (var item in db.Set<Permission>())
{
superRole.RolePermissions.Add(new RolePermission { IsReadOnly = true, Permission = item });
db.Set<RolePermission>().Add(new RolePermission {IsReadOnly = true,RoleId = superRole.Id,PermissionId=item.Id });
if (!item.Name.Contains("删除") && !skips.Contains(item.Name))
{
adminRole.RolePermissions.Add(new RolePermission { Permission = item });
db.Set<RolePermission>().Add(new RolePermission { IsReadOnly = true, RoleId = adminRole.Id, PermissionId = item.Id });
if (item.Type == PermissionType.Organ)
{
organRole.RolePermissions.Add(new RolePermission { Permission = item });
db.Set<RolePermission>().Add(new RolePermission { IsReadOnly = true, RoleId = organRole.Id, PermissionId = item.Id });
}
}
db.SaveChanges();
}
db.Set<Role>().AddRange(superRole, adminRole, organRole);
db.SaveChanges();
var securityStam = "123456";
db.Set<User>().Add(new User

@ -1,4 +1,5 @@
using Microsoft.AspNetCore;
using Infrastructure.Extensions;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
@ -55,19 +56,27 @@ namespace Platform
private static ILogger GetLogger(IConfigurationRoot config)
{
return new LoggerConfiguration()
.ReadFrom.Configuration(config, ConfigurationAssemblySource.AlwaysScanDllFiles)
.WriteTo.Console()
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(config.GetConnectionString("Log")))
var loggerConfiguration = new LoggerConfiguration().ReadFrom.Configuration(config, ConfigurationAssemblySource.AlwaysScanDllFiles);
loggerConfiguration.WriteTo.Console();
var logType = config.GetAppSetting("Log", "File");
if (logType == "Elasticsearch")
{
loggerConfiguration.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(config.GetConnectionString("Log.Elasticsearch")))
{
AutoRegisterTemplate = true,
AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7,
CustomFormatter = new ExceptionAsObjectJsonFormatter(renderMessage: true),
FailureCallback = e => Console.WriteLine("Unable to submit event " + e.MessageTemplate),
EmitEventFailure = EmitEventFailureHandling.WriteToSelfLog |EmitEventFailureHandling.WriteToFailureSink | EmitEventFailureHandling.RaiseCallback,
EmitEventFailure = EmitEventFailureHandling.WriteToSelfLog | EmitEventFailureHandling.WriteToFailureSink | EmitEventFailureHandling.RaiseCallback,
FailureSink = new RollingFileSink("logs/log.json", new JsonFormatter(), 100 * 1024 * 1024, 1, Encoding.UTF8)
})
.CreateLogger();
});
}
else
{
loggerConfiguration.WriteTo
.File("logs/log.txt", rollOnFileSizeLimit: true, fileSizeLimitBytes: 100 * 1024 * 1024, rollingInterval: RollingInterval.Infinite);
}
return loggerConfiguration.CreateLogger();
}
}
}

@ -1,8 +1,8 @@
{
"ConnectionStrings": {
"SQLite": "Data Source=iotcenter.db",
"MySQL": "Server=mysql;Port=3306;Database=iotcenter;Uid=root;Pwd=aA123456!;",
"Log": "http://elasticsearch:9200",
"MySQL": "Server=mysql;Port=3306;Database=iotcenter;Uid=root;Pwd=aA123456!;default command timeout=300;",
"Log.Elasticsearch": "http://elasticsearch:9200",
"Job.MySQL": "Server=mysql;Port=3306;Database=jobserver;Uid=root;Pwd=aA123456!;Allow User Variables=True;",
"PostgreSQL": "User ID=root;Host=localhost;Port=26257;Database=iotcenter;CommandTimeout=600;TrustServerCertificate=true;",
"Redis": "redis:6379,password=aA123456!,allowAdmin=true",

@ -13,6 +13,7 @@
"OpenApi": "name=v1;title=title;version=1.0",
"BasePath": "/platform",
"TablePrefix": "",
"Log": "Elasticsearch",
"Database": "MySQL",
"JobDatabase": "MySQL",
"FileServer": "MinIO",
@ -22,8 +23,8 @@
},
"ConnectionStrings": {
"SQLite": "Data Source=iotcenter.db",
"MySQL": "Server=localhost;Port=3306;Database=iotcenter;Uid=root;Pwd=aA123456!;",
"Log": "http://localhost:9200",
"MySQL": "Server=localhost;Port=3306;Database=iotcenter;Uid=root;Pwd=aA123456!;default command timeout=300;",
"Log.Elasticsearch": "http://localhost:9200",
"Job.MySQL": "Server=localhost;Port=3306;Database=jobserver;Uid=root;Pwd=aA123456!;Allow User Variables=True;",
"PostgreSQL": "User ID=root;Host=localhost;Port=26257;Database=iotcenter;CommandTimeout=600;TrustServerCertificate=true;",
"Redis": "localhost:6379,password=aA123456!,allowAdmin=true",

@ -5,6 +5,11 @@ services:
#monitor
platform:
image: mcr.microsoft.com/dotnet/aspnet:5.0
deploy:
resources:
limits:
memory: 2g
cpus: '0.20'
restart: always
environment:
- TZ=Asia/Shanghai

@ -1,7 +1,4 @@
version: "3.8"
networks:
default:
driver: bridge
services:
#netdata
netdata:
@ -71,10 +68,6 @@ services:
mysql:
image: mysql:8.0
restart: always
deploy:
resources:
limits:
memory: 2g
environment:
- MYSQL_ROOT_PASSWORD=aA123456!
command: --default-authentication-plugin=mysql_native_password
@ -125,13 +118,9 @@ services:
elasticsearch:
image: elasticsearch:7.12.0
restart: always
deploy:
resources:
limits:
memory: 2g
environment:
- discovery.type=single-node
- ES_JAVA_OPTS=-Xms1g -Xmx1g
- ES_JAVA_OPTS=-Xms512m -Xmx512m
- http.cors.enabled=true
- http.cors.allow-origin=*
ports:
@ -144,4 +133,6 @@ services:
image: kibana:7.12.0
restart: always
ports:
- 5601:5601
- 5601:5601
depends_on:
- elasticsearch
Loading…
Cancel
Save