From b47ff377e85dd2451c67b49d100a6713ee9f77d0 Mon Sep 17 00:00:00 2001 From: zhaoy <137053305@qq.com> Date: Thu, 18 Jan 2024 10:12:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8E=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BPA.SAAS.KitChenManage.Application.csproj | 25 +++++ .../BPA.SAAS.KitChenManage.Application.xml | 103 ++++++++++++++++++ .../GlobalUsings.cs | 15 +++ .../Store/Dtos/StoreDtoInput.cs | 19 ++++ .../Store/Dtos/StoreDtoOutput.cs | 21 ++++ .../Store/Dtos/StoreDtoPageInput.cs | 16 +++ .../Store/Services/IStoreService.cs | 38 +++++++ .../Store/Services/StoreService.cs | 103 ++++++++++++++++++ .../Store/StoreServices.cs | 62 +++++++++++ .../System/Dtos/Mapper.cs | 9 ++ .../System/Services/ISystemService.cs | 7 ++ .../System/Services/SystemService.cs | 10 ++ .../System/SystemAppService.cs | 23 ++++ .../BPA.SAAS.KitChenManage.Comm.csproj | 9 ++ .../Const/ClaimConst.cs | 57 ++++++++++ .../BPA.SAAS.KitChenManage.Core.csproj | 27 +++++ .../BPA.SAAS.KitChenManage.Core.xml | 64 +++++++++++ .../Base/IBaseEntity.cs | 45 ++++++++ BPA.SAAS.KitChenManage.Core/Base/IDeleted.cs | 16 +++ BPA.SAAS.KitChenManage.Core/Base/IGroupId.cs | 13 +++ .../Base/PageInputBase.cs | 54 +++++++++ BPA.SAAS.KitChenManage.Core/Base/PageUtil.cs | 25 +++++ BPA.SAAS.KitChenManage.Core/DbContext.cs | 81 ++++++++++++++ .../Model/BPA_Store.cs | 22 ++++ .../BPA.SAAS.KitChenManage.Web.Core.csproj | 20 ++++ .../BPA.SAAS.KitChenManage.Web.Core.xml | 8 ++ .../Handlers/JwtHandler.cs | 17 +++ BPA.SAAS.KitChenManage.Web.Core/Startup.cs | 47 ++++++++ .../BPA.SAAS.KitChenManage.Web.Entry.csproj | 22 ++++ ...A.SAAS.KitChenManage.Web.Entry.csproj.user | 9 ++ BPA.SAAS.KitChenManage.Web.Entry/Program.cs | 1 + .../Properties/launchSettings.json | 31 ++++++ .../SingleFilePublish.cs | 23 ++++ .../appsettings.Development.json | 10 ++ .../appsettings.json | 18 +++ BPA.SAAS.KitChenManage.sln | 49 +++++++++ 36 files changed, 1119 insertions(+) create mode 100644 BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.csproj create mode 100644 BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml create mode 100644 BPA.SAAS.KitChenManage.Application/GlobalUsings.cs create mode 100644 BPA.SAAS.KitChenManage.Application/Store/Dtos/StoreDtoInput.cs create mode 100644 BPA.SAAS.KitChenManage.Application/Store/Dtos/StoreDtoOutput.cs create mode 100644 BPA.SAAS.KitChenManage.Application/Store/Dtos/StoreDtoPageInput.cs create mode 100644 BPA.SAAS.KitChenManage.Application/Store/Services/IStoreService.cs create mode 100644 BPA.SAAS.KitChenManage.Application/Store/Services/StoreService.cs create mode 100644 BPA.SAAS.KitChenManage.Application/Store/StoreServices.cs create mode 100644 BPA.SAAS.KitChenManage.Application/System/Dtos/Mapper.cs create mode 100644 BPA.SAAS.KitChenManage.Application/System/Services/ISystemService.cs create mode 100644 BPA.SAAS.KitChenManage.Application/System/Services/SystemService.cs create mode 100644 BPA.SAAS.KitChenManage.Application/System/SystemAppService.cs create mode 100644 BPA.SAAS.KitChenManage.Comm/BPA.SAAS.KitChenManage.Comm.csproj create mode 100644 BPA.SAAS.KitChenManage.Comm/Const/ClaimConst.cs create mode 100644 BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.csproj create mode 100644 BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.xml create mode 100644 BPA.SAAS.KitChenManage.Core/Base/IBaseEntity.cs create mode 100644 BPA.SAAS.KitChenManage.Core/Base/IDeleted.cs create mode 100644 BPA.SAAS.KitChenManage.Core/Base/IGroupId.cs create mode 100644 BPA.SAAS.KitChenManage.Core/Base/PageInputBase.cs create mode 100644 BPA.SAAS.KitChenManage.Core/Base/PageUtil.cs create mode 100644 BPA.SAAS.KitChenManage.Core/DbContext.cs create mode 100644 BPA.SAAS.KitChenManage.Core/Model/BPA_Store.cs create mode 100644 BPA.SAAS.KitChenManage.Web.Core/BPA.SAAS.KitChenManage.Web.Core.csproj create mode 100644 BPA.SAAS.KitChenManage.Web.Core/BPA.SAAS.KitChenManage.Web.Core.xml create mode 100644 BPA.SAAS.KitChenManage.Web.Core/Handlers/JwtHandler.cs create mode 100644 BPA.SAAS.KitChenManage.Web.Core/Startup.cs create mode 100644 BPA.SAAS.KitChenManage.Web.Entry/BPA.SAAS.KitChenManage.Web.Entry.csproj create mode 100644 BPA.SAAS.KitChenManage.Web.Entry/BPA.SAAS.KitChenManage.Web.Entry.csproj.user create mode 100644 BPA.SAAS.KitChenManage.Web.Entry/Program.cs create mode 100644 BPA.SAAS.KitChenManage.Web.Entry/Properties/launchSettings.json create mode 100644 BPA.SAAS.KitChenManage.Web.Entry/SingleFilePublish.cs create mode 100644 BPA.SAAS.KitChenManage.Web.Entry/appsettings.Development.json create mode 100644 BPA.SAAS.KitChenManage.Web.Entry/appsettings.json create mode 100644 BPA.SAAS.KitChenManage.sln diff --git a/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.csproj b/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.csproj new file mode 100644 index 0000000..dbb6614 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.csproj @@ -0,0 +1,25 @@ + + + + + net6.0 + 1701;1702;1591 + BPA.SAAS.KitChenManage.Application.xml + enable + + + + + + + + + + + + + + + + + diff --git a/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml b/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml new file mode 100644 index 0000000..9b1515c --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml @@ -0,0 +1,103 @@ + + + + BPA.SAAS.KitChenManage.Application + + + + + 分页 + + + + + + + 添加 + + + + + + + 修改 + + + + + + + 删除 + + + + + + + 分页 + + + + + + + 添加 + + + + + + + 修改 + + + + + + + 删除 + + + + + + + 分页查询 + + + + + + + 添加 + + + + + + + 修改 + + + + + + + 删除 + + + + + + + 系统服务接口 + + + + + 获取系统描述 + + + + + diff --git a/BPA.SAAS.KitChenManage.Application/GlobalUsings.cs b/BPA.SAAS.KitChenManage.Application/GlobalUsings.cs new file mode 100644 index 0000000..b04cde4 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/GlobalUsings.cs @@ -0,0 +1,15 @@ +global using Furion; +global using Furion.DataEncryption; +global using Furion.DataValidation; +global using Furion.DependencyInjection; +global using Furion.DynamicApiController; +global using Furion.Extensions; +global using Furion.FriendlyException; +global using Furion.Logging; +global using Mapster; +global using Microsoft.AspNetCore.Authorization; +global using Microsoft.AspNetCore.Http; +global using Microsoft.AspNetCore.Mvc; +global using Microsoft.CodeAnalysis; +global using SqlSugar; +global using System.ComponentModel.DataAnnotations; diff --git a/BPA.SAAS.KitChenManage.Application/Store/Dtos/StoreDtoInput.cs b/BPA.SAAS.KitChenManage.Application/Store/Dtos/StoreDtoInput.cs new file mode 100644 index 0000000..593f67e --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/Store/Dtos/StoreDtoInput.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Application.Store.Dtos +{ + public class StoreDtoInput + { + public string Id { get; set; } + public string Name { get; set; } + public string OrgId { get; set; } + public string Phone { get; set; } + public int Sort { get; set; } + public string Description { get; set; } + public string OrgName { get; set; } + } +} diff --git a/BPA.SAAS.KitChenManage.Application/Store/Dtos/StoreDtoOutput.cs b/BPA.SAAS.KitChenManage.Application/Store/Dtos/StoreDtoOutput.cs new file mode 100644 index 0000000..03529f6 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/Store/Dtos/StoreDtoOutput.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Application.Store.Dtos +{ + public class StoreDtoOutput + { + public string Id { get; set; } + public string Name { get; set; } + public string OrgId { get; set; } + public string OrgName { get; set; } + public string Phone { get; set; } + public int Sort { get; set; } + public string Description { get; set; } + public string GroupId { get; set; } + public DateTime CreateAt { get; set; } + } +} diff --git a/BPA.SAAS.KitChenManage.Application/Store/Dtos/StoreDtoPageInput.cs b/BPA.SAAS.KitChenManage.Application/Store/Dtos/StoreDtoPageInput.cs new file mode 100644 index 0000000..f9fcdad --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/Store/Dtos/StoreDtoPageInput.cs @@ -0,0 +1,16 @@ +using BPA.SAAS.KitChenManage.Core.Base; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Application.Store.Dtos +{ + public class StoreDtoPageInput: PageInputBase + { + public string Name { get; set; } + public string OrgId { get; set; } + public string Phone { get; set; } + } +} diff --git a/BPA.SAAS.KitChenManage.Application/Store/Services/IStoreService.cs b/BPA.SAAS.KitChenManage.Application/Store/Services/IStoreService.cs new file mode 100644 index 0000000..4d2f354 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/Store/Services/IStoreService.cs @@ -0,0 +1,38 @@ +using BPA.SAAS.KitChenManage.Application.Store.Dtos; +using BPA.SAAS.KitChenManage.Core.Base; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Application.Store.Services +{ + public interface IStoreService + { + /// + /// 分页 + /// + /// + /// + Task Page(StoreDtoPageInput input); + /// + /// 添加 + /// + /// + /// + Task Add(StoreDtoInput input); + /// + /// 修改 + /// + /// + /// + Task Update(StoreDtoInput input); + /// + /// 删除 + /// + /// + /// + Task Delete(List input); + } +} diff --git a/BPA.SAAS.KitChenManage.Application/Store/Services/StoreService.cs b/BPA.SAAS.KitChenManage.Application/Store/Services/StoreService.cs new file mode 100644 index 0000000..c76ad5f --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/Store/Services/StoreService.cs @@ -0,0 +1,103 @@ +using BPA.SAAS.KitChenManage.Application.Store.Dtos; +using BPA.SAAS.KitChenManage.Core.Base; +using BPA.SAAS.KitChenManage.Core.Model; +using Furion.LinqBuilder; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Application.Store.Services +{ + public class StoreService: IStoreService, ITransient + { + private readonly ISqlSugarClient _db; + public StoreService(ISqlSugarClient db) + { + _db=db; + } + /// + /// 分页 + /// + /// + /// + public async Task Page(StoreDtoPageInput input) + { + RefAsync total = 0; + var res = await _db.Queryable() + .WhereIF(!input.OrgId.IsNullOrEmpty(), t => t.OrgId.Contains(input.OrgId)) + .WhereIF(!input.Name.IsNullOrEmpty(), t => t.Name.Contains(input.Name)) + + .Select(t => new StoreDtoOutput + { + CreateAt = t.CreateAt, + Id = t.Id, + Name = t.Name, + Phone = t.Phone, + Description = t.Description, + OrgName=t.OrgName, + OrgId=t.OrgId, + Sort = t.Sort, + }).OrderBy(t => t.Sort).OrderBy(x => x.CreateAt, OrderByType.Desc).ToPageListAsync(input.Current, input.PageSize, total); + PageUtil util = new PageUtil() + { + Total = total, + Data = res + + }; + return util; + } + /// + /// 添加 + /// + /// + /// + public async Task Add(StoreDtoInput input) + { + var Store = input.Adapt(); + // role.DataScopeType = DataScopeType.ALL; + return await _db.Insertable(Store).CallEntityMethod(t => t.Create()).ExecuteCommandAsync() > 0; + } + /// + /// 修改 + /// + /// + /// + public async Task Update(StoreDtoInput input) + { + var BPA_Store = await _db.Queryable().Where(a => a.Id == input.Id).FirstAsync(); + + var Store = await _db.Queryable().Where(a => a.Id == input.Id).FirstAsync(); + Store.Name = input.Name; + Store.OrgId = input.OrgId; + Store.Phone = input.Phone; + Store.Description = input.Description; + Store.Phone = input.Phone; + Store.Sort = input.Sort; + Store.OrgName = input.OrgName; + return _db.Updateable(Store).ExecuteCommandHasChange(); + + } + /// + /// 删除 + /// + /// + /// + public async Task Delete(List input) + { + try + { + // 查询数据库中是否存在未删除的活动信息 + var resEntitites = _db.Queryable().In(input).ToList(); + var res = await _db.Deleteable(resEntitites).ExecuteCommandAsync(); + return res > 0; + + } + catch (Exception) + { + throw Oops.Oh("删除失败"); + } + } + } +} diff --git a/BPA.SAAS.KitChenManage.Application/Store/StoreServices.cs b/BPA.SAAS.KitChenManage.Application/Store/StoreServices.cs new file mode 100644 index 0000000..cb4f569 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/Store/StoreServices.cs @@ -0,0 +1,62 @@ +using BPA.SAAS.KitChenManage.Application.Store.Dtos; +using BPA.SAAS.KitChenManage.Application.Store.Services; +using BPA.SAAS.KitChenManage.Core.Base; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Application.Store +{ + [ApiDescriptionSettings("Store", Tag = "场景管理")] + public class StoreServices: IDynamicApiController + { + IStoreService _storeService; + public StoreServices(IStoreService storeService) + { + _storeService=storeService; + } + /// + /// 分页查询 + /// + /// + /// + [HttpPost("/api/store/page")] + + public async Task Page(StoreDtoPageInput input) + { + return await _storeService.Page(input); + } + /// + /// 添加 + /// + /// + /// + [HttpPost("/api/store/add")] + public async Task Add(StoreDtoInput input) + { + return await _storeService.Add(input); + } + /// + /// 修改 + /// + /// + /// + [HttpPost("/api/store/update")] + public async Task Update(StoreDtoInput input) + { + return await _storeService.Update(input); + } + /// + /// 删除 + /// + /// + /// + [HttpPost("/api/store/delete")] + public async Task Delete(List input) + { + return await _storeService.Delete(input); + } + } +} diff --git a/BPA.SAAS.KitChenManage.Application/System/Dtos/Mapper.cs b/BPA.SAAS.KitChenManage.Application/System/Dtos/Mapper.cs new file mode 100644 index 0000000..4ec4ba8 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/System/Dtos/Mapper.cs @@ -0,0 +1,9 @@ +namespace BPA.SAAS.KitChenManage.Application +{ + public class Mapper : IRegister + { + public void Register(TypeAdapterConfig config) + { + } + } +} \ No newline at end of file diff --git a/BPA.SAAS.KitChenManage.Application/System/Services/ISystemService.cs b/BPA.SAAS.KitChenManage.Application/System/Services/ISystemService.cs new file mode 100644 index 0000000..8377952 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/System/Services/ISystemService.cs @@ -0,0 +1,7 @@ +namespace BPA.SAAS.KitChenManage.Application +{ + public interface ISystemService + { + string GetDescription(); + } +} \ No newline at end of file diff --git a/BPA.SAAS.KitChenManage.Application/System/Services/SystemService.cs b/BPA.SAAS.KitChenManage.Application/System/Services/SystemService.cs new file mode 100644 index 0000000..34dd316 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/System/Services/SystemService.cs @@ -0,0 +1,10 @@ +namespace BPA.SAAS.KitChenManage.Application +{ + public class SystemService : ISystemService, ITransient + { + public string GetDescription() + { + return "让 .NET 开发更简单,更通用,更流行。"; + } + } +} \ No newline at end of file diff --git a/BPA.SAAS.KitChenManage.Application/System/SystemAppService.cs b/BPA.SAAS.KitChenManage.Application/System/SystemAppService.cs new file mode 100644 index 0000000..8578ff2 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/System/SystemAppService.cs @@ -0,0 +1,23 @@ +namespace BPA.SAAS.KitChenManage.Application +{ + /// + /// 系统服务接口 + /// + public class SystemAppService : IDynamicApiController + { + private readonly ISystemService _systemService; + public SystemAppService(ISystemService systemService) + { + _systemService = systemService; + } + + /// + /// 获取系统描述 + /// + /// + public string GetDescription() + { + return _systemService.GetDescription(); + } + } +} \ No newline at end of file diff --git a/BPA.SAAS.KitChenManage.Comm/BPA.SAAS.KitChenManage.Comm.csproj b/BPA.SAAS.KitChenManage.Comm/BPA.SAAS.KitChenManage.Comm.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/BPA.SAAS.KitChenManage.Comm/BPA.SAAS.KitChenManage.Comm.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/BPA.SAAS.KitChenManage.Comm/Const/ClaimConst.cs b/BPA.SAAS.KitChenManage.Comm/Const/ClaimConst.cs new file mode 100644 index 0000000..d537217 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Comm/Const/ClaimConst.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Comm.Const +{ + public class ClaimConst + { + /// + /// 用户Id + /// + public const string CLAINM_USERID = "UserId"; + + /// + /// 账号 + /// + public const string CLAINM_ACCOUNT = "Account"; + + /// + /// 名称 + /// + public const string CLAINM_NAME = "Name"; + + /// + /// 是否超级管理 + /// + public const string CLAINM_SUPERADMIN = "SuperAdmin"; + + /// + /// 登录类型1平台用户登录,0加盟商登录 + /// + public const string LoginType = "LoginType"; + /// + /// 加盟商编号 + /// + public const string FranchID = "FranchID"; + /// + /// 加盟商通知手机号 + /// + public const string FranchTel = "18782023833"; + + /// + /// 加盟商组id + /// + public const string GroupId = "GroupId"; + + /// + /// 权限 + /// + public const string RoleId = "RoleId"; + public const string OrgId = ""; + + public const string SupplyPlatformId = "SupplyPlatformId"; + } +} diff --git a/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.csproj b/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.csproj new file mode 100644 index 0000000..82e9de3 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.csproj @@ -0,0 +1,27 @@ + + + + + net6.0 + 1701;1702;1591 + BPA.SAAS.KitChenManage.Core.xml + + + + + + + + + + + + + + + + + + + + diff --git a/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.xml b/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.xml new file mode 100644 index 0000000..5cc252c --- /dev/null +++ b/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.xml @@ -0,0 +1,64 @@ + + + + BPA.SAAS.KitChenManage.Core + + + + + 主键 Guid + + + + + 是否删除 + + + + + 新增 + + + + + 是否删除 + + + + + 当前页码 + + + + + 页码容量 + + + + + 分页实体 + + + + + Data + + + + + Total + + + + + 数据库上下文对象 + + + + + SqlSugar 数据库实例 + + + + + diff --git a/BPA.SAAS.KitChenManage.Core/Base/IBaseEntity.cs b/BPA.SAAS.KitChenManage.Core/Base/IBaseEntity.cs new file mode 100644 index 0000000..c35ffdd --- /dev/null +++ b/BPA.SAAS.KitChenManage.Core/Base/IBaseEntity.cs @@ -0,0 +1,45 @@ +using BPA.SAAS.KitChenManage.Comm.Const; +using Furion; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Core.Base +{ + public abstract class IBaseEntity : IDeleted + { + /// + /// 主键 Guid + /// + [SugarColumn(IsPrimaryKey = true, ColumnDataType = "Nvarchar(64)", IsNullable = false)] + public string Id { get; set; } + public DateTime CreateAt { get; set; } = DateTime.Now; + public string CreateBy { get; set; } + /// + /// 是否删除 + /// + public int IsDeleted { get; set; } = 0; + /// + /// 新增 + /// + public virtual void Create() + { + var userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value; + this.Id = Guid.NewGuid().ToString(); + this.CreateAt = DateTime.Now; + if (!string.IsNullOrEmpty(userId)) + { + this.CreateBy = userId; + } + else + { + + this.CreateBy = "admin"; + } + } + + } +} diff --git a/BPA.SAAS.KitChenManage.Core/Base/IDeleted.cs b/BPA.SAAS.KitChenManage.Core/Base/IDeleted.cs new file mode 100644 index 0000000..c9d9a9b --- /dev/null +++ b/BPA.SAAS.KitChenManage.Core/Base/IDeleted.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Core.Base +{ + public interface IDeleted + { + /// + /// 是否删除 + /// + public int IsDeleted { get; set; } + } +} diff --git a/BPA.SAAS.KitChenManage.Core/Base/IGroupId.cs b/BPA.SAAS.KitChenManage.Core/Base/IGroupId.cs new file mode 100644 index 0000000..0cc11ef --- /dev/null +++ b/BPA.SAAS.KitChenManage.Core/Base/IGroupId.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Core.Base +{ + public interface IGroupId + { + public string GroupId { get; set; } + } +} diff --git a/BPA.SAAS.KitChenManage.Core/Base/PageInputBase.cs b/BPA.SAAS.KitChenManage.Core/Base/PageInputBase.cs new file mode 100644 index 0000000..328183a --- /dev/null +++ b/BPA.SAAS.KitChenManage.Core/Base/PageInputBase.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Core.Base +{ + public class PageInputBase + { + /// + /// 当前页码 + /// + private int current; + public virtual int Current + { + get + { + return current; + } + set + { + + current = value; + if (current <= 0) + { + current = 1; + } + } + } + //public int? Status { get; set; } + /// + /// 页码容量 + /// + + private int pagesize; + public virtual int PageSize + { + get + { + return pagesize; + } + set + { + + pagesize = value; + if (pagesize <= 0) + { + pagesize = 10; + } + } + } + } +} diff --git a/BPA.SAAS.KitChenManage.Core/Base/PageUtil.cs b/BPA.SAAS.KitChenManage.Core/Base/PageUtil.cs new file mode 100644 index 0000000..d18d190 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Core/Base/PageUtil.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Core.Base +{ + /// + /// 分页实体 + /// + public class PageUtil + { + /// + /// Data + /// + + public object Data { get; set; } + /// + /// Total + /// + + public int Total { get; set; } + } +} diff --git a/BPA.SAAS.KitChenManage.Core/DbContext.cs b/BPA.SAAS.KitChenManage.Core/DbContext.cs new file mode 100644 index 0000000..52fa64a --- /dev/null +++ b/BPA.SAAS.KitChenManage.Core/DbContext.cs @@ -0,0 +1,81 @@ +using BPA.SAAS.KitChenManage.Comm.Const; +using BPA.SAAS.KitChenManage.Core.Base; +using Furion; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; + +namespace BPA.SAAS.KitChenManage.Core +{ + /// + /// 数据库上下文对象 + /// + public static class DbContext + { + /// + /// SqlSugar 数据库实例 + /// + public static void AddSqlsugarSetup(this IServiceCollection services, IConfiguration configuration) + { + var connectionConfigs = App.GetConfig>("ConnectionConfigs"); + //如果多个数数据库传 List + var configConnection = new ConnectionConfig() + { + ConnectionString = connectionConfigs[0].ConnectionString, + DbType = SqlSugar.DbType.MySql,//设置数据库类型 + IsAutoCloseConnection = true,//自动释放数据务,如果存在事务,在事务结束后释放 + InitKeyType = InitKeyType.Attribute, //从实体特性中读取主键自增列信息 + ConfigId = "default", + }; + + SqlSugarScope sqlSugar = new SqlSugarScope(configConnection, + db => + { + db.Aop.DataExecuting = (oldValue, entityInfo) => + { + //新增添加加盟商id赋值 + var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; + if (entityInfo.PropertyName == "GroupId" && entityInfo.OperationType == DataFilterType.InsertByObject) + { + if (oldValue == null || oldValue == Convert.DBNull) + { + entityInfo.SetValue(groupId); + } + } + }; + + //单例参数配置,所有上下文生效 + db.Aop.OnLogExecuting = (sql, pars) => + { + //过滤已删除数据 + db.QueryFilter.AddTableFilter(it => it.IsDeleted == 0); + + if (!IsSuperAdmin()) + { + //非管理员账户过滤加盟商数据 + var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; + db.QueryFilter.AddTableFilter(it => it.GroupId == groupId); + } + + //Console.WriteLine(sql);//输出sql + Console.WriteLine($"当前SQL语句:【{sql}】,参数:【{string.Join(",", pars.Select(t => t.Value))}】"); + }; + }); + + services.AddSingleton(sqlSugar);//这边是SqlSugarScope用AddSingleton + } + // + /// 判断是不是超级管理员 + /// + /// + private static bool IsSuperAdmin() + { + if (App.User == null) return false; + return App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value == "1"; + } + } +} \ No newline at end of file diff --git a/BPA.SAAS.KitChenManage.Core/Model/BPA_Store.cs b/BPA.SAAS.KitChenManage.Core/Model/BPA_Store.cs new file mode 100644 index 0000000..440a45a --- /dev/null +++ b/BPA.SAAS.KitChenManage.Core/Model/BPA_Store.cs @@ -0,0 +1,22 @@ +using BPA.SAAS.KitChenManage.Core.Base; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Core.Model +{ + [SugarTable("bpa_store")] + public class BPA_Store : IBaseEntity, IGroupId + { + public string Name { get; set; } + public string OrgId { get; set; } + public string Phone { get; set; } + public int Sort { get; set; } + public string Description { get; set; } + public string GroupId { get; set; } + public string OrgName { get; set; } + } +} diff --git a/BPA.SAAS.KitChenManage.Web.Core/BPA.SAAS.KitChenManage.Web.Core.csproj b/BPA.SAAS.KitChenManage.Web.Core/BPA.SAAS.KitChenManage.Web.Core.csproj new file mode 100644 index 0000000..5b7ffb4 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Web.Core/BPA.SAAS.KitChenManage.Web.Core.csproj @@ -0,0 +1,20 @@ + + + + + net6.0 + 1701;1702;1591 + BPA.SAAS.KitChenManage.Web.Core.xml + + + + + + + + + + + + + diff --git a/BPA.SAAS.KitChenManage.Web.Core/BPA.SAAS.KitChenManage.Web.Core.xml b/BPA.SAAS.KitChenManage.Web.Core/BPA.SAAS.KitChenManage.Web.Core.xml new file mode 100644 index 0000000..135ba5c --- /dev/null +++ b/BPA.SAAS.KitChenManage.Web.Core/BPA.SAAS.KitChenManage.Web.Core.xml @@ -0,0 +1,8 @@ + + + + BPA.SAAS.KitChenManage.Web.Core + + + + diff --git a/BPA.SAAS.KitChenManage.Web.Core/Handlers/JwtHandler.cs b/BPA.SAAS.KitChenManage.Web.Core/Handlers/JwtHandler.cs new file mode 100644 index 0000000..ba11ba7 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Web.Core/Handlers/JwtHandler.cs @@ -0,0 +1,17 @@ +using Furion.Authorization; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using System.Threading.Tasks; + +namespace BPA.SAAS.KitChenManage.Web.Core +{ + public class JwtHandler : AppAuthorizeHandler + { + public override Task PipelineAsync(AuthorizationHandlerContext context, DefaultHttpContext httpContext) + { + // 这里写您的授权判断逻辑,授权通过返回 true,否则返回 false + + return Task.FromResult(true); + } + } +} \ No newline at end of file diff --git a/BPA.SAAS.KitChenManage.Web.Core/Startup.cs b/BPA.SAAS.KitChenManage.Web.Core/Startup.cs new file mode 100644 index 0000000..5fceaf1 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Web.Core/Startup.cs @@ -0,0 +1,47 @@ +using BPA.SAAS.KitChenManage.Core; +using Furion; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace BPA.SAAS.KitChenManage.Web.Core +{ + public class Startup : AppStartup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddConsoleFormatter(); + services.AddJwt(); + + services.AddCorsAccessor(); + services.AddSqlsugarSetup(App.Configuration); + services.AddControllers() + .AddInjectWithUnifyResult(); + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseHttpsRedirection(); + + app.UseRouting(); + + app.UseCorsAccessor(); + + app.UseAuthentication(); + app.UseAuthorization(); + + app.UseInject(string.Empty); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} \ No newline at end of file diff --git a/BPA.SAAS.KitChenManage.Web.Entry/BPA.SAAS.KitChenManage.Web.Entry.csproj b/BPA.SAAS.KitChenManage.Web.Entry/BPA.SAAS.KitChenManage.Web.Entry.csproj new file mode 100644 index 0000000..bddccaa --- /dev/null +++ b/BPA.SAAS.KitChenManage.Web.Entry/BPA.SAAS.KitChenManage.Web.Entry.csproj @@ -0,0 +1,22 @@ + + + + + net6.0 + enable + en-US + true + + + + + + + + + + + + + + diff --git a/BPA.SAAS.KitChenManage.Web.Entry/BPA.SAAS.KitChenManage.Web.Entry.csproj.user b/BPA.SAAS.KitChenManage.Web.Entry/BPA.SAAS.KitChenManage.Web.Entry.csproj.user new file mode 100644 index 0000000..91726c3 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Web.Entry/BPA.SAAS.KitChenManage.Web.Entry.csproj.user @@ -0,0 +1,9 @@ + + + + ProjectDebugger + + + BPA.SAAS.KitChenManage.Web.Entry + + \ No newline at end of file diff --git a/BPA.SAAS.KitChenManage.Web.Entry/Program.cs b/BPA.SAAS.KitChenManage.Web.Entry/Program.cs new file mode 100644 index 0000000..65ae485 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Web.Entry/Program.cs @@ -0,0 +1 @@ +Serve.Run(RunOptions.Default.WithArgs(args)); diff --git a/BPA.SAAS.KitChenManage.Web.Entry/Properties/launchSettings.json b/BPA.SAAS.KitChenManage.Web.Entry/Properties/launchSettings.json new file mode 100644 index 0000000..b8afba7 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Web.Entry/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:53785", + "sslPort": 44342 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "BPA.SAAS.KitChenManage.Web.Entry": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "", + "applicationUrl": "http://192.168.1.19:5008", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/BPA.SAAS.KitChenManage.Web.Entry/SingleFilePublish.cs b/BPA.SAAS.KitChenManage.Web.Entry/SingleFilePublish.cs new file mode 100644 index 0000000..691fae3 --- /dev/null +++ b/BPA.SAAS.KitChenManage.Web.Entry/SingleFilePublish.cs @@ -0,0 +1,23 @@ +using Furion; +using System.Reflection; + +namespace BPA.SAAS.KitChenManage.Web.Entry +{ + public class SingleFilePublish : ISingleFilePublish + { + public Assembly[] IncludeAssemblies() + { + return Array.Empty(); + } + + public string[] IncludeAssemblyNames() + { + return new[] + { + "BPA.SAAS.KitChenManage.Application", + "BPA.SAAS.KitChenManage.Core", + "BPA.SAAS.KitChenManage.Web.Core" + }; + } + } +} \ No newline at end of file diff --git a/BPA.SAAS.KitChenManage.Web.Entry/appsettings.Development.json b/BPA.SAAS.KitChenManage.Web.Entry/appsettings.Development.json new file mode 100644 index 0000000..5f187ae --- /dev/null +++ b/BPA.SAAS.KitChenManage.Web.Entry/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json", + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Microsoft.EntityFrameworkCore": "Information" + } + } +} \ No newline at end of file diff --git a/BPA.SAAS.KitChenManage.Web.Entry/appsettings.json b/BPA.SAAS.KitChenManage.Web.Entry/appsettings.json new file mode 100644 index 0000000..d6921ce --- /dev/null +++ b/BPA.SAAS.KitChenManage.Web.Entry/appsettings.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json", + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Microsoft.EntityFrameworkCore": "Information" + } + }, + "AllowedHosts": "*", + "ConnectionConfigs": [ + { + "ConnectionString": "server=10.2.1.21;Database=bpa_kitchen_kitchenmanage;Uid=root;Pwd=cygadmin;Allow Zero Datetime=True;Convert Zero Datetime=True;", + "DbType": "Mysql", + "IsAutoCloseConnection": true + } + ] +} \ No newline at end of file diff --git a/BPA.SAAS.KitChenManage.sln b/BPA.SAAS.KitChenManage.sln new file mode 100644 index 0000000..7f5f56c --- /dev/null +++ b/BPA.SAAS.KitChenManage.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPA.SAAS.KitChenManage.Application", "BPA.SAAS.KitChenManage.Application\BPA.SAAS.KitChenManage.Application.csproj", "{D28EBCAE-1D41-4D87-9D88-FC5C90FFA80C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPA.SAAS.KitChenManage.Core", "BPA.SAAS.KitChenManage.Core\BPA.SAAS.KitChenManage.Core.csproj", "{AEC1516E-41FC-41E5-9635-D4B304952FD1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPA.SAAS.KitChenManage.Web.Core", "BPA.SAAS.KitChenManage.Web.Core\BPA.SAAS.KitChenManage.Web.Core.csproj", "{4F50D938-38C1-40FA-87CF-C6F57679060A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPA.SAAS.KitChenManage.Web.Entry", "BPA.SAAS.KitChenManage.Web.Entry\BPA.SAAS.KitChenManage.Web.Entry.csproj", "{3021297F-13CD-4B89-AA86-9ABC20A82A22}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPA.SAAS.KitChenManage.Comm", "BPA.SAAS.KitChenManage.Comm\BPA.SAAS.KitChenManage.Comm.csproj", "{E1B95273-F2CB-4BFC-BBC7-7D556129D878}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D28EBCAE-1D41-4D87-9D88-FC5C90FFA80C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D28EBCAE-1D41-4D87-9D88-FC5C90FFA80C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D28EBCAE-1D41-4D87-9D88-FC5C90FFA80C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D28EBCAE-1D41-4D87-9D88-FC5C90FFA80C}.Release|Any CPU.Build.0 = Release|Any CPU + {AEC1516E-41FC-41E5-9635-D4B304952FD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEC1516E-41FC-41E5-9635-D4B304952FD1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEC1516E-41FC-41E5-9635-D4B304952FD1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AEC1516E-41FC-41E5-9635-D4B304952FD1}.Release|Any CPU.Build.0 = Release|Any CPU + {4F50D938-38C1-40FA-87CF-C6F57679060A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F50D938-38C1-40FA-87CF-C6F57679060A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F50D938-38C1-40FA-87CF-C6F57679060A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F50D938-38C1-40FA-87CF-C6F57679060A}.Release|Any CPU.Build.0 = Release|Any CPU + {3021297F-13CD-4B89-AA86-9ABC20A82A22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3021297F-13CD-4B89-AA86-9ABC20A82A22}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3021297F-13CD-4B89-AA86-9ABC20A82A22}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3021297F-13CD-4B89-AA86-9ABC20A82A22}.Release|Any CPU.Build.0 = Release|Any CPU + {E1B95273-F2CB-4BFC-BBC7-7D556129D878}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1B95273-F2CB-4BFC-BBC7-7D556129D878}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1B95273-F2CB-4BFC-BBC7-7D556129D878}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1B95273-F2CB-4BFC-BBC7-7D556129D878}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B2F45D5A-A815-46D9-B4C4-483D53175EA2} + EndGlobalSection +EndGlobal