diff --git a/Learn.Archives.API/Controllers/SchoolController.cs b/Learn.Archives.API/Controllers/SchoolController.cs new file mode 100644 index 0000000..7701775 --- /dev/null +++ b/Learn.Archives.API/Controllers/SchoolController.cs @@ -0,0 +1,26 @@ +using Learn.Archives.API.Controllers.Dto; +using Learn.Archives.API.Expand; +using Learn.Archives.Core.Common; +using Learn.Archives.Core.Model; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Diagnostics; +using System.Security.Claims; +using UserCenter.Model; + +namespace Learn.Archives.API.Controllers +{ + public class SchoolController : BackController + { + readonly Repository baseService; + public SchoolController(Repository baseService) : base(baseService) + { + this.baseService = baseService; + } + + public override Task Del([FromBody] params long[] ids) + { + return base.Del(ids); + } + } +} diff --git a/Learn.Archives.API/appsettings.Production.json b/Learn.Archives.API/appsettings.Production.json index 677ce98..30cefab 100644 --- a/Learn.Archives.API/appsettings.Production.json +++ b/Learn.Archives.API/appsettings.Production.json @@ -5,14 +5,21 @@ "Microsoft.AspNetCore": "Error" } }, - "Redis": { - "ConnectionString": "redis-external.23544.com:16379,password=poiuyt)(*&^%,defaultDatabase=3" - }, - "DB": { - //"ConnectionString": "AllowLoadLocalInfile=true;Server=10.255.255.3;Port=3306;Database=learn.videoanalysis;User ID=marking;Password=qwe123!@#;CharSet=utf8mb4;pooling=true;SslMode=None", - "ConnectionString": "AllowLoadLocalInfile=true;Server=rm-2vc20nd3d11g0oh6g2o.rwlb.cn-chengdu.rds.aliyuncs.com;User ID=marking;Password=poiuytPOIUYT098765)(*&^%;Port=3306;Database=learn.videoanalysis;CharSet=utf8mb4;pooling=true;SslMode=None", - "SqlType": "MySql", - "UpdateTable": false + "Redis": { + "ConnectionString": "redis-external.23544.com:16379,password=poiuyt)(*&^%,defaultDatabase=3" + }, + "DB": { + //"ConnectionString": "AllowLoadLocalInfile=true;Server=10.255.255.3;Port=3306;Database=learn.videoanalysis;User ID=marking;Password=qwe123!@#;CharSet=utf8mb4;pooling=true;SslMode=None", + "ConnectionString": "AllowLoadLocalInfile=true;Server=rm-2vc20nd3d11g0oh6g2o.rwlb.cn-chengdu.rds.aliyuncs.com;User ID=marking;Password=poiuytPOIUYT098765)(*&^%;Port=3306;Database=learn.videoanalysis;CharSet=utf8mb4;pooling=true;SslMode=None", + "SqlType": "MySql", + "UpdateTable": false + }, + "OtherDBArr": [ + { + "ConfigId": 1001, //用户中心 + "ConnectionString": "AllowLoadLocalInfile=true;Server=rm-2vc20nd3d11g0oh6g2o.rwlb.cn-chengdu.rds.aliyuncs.com;User ID=marking;Password=poiuytPOIUYT098765)(*&^%;Port=3306;Database=usercenter;CharSet=utf8mb4;pooling=true;SslMode=None", + "SqlType": "MySql" } - } + ] +} } diff --git a/Learn.Archives.API/appsettings.json b/Learn.Archives.API/appsettings.json index 3f7b1b1..f744304 100644 --- a/Learn.Archives.API/appsettings.json +++ b/Learn.Archives.API/appsettings.json @@ -14,7 +14,7 @@ "DB": { "ConnectionString": "AllowLoadLocalInfile=true;Server=192.168.2.9;User ID=root;Password=qwe123!@#;Port=3306;Database=learn.archives;CharSet=utf8mb4;pooling=true;SslMode=None", "SqlType": "MySql", - "UpdateTable": false + "UpdateTable": true }, "AuthKey": { "Secret": "9FAB7AC7-F2DB-4C52-B81F-044055A34AF2", @@ -23,11 +23,11 @@ "Expires": 120 // 过期时间120小时 }, "OtherDBArr": [ - //{ - // "ConfigId": 1001, //ResourceBank - // "ConnectionString": "Server=47.109.35.116;Database=ResourceBank;UID=live;Password=Woshiren^&*();MultipleActiveResultSets=true;Encrypt=True;TrustServerCertificate=True;", - // "SqlType": "SqlServer" - //} + { + "ConfigId": 1001, //用户中心 + "ConnectionString": "AllowLoadLocalInfile=true;Server=192.168.2.9;User ID=root;Password=qwe123!@#;Port=3306;Database=usercenter;CharSet=utf8mb4;pooling=true;SslMode=None", + "SqlType": "MySql" + } ] } } diff --git a/Learn.Archives.Core/Common/AppCommon.cs b/Learn.Archives.Core/Common/AppCommon.cs index c4603f1..f05d31e 100644 --- a/Learn.Archives.Core/Common/AppCommon.cs +++ b/Learn.Archives.Core/Common/AppCommon.cs @@ -33,16 +33,18 @@ namespace Learn.Archives.Core.Common /// 主库数据库表类型 /// public static readonly IEnumerable DbMatserType; - public static readonly IEnumerable KnowsType; + public static readonly IEnumerable UserCenterType; static AppCommon() { try { Assemblies = ExpandFunction.GetAssemblies(); - var assembliesType = Assemblies.Where(s => s.FullName.Contains("VideoAnalysis")).SelectMany(s => s.ExportedTypes + var assembliesType = Assemblies.Where(s => s.FullName.Contains("Archives")).SelectMany(s => s.ExportedTypes .Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.IsDefined(typeof(SugarTable), false))); DbMatserType = assembliesType .Where(u => u.GetInterfaces().Contains(typeof(IDB))); + UserCenterType = assembliesType + .Where(u => u.FullName.Contains("UserCenter")); } catch { diff --git a/Learn.Archives.Core/Common/Repository.cs b/Learn.Archives.Core/Common/Repository.cs index 959ce7c..a908e12 100644 --- a/Learn.Archives.Core/Common/Repository.cs +++ b/Learn.Archives.Core/Common/Repository.cs @@ -6,12 +6,12 @@ using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; +using UserCenter.Model; namespace Learn.Archives.Core.Common { public class Repository : SimpleClient where T : class, new() { - readonly Dictionary CID = new Dictionary(); public Repository() { SwitchConnection(); @@ -19,19 +19,10 @@ namespace Learn.Archives.Core.Common public void SwitchConnection() { var t = typeof(T); - if (CID.ContainsKey(t)) - { - base.Context = CID[t] != null - ? DbScoped.Sugar.GetConnectionScope(CID[t]) - : DbScoped.Sugar; - return; - } - var c = t.GetCustomAttribute(); - if (!CID.ContainsKey(t)) - CID.Add(t, c?.configId); - base.Context = c != null - ? DbScoped.Sugar.GetConnectionScope(c.configId) - : DbScoped.Sugar; + if (AppCommon.DbMatserType.Contains(t)) + base.Context = DbScoped.Sugar; + else if (AppCommon.UserCenterType.Contains(t)) + base.Context = DbScoped.Sugar.GetConnectionScope(1001); } } } diff --git a/Learn.Archives.Core/Model/Admin.cs b/Learn.Archives.Core/Model/Admin.cs index 6895a62..75a5925 100644 --- a/Learn.Archives.Core/Model/Admin.cs +++ b/Learn.Archives.Core/Model/Admin.cs @@ -13,13 +13,21 @@ namespace Learn.Archives.Core.Model /// 管理员 /// [SugarTable("admin")] - public class Admin : EntityBaseId,IDB + public class Admin : EntityBaseId, IDB { /// /// 账号 /// [SugarColumn(Length = 12)] public string Name { get; set; } + /// + /// 电话号码 + /// + [SugarColumn(Length = 20)] + public string Phone { get; set; } + /// + /// 账号 + /// [SugarColumn(Length = 12)] public string Account { get; set; } /// diff --git a/Learn.Archives.Core/Model/AdminRole.cs b/Learn.Archives.Core/Model/AdminRole.cs new file mode 100644 index 0000000..22d5a28 --- /dev/null +++ b/Learn.Archives.Core/Model/AdminRole.cs @@ -0,0 +1,38 @@ +using Learn.Archives.Core.Model.Interface; +using SqlSugar; +using System.ComponentModel.DataAnnotations; +using System.Net; +using System.Text.Json; +using UserCenter.Model; +using UserCenter.Model.Enum; +using UserCenter.Model.Interface; + +namespace Learn.Archives.Core.Model +{ + /// + /// 角色 + /// + [SugarTable("adminrole")] + public class AdminRole : EntityBaseId, IDB + { + /// + /// 角色名称 + /// + [SugarColumn(Length = 12)] + public string Name { get; set; } + /// + /// 备注 + /// + [SugarColumn(Length = 20)] + public string Remark { get; set; } + /// + /// 状态 + /// + public bool Enable { get; set; } + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } = DateTime.Now; + + } +} diff --git a/Learn.Archives.Core/Model/HttpLog.cs b/Learn.Archives.Core/Model/HttpLog.cs index 8bf0bd4..28084bc 100644 --- a/Learn.Archives.Core/Model/HttpLog.cs +++ b/Learn.Archives.Core/Model/HttpLog.cs @@ -1,4 +1,5 @@ -using SqlSugar; +using Learn.Archives.Core.Model.Interface; +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; @@ -13,7 +14,7 @@ namespace Learn.Archives.Core.Model /// 管理员角色表 /// [SugarTable("httplog")] - public partial class HttpLog : EntityBaseId + public partial class HttpLog : EntityBaseId, IDB { /// /// 创建时间 diff --git a/Learn.Archives.Core/Model/Menu.cs b/Learn.Archives.Core/Model/Menu.cs new file mode 100644 index 0000000..a1cc092 --- /dev/null +++ b/Learn.Archives.Core/Model/Menu.cs @@ -0,0 +1,55 @@ +using Learn.Archives.Core.Model.Interface; +using SqlSugar; +using System.ComponentModel.DataAnnotations; +using System.Net; +using System.Text.Json; +using UserCenter.Model; +using UserCenter.Model.Enum; +using UserCenter.Model.Interface; + +namespace Learn.Archives.Core.Model +{ + /// + /// 菜单 + /// + [SugarTable("menu")] + public class Menu : EntityBaseId, IDB + { + /// + /// 名称 + /// + [SugarColumn(Length = 50)] + public required string Name { get; set; } + /// + /// 标题 + /// + [SugarColumn(Length = 20)] + public required string Title { get; set; } + /// + /// 路径 + /// + public string? Path { get; set; } + /// + /// 是按钮权限 + /// + public bool IsButton { get; set; } + /// + /// 图标 + /// + public string? Icon { get; set; } + /// + /// 需要的授权码 + /// + public string? Auths { get; set; } + /// + /// 排名 + /// + public int Rank { get; set; } + + /// + /// 显示菜单? + /// + public bool ShowLink { get; set; } + + } +} diff --git a/Learn.Archives.Core/Model/MenuRelation.cs b/Learn.Archives.Core/Model/MenuRelation.cs new file mode 100644 index 0000000..efe7bb8 --- /dev/null +++ b/Learn.Archives.Core/Model/MenuRelation.cs @@ -0,0 +1,33 @@ +using Learn.Archives.Core.Model.Interface; +using SqlSugar; +using System.ComponentModel.DataAnnotations; +using System.Net; +using System.Text.Json; +using UserCenter.Model; +using UserCenter.Model.Enum; +using UserCenter.Model.Interface; + +namespace Learn.Archives.Core.Model +{ + /// + /// 菜单 + /// + [SugarTable("menurelation")] + public class MenuRelation : EntityBaseId, IDB + { + /// + /// 菜单id + /// + public required long MenuId { get; set; } + /// + /// 管理员id + /// + public required long AdminId { get; set; } + + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } = DateTime.Now; + + } +} diff --git a/Learn.Archives.Core/Model/User.cs b/Learn.Archives.Core/Model/User.cs index 2a4d067..b674b78 100644 --- a/Learn.Archives.Core/Model/User.cs +++ b/Learn.Archives.Core/Model/User.cs @@ -12,8 +12,8 @@ namespace Learn.Archives.Core.Model /// 用户 /// 数据中心拓展用户 /// - [SugarTable("user")] - public class User : EntityBaseId, IDB + [SugarTable("userexpand")] + public class UserExpand : EntityBaseId, IDB { /// /// 用户中心的id