添加项目文件。
This commit is contained in:
213
app/Tnb.Apps/AppDataService.cs
Normal file
213
app/Tnb.Apps/AppDataService.cs
Normal file
@@ -0,0 +1,213 @@
|
||||
using JNPF.Apps.Entitys;
|
||||
using JNPF.Apps.Entitys.Dto;
|
||||
using JNPF.Apps.Interfaces;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.WorkFlow.Entitys.Dto.FlowEngine;
|
||||
using JNPF.WorkFlow.Entitys.Entity;
|
||||
using JNPF.WorkFlow.Interfaces.Service;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JNPF.Apps;
|
||||
|
||||
/// <summary>
|
||||
/// App常用数据
|
||||
/// 版 本:V3.2
|
||||
/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com)
|
||||
/// 日 期:2021-06-01 .
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = "App", Name = "Data", Order = 800)]
|
||||
[Route("api/App/[controller]")]
|
||||
public class AppDataService : IAppDataService, IDynamicApiController, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务基础仓储.
|
||||
/// </summary>
|
||||
private readonly ISqlSugarRepository<AppDataEntity> _repository; // App常用数据
|
||||
|
||||
/// <summary>
|
||||
/// 用户管理.
|
||||
/// </summary>
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 流程管理.
|
||||
/// </summary>
|
||||
private readonly IFlowTemplateService _flowTemplateService;
|
||||
|
||||
/// <summary>
|
||||
/// 构造.
|
||||
/// </summary>
|
||||
/// <param name="repository"></param>
|
||||
/// <param name="userManager"></param>
|
||||
/// <param name="flowTemplateService"></param>
|
||||
public AppDataService(
|
||||
ISqlSugarRepository<AppDataEntity> repository,
|
||||
IUserManager userManager,
|
||||
IFlowTemplateService flowTemplateService)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
_flowTemplateService = flowTemplateService;
|
||||
}
|
||||
|
||||
#region Get
|
||||
|
||||
/// <summary>
|
||||
/// 常用数据.
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("")]
|
||||
public async Task<dynamic> GetList([FromQuery] string type)
|
||||
{
|
||||
List<AppDataEntity>? list = await GetListByType(type);
|
||||
List<AppDataListOutput>? output = list.Adapt<List<AppDataListOutput>>();
|
||||
if (type.Equals("1"))
|
||||
{
|
||||
foreach (var item in output)
|
||||
{
|
||||
var flowJson = _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().First(x => x.TemplateId == item.objectId && x.EnabledMark == 1 && x.DeleteMark == null);
|
||||
if (flowJson != null)
|
||||
{
|
||||
item.objectId = flowJson.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new { list = output };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 所有流程.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getFlowList")]
|
||||
public async Task<dynamic> GetFlowList([FromQuery] FlowEngineListInput input)
|
||||
{
|
||||
var list = await _repository.AsSugarClient().Queryable<FlowTemplateEntity>()
|
||||
.Where(a => a.DeleteMark == null && a.EnabledMark == 1 && a.Type == 0)
|
||||
.WhereIF(input.category.IsNotEmptyOrNull(), a => a.Category == input.category)
|
||||
.WhereIF(input.keyword.IsNotEmptyOrNull(), a => a.FullName.Contains(input.keyword) || a.EnCode.Contains(input.keyword))
|
||||
.OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc)
|
||||
.OrderBy(a => a.LastModifyTime, OrderByType.Desc)
|
||||
.Select(a => new AppFlowListAllOutput
|
||||
{
|
||||
id = a.Id,
|
||||
icon = a.Icon,
|
||||
enCode = a.EnCode,
|
||||
fullName = a.FullName,
|
||||
iconBackground = a.IconBackground,
|
||||
isData = SqlFunc.Subqueryable<AppDataEntity>().Where(x => x.ObjectType == "1" && x.CreatorUserId == _userManager.UserId && x.ObjectId == a.Id && x.DeleteMark == null).Any(),
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return PageResult<AppFlowListAllOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 所有流程.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getDataList")]
|
||||
public async Task<dynamic> GetDataList(string keyword)
|
||||
{
|
||||
List<AppDataListAllOutput>? list = (await GetAppMenuList(keyword)).Adapt<List<AppDataListAllOutput>>();
|
||||
foreach (AppDataListAllOutput? item in list)
|
||||
{
|
||||
item.isData = _repository.IsAny(x => x.ObjectType == "2" && x.CreatorUserId == _userManager.UserId && x.ObjectId == item.id && x.DeleteMark == null);
|
||||
}
|
||||
|
||||
List<AppDataListAllOutput>? output = list.ToTree("-1");
|
||||
return new { list = output };
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Post
|
||||
|
||||
/// <summary>
|
||||
/// 新增.
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("")]
|
||||
public async Task Create([FromBody] AppDataCrInput input)
|
||||
{
|
||||
AppDataEntity? entity = input.Adapt<AppDataEntity>();
|
||||
int isOk = await _repository.AsInsertable(entity).IgnoreColumns(ignoreNullColumn: true).CallEntityMethod(m => m.Creator()).ExecuteCommandAsync();
|
||||
if (isOk < 1)
|
||||
throw Oops.Oh(ErrorCode.COM1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除.
|
||||
/// </summary>
|
||||
/// <param name="objectId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{objectId}")]
|
||||
public async Task Delete(string objectId)
|
||||
{
|
||||
AppDataEntity? entity = await _repository.GetSingleAsync(x => x.ObjectId == objectId && x.CreatorUserId == _userManager.UserId && x.DeleteMark == null);
|
||||
var isOk = await _repository.AsUpdateable(entity).CallEntityMethod(m => m.Delete()).UpdateColumns(it => new { it.DeleteMark, it.DeleteTime, it.DeleteUserId }).ExecuteCommandHasChangeAsync();
|
||||
if (!isOk)
|
||||
throw Oops.Oh(ErrorCode.COM1002);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PrivateMethod
|
||||
|
||||
/// <summary>
|
||||
/// 列表.
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<AppDataEntity>> GetListByType(string type)
|
||||
{
|
||||
return await _repository.AsQueryable().Where(x => x.ObjectType == type && x.CreatorUserId == _userManager.UserId && x.DeleteMark == null).ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单列表.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
public async Task<List<ModuleEntity>> GetAppMenuList(string keyword)
|
||||
{
|
||||
List<ModuleEntity>? menuList = new List<ModuleEntity>();
|
||||
if (_userManager.IsAdministrator)
|
||||
{
|
||||
menuList = await _repository.AsSugarClient().Queryable<ModuleEntity>()
|
||||
.Where(x => x.EnabledMark == 1 && x.Category == "App" && x.DeleteMark == null && x.SystemId == _userManager.User.SystemId)
|
||||
.WhereIF(!string.IsNullOrEmpty(keyword), x => x.FullName.Contains(keyword) || x.ParentId == "-1")
|
||||
.OrderBy(o => o.SortCode)
|
||||
.ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
string[]? objectIds = _userManager.Roles.ToArray();
|
||||
if (objectIds.Length == 0)
|
||||
return menuList;
|
||||
List<string>? ids = await _repository.AsSugarClient().Queryable<AuthorizeEntity>()
|
||||
.Where(x => objectIds.Contains(x.ObjectId) && x.ObjectType == "Role" && x.ItemType == "module").Select(x => x.ItemId).ToListAsync();
|
||||
if (ids.Count == 0)
|
||||
return menuList;
|
||||
menuList = await _repository.AsSugarClient().Queryable<ModuleEntity>()
|
||||
.Where(x => ids.Contains(x.Id) && x.EnabledMark == 1 && x.Category == "App" && x.DeleteMark == null && x.SystemId == _userManager.User.SystemId)
|
||||
.WhereIF(!string.IsNullOrEmpty(keyword), x => x.FullName.Contains(keyword) || x.ParentId == "-1")
|
||||
.OrderBy(o => o.SortCode)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
return menuList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
48
app/Tnb.Apps/AppMenuService.cs
Normal file
48
app/Tnb.Apps/AppMenuService.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using JNPF.Apps.Entitys.Dto;
|
||||
using JNPF.Apps.Interfaces;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Mapster;
|
||||
|
||||
namespace JNPF.Apps;
|
||||
|
||||
/// <summary>
|
||||
/// App菜单
|
||||
/// 版 本:V3.2
|
||||
/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com)
|
||||
/// 日 期:2021-06-01 .
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = "App", Name = "Menu", Order = 800)]
|
||||
[Route("api/App/[controller]")]
|
||||
public class AppMenuService : IDynamicApiController, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// App常用数据.
|
||||
/// </summary>
|
||||
private readonly IAppDataService _appDataService;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化一个<see cref="AppMenuService"/>类型的新实例.
|
||||
/// </summary>
|
||||
public AppMenuService(IAppDataService appDataService)
|
||||
{
|
||||
_appDataService = appDataService;
|
||||
}
|
||||
|
||||
#region Get
|
||||
|
||||
/// <summary>
|
||||
/// 获取菜单列表.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("")]
|
||||
public async Task<dynamic> GetList(string keyword)
|
||||
{
|
||||
List<AppMenuListOutput>? list = (await _appDataService.GetAppMenuList(keyword)).Adapt<List<AppMenuListOutput>>();
|
||||
return new { list = list.ToTree("-1") };
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
95
app/Tnb.Apps/AppUserService.cs
Normal file
95
app/Tnb.Apps/AppUserService.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using JNPF.Apps.Entitys.Dto;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Interfaces.Permission;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace JNPF.Apps;
|
||||
|
||||
/// <summary>
|
||||
/// App用户信息
|
||||
/// 版 本:V3.2
|
||||
/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com)
|
||||
/// 日 期:2021-06-01.
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = "App", Name = "User", Order = 800)]
|
||||
[Route("api/App/[controller]")]
|
||||
public class AppUserService : IDynamicApiController, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户信息.
|
||||
/// </summary>
|
||||
private readonly IUsersService _usersService;
|
||||
|
||||
/// <summary>
|
||||
/// 部门管理.
|
||||
/// </summary>
|
||||
private readonly IDepartmentService _departmentService;
|
||||
|
||||
/// <summary>
|
||||
/// 岗位管理.
|
||||
/// </summary>
|
||||
private readonly IPositionService _positionService;
|
||||
|
||||
/// <summary>
|
||||
/// 用户管理.
|
||||
/// </summary>
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 构造.
|
||||
/// </summary>
|
||||
/// <param name="usersService"></param>
|
||||
/// <param name="departmentService"></param>
|
||||
/// <param name="positionService"></param>
|
||||
/// <param name="userManager"></param>
|
||||
public AppUserService(IUsersService usersService, IDepartmentService departmentService, IPositionService positionService, IUserManager userManager)
|
||||
{
|
||||
_usersService = usersService;
|
||||
_departmentService = departmentService;
|
||||
_positionService = positionService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region Get
|
||||
|
||||
/// <summary>
|
||||
/// 用户信息.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("")]
|
||||
public async Task<dynamic> GetInfo()
|
||||
{
|
||||
UserEntity? userEntity = _usersService.GetInfoByUserId(_userManager.UserId);
|
||||
AppUserOutput? appUserInfo = userEntity.Adapt<AppUserOutput>();
|
||||
appUserInfo.positionIds = userEntity.PositionId == null ? null : await _usersService.GetPosition(userEntity.PositionId);
|
||||
appUserInfo.departmentName = _departmentService.GetOrganizeNameTree(userEntity.OrganizeId);
|
||||
appUserInfo.organizeId = _departmentService.GetCompanyId(userEntity.OrganizeId);
|
||||
appUserInfo.organizeName = appUserInfo.departmentName;
|
||||
|
||||
// 获取当前组织角色和全局角色
|
||||
List<string>? roleList = await _userManager.GetUserOrgRoleIds(userEntity.RoleId, userEntity.OrganizeId);
|
||||
appUserInfo.roleName = await _userManager.GetRoleNameByIds(string.Join(",", roleList));
|
||||
appUserInfo.manager = await _usersService.GetUserName(userEntity.ManagerId);
|
||||
return appUserInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户信息.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
public dynamic GetInfo(string id)
|
||||
{
|
||||
UserEntity? userEntity = _usersService.GetInfoByUserId(id);
|
||||
AppUserInfoOutput? appUserInfo = userEntity.Adapt<AppUserInfoOutput>();
|
||||
appUserInfo.organizeName = _departmentService.GetDepName(userEntity.OrganizeId);
|
||||
appUserInfo.positionName = _positionService.GetName(userEntity.PositionId);
|
||||
return appUserInfo;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
67
app/Tnb.Apps/AppVersion.cs
Normal file
67
app/Tnb.Apps/AppVersion.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using JNPF.Common.Configuration;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JNPF.Apps;
|
||||
|
||||
/// <summary>
|
||||
/// App版本信息
|
||||
/// 版 本:V3.3
|
||||
/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com)
|
||||
/// 日 期:2022-04-07.
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = "App", Name = "Version", Order = 806)]
|
||||
[Route("api/App/[controller]")]
|
||||
public class AppVersion : IDynamicApiController, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务基础仓储.
|
||||
/// </summary>
|
||||
private readonly ISqlSugarRepository<SysConfigEntity> _repository; // 系统设置
|
||||
|
||||
/// <summary>
|
||||
/// 原始数据库.
|
||||
/// </summary>
|
||||
private readonly SqlSugarScope _db;
|
||||
|
||||
/// <summary>
|
||||
/// 构造.
|
||||
/// </summary>
|
||||
/// <param name="sysConfigRepository"></param>
|
||||
/// <param name="context"></param>
|
||||
public AppVersion(
|
||||
ISqlSugarRepository<SysConfigEntity> repository,
|
||||
ISqlSugarClient context)
|
||||
{
|
||||
_repository = repository;
|
||||
_db = (SqlSugarScope)context;
|
||||
}
|
||||
|
||||
#region Get
|
||||
|
||||
/// <summary>
|
||||
/// 版本信息.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("")]
|
||||
public async Task<dynamic> GetInfo()
|
||||
{
|
||||
SysConfigEntity? data = new SysConfigEntity();
|
||||
|
||||
if (KeyVariable.MultiTenancy)
|
||||
{
|
||||
data = await _db.Queryable<SysConfigEntity>().Where(x => x.Category.Equals("SysConfig") && x.Key == "sysVersion").FirstAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
data = await _repository.AsQueryable().Where(x => x.Category.Equals("SysConfig") && x.Key == "sysVersion").FirstAsync();
|
||||
}
|
||||
|
||||
return new { sysVersion = data.Value };
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
18
app/Tnb.Apps/Tnb.Apps.csproj
Normal file
18
app/Tnb.Apps/Tnb.Apps.csproj
Normal file
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$(SolutionDir)\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\common\Tnb.Common.Core\Tnb.Common.Core.csproj" />
|
||||
<ProjectReference Include="..\..\system\Tnb.Systems.Interfaces\Tnb.Systems.Interfaces.csproj" />
|
||||
<ProjectReference Include="..\..\workflow\Tnb.WorkFlow.Interfaces\Tnb.WorkFlow.Interfaces.csproj" />
|
||||
<ProjectReference Include="..\Tnb.Apps.Interfaces\Tnb.Apps.Interfaces.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user