From 70dcd21a581aeba2ee755584c6cebf548971eb69 Mon Sep 17 00:00:00 2001
From: zhaoy <137053305@qq.com>
Date: Sat, 30 Dec 2023 15:27:25 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=BF=81=E7=A7=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Org/CompanyServices.cs | 81 ++++
.../Org/Dtos/Role/RoleDtoInput.cs | 37 ++
.../Org/Interface/ICompanyService.cs | 41 +-
.../Org/Interface/IRoleService.cs | 6 +-
.../Org/Services/CompanyService.cs | 29 +-
.../Org/Services/RoleService.cs | 23 +-
BPA.SAAS.Manage.Core/Org/BPA_Roles.cs | 4 +
BPA.SAAS.Manage.Core/Org/BPA_UserRole.cs | 30 ++
.../bin/Debug/net6.0/BPA.SAAS.Manage.Core.xml | 368 ++++++++++++++++++
9 files changed, 600 insertions(+), 19 deletions(-)
create mode 100644 BPA.SAAS.Manage.Application/Org/CompanyServices.cs
create mode 100644 BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleDtoInput.cs
create mode 100644 BPA.SAAS.Manage.Core/Org/BPA_UserRole.cs
create mode 100644 BPA.SAAS.Manage.Core/bin/Debug/net6.0/BPA.SAAS.Manage.Core.xml
diff --git a/BPA.SAAS.Manage.Application/Org/CompanyServices.cs b/BPA.SAAS.Manage.Application/Org/CompanyServices.cs
new file mode 100644
index 0000000..e08f89d
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/Org/CompanyServices.cs
@@ -0,0 +1,81 @@
+using BPA.SAAS.Manage.Application.Org.Dtos.Company;
+using BPA.SAAS.Manage.Application.Org.Interface;
+using BPA.SAAS.Manage.Core.Base;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.Manage.Application.Org
+{
+ [ApiDescriptionSettings("Org", Tag = "加盟商信息")]
+ public class CompanyServices: IDynamicApiController
+ {
+ ICompanyService _companyService;
+ public CompanyServices(ICompanyService companyService)
+ {
+ _companyService=companyService;
+ }
+ ///
+ /// 查询企业信息
+ ///
+ ///
+ ///
+ [HttpPost("/api/company/companypage")]
+ public async Task CompanyPage(CompanyDtoPageInput input)
+ {
+ return await _companyService.CompanyPage(input);
+ }
+ ///
+ /// 添加企业信息
+ ///
+ ///
+ ///
+ [HttpPost("/api/company/add")]
+ public async Task AddCompany(CompanyDtoInput input)
+ {
+ return await _companyService.AddCompany(input);
+ }
+ ///
+ /// 修改企业信息
+ ///
+ ///
+ ///
+ [HttpPost("/api/company/update")]
+ public async Task UpdateCompany(CompanyDtoInput input)
+ {
+ return await _companyService.UpdateCompany(input);
+ }
+ ///
+ /// 删除企业信息
+ ///
+ ///
+ ///
+ [HttpPost("/api/company/delete")]
+ public async Task BatchDelCompany(List inputList)
+ {
+ return await _companyService.BatchDelCompany(inputList);
+ }
+ ///
+ /// 启用
+ ///
+ ///
+ ///
+ [HttpGet("/api/company/enable")]
+ public async Task Enable(string Id)
+ {
+ return await _companyService.Enable(Id);
+ }
+ ///
+ /// 禁用
+ ///
+ ///
+ ///
+ [HttpGet("/api/company/disable")]
+ public async Task Disable(string Id)
+ {
+ return await _companyService.Disable(Id);
+ }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleDtoInput.cs b/BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleDtoInput.cs
new file mode 100644
index 0000000..87f606a
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleDtoInput.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.Manage.Application.Org.Dtos.Role
+{
+ public class RoleDtoInput
+ {
+ public string Id { get; set; }
+ ///
+ /// 角色名称
+ ///
+ public string Name { get; set; }
+ ///
+ /// 编码
+ ///
+ public string Code { get; set; }
+ ///
+ /// 排序
+ ///
+ public string Sort { get; set; }
+ ///
+ /// 备注
+ ///
+ public string Remark { get; set; }
+ ///
+ /// 角色类型-集团角色_0、加盟商角色_1、门店角色_2
+ ///
+ public string RoleType { get; set; }
+ ///
+ /// 加盟商id
+ ///
+ public string GroupId { get; set; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/Org/Interface/ICompanyService.cs b/BPA.SAAS.Manage.Application/Org/Interface/ICompanyService.cs
index 2ff041c..3324f7b 100644
--- a/BPA.SAAS.Manage.Application/Org/Interface/ICompanyService.cs
+++ b/BPA.SAAS.Manage.Application/Org/Interface/ICompanyService.cs
@@ -1,4 +1,6 @@
-using System;
+using BPA.SAAS.Manage.Application.Org.Dtos.Company;
+using BPA.SAAS.Manage.Core.Base;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,5 +10,42 @@ namespace BPA.SAAS.Manage.Application.Org.Interface
{
public interface ICompanyService
{
+ ///
+ /// 查询企业信息
+ ///
+ ///
+ ///
+
+ Task CompanyPage(CompanyDtoPageInput input);
+ ///
+ /// 添加企业信息
+ ///
+ ///
+ ///
+ Task AddCompany(CompanyDtoInput input);
+ ///
+ /// 修改企业信息
+ ///
+ ///
+ ///
+ Task UpdateCompany(CompanyDtoInput input);
+ //
+ /// 删除企业信息
+ ///
+ ///
+ ///
+ Task BatchDelCompany(List inputList);
+ ///
+ /// 启用
+ ///
+ ///
+ ///
+ Task Enable(string Id);
+ ///
+ /// 禁用
+ ///
+ ///
+ ///
+ Task Disable(string Id);
}
}
diff --git a/BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs b/BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs
index e715898..52f6475 100644
--- a/BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs
+++ b/BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs
@@ -1,4 +1,5 @@
-using System;
+using BPA.SAAS.Manage.Application.Org.Dtos.Role;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -6,7 +7,8 @@ using System.Threading.Tasks;
namespace BPA.SAAS.Manage.Application.Org.Interface
{
- public class IRoleService
+ public interface IRoleService
{
+ Task Add(RoleDtoInput input);
}
}
diff --git a/BPA.SAAS.Manage.Application/Org/Services/CompanyService.cs b/BPA.SAAS.Manage.Application/Org/Services/CompanyService.cs
index 08f2641..0c40f1b 100644
--- a/BPA.SAAS.Manage.Application/Org/Services/CompanyService.cs
+++ b/BPA.SAAS.Manage.Application/Org/Services/CompanyService.cs
@@ -1,4 +1,5 @@
using BPA.SAAS.Manage.Application.Org.Dtos.Company;
+using BPA.SAAS.Manage.Application.Org.Dtos.Role;
using BPA.SAAS.Manage.Application.Org.Dtos.Users;
using BPA.SAAS.Manage.Application.Org.Interface;
using BPA.SAAS.Manage.Comm.Enum;
@@ -17,17 +18,18 @@ namespace BPA.SAAS.Manage.Application.Org.Services
{
private readonly ISqlSugarClient _db;
IUserService _UserService;
- public CompanyService(ISqlSugarClient db, IUserService userService)
+ IRoleService _RoleService;
+ public CompanyService(ISqlSugarClient db, IUserService userService, IRoleService roleService)
{
_db = db;
_UserService = userService;
+ _RoleService = roleService;
}
///
/// 查询企业信息
///
///
///
- [HttpPost("/api/company/companypage")]
public async Task CompanyPage(CompanyDtoPageInput input)
{
var total = 0;
@@ -59,7 +61,6 @@ namespace BPA.SAAS.Manage.Application.Org.Services
///
///
///
- [HttpPost("/api/company/add")]
public async Task AddCompany(CompanyDtoInput input)
{
var company = input.Adapt();
@@ -84,6 +85,7 @@ namespace BPA.SAAS.Manage.Application.Org.Services
{
var addrole = _RoleService.Add(new RoleDtoInput
{
+ Id= Guid.NewGuid().ToString(),
GroupId = res.Id,
Name = input.Name + "管理员",
Remark = "系统默认创建管理员角色不允许修改",
@@ -97,6 +99,7 @@ namespace BPA.SAAS.Manage.Application.Org.Services
if (UserRes.Count() > 0 && RoleRes.Count() > 0)
{
BPA_UserRole userRole = new BPA_UserRole();
+ userRole.Id= Guid.NewGuid().ToString();
userRole.SysUserId = UserRes.First().Id;
userRole.SysRoleId = RoleRes.First().Id;
_db.Insertable(userRole).ExecuteReturnEntity();
@@ -115,8 +118,7 @@ namespace BPA.SAAS.Manage.Application.Org.Services
///
///
///
- [HttpPut("/api/company/update")]
- public bool UpdateCompany(CompanyDtoInput input)
+ public async Task UpdateCompany(CompanyDtoInput input)
{
var company = input.Adapt();
@@ -126,7 +128,7 @@ namespace BPA.SAAS.Manage.Application.Org.Services
return false;
if (check.Email != input.Email)
return false;
- return _db.Updateable(company).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(t => t.Modify()).Where(x => x.Id == input.Id).ExecuteCommandHasChange();
+ return await _db.Updateable(company).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandHasChangeAsync();
}
///
@@ -134,8 +136,7 @@ namespace BPA.SAAS.Manage.Application.Org.Services
///
///
///
- [HttpDelete("/api/company/delete"), ApiDescriptionSettings(SplitCamelCase = false), NonUnify]
- public bool BatchDelCompany(List inputList)
+ public async Task BatchDelCompany(List inputList)
{
try
{
@@ -146,7 +147,7 @@ namespace BPA.SAAS.Manage.Application.Org.Services
{
x.IsDeleted = 1;
});
- var res = _db.Updateable(resEntitites).CallEntityMethod(m => m.Delete()).ExecuteCommand();
+ var res = await _db.Updateable(resEntitites).ExecuteCommandAsync();
_db.Ado.CommitTran();
return true;
}
@@ -161,15 +162,14 @@ namespace BPA.SAAS.Manage.Application.Org.Services
///
///
///
- [HttpGet("/api/company/enable"), ApiDescriptionSettings(SplitCamelCase = false), NonUnify]
- public bool Enable(string Id)
+ public async Task Enable(string Id)
{
var resEntitites = _db.Queryable().In(Id).ToList();
resEntitites.ForEach(x =>
{
x.Status = CommonStatus.ENABLE;
});
- var res = _db.Updateable(resEntitites).CallEntityMethod(m => m.Modify()).ExecuteCommand();
+ var res =await _db.Updateable(resEntitites).ExecuteCommandAsync();
return true;
}
///
@@ -177,15 +177,14 @@ namespace BPA.SAAS.Manage.Application.Org.Services
///
///
///
- [HttpGet("/api/company/disable"), ApiDescriptionSettings(SplitCamelCase = false), NonUnify]
- public bool Disable(string Id)
+ public async Task Disable(string Id)
{
var resEntitites = _db.Queryable().In(Id).ToList();
resEntitites.ForEach(x =>
{
x.Status = CommonStatus.DISABLE;
});
- var res = _db.Updateable(resEntitites).CallEntityMethod(m => m.Modify()).ExecuteCommand();
+ var res =await _db.Updateable(resEntitites).ExecuteCommandAsync();
return true;
}
}
diff --git a/BPA.SAAS.Manage.Application/Org/Services/RoleService.cs b/BPA.SAAS.Manage.Application/Org/Services/RoleService.cs
index c8b3718..03ecfcc 100644
--- a/BPA.SAAS.Manage.Application/Org/Services/RoleService.cs
+++ b/BPA.SAAS.Manage.Application/Org/Services/RoleService.cs
@@ -1,4 +1,7 @@
-using BPA.SAAS.Manage.Application.Org.Interface;
+using BPA.SAAS.Manage.Application.Org.Dtos.Role;
+using BPA.SAAS.Manage.Application.Org.Interface;
+using BPA.SAAS.Manage.Comm.Const;
+using BPA.SAAS.Manage.Core.Org;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -14,5 +17,23 @@ namespace BPA.SAAS.Manage.Application.Org.Services
{
_db=db;
}
+ public async Task Add(RoleDtoInput input)
+ {
+
+ if (input.Code != "sys_manager_role")
+ {
+ var resEntitites = _db.Queryable().Where(a => a.Code == input.Code).ToList();
+ if (resEntitites.Count() > 0)
+ {
+ throw Oops.Oh("已存在相同编码的角色");
+ }
+ }
+ var role = input.Adapt();
+ role.Id = Guid.NewGuid().ToString();
+ role.CreateAt=DateTime.Now;
+ role.CreateBy = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
+ // role.DataScopeType = DataScopeType.ALL;
+ return await _db.Insertable(role).ExecuteCommandAsync() > 0;
+ }
}
}
diff --git a/BPA.SAAS.Manage.Core/Org/BPA_Roles.cs b/BPA.SAAS.Manage.Core/Org/BPA_Roles.cs
index fc76e88..787e551 100644
--- a/BPA.SAAS.Manage.Core/Org/BPA_Roles.cs
+++ b/BPA.SAAS.Manage.Core/Org/BPA_Roles.cs
@@ -19,6 +19,10 @@ namespace BPA.SAAS.Manage.Core.Org
///
public string Name { get; set; }
///
+ /// 编码
+ ///
+ public string Code { get; set; }
+ ///
/// 排序
///
public string Sort { get; set; }
diff --git a/BPA.SAAS.Manage.Core/Org/BPA_UserRole.cs b/BPA.SAAS.Manage.Core/Org/BPA_UserRole.cs
new file mode 100644
index 0000000..371c4de
--- /dev/null
+++ b/BPA.SAAS.Manage.Core/Org/BPA_UserRole.cs
@@ -0,0 +1,30 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.Manage.Core.Org
+{
+ [SugarTable("bpa_userrole")]
+ public class BPA_UserRole
+ {
+ ///
+ /// 主键 Guid
+ ///
+ [SugarColumn(IsPrimaryKey = true, ColumnDataType = "Nvarchar(64)", IsNullable = false)]
+ public string Id { get; set; }
+ ///
+ /// 用户Id
+ ///
+ [SugarColumn(ColumnDataType = "Nvarchar(64)", ColumnDescription = "用户Id", IsNullable = false)]
+ public string SysUserId { get; set; }
+ ///
+ /// 角色Id
+ ///
+
+ [SugarColumn(ColumnDataType = "Nvarchar(64)", ColumnDescription = "角色Id", IsNullable = false)]
+ public string SysRoleId { get; set; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Core/bin/Debug/net6.0/BPA.SAAS.Manage.Core.xml b/BPA.SAAS.Manage.Core/bin/Debug/net6.0/BPA.SAAS.Manage.Core.xml
new file mode 100644
index 0000000..4b1237c
--- /dev/null
+++ b/BPA.SAAS.Manage.Core/bin/Debug/net6.0/BPA.SAAS.Manage.Core.xml
@@ -0,0 +1,368 @@
+
+
+
+ BPA.SAAS.Manage.Core
+
+
+
+
+ 主键 Guid
+
+
+
+
+ 是否删除
+
+
+
+
+ 当前页码
+
+
+
+
+ 页码容量
+
+
+
+
+ 分页实体
+
+
+
+
+ Data
+
+
+
+
+ Total
+
+
+
+
+ 数据库上下文对象
+
+
+
+
+ SqlSugar 数据库实例
+
+
+
+
+ 加盟商信息
+
+
+
+
+ 加盟商名称
+
+
+
+
+ 管理员姓名
+
+
+
+
+ 邮箱账号
+
+
+
+
+ 电话
+
+
+
+
+ 备注
+
+
+
+
+ logo
+
+
+
+
+ 状态 【正常 停用】默认 正常
+
+
+
+
+ 组织机构
+
+
+
+
+ 机构名称
+
+
+
+
+ 上级id
+
+
+
+
+ 类型 默认 机构
+
+
+
+
+ 上级ID集合
+
+
+
+
+ 备注
+
+
+
+
+ 店铺地址
+
+
+
+
+ 店铺坐标
+
+
+
+
+ AutoKey 唯一值
+
+
+
+
+ 状态 【正常 停用】默认 正常
+
+
+
+
+ 加盟商id
+
+
+
+
+ 角色
+
+
+
+
+ 角色名称
+
+
+
+
+ 排序
+
+
+
+
+ 备注
+
+
+
+
+ 角色类型-集团角色_0、加盟商角色_1、门店角色_2
+
+
+
+
+ 加盟商id
+
+
+
+
+ 用户名称
+
+
+
+
+ 登录账号
+
+
+
+
+ 登录密码
+
+
+
+
+ 手机号码
+
+
+
+
+ 管理员类型-超级管理员_1、管理员_2、普通账号_3
+
+
+
+
+ 归属组织
+
+
+
+
+ 加盟商id
+
+
+
+
+ 字典类型id
+
+
+
+
+ 字典值
+
+
+
+
+ 字典编码
+
+
+
+
+ 备注
+
+
+
+
+ 状态 【正常 停用】默认 正常
+
+
+
+
+ 类型名称
+
+
+
+
+ 类型编码
+
+
+
+
+ 备注
+
+
+
+
+ 状态 【正常 停用】默认 正常
+
+
+
+
+ 操作人
+
+
+
+
+ 请求地址
+
+
+
+
+ 请求数据
+
+
+
+
+ 返回数据
+
+
+
+
+ ip地址
+
+
+
+
+ 加盟商id
+
+
+
+
+ 菜单名称
+
+
+
+
+ 父级id
+
+
+
+
+ 菜单编码 唯一
+
+
+
+
+ 图标
+
+
+
+
+ 路径
+
+
+
+
+ 组件路径
+
+
+
+
+ 是否可见
+
+
+
+
+ 排序
+
+
+
+
+ 备注
+
+
+
+
+ 操作人
+
+
+
+
+ 请求地址
+
+
+
+
+ 请求数据
+
+
+
+
+ 返回数据
+
+
+
+
+ ip地址
+
+
+
+
+ 加盟商id
+
+
+
+
+ 主键 Guid
+
+
+
+