diff --git a/New_College.Api/Controllers/Back/Sys_TenantController.cs b/New_College.Api/Controllers/Back/Sys_TenantController.cs new file mode 100644 index 0000000..0c92526 --- /dev/null +++ b/New_College.Api/Controllers/Back/Sys_TenantController.cs @@ -0,0 +1,115 @@ +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Linq.Expressions; +using System.Threading.Tasks; + +namespace New_College.Api.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + [Authorize(Permissions.Name)] + public class Sys_TenantController : ControllerBase + { + /// + /// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下 + /// + private readonly ISys_TenantServices _sys_TenantServices; + + public Sys_TenantController(ISys_TenantServices Sys_TenantServices) + { + _sys_TenantServices = Sys_TenantServices; + } + + [HttpGet] + public async Task>> Get(int page = 1, string key = "", int intPageSize = 50) + { + if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) + { + key = ""; + } + + Expression> whereExpression = a => a.Id > 0; + + return new MessageModel>() + { + msg = "获取成功", + success = true, + response = await _sys_TenantServices.QueryPage(whereExpression, page, intPageSize) + }; + + } + + [HttpGet("{id}")] + public async Task> Get(int id = 0) + { + return new MessageModel() + { + msg = "获取成功", + success = true, + response = await _sys_TenantServices.QueryById(id) + }; + } + + [HttpPost] + public async Task> Post([FromBody] Sys_Tenant request) + { + var data = new MessageModel(); + + var id = await _sys_TenantServices.Add(request); + data.success = id > 0; + + if (data.success) + { + data.response = id.ObjToString(); + data.msg = "添加成功"; + } + + return data; + } + + [HttpPut] + public async Task> Put([FromBody] Sys_Tenant request) + { + var data = new MessageModel(); + if (request.Id > 0) + { + data.success = await _sys_TenantServices.Update(request); + if (data.success) + { + data.msg = "更新成功"; + data.response = request?.Id.ObjToString(); + } + } + + return data; + } + + [HttpDelete("{id}")] + public async Task> Delete(int id = 0) + { + var data = new MessageModel(); + if (id > 0) + { + var detail = await _sys_TenantServices.QueryById(id); + + detail.IsDelete = true; + + if (detail != null) + { + data.success = await _sys_TenantServices.Update(detail); + if (data.success) + { + data.msg = "删除成功"; + data.response = id.ObjToString(); + } + } + } + + return data; + } + } +} \ No newline at end of file diff --git a/New_College.Api/Controllers/Front/CustomerController.cs b/New_College.Api/Controllers/Front/CustomerController.cs index a964c1b..8edb47d 100644 --- a/New_College.Api/Controllers/Front/CustomerController.cs +++ b/New_College.Api/Controllers/Front/CustomerController.cs @@ -88,6 +88,7 @@ namespace New_College.Api.Controllers.Front [AllowAnonymous] + [HttpPost] [DisplayName("获取微信用户电话号码")] public async Task> GetWxPhone(DecryptUserPhoneRequest request) { diff --git a/New_College.Api/New_College.Model.xml b/New_College.Api/New_College.Model.xml index 1ed7116..0add842 100644 --- a/New_College.Api/New_College.Model.xml +++ b/New_College.Api/New_College.Model.xml @@ -1090,6 +1090,11 @@ ID + + + 租户id + + 获取或设置是否禁用,逻辑上的删除,非物理删除 @@ -1255,6 +1260,21 @@ 是否删除 + + + 租户id + + + + + 带上租户Id + + + + + 租户id + + 不带创建人BaseModel @@ -1301,6 +1321,11 @@ 用户信息表 + + + 租户Id + + 用户ID @@ -1356,6 +1381,51 @@ 登录账号 + + + 租户表 + + + + + 公司名称 + + + + + 管理员名称 + + + + + 主机 + + + + + 电子邮箱 + + + + + 电话 + + + + + 数据库连接 + + + + + 架构 + + + + + 备注 + + 任务计划表 diff --git a/New_College.Api/New_College.xml b/New_College.Api/New_College.xml index 3e47b9d..6f65242 100644 --- a/New_College.Api/New_College.xml +++ b/New_College.Api/New_College.xml @@ -108,6 +108,11 @@ + + + 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下 + + 获取微信openid diff --git a/New_College.Api/Startup.cs b/New_College.Api/Startup.cs index 9e494b8..fadae71 100644 --- a/New_College.Api/Startup.cs +++ b/New_College.Api/Startup.cs @@ -152,7 +152,7 @@ namespace New_College public void Configure(IApplicationBuilder app, IWebHostEnvironment env, MyContext myContext, ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter, IHostApplicationLifetime lifetime) { // Ip限流,尽量放管道外层 - //app.UseIpLimitMildd(); + app.UseIpLimitMildd(); // 记录请求与返回数据 app.UseReuestResponseLog(); // signalr @@ -215,7 +215,7 @@ namespace New_College }); // 生成种子数据 - app.UseSeedDataMildd(myContext, Env.WebRootPath); + // app.UseSeedDataMildd(myContext, Env.WebRootPath); // 开启QuartzNetJob调度服务 app.UseQuartzJobMildd(tasksQzServices, schedulerCenter); //服务注册 diff --git a/New_College.Api/appsettings.json b/New_College.Api/appsettings.json index bce4af3..cb58023 100644 --- a/New_College.Api/appsettings.json +++ b/New_College.Api/appsettings.json @@ -48,7 +48,7 @@ }, "Date": "2018-08-28", "SeedDBEnabled": true, //只生成表结构 - "SeedDBDataEnabled": true, //生成表,并初始化数据 + "SeedDBDataEnabled": false, //生成表,并初始化数据 "Author": "New_College" }, @@ -168,22 +168,22 @@ { "Endpoint": "*:/api/blog*", "Period": "1m", - "Limit": 20000 + "Limit": 200000 }, { "Endpoint": "*/api/*", "Period": "1s", - "Limit": 3000 - }, - { - "Endpoint": "*/api/*", - "Period": "1m", "Limit": 300000 }, + { + "Endpoint": "*/api/*", + "Period": "1m", + "Limit": 3000000 + }, { "Endpoint": "*/api/*", "Period": "12h", - "Limit": 5000000 + "Limit": 50000000000 } ] diff --git a/New_College.Extensions/Middlewares/SeedDataMildd.cs b/New_College.Extensions/Middlewares/SeedDataMildd.cs index f592bf0..d47311b 100644 --- a/New_College.Extensions/Middlewares/SeedDataMildd.cs +++ b/New_College.Extensions/Middlewares/SeedDataMildd.cs @@ -20,7 +20,7 @@ namespace New_College.Extensions { if (Appsettings.app("AppSettings", "SeedDBEnabled").ObjToBool() || Appsettings.app("AppSettings", "SeedDBDataEnabled").ObjToBool()) { - // DBSeed.SeedAsync(myContext, webRootPath).Wait(); + DBSeed.SeedAsync(myContext, webRootPath).Wait(); } } catch (Exception e) diff --git a/New_College.IServices/ISys_TenantServices.cs b/New_College.IServices/ISys_TenantServices.cs new file mode 100644 index 0000000..371acbc --- /dev/null +++ b/New_College.IServices/ISys_TenantServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ISys_TenantServices + /// + public interface ISys_TenantServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.Model/Models/BannerInfo.cs b/New_College.Model/Models/BannerInfo.cs index 3d78ca3..39024c4 100644 --- a/New_College.Model/Models/BannerInfo.cs +++ b/New_College.Model/Models/BannerInfo.cs @@ -9,7 +9,7 @@ namespace New_College.Model.Models /// /// 海报管理 /// - public class BannerInfo : RootEntity + public class BannerInfo : DEntityRootTenant { /// /// banner name diff --git a/New_College.Model/Models/D_NewsInfo.cs b/New_College.Model/Models/D_NewsInfo.cs index 83c6810..d521b77 100644 --- a/New_College.Model/Models/D_NewsInfo.cs +++ b/New_College.Model/Models/D_NewsInfo.cs @@ -4,7 +4,7 @@ using System.Text; namespace New_College.Model.Models { - public class D_NewsInfo : RootEntity + public class D_NewsInfo : DEntityRootTenant { public int CategoryId { get; set; } diff --git a/New_College.Model/Models/Role.cs b/New_College.Model/Models/Role.cs index ff29a56..9e1ea59 100644 --- a/New_College.Model/Models/Role.cs +++ b/New_College.Model/Models/Role.cs @@ -32,7 +32,10 @@ namespace New_College.Model.Models [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)] public int Id { get; set; } - + /// + /// 租户id + /// + public virtual int? TenantId { get; set; } /// ///获取或设置是否禁用,逻辑上的删除,非物理删除 /// diff --git a/New_College.Model/Models/RootEntity.cs b/New_College.Model/Models/RootEntity.cs index 2df5b49..5fefb8d 100644 --- a/New_College.Model/Models/RootEntity.cs +++ b/New_College.Model/Models/RootEntity.cs @@ -59,6 +59,25 @@ namespace New_College.Model.Models } + public abstract class DEntityRootTenant : RootEntity + { + /// + /// 租户id + /// + public virtual int? TenantId { get; set; } + } + /// + ///带上租户Id + /// + public abstract class DEntityTenant : EntityModel + { + /// + /// 租户id + /// + public virtual int? TenantId { get; set; } + } + + /// /// 不带创建人BaseModel /// diff --git a/New_College.Model/Models/Sys_Tenant.cs b/New_College.Model/Models/Sys_Tenant.cs new file mode 100644 index 0000000..8ca3bde --- /dev/null +++ b/New_College.Model/Models/Sys_Tenant.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Text; + +namespace New_College.Model.Models +{ + + /// + /// 租户表 + /// + [Table("sys_tenant")] + public class Sys_Tenant : EntityModel + { + /// + /// 公司名称 + /// + [Required, MaxLength(30)] + public string Name { get; set; } + + /// + /// 管理员名称 + /// + [Required, MaxLength(20)] + public string AdminName { get; set; } + + /// + /// 主机 + /// + [MaxLength(100)] + public string Host { get; set; } + + /// + /// 电子邮箱 + /// + [MaxLength(50)] + public string Email { get; set; } + + /// + /// 电话 + /// + [MaxLength(20)] + public string Phone { get; set; } + + /// + /// 数据库连接 + /// + [MaxLength(200)] + public string Connection { get; set; } + + /// + /// 架构 + /// + [MaxLength(50)] + public string Schema { get; set; } + + /// + /// 备注 + /// + [MaxLength(100)] + public string Remark { get; set; } + } +} diff --git a/New_College.Model/Models/UserRole.cs b/New_College.Model/Models/UserRole.cs index 621959f..a846a50 100644 --- a/New_College.Model/Models/UserRole.cs +++ b/New_College.Model/Models/UserRole.cs @@ -10,7 +10,7 @@ namespace New_College.Model.Models /// /// 用户跟角色关联表 /// - public class UserRole : RootEntity + public class UserRole : DEntityRootTenant { public UserRole() { } diff --git a/New_College.Model/Models/V_CustomerInfo.cs b/New_College.Model/Models/V_CustomerInfo.cs index 2aa7fc5..d4eed32 100644 --- a/New_College.Model/Models/V_CustomerInfo.cs +++ b/New_College.Model/Models/V_CustomerInfo.cs @@ -6,7 +6,7 @@ using System.Text; namespace New_College.Model.Models { - public class V_CustomerInfo : EntityModel + public class V_CustomerInfo : DEntityTenant { /// /// 用户头像 diff --git a/New_College.Model/Models/sysUserInfo.cs b/New_College.Model/Models/sysUserInfo.cs index 6d4582b..a88324c 100644 --- a/New_College.Model/Models/sysUserInfo.cs +++ b/New_College.Model/Models/sysUserInfo.cs @@ -27,6 +27,12 @@ namespace New_College.Model.Models name = ""; } + + /// + /// 租户Id + /// + public virtual int? TenantId { get; set; } + /// /// 用户ID /// diff --git a/New_College.Repository/BASE/ISys_TenantRepository.cs b/New_College.Repository/BASE/ISys_TenantRepository.cs new file mode 100644 index 0000000..7822bc1 --- /dev/null +++ b/New_College.Repository/BASE/ISys_TenantRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ISys_TenantRepository + /// + public interface ISys_TenantRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/Sys_TenantRepository.cs b/New_College.Repository/BASE/Sys_TenantRepository.cs new file mode 100644 index 0000000..b157149 --- /dev/null +++ b/New_College.Repository/BASE/Sys_TenantRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// Sys_TenantRepository + /// + public class Sys_TenantRepository : BaseRepository, ISys_TenantRepository + { + public Sys_TenantRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Services/Sys_TenantServices.cs b/New_College.Services/Sys_TenantServices.cs new file mode 100644 index 0000000..3548ec3 --- /dev/null +++ b/New_College.Services/Sys_TenantServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class Sys_TenantServices : BaseServices, ISys_TenantServices + { + private readonly IBaseRepository _dal; + public Sys_TenantServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file