v3.4.6
This commit is contained in:
184
system/Tnb.Systems/System/CommonWordsService.cs
Normal file
184
system/Tnb.Systems/System/CommonWordsService.cs
Normal file
@@ -0,0 +1,184 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Entitys.Dto.System.CommonWords;
|
||||
using JNPF.Systems.Entitys.Entity.System;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JNPF.Systems.System;
|
||||
|
||||
/// <summary>
|
||||
/// 常用语.
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = "System", Name = "CommonWords", Order = 200)]
|
||||
[Route("api/system/[controller]")]
|
||||
public class CommonWordsService : IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<CommonWordsEntity> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化一个<see cref="ModuleService"/>类型的新实例.
|
||||
/// </summary>
|
||||
public CommonWordsService(
|
||||
ISqlSugarRepository<CommonWordsEntity> repository,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region Get
|
||||
|
||||
/// <summary>
|
||||
/// 列表.
|
||||
/// </summary>
|
||||
/// <param name="input">参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("")]
|
||||
public async Task<dynamic> GetList([FromQuery] PageInputBase input)
|
||||
{
|
||||
var list = await _repository.AsSugarClient().Queryable<CommonWordsEntity>()
|
||||
.Where(a => a.CommonWordsType == 0 && a.DeleteMark == null)
|
||||
.WhereIF(input.keyword.IsNotEmptyOrNull(), a => SqlFunc.ToString(a.SystemNames).Contains(input.keyword) || SqlFunc.ToString(a.CommonWordsText).Contains(input.keyword))
|
||||
.OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc)
|
||||
.Select(a => new CommonWordsOutput()
|
||||
{
|
||||
id = a.Id,
|
||||
systemNames = SqlFunc.ToString(a.SystemNames),
|
||||
commonWordsText = SqlFunc.ToString(a.CommonWordsText),
|
||||
sortCode = a.SortCode,
|
||||
enabledMark = a.EnabledMark,
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return PageResult<CommonWordsOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取信息.
|
||||
/// </summary>
|
||||
/// <param name="id">主键id.</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<dynamic> GetInfo(string id)
|
||||
{
|
||||
var data = await _repository.GetFirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
var output = new CommonWordsInput();
|
||||
if (data.IsNotEmptyOrNull())
|
||||
{
|
||||
output.id = data.Id;
|
||||
output.commonWordsText = data.CommonWordsText;
|
||||
output.sortCode = data.SortCode;
|
||||
output.enabledMark = data.EnabledMark;
|
||||
output.commonWordsType = data.CommonWordsType;
|
||||
foreach (var item in data.SystemIds.Split(","))
|
||||
{
|
||||
var systemEntity = await _repository.AsSugarClient().Queryable<SystemEntity>().FirstAsync(x => x.Id == item && x.EnabledMark == 1 && x.DeleteMark == null);
|
||||
if (systemEntity.IsNotEmptyOrNull())
|
||||
{
|
||||
output.systemIds.Add(systemEntity.Id);
|
||||
output.systemNames.Add(systemEntity.FullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下拉列表.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Selector")]
|
||||
public async Task<dynamic> GetSelector()
|
||||
{
|
||||
var list = await _repository.AsSugarClient().Queryable<CommonWordsEntity>()
|
||||
.Where(a => (a.CommonWordsType == 0 || a.CreatorUserId == _userManager.UserId) && a.SystemIds.Contains(_userManager.User.SystemId) && a.EnabledMark == 1 && a.DeleteMark == null)
|
||||
.OrderBy(a => a.CommonWordsType, OrderByType.Desc).OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc)
|
||||
.Select(a => new CommonWordsOutput()
|
||||
{
|
||||
id = a.Id,
|
||||
systemNames = SqlFunc.ToString(a.SystemNames),
|
||||
commonWordsText = SqlFunc.ToString(a.CommonWordsText),
|
||||
sortCode = a.SortCode,
|
||||
enabledMark = a.EnabledMark,
|
||||
commonWordsType = a.CommonWordsType,
|
||||
}).ToListAsync();
|
||||
return new { list = list };
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Post
|
||||
|
||||
/// <summary>
|
||||
/// 新建.
|
||||
/// </summary>
|
||||
/// <param name="input">实体对象.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("")]
|
||||
public async Task Create([FromBody] CommonWordsInput input)
|
||||
{
|
||||
var entity = input.Adapt<CommonWordsEntity>();
|
||||
if (input.systemIds.Any())
|
||||
{
|
||||
entity.SystemIds = string.Join(",", input.systemIds);
|
||||
entity.SystemNames = string.Join(",", input.systemNames);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.SystemIds = _userManager.User.SystemId;
|
||||
entity.SystemNames = _repository.AsSugarClient().Queryable<SystemEntity>().First(x => x.Id == _userManager.User.SystemId && x.DeleteMark == null).FullName;
|
||||
}
|
||||
var 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="id">主键值.</param>
|
||||
/// <param name="input">实体对象.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
public async Task Update(string id, [FromBody] CommonWordsInput input)
|
||||
{
|
||||
var entity = input.Adapt<CommonWordsEntity>();
|
||||
if (input.systemIds.Any())
|
||||
{
|
||||
entity.SystemIds = string.Join(",", input.systemIds);
|
||||
entity.SystemNames = string.Join(",", input.systemNames);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.SystemIds = _userManager.User.SystemId;
|
||||
entity.SystemNames = _repository.AsSugarClient().Queryable<SystemEntity>().First(x => x.Id == _userManager.User.SystemId && x.DeleteMark == null).FullName;
|
||||
}
|
||||
var isOk = await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandHasChangeAsync();
|
||||
if (!isOk)
|
||||
throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除.
|
||||
/// </summary>
|
||||
/// <param name="id">主键.</param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task Delete(string id)
|
||||
{
|
||||
var entity = await _repository.GetFirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
if (entity == null)
|
||||
throw Oops.Oh(ErrorCode.COM1005);
|
||||
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
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
using System.ArrayExtensions;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using JNPF.Common.Configuration;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Core.Manager.Files;
|
||||
using JNPF.Common.Dtos.DataBase;
|
||||
@@ -26,8 +22,6 @@ using Mapster;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Org.BouncyCastle.Asn1.Cms;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JNPF.Systems;
|
||||
@@ -101,30 +95,41 @@ public class DataBaseService : IDynamicApiController, ITransient
|
||||
/// <param name="input">过滤条件.</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/Tables")]
|
||||
public async Task<dynamic> GetList(string id, [FromQuery] KeywordInput input)
|
||||
public async Task<dynamic> GetList(string id, [FromQuery] PageInputBase input)
|
||||
{
|
||||
var link = await _dbLinkService.GetInfo(id);
|
||||
var tenantLink = link ?? _dataBaseManager.GetTenantDbLink(_userManager.TenantId, _userManager.TenantDbName);
|
||||
var tables = _dataBaseManager.GetDBTableList(tenantLink);
|
||||
//tables = tables.Where((x, i) => tables.FindIndex(z => z.Name == x.Name) == i).ToList();
|
||||
//var output = tables.Adapt<List<DatabaseTableListOutput>>();
|
||||
if (!string.IsNullOrEmpty(input.keyword))
|
||||
try
|
||||
{
|
||||
var keyword = input.keyword.ToLower();
|
||||
tables = tables.FindAll(d => d.table.ToLower().Contains(keyword) || (d.tableName.IsNotEmptyOrNull() && d.tableName.ToLower().Contains(keyword)));
|
||||
var link = await _dbLinkService.GetInfo(id);
|
||||
var tenantLink = link ?? _dataBaseManager.GetTenantDbLink(_userManager.TenantId, _userManager.TenantDbName);
|
||||
var tables = _dataBaseManager.GetTableInfos(tenantLink);
|
||||
tables = tables.Where((x, i) => tables.FindIndex(z => z.Name == x.Name) == i).ToList();//去重
|
||||
var output = tables.Adapt<List<DatabaseTableListOutput>>();
|
||||
if (!string.IsNullOrEmpty(input.keyword))
|
||||
output = output.FindAll(d => d.table.ToLower().Contains(input.keyword.ToLower()) || (d.tableName.IsNotEmptyOrNull() && d.tableName.ToLower().Contains(input.keyword.ToLower())));
|
||||
return PageResult<DatabaseTableListOutput>.SqlSugarPageResult(new SqlSugarPagedList<DatabaseTableListOutput>()
|
||||
{
|
||||
list = output.OrderBy(x => x.table).Skip((input.currentPage - 1) * input.pageSize).Take(input.pageSize).OrderBy(x => x.table).ToList(),
|
||||
pagination = new Pagination()
|
||||
{
|
||||
CurrentPage = input.currentPage,
|
||||
PageSize = input.pageSize,
|
||||
Total = output.Count
|
||||
}
|
||||
});
|
||||
}
|
||||
if (tenantLink.DbType.ToLower().Equals("dm"))
|
||||
catch (Exception ex)
|
||||
{
|
||||
GetTableCount(tables, tenantLink);
|
||||
return PageResult<DatabaseTableListOutput>.SqlSugarPageResult(new SqlSugarPagedList<DatabaseTableListOutput>()
|
||||
{
|
||||
list = new List<DatabaseTableListOutput>(),
|
||||
pagination = new Pagination()
|
||||
{
|
||||
CurrentPage = input.currentPage,
|
||||
PageSize = input.pageSize,
|
||||
Total = 0
|
||||
}
|
||||
});
|
||||
}
|
||||
return new { list = tables.OrderBy(x => x.table).ToList() };
|
||||
//try
|
||||
//{
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// return new { list = new List<DatabaseTableListOutput>() };
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -186,8 +191,7 @@ public class DataBaseService : IDynamicApiController, ITransient
|
||||
if (string.IsNullOrEmpty(tableName)) return new PageResult();
|
||||
var tenantLink = link ?? _dataBaseManager.GetTenantDbLink(_userManager.TenantId, _userManager.TenantDbName);
|
||||
var output = _dataBaseManager.GetDataBaseTableInfo(tenantLink, tableName);
|
||||
var data = _dataBaseManager.GetData(tenantLink, tableName);
|
||||
output.hasTableData = data.Rows.Count > 0;
|
||||
output.hasTableData = _dataBaseManager.IsAnyData(tenantLink, tableName);
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -262,6 +266,8 @@ public class DataBaseService : IDynamicApiController, ITransient
|
||||
var tenantLink = link ?? _dataBaseManager.GetTenantDbLink(_userManager.TenantId, _userManager.TenantDbName);
|
||||
if (_dataBaseManager.IsAnyTable(tenantLink, input.tableInfo.newTable))
|
||||
throw Oops.Oh(ErrorCode.D1503);
|
||||
if (input.tableInfo.newTable.Length >= 30) throw Oops.Oh(ErrorCode.D1514);
|
||||
if (input.tableFieldList.Any(x => x.field.Length >= 30)) throw Oops.Oh(ErrorCode.D1515);
|
||||
var tableInfo = input.tableInfo.Adapt<DbTableModel>();
|
||||
tableInfo.table = input.tableInfo.newTable;
|
||||
var tableFieldList = input.tableFieldList.Adapt<List<DbTableFieldModel>>();
|
||||
@@ -280,10 +286,12 @@ public class DataBaseService : IDynamicApiController, ITransient
|
||||
public async Task Update(string linkId, [FromBody] DatabaseTableUpInput input)
|
||||
{
|
||||
var link = await _dbLinkService.GetInfo(linkId);
|
||||
if (input.tableInfo.newTable.Length >= 30) throw Oops.Oh(ErrorCode.D1514);
|
||||
if (input.tableFieldList.Any(x => x.field.Length >= 30)) throw Oops.Oh(ErrorCode.D1515);
|
||||
var tenantLink = link ?? _dataBaseManager.GetTenantDbLink(_userManager.TenantId, _userManager.TenantDbName);
|
||||
var oldFieldList = _dataBaseManager.GetFieldList(tenantLink, input.tableInfo.table).Adapt<List<TableFieldOutput>>();
|
||||
oldFieldList = _dataBaseManager.ViewDataTypeConversion(oldFieldList, _dataBaseManager.ToDbType(tenantLink.DbType));
|
||||
var oldTableInfo = _dataBaseManager.GetDBTableList(tenantLink).Find(m => m.table == input.tableInfo.table).Adapt<DbTableModel>();
|
||||
var oldTableInfo = _dataBaseManager.GetTableInfos(tenantLink).Find(m => m.Name == input.tableInfo.table).Adapt<DbTableModel>();
|
||||
var data = _dataBaseManager.GetData(tenantLink, input.tableInfo.table);
|
||||
if (data.Rows.Count > 0)
|
||||
throw Oops.Oh(ErrorCode.D1508);
|
||||
@@ -313,6 +321,7 @@ public class DataBaseService : IDynamicApiController, ITransient
|
||||
{
|
||||
try
|
||||
{
|
||||
if (input.tableFieldList.Any(x => x.field.Length >= 30)) throw Oops.Oh(ErrorCode.D1515);
|
||||
var link = await _dbLinkService.GetInfo(linkId);
|
||||
var tenantLink = link ?? _dataBaseManager.GetTenantDbLink(_userManager.TenantId, _userManager.TenantDbName);
|
||||
_dataBaseManager.AddTableColumn(tenantLink, input.tableInfo.table, input.tableFieldList.Adapt<List<DbTableFieldModel>>());
|
||||
@@ -631,7 +640,7 @@ public class DataBaseService : IDynamicApiController, ITransient
|
||||
{"tool_", "Tnb.EquipMgr.Entities" },
|
||||
{"qc_", "Tnb.QcMgr.Entities" },
|
||||
};
|
||||
var allTables = sugar.DbMaintenance.GetTableInfoList().WhereIF(!string.IsNullOrEmpty(tbName), t=>t.Name == tbName);
|
||||
var allTables = sugar.DbMaintenance.GetTableInfoList().WhereIF(!string.IsNullOrEmpty(tbName), t => t.Name == tbName);
|
||||
foreach (var tbl in allTables)
|
||||
{
|
||||
var prefix = tbl.Name.Split('_')[0] + "_";
|
||||
|
||||
@@ -21,6 +21,7 @@ using JNPF.Common.Security;
|
||||
using JNPF.DatabaseAccessor;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Extras.DatabaseAccessor.SqlSugar.Models;
|
||||
using JNPF.Extras.Thirdparty.JSEngine;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.LinqBuilder;
|
||||
@@ -506,19 +507,65 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController
|
||||
ConnectionString = string.Format($"{App.Configuration["ConnectionStrings:DefaultConnection"]}", result.data.dotnet)
|
||||
});
|
||||
}
|
||||
|
||||
_sqlSugarClient.ChangeDatabase(tenantId);
|
||||
if (!"default".Equals(tenantId) && KeyVariable.MultiTenancyType.Equals("COLUMN"))
|
||||
{
|
||||
_sqlSugarClient.QueryFilter.AddTableFilter<ITenantFilter>(it => it.TenantId == tenantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sqlSugarClient.ChangeDatabase(tenantId);
|
||||
}
|
||||
}
|
||||
var interfaceOauthEntity = await _sqlSugarClient.Queryable<InterfaceOauthEntity>().FirstAsync(x => x.AppId == appId && x.DeleteMark == null && x.EnabledMark == 1);
|
||||
if (interfaceOauthEntity == null) return null;
|
||||
var ymDate = DateTime.Now.ParseToUnixTime().ToString();
|
||||
var authorization = GetVerifySignature(interfaceOauthEntity, intefaceId, ymDate);
|
||||
return new
|
||||
{
|
||||
return new {
|
||||
YmDate = ymDate,
|
||||
Authorization = authorization,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 复制.
|
||||
/// </summary>
|
||||
/// <param name="id">主键值.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}/Actions/Copy")]
|
||||
public async Task ActionsCopy(string id)
|
||||
{
|
||||
var entity = await _repository.GetFirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
if (entity == null)
|
||||
throw Oops.Oh(ErrorCode.COM1005);
|
||||
var random = RandomExtensions.NextLetterAndNumberString(new Random(), 5).ToLower();
|
||||
entity.FullName = string.Format("{0}.副本{1}", entity.FullName, random);
|
||||
entity.EnCode = string.Format("{0}{1}", entity.EnCode, random);
|
||||
if (entity.FullName.Length >= 50 || entity.EnCode.Length >= 50)
|
||||
throw Oops.Oh(ErrorCode.COM1009);
|
||||
entity.EnabledMark = 0;
|
||||
var 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="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}/Actions/GetFields")]
|
||||
[UnitOfWork]
|
||||
public async Task<dynamic> GetFields(string id, [FromBody] DataInterfacePreviewInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (await Preview(id, input)).ToObject<List<Dictionary<string, object>>>().FirstOrDefault().Keys.ToList();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.COM1020);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PublicMethod
|
||||
@@ -549,7 +596,7 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController
|
||||
/// 根据不同类型请求接口.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="type">0 : 分页 1 :详情 ,其他 原始.</param>
|
||||
/// <param name="type">0 : 分页 1 :详情 2:数据视图 ,其他 原始.</param>
|
||||
/// <param name="tenantId"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
@@ -579,36 +626,61 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController
|
||||
});
|
||||
}
|
||||
|
||||
_sqlSugarClient.ChangeDatabase(tenantId);
|
||||
if (!"default".Equals(tenantId) && KeyVariable.MultiTenancyType.Equals("COLUMN"))
|
||||
{
|
||||
_sqlSugarClient.QueryFilter.AddTableFilter<ITenantFilter>(it => it.TenantId == tenantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sqlSugarClient.ChangeDatabase(tenantId);
|
||||
}
|
||||
_configId = tenantId;
|
||||
_dbName = result.data.dotnet;
|
||||
}
|
||||
|
||||
var data = await _sqlSugarClient.Queryable<DataInterfaceEntity>().FirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
var data = await _sqlSugarClient.CopyNew().Queryable<DataInterfaceEntity>().FirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
if (data == null)
|
||||
throw Oops.Oh(ErrorCode.COM1005);
|
||||
|
||||
// 远端数据(sql过滤)
|
||||
if (input.IsNotEmptyOrNull())
|
||||
{
|
||||
var columnList = new List<string>();
|
||||
if (input.keyword.IsNotEmptyOrNull())
|
||||
input.columnOptions.Split(",").ToList().ForEach(x => columnList.Add(string.Format("{0} like '%{1}%'", x, input.keyword)));
|
||||
|
||||
if (columnList.Any() && !string.IsNullOrWhiteSpace(input.keyword))
|
||||
data.Query = string.Format("select * from ({0}) t where {1} ", data.Query.TrimEnd(';'), string.Join(" or ", columnList));
|
||||
else if (!string.IsNullOrWhiteSpace(input.relationField) && !string.IsNullOrWhiteSpace(input.keyword))
|
||||
data.Query = string.Format("select * from ({0}) t where {1} like '%{2}%' ", data.Query.TrimEnd(';'), input.relationField, input.keyword);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(input.propsValue) && !string.IsNullOrWhiteSpace(input.id))
|
||||
data.Query = string.Format("select * from ({0}) t where {1} = '{2}' ", data.Query.TrimEnd(';'), input.propsValue, input.id);
|
||||
if (!string.IsNullOrWhiteSpace(input.propsValue) && input.ids.Any())
|
||||
data.Query = string.Format("select * from ({0}) t where {1} in ('{2}') ", data.Query.TrimEnd(';'), input.propsValue, string.Join("','", input.ids));
|
||||
if (input.columnOptions.IsNotEmptyOrNull() && !string.IsNullOrWhiteSpace(input.keyword))
|
||||
if (type == 2 && !2.Equals(data.DataType) && (input.queryJson.IsNotEmptyOrNull() || input.sidx.IsNotEmptyOrNull()))
|
||||
{
|
||||
var whereStr = new List<string>();
|
||||
input.columnOptions.Split(",").ToList().ForEach(item => whereStr.Add(string.Format(" {0} like '%{1}%' ", item, input.keyword)));
|
||||
data.Query = string.Format("select * from ({0}) t where {1} ", data.Query.TrimEnd(';'), string.Join(" or ", whereStr));
|
||||
if (input.queryJson.IsNotEmptyOrNull())
|
||||
{
|
||||
var sqlFields = input.queryJson.ToObject<Dictionary<string, string>>();
|
||||
var whereList = new List<string>();
|
||||
foreach (var item in sqlFields)
|
||||
{
|
||||
if (item.Key.Contains("jnpf_searchType_equals_")) whereList.Add(string.Format("{0} = '{1}' ", item.Key.Replace("jnpf_searchType_equals_", string.Empty), item.Value));
|
||||
else whereList.Add(string.Format("{0} like '%{1}%' ", item.Key, item.Value));
|
||||
}
|
||||
data.Query = string.Format("select * from ({0}) t where {1} ", data.Query.TrimEnd(';'), string.Join(" and ", whereList));
|
||||
}
|
||||
if (input.sidx.IsNotEmptyOrNull()) data.Query = string.Format("{0} order by {1} {2}", data.Query.TrimEnd(';'), input.sidx, input.sort);
|
||||
}
|
||||
else
|
||||
{
|
||||
var columnList = new List<string>();
|
||||
if (input.keyword.IsNotEmptyOrNull())
|
||||
input.columnOptions.Split(",").ToList().ForEach(x => columnList.Add(string.Format("{0} like '%{1}%'", x, input.keyword)));
|
||||
|
||||
if (columnList.Any() && !string.IsNullOrWhiteSpace(input.keyword))
|
||||
data.Query = string.Format("select * from ({0}) t where {1} ", data.Query.TrimEnd(';'), string.Join(" or ", columnList));
|
||||
else if (!string.IsNullOrWhiteSpace(input.relationField) && !string.IsNullOrWhiteSpace(input.keyword))
|
||||
data.Query = string.Format("select * from ({0}) t where {1} like '%{2}%' ", data.Query.TrimEnd(';'), input.relationField, input.keyword);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(input.propsValue) && !string.IsNullOrWhiteSpace(input.id))
|
||||
data.Query = string.Format("select * from ({0}) t where {1} = '{2}' ", data.Query.TrimEnd(';'), input.propsValue, input.id);
|
||||
if (!string.IsNullOrWhiteSpace(input.propsValue) && input.ids.Any())
|
||||
data.Query = string.Format("select * from ({0}) t where {1} in ('{2}') ", data.Query.TrimEnd(';'), input.propsValue, string.Join("','", input.ids));
|
||||
if (input.columnOptions.IsNotEmptyOrNull() && !string.IsNullOrWhiteSpace(input.keyword))
|
||||
{
|
||||
var whereStr = new List<string>();
|
||||
input.columnOptions.Split(",").ToList().ForEach(item => whereStr.Add(string.Format(" {0} like '%{1}%' ", item, input.keyword)));
|
||||
data.Query = string.Format("select * from ({0}) t where {1} ", data.Query.TrimEnd(';'), string.Join(" or ", whereStr));
|
||||
}
|
||||
}
|
||||
if (input.paramList.IsNotEmptyOrNull() && input.paramList.Count > 0)
|
||||
{
|
||||
@@ -625,12 +697,11 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController
|
||||
if (1.Equals(data.DataType))
|
||||
{
|
||||
var resTable = await GetData(data);
|
||||
if (type == 0)
|
||||
if (type == 0 || type == 2)
|
||||
{
|
||||
// 分页
|
||||
var dt = GetPageToDataTable(resTable, input.currentPage, input.pageSize);
|
||||
output = new
|
||||
{
|
||||
output = new {
|
||||
pagination = new PageResult()
|
||||
{
|
||||
currentPage = input.currentPage,
|
||||
@@ -677,8 +748,7 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController
|
||||
// });
|
||||
//}
|
||||
resList = resList.FindAll(x => x.Where(xx => xx.Value != null && xx.Value.Contains(input.keyword)).Any());
|
||||
output = new
|
||||
{
|
||||
output = new {
|
||||
pagination = new PageResult()
|
||||
{
|
||||
currentPage = input.currentPage,
|
||||
@@ -699,6 +769,47 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController
|
||||
return resList.FindAll(x => x.ContainsKey(input.propsValue) && x.Any(it => input.ids.Contains(it.Value)));
|
||||
}
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
if (input.queryJson.IsNotEmptyOrNull() || input.sidx.IsNotEmptyOrNull())
|
||||
{
|
||||
if (input.queryJson.IsNotEmptyOrNull())
|
||||
{
|
||||
var querList = input.queryJson.ToObject<Dictionary<string, string>>();
|
||||
foreach (var item in querList)
|
||||
{
|
||||
if (item.Key.Contains("jnpf_searchType_equals_")) resList = resList.Where(x => x[item.Key.Replace("jnpf_searchType_equals_", "")].Equals(item.Value)).ToList();
|
||||
else resList = resList.Where(x => x[item.Key].Contains(item.Value)).ToList();
|
||||
}
|
||||
}
|
||||
if (input.sidx.IsNotEmptyOrNull())
|
||||
{
|
||||
if (input.sort.Equals("desc")) resList = resList.OrderBy(x => x[input.sidx]).ToList();
|
||||
else resList = resList.OrderByDescending(x => x[input.sidx]).ToList();
|
||||
}
|
||||
output = new {
|
||||
pagination = new PageResult()
|
||||
{
|
||||
currentPage = input.currentPage,
|
||||
pageSize = input.pageSize,
|
||||
total = resList.Count
|
||||
},
|
||||
list = resList.Skip((input.currentPage - 1) * input.pageSize).Take(input.pageSize).ToList(),
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
output = new {
|
||||
pagination = new PageResult()
|
||||
{
|
||||
currentPage = input.currentPage,
|
||||
pageSize = input.pageSize,
|
||||
total = resList.Count
|
||||
},
|
||||
list = resList.Skip((input.currentPage - 1) * input.pageSize).Take(input.pageSize).ToList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
output = result;
|
||||
@@ -800,12 +911,12 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController
|
||||
}
|
||||
else
|
||||
{
|
||||
dataProcessingResults = resList.ToJsonString();
|
||||
dataProcessingResults = resList;
|
||||
}
|
||||
break;
|
||||
// 静态数据
|
||||
case 2:
|
||||
dataProcessingResults = resList.ToJsonString();
|
||||
dataProcessingResults = resList;
|
||||
break;
|
||||
}
|
||||
if (!dataProcessingResults.IsNullOrEmpty())
|
||||
@@ -868,11 +979,11 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController
|
||||
var link = new DbLinkEntity();
|
||||
if (!_sqlSugarClient.AsTenant().IsAnyConnection(_configId))
|
||||
{
|
||||
link = await _sqlSugarClient.Queryable<DbLinkEntity>().FirstAsync(x => x.Id == dbLinkId && x.DeleteMark == null);
|
||||
link = await _sqlSugarClient.CopyNew().Queryable<DbLinkEntity>().FirstAsync(x => x.Id == dbLinkId && x.DeleteMark == null);
|
||||
}
|
||||
else
|
||||
{
|
||||
link = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(x => x.Id == dbLinkId && x.DeleteMark == null);
|
||||
link = await _repository.AsSugarClient().CopyNew().Queryable<DbLinkEntity>().FirstAsync(x => x.Id == dbLinkId && x.DeleteMark == null);
|
||||
}
|
||||
|
||||
var tenantLink = link ?? await GetTenantDbLink();
|
||||
@@ -880,7 +991,7 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController
|
||||
sql = await GetSqlParameter(sql, parameter);
|
||||
if (reqMethod.Equals("3"))
|
||||
{
|
||||
return _dataBaseManager.GetInterFaceData(tenantLink, sql, parameter.ToArray());
|
||||
return _dataBaseManager.GetInterFaceDataCopyNew(tenantLink, sql, parameter.ToArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -914,16 +1025,23 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController
|
||||
dicHerader[key.field] = key.defaultValue;
|
||||
}
|
||||
|
||||
switch (entity?.RequestMethod)
|
||||
try
|
||||
{
|
||||
case "6":
|
||||
result = (await entity.Path.SetHeaders(dicHerader).SetQueries(dic).GetAsStringAsync()).ToObject<JObject>();
|
||||
break;
|
||||
case "7":
|
||||
result = (await entity.Path.SetHeaders(dicHerader).SetBody(dic).PostAsStringAsync()).ToObject<JObject>();
|
||||
break;
|
||||
switch (entity.RequestMethod)
|
||||
{
|
||||
case "6":
|
||||
result = (await entity.Path.SetHeaders(dicHerader).SetQueries(dic).GetAsStringAsync()).ToObject<JObject>();
|
||||
break;
|
||||
case "7":
|
||||
result = (await entity.Path.SetHeaders(dicHerader).SetBody(dic).PostAsStringAsync()).ToObject<JObject>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result.ContainsKey("data") ? result["data"].ToObject<JObject>() : result;
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.COM1018);
|
||||
}
|
||||
return result.ContainsKey("data") && result["data"].IsNotEmptyOrNull() ? result["data"].ToObject<JObject>() : result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1158,7 +1276,14 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController
|
||||
});
|
||||
}
|
||||
|
||||
_sqlSugarClient.ChangeDatabase(tenantId);
|
||||
if (!"default".Equals(tenantId) && KeyVariable.MultiTenancyType.Equals("COLUMN"))
|
||||
{
|
||||
_sqlSugarClient.QueryFilter.AddTableFilter<ITenantFilter>(it => it.TenantId == tenantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sqlSugarClient.ChangeDatabase(tenantId);
|
||||
}
|
||||
_configId = tenantId;
|
||||
_dbName = result.data.dotnet;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JNPF.Systems;
|
||||
@@ -43,21 +42,17 @@ public class DbLinkService : IDbLinkService, IDynamicApiController, ITransient
|
||||
/// </summary>
|
||||
private readonly IDataBaseManager _dataBaseManager;
|
||||
|
||||
private readonly IMemoryCache _memCache;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化一个<see cref="DbLinkService"/>类型的新实例.
|
||||
/// </summary>
|
||||
public DbLinkService(
|
||||
ISqlSugarRepository<DbLinkEntity> repository,
|
||||
IDictionaryDataService dictionaryDataService,
|
||||
IDataBaseManager dataBaseManager,
|
||||
IMemoryCache memCache)
|
||||
IDataBaseManager dataBaseManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
_dataBaseManager = dataBaseManager;
|
||||
_memCache = memCache;
|
||||
}
|
||||
|
||||
#region GET
|
||||
@@ -318,7 +313,7 @@ public class DbLinkService : IDbLinkService, IDynamicApiController, ITransient
|
||||
[NonAction]
|
||||
public async Task<DbLinkEntity> GetInfo(string id)
|
||||
{
|
||||
return await _repository.AsSugarClient().CopyNew().Queryable<DbLinkEntity>().FirstAsync(m => m.Id == id && m.DeleteMark == null);
|
||||
return await _repository.GetFirstAsync(m => m.Id == id && m.DeleteMark == null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -16,220 +16,221 @@ using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JNPF.Systems.System
|
||||
namespace JNPF.Systems.System;
|
||||
|
||||
/// <summary>
|
||||
/// 接口认证
|
||||
/// 版 本:V3.2
|
||||
/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com)
|
||||
/// 日 期:2021-06-01.
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = "System", Name = "InterfaceOauth", Order = 202)]
|
||||
[Route("api/system/[controller]")]
|
||||
public class InterfaceOauthService : IDynamicApiController, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 接口认证
|
||||
/// 版 本:V3.2
|
||||
/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com)
|
||||
/// 日 期:2021-06-01.
|
||||
/// 服务基本仓储.
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = "System", Name = "InterfaceOauth", Order = 202)]
|
||||
[Route("api/system/[controller]")]
|
||||
public class InterfaceOauthService : IDynamicApiController, ITransient
|
||||
private readonly ISqlSugarRepository<InterfaceOauthEntity> _repository;
|
||||
|
||||
/// <summary>
|
||||
/// 用户管理.
|
||||
/// </summary>
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化一个<see cref="DictionaryTypeService"/>类型的新实例.
|
||||
/// </summary>
|
||||
public InterfaceOauthService(
|
||||
ISqlSugarRepository<InterfaceOauthEntity> repository,
|
||||
IUserManager userManager)
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务基本仓储.
|
||||
/// </summary>
|
||||
private readonly ISqlSugarRepository<InterfaceOauthEntity> _repository;
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户管理.
|
||||
/// </summary>
|
||||
private readonly IUserManager _userManager;
|
||||
#region Get
|
||||
|
||||
/// <summary>
|
||||
/// 初始化一个<see cref="DictionaryTypeService"/>类型的新实例.
|
||||
/// </summary>
|
||||
public InterfaceOauthService(
|
||||
ISqlSugarRepository<InterfaceOauthEntity> repository,
|
||||
IUserManager userManager)
|
||||
/// <summary>
|
||||
/// 信息.
|
||||
/// </summary>
|
||||
/// <param name="id">请求参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<dynamic> GetInfo(string id)
|
||||
{
|
||||
var info = await _repository.GetFirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
var output = info.Adapt<InterfaceOauthOutput>();
|
||||
if (info.IsNotEmptyOrNull() && info.DataInterfaceIds.IsNotEmptyOrNull())
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region Get
|
||||
|
||||
/// <summary>
|
||||
/// 信息.
|
||||
/// </summary>
|
||||
/// <param name="id">请求参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<dynamic> GetInfo(string id)
|
||||
{
|
||||
var info = await _repository.GetFirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
var output = info.Adapt<InterfaceOauthOutput>();
|
||||
if (info.IsNotEmptyOrNull() && info.DataInterfaceIds.IsNotEmptyOrNull())
|
||||
{
|
||||
var ids = info.DataInterfaceIds.Split(",");
|
||||
output.list = await _repository.AsSugarClient().Queryable<DataInterfaceEntity>()
|
||||
.Where(a => ids.Contains(a.Id))
|
||||
.Select(a => new DataInterfaceListOutput
|
||||
{
|
||||
id = a.Id,
|
||||
fullName = a.FullName,
|
||||
enCode = a.EnCode,
|
||||
path = a.Path,
|
||||
requestParameters = a.RequestParameters,
|
||||
dataType = a.DataType,
|
||||
requestMethod = SqlFunc.IF(a.RequestMethod.Equals("1")).Return("新增").ElseIF(a.RequestMethod.Equals("2")).Return("修改")
|
||||
.ElseIF(a.RequestMethod.Equals("3")).Return("查询").ElseIF(a.RequestMethod.Equals("4")).Return("删除")
|
||||
.ElseIF(a.RequestMethod.Equals("5")).Return("存储过程").ElseIF(a.RequestMethod.Equals("6")).Return("Get")
|
||||
.End("Post")
|
||||
}).ToListAsync();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表.
|
||||
/// </summary>
|
||||
[HttpGet("")]
|
||||
public async Task<dynamic> GetList([FromQuery] PageInputBase input)
|
||||
{
|
||||
var list = await _repository.AsSugarClient().Queryable<InterfaceOauthEntity, UserEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == a.CreatorUserId))
|
||||
.Where(a => a.DeleteMark == null)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.keyword), a => a.AppId.Contains(input.keyword) || a.AppName.Contains(input.keyword))
|
||||
.OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc)
|
||||
.Select((a, b) => new InterfaceOauthListOutput
|
||||
{
|
||||
id = a.Id,
|
||||
lastModifyTime = a.LastModifyTime,
|
||||
enabledMark = a.EnabledMark,
|
||||
creatorUser = SqlFunc.MergeString(b.RealName, "/", b.Account),
|
||||
appId = a.AppId,
|
||||
appName = a.AppName,
|
||||
usefulLife = a.UsefulLife,
|
||||
sortCode = a.SortCode,
|
||||
creatorTime = a.CreatorTime
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return PageResult<InterfaceOauthListOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取秘钥.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getAppSecret")]
|
||||
public async Task<dynamic> GetAppSecret()
|
||||
{
|
||||
return Guid.NewGuid().ToString().Replace("-", string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日志.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("dataInterfaceLog/{id}")]
|
||||
public async Task<dynamic> GetList(string id, [FromQuery] DataInterfaceLogListQuery input)
|
||||
{
|
||||
var entity = await _repository.GetFirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
var whereLambda = LinqExpression.And<DataInterfaceLogListOutput>();
|
||||
if (!input.startTime.IsNullOrEmpty() && !input.endTime.IsNullOrEmpty())
|
||||
{
|
||||
var startTime = Convert.ToDateTime(string.Format("{0:yyyy-MM-dd 00:00:00}", input.startTime?.TimeStampToDateTime()));
|
||||
var endTime = Convert.ToDateTime(string.Format("{0:yyyy-MM-dd 23:59:59}", input.endTime?.TimeStampToDateTime()));
|
||||
whereLambda = whereLambda.And(a => SqlFunc.Between(a.invokTime, startTime, endTime));
|
||||
}
|
||||
var list = await _repository.AsSugarClient().Queryable<DataInterfaceLogEntity, UserEntity, DataInterfaceEntity>((a, b, c) =>
|
||||
new JoinQueryInfos(JoinType.Left, b.Id == a.UserId, JoinType.Left, a.InvokId == c.Id))
|
||||
.Where(a => a.OauthAppId == entity.AppId)
|
||||
.WhereIF(input.keyword.IsNotEmptyOrNull(), a => a.UserId.Contains(input.keyword) || a.InvokIp.Contains(input.keyword))
|
||||
.Select((a, b, c) => new DataInterfaceLogListOutput
|
||||
var ids = info.DataInterfaceIds.Split(",");
|
||||
output.list = await _repository.AsSugarClient().Queryable<DataInterfaceEntity>()
|
||||
.Where(a => ids.Contains(a.Id))
|
||||
.Select(a => new DataInterfaceListOutput
|
||||
{
|
||||
id = a.Id,
|
||||
fullName = c.FullName,
|
||||
enCode = c.EnCode,
|
||||
invokDevice = a.InvokDevice,
|
||||
invokIp = a.InvokIp,
|
||||
userId = SqlFunc.MergeString(b.RealName, "/", b.Account),
|
||||
invokTime = a.InvokTime,
|
||||
invokType = a.InvokType,
|
||||
invokWasteTime = a.InvokWasteTime
|
||||
}).MergeTable().Where(whereLambda).OrderBy(a => a.invokTime).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return PageResult<DataInterfaceLogListOutput>.SqlSugarPageResult(list);
|
||||
fullName = a.FullName,
|
||||
enCode = a.EnCode,
|
||||
path = a.Path,
|
||||
requestParameters = a.RequestParameters,
|
||||
dataType = a.DataType,
|
||||
requestMethod = SqlFunc.IF(a.RequestMethod.Equals("1")).Return("新增").ElseIF(a.RequestMethod.Equals("2")).Return("修改")
|
||||
.ElseIF(a.RequestMethod.Equals("3")).Return("查询").ElseIF(a.RequestMethod.Equals("4")).Return("删除")
|
||||
.ElseIF(a.RequestMethod.Equals("5")).Return("存储过程").ElseIF(a.RequestMethod.Equals("6")).Return("Get")
|
||||
.End("Post")
|
||||
}).ToListAsync();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Post
|
||||
|
||||
/// <summary>
|
||||
/// 新增.
|
||||
/// </summary>
|
||||
/// <param name="input">请求参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("")]
|
||||
public async Task Create_Api([FromBody] InterfaceOauthInput input)
|
||||
{
|
||||
if (await _repository.IsAnyAsync(x => (x.AppId == input.appId || x.AppName == input.appName) && x.DeleteMark == null))
|
||||
throw Oops.Oh(ErrorCode.D3001);
|
||||
var entity = input.Adapt<InterfaceOauthEntity>();
|
||||
if (input.usefulLife.IsNullOrEmpty() || input.usefulLife == "0")
|
||||
{
|
||||
entity.UsefulLife = null;
|
||||
}
|
||||
var 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="id">请求参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task Delete(string id)
|
||||
{
|
||||
var entity = await _repository.GetFirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
if (entity == null)
|
||||
throw Oops.Oh(ErrorCode.COM1005);
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改.
|
||||
/// </summary>
|
||||
/// <param name="id">id.</param>
|
||||
/// <param name="input">请求参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
public async Task Update(string id, [FromBody] InterfaceOauthInput input)
|
||||
{
|
||||
if (await _repository.IsAnyAsync(x => x.Id != id && (x.AppId == input.appId || x.AppName == input.appName) && x.DeleteMark == null))
|
||||
throw Oops.Oh(ErrorCode.COM1004);
|
||||
var entity = input.Adapt<InterfaceOauthEntity>();
|
||||
var isOk = await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandHasChangeAsync();
|
||||
if (input.usefulLife.IsNullOrEmpty() || input.usefulLife == "0")
|
||||
{
|
||||
await _repository.AsUpdateable().SetColumns(it => new InterfaceOauthEntity()
|
||||
{
|
||||
UsefulLife = null
|
||||
}).Where(it => it.Id.Equals(id)).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
if (!isOk)
|
||||
throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 授权接口.
|
||||
/// </summary>
|
||||
/// <param name="input">请求参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("saveInterfaceList")]
|
||||
public async Task SaveInterFaceList([FromBody] InterfaceOauthSaveInput input)
|
||||
{
|
||||
var isOk = await _repository.AsSugarClient().Updateable<InterfaceOauthEntity>()
|
||||
.SetColumns(it => it.DataInterfaceIds == input.dataInterfaceIds).Where(x => x.Id == input.interfaceIdentId).ExecuteCommandHasChangeAsync();
|
||||
if (!isOk)
|
||||
throw Oops.Oh(ErrorCode.COM1002);
|
||||
}
|
||||
#endregion
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表.
|
||||
/// </summary>
|
||||
[HttpGet("")]
|
||||
public async Task<dynamic> GetList([FromQuery] PageInputBase input)
|
||||
{
|
||||
var list = await _repository.AsSugarClient().Queryable<InterfaceOauthEntity, UserEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == a.CreatorUserId))
|
||||
.Where(a => a.DeleteMark == null)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.keyword), a => a.AppId.Contains(input.keyword) || a.AppName.Contains(input.keyword))
|
||||
.OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc)
|
||||
.Select((a, b) => new InterfaceOauthListOutput
|
||||
{
|
||||
id = a.Id,
|
||||
lastModifyTime = a.LastModifyTime,
|
||||
enabledMark = a.EnabledMark,
|
||||
creatorUser = SqlFunc.MergeString(b.RealName, "/", b.Account),
|
||||
appId = a.AppId,
|
||||
appName = a.AppName,
|
||||
usefulLife = a.UsefulLife,
|
||||
sortCode = a.SortCode,
|
||||
creatorTime = a.CreatorTime
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return PageResult<InterfaceOauthListOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取秘钥.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getAppSecret")]
|
||||
public async Task<dynamic> GetAppSecret()
|
||||
{
|
||||
return Guid.NewGuid().ToString().Replace("-", string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日志.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("dataInterfaceLog/{id}")]
|
||||
public async Task<dynamic> GetList(string id, [FromQuery] DataInterfaceLogListQuery input)
|
||||
{
|
||||
var entity = await _repository.GetFirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
var whereLambda = LinqExpression.And<DataInterfaceLogListOutput>();
|
||||
if (!input.startTime.IsNullOrEmpty() && !input.endTime.IsNullOrEmpty())
|
||||
{
|
||||
var startTime = Convert.ToDateTime(string.Format("{0:yyyy-MM-dd 00:00:00}", input.startTime?.TimeStampToDateTime()));
|
||||
var endTime = Convert.ToDateTime(string.Format("{0:yyyy-MM-dd 23:59:59}", input.endTime?.TimeStampToDateTime()));
|
||||
whereLambda = whereLambda.And(a => SqlFunc.Between(a.invokTime, startTime, endTime));
|
||||
}
|
||||
var list = await _repository.AsSugarClient().Queryable<DataInterfaceLogEntity, UserEntity, DataInterfaceEntity>((a, b, c) =>
|
||||
new JoinQueryInfos(JoinType.Left, b.Id == a.UserId, JoinType.Left, a.InvokId == c.Id))
|
||||
.Where(a => a.OauthAppId == entity.AppId)
|
||||
.WhereIF(input.keyword.IsNotEmptyOrNull(), a => a.UserId.Contains(input.keyword) || a.InvokIp.Contains(input.keyword))
|
||||
.Select((a, b, c) => new DataInterfaceLogListOutput
|
||||
{
|
||||
id = a.Id,
|
||||
fullName = c.FullName,
|
||||
enCode = c.EnCode,
|
||||
invokDevice = a.InvokDevice,
|
||||
invokIp = a.InvokIp,
|
||||
userId = SqlFunc.MergeString(b.RealName, "/", b.Account),
|
||||
invokTime = a.InvokTime,
|
||||
invokType = a.InvokType,
|
||||
invokWasteTime = a.InvokWasteTime
|
||||
}).MergeTable().Where(whereLambda).OrderBy(a => a.invokTime).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return PageResult<DataInterfaceLogListOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Post
|
||||
|
||||
/// <summary>
|
||||
/// 新增.
|
||||
/// </summary>
|
||||
/// <param name="input">请求参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("")]
|
||||
public async Task Create_Api([FromBody] InterfaceOauthInput input)
|
||||
{
|
||||
if (await _repository.IsAnyAsync(x => (x.AppId == input.appId || x.AppName == input.appName) && x.DeleteMark == null))
|
||||
throw Oops.Oh(ErrorCode.D3001);
|
||||
var entity = input.Adapt<InterfaceOauthEntity>();
|
||||
if (input.usefulLife.IsNullOrEmpty() || input.usefulLife == "0")
|
||||
{
|
||||
entity.UsefulLife = null;
|
||||
}
|
||||
var 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="id">请求参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task Delete(string id)
|
||||
{
|
||||
var entity = await _repository.GetFirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
if (entity == null)
|
||||
throw Oops.Oh(ErrorCode.COM1005);
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改.
|
||||
/// </summary>
|
||||
/// <param name="id">id.</param>
|
||||
/// <param name="input">请求参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
public async Task Update(string id, [FromBody] InterfaceOauthInput input)
|
||||
{
|
||||
if (await _repository.IsAnyAsync(x => x.Id != id && (x.AppId == input.appId || x.AppName == input.appName) && x.DeleteMark == null))
|
||||
throw Oops.Oh(ErrorCode.COM1004);
|
||||
var entity = input.Adapt<InterfaceOauthEntity>();
|
||||
var isOk = await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandHasChangeAsync();
|
||||
if (input.usefulLife.IsNullOrEmpty() || input.usefulLife == "0")
|
||||
{
|
||||
await _repository.AsUpdateable().SetColumns(it => new InterfaceOauthEntity()
|
||||
{
|
||||
UsefulLife = null
|
||||
}).Where(it => it.Id.Equals(id)).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
if (!isOk)
|
||||
throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 授权接口.
|
||||
/// </summary>
|
||||
/// <param name="input">请求参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("saveInterfaceList")]
|
||||
public async Task SaveInterFaceList([FromBody] InterfaceOauthSaveInput input)
|
||||
{
|
||||
var isOk = await _repository.AsSugarClient().Updateable<InterfaceOauthEntity>()
|
||||
.SetColumns(it => it.DataInterfaceIds == input.dataInterfaceIds).Where(x => x.Id == input.interfaceIdentId).ExecuteCommandHasChangeAsync();
|
||||
if (!isOk)
|
||||
throw Oops.Oh(ErrorCode.COM1002);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -375,7 +375,8 @@ public class MessageTemplateService : IMessageTemplateService, IDynamicApiContro
|
||||
Account = sysconfig.emailAccount,
|
||||
Password = sysconfig.emailPassword,
|
||||
SMTPHost = sysconfig.emailSmtpHost,
|
||||
SMTPPort = sysconfig.emailSmtpPort.ParseToInt()
|
||||
SMTPPort = sysconfig.emailSmtpPort.ParseToInt(),
|
||||
Ssl = sysconfig.emailSsl,
|
||||
}, mailModel);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Const;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
@@ -120,7 +121,7 @@ public class ModuleColumnService : IModuleColumnService, IDynamicApiController,
|
||||
var visualDevId = moduleEntity.PropertyJson.ToObject<JObject>()["moduleId"].ToString();
|
||||
var visualDevEntity = await _repository.AsSugarClient().Queryable<VisualDevEntity>().FirstAsync(x => x.Id == visualDevId && x.DeleteMark == null);
|
||||
var defaultColumnList = visualDevEntity.ColumnData.ToObject<ColumnDesignModel>().defaultColumnList;
|
||||
var uelessList = new List<string>() { "PsdInput", "colorPicker", "rate", "slider", "divider", "uploadImg", "uploadFz", "editor", "JNPFText", "relationFormAttr", "popupAttr", "groupTitle" };
|
||||
var uelessList = new List<string>() { "PsdInput", JnpfKeyConst.COLORPICKER, JnpfKeyConst.RATE, JnpfKeyConst.SLIDER, JnpfKeyConst.DIVIDER, JnpfKeyConst.UPLOADIMG, JnpfKeyConst.UPLOADFZ, JnpfKeyConst.EDITOR, JnpfKeyConst.JNPFTEXT, JnpfKeyConst.RELATIONFORMATTR, JnpfKeyConst.POPUPATTR, JnpfKeyConst.GROUPTITLE };
|
||||
return defaultColumnList?.Where(x => !uelessList.Contains(x.jnpfKey)).Select(x => new { field = x.prop, fieldName = x.label }).ToList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -73,7 +73,7 @@ public class ModuleDataAuthorizeService : IModuleDataAuthorizeService, IDynamicA
|
||||
type = a.Type,
|
||||
conditionSymbol = a.ConditionSymbol,
|
||||
conditionText = a.ConditionText,
|
||||
conditionSymbolName = a.ConditionSymbol.Replace("Equal", "等于").Replace("Included", "包含").Replace("GreaterThan", "大于").Replace("LessThan", "小于").Replace("Not", "不").Replace("Or", ""),
|
||||
conditionSymbolName = SqlFunc.ToString(a.ConditionSymbol).Replace("Equal", "等于").Replace("Included", "包含").Replace("GreaterThan", "大于").Replace("LessThan", "小于").Replace("Not", "不").Replace("Or", ""),
|
||||
bindTable = a.BindTable,
|
||||
fieldRule = a.FieldRule,
|
||||
enCode = SqlFunc.IF(b.Type == 2 && a.FieldRule == 1 && !SqlFunc.IsNullOrEmpty(a.BindTable)).Return(a.EnCode.Replace("jnpf_" + a.BindTable + "_jnpf_", ""))
|
||||
|
||||
@@ -142,7 +142,7 @@ public class OnlineUserService : IDynamicApiController, ITransient
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DelUserInfo(string tenantId, string userId)
|
||||
{
|
||||
var cacheKey = string.Format("{0}{1}_{2}", CommonConst.CACHEKEYUSER, tenantId, userId);
|
||||
var cacheKey = string.Format("{0}:{1}:{2}", tenantId, CommonConst.CACHEKEYUSER, userId);
|
||||
return await _cacheManager.DelAsync(cacheKey);
|
||||
}
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public class PrintDevService : IDynamicApiController, ITransient
|
||||
|
||||
var fieldModel = new PrintDevFieldModel()
|
||||
{
|
||||
id = index == 0 ? "headTable" : "childrenDataTable" + (index-1),
|
||||
id = index == 0 ? "headTable" : "childrenDataTable" + (index - 1),
|
||||
parentId = "struct",
|
||||
fullName = index == 0 ? "主表" : "子表" + (index - 1),
|
||||
};
|
||||
@@ -228,51 +228,37 @@ public class PrintDevService : IDynamicApiController, ITransient
|
||||
[HttpGet("Data")]
|
||||
public async Task<dynamic> GetData([FromQuery] PrintDevSqlDataQuery input)
|
||||
{
|
||||
var output = new PrintDevDataOutput();
|
||||
var entity = await GetInfo(input.id);
|
||||
if (entity == null)
|
||||
throw Oops.Oh(ErrorCode.COM1005);
|
||||
var link = await _dbLinkService.GetInfo(entity.DbLinkId);
|
||||
var tenantLink = link ?? _dataBaseManager.GetTenantDbLink(_userManager.TenantId, _userManager.TenantDbName);
|
||||
var parameter = new List<SugarParameter>()
|
||||
{
|
||||
new SugarParameter("@formId", input.formId)
|
||||
};
|
||||
var sqlList = entity.SqlTemplate.ToList<PrintDevSqlModel>();
|
||||
var dataTable = _dataBaseManager.GetInterFaceData(tenantLink, sqlList.FirstOrDefault().sql, parameter.ToArray());
|
||||
var dic = DateConver(DataTableToDicList(dataTable)).FirstOrDefault();
|
||||
for (int i = 1; i < sqlList.Count; i++)
|
||||
{
|
||||
if (sqlList[i].sql.IsNullOrEmpty())
|
||||
throw Oops.Oh(ErrorCode.COM1005);
|
||||
var childDataTable = _dataBaseManager.GetInterFaceData(tenantLink, sqlList[i].sql, parameter.ToArray());
|
||||
if (childDataTable.Rows.Count > 0)
|
||||
dic.Add("childrenDataTable" + (i - 1), DateConver(DataTableToDicList(childDataTable)));
|
||||
}
|
||||
|
||||
output.printData = dic;
|
||||
output.printTemplate = entity.PrintTemplate;
|
||||
output.operatorRecordList = await _repository.AsSugarClient().Queryable<FlowTaskOperatorRecordEntity>()
|
||||
.Where(a => a.TaskId == input.formId)
|
||||
.Select(a => new PrintDevDataModel()
|
||||
{
|
||||
id = a.Id,
|
||||
handleId = a.HandleId,
|
||||
handleOpinion = a.HandleOpinion,
|
||||
handleStatus = a.HandleStatus,
|
||||
nodeCode = a.NodeCode,
|
||||
handleTime = a.HandleTime,
|
||||
nodeName = a.NodeName,
|
||||
signImg = a.SignImg,
|
||||
taskId = a.TaskId,
|
||||
operatorId = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id == a.OperatorId).Select(u => SqlFunc.MergeString(u.RealName, "/", u.Account)),
|
||||
userName = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id == a.HandleId).Select(u => SqlFunc.MergeString(u.RealName, "/", u.Account)),
|
||||
status = a.Status,
|
||||
taskNodeId = a.TaskNodeId,
|
||||
taskOperatorId = a.TaskOperatorId,
|
||||
}).ToListAsync();
|
||||
var output = await GetPrintDevDataOutput(input.id, input.formId);
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 模板数据.
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("BatchData")]
|
||||
public async Task<dynamic> GetBatchData([FromQuery] PrintDevSqlDataQuery input)
|
||||
{
|
||||
var output = new List<PrintDevDataOutput>();
|
||||
foreach (var formId in input.formId.Split(','))
|
||||
{
|
||||
var data = await GetPrintDevDataOutput(input.id, formId);
|
||||
output.Add(data);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 模板列表.
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("getListOptions")]
|
||||
public async Task<dynamic> GetListOptions([FromBody] PrintDevSqlDataQuery input)
|
||||
{
|
||||
return _repository.GetList(x => input.ids.Contains(x.Id)).Select(x => new { id = x.Id, fullName = x.FullName }).ToList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Post
|
||||
@@ -362,6 +348,8 @@ public class PrintDevService : IDynamicApiController, ITransient
|
||||
entity.FullName = entity.FullName + "副本" + random;
|
||||
entity.EnabledMark = 0;
|
||||
entity.EnCode += random;
|
||||
entity.LastModifyTime = null;
|
||||
entity.LastModifyUserId = null;
|
||||
if (entity.FullName.Length >= 50 || entity.EnCode.Length >= 50)
|
||||
throw Oops.Oh(ErrorCode.COM1009);
|
||||
var isOk = await _repository.AsInsertable(entity).IgnoreColumns(ignoreNullColumn: true).CallEntityMethod(m => m.Creator()).ExecuteCommandAsync();
|
||||
@@ -407,6 +395,60 @@ public class PrintDevService : IDynamicApiController, ITransient
|
||||
|
||||
#region PrivateMethod
|
||||
|
||||
/// <summary>
|
||||
/// 模板数据.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="formId"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<PrintDevDataOutput> GetPrintDevDataOutput(string id, string formId)
|
||||
{
|
||||
var output = new PrintDevDataOutput();
|
||||
var entity = await GetInfo(id);
|
||||
if (entity == null)
|
||||
throw Oops.Oh(ErrorCode.D9010);
|
||||
var link = await _dbLinkService.GetInfo(entity.DbLinkId);
|
||||
var tenantLink = link ?? _dataBaseManager.GetTenantDbLink(_userManager.TenantId, _userManager.TenantDbName);
|
||||
var parameter = new List<SugarParameter>()
|
||||
{
|
||||
new SugarParameter("@formId", formId)
|
||||
};
|
||||
var sqlList = entity.SqlTemplate.ToList<PrintDevSqlModel>();
|
||||
var dataTable = _dataBaseManager.GetInterFaceData(tenantLink, sqlList.FirstOrDefault().sql, parameter.ToArray());
|
||||
var dic = DateConver(DataTableToDicList(dataTable)).FirstOrDefault();
|
||||
for (int i = 1; i < sqlList.Count; i++)
|
||||
{
|
||||
if (sqlList[i].sql.IsNullOrEmpty())
|
||||
throw Oops.Oh(ErrorCode.COM1005);
|
||||
var childDataTable = _dataBaseManager.GetInterFaceData(tenantLink, sqlList[i].sql, parameter.ToArray());
|
||||
if (childDataTable.Rows.Count > 0)
|
||||
dic.Add("childrenDataTable" + (i - 1), DateConver(DataTableToDicList(childDataTable)));
|
||||
}
|
||||
|
||||
output.printData = dic;
|
||||
output.printTemplate = entity.PrintTemplate;
|
||||
output.operatorRecordList = await _repository.AsSugarClient().Queryable<FlowTaskOperatorRecordEntity>()
|
||||
.Where(a => a.TaskId == formId)
|
||||
.Select(a => new PrintDevDataModel()
|
||||
{
|
||||
id = a.Id,
|
||||
handleId = a.HandleId,
|
||||
handleOpinion = a.HandleOpinion,
|
||||
handleStatus = a.HandleStatus,
|
||||
nodeCode = a.NodeCode,
|
||||
handleTime = a.HandleTime,
|
||||
nodeName = a.NodeName,
|
||||
signImg = a.SignImg,
|
||||
taskId = a.TaskId,
|
||||
operatorId = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id == a.OperatorId).Select(u => SqlFunc.MergeString(u.RealName, "/", u.Account)),
|
||||
userName = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id == a.HandleId).Select(u => SqlFunc.MergeString(u.RealName, "/", u.Account)),
|
||||
status = a.Status,
|
||||
taskNodeId = a.TaskNodeId,
|
||||
taskOperatorId = a.TaskOperatorId,
|
||||
}).ToListAsync();
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取字段模型.
|
||||
/// </summary>
|
||||
|
||||
105
system/Tnb.Systems/System/PrintLogService.cs
Normal file
105
system/Tnb.Systems/System/PrintLogService.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.LinqBuilder;
|
||||
using JNPF.Systems.Entitys.Dto.System.PrintLog;
|
||||
using JNPF.Systems.Entitys.Entity.System;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using JNPF.Common.Extension;
|
||||
|
||||
namespace JNPF.Systems.System;
|
||||
|
||||
/// <summary>
|
||||
/// 打印模板日志
|
||||
/// 版 本:V3.2
|
||||
/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com)
|
||||
/// 作 者:JNPF开发平台组
|
||||
/// 日 期:2021-06-01.
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = "System", Name = "PrintLog", Order = 200)]
|
||||
[Route("api/system/[controller]")]
|
||||
public class PrintLogService : IDynamicApiController, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务基础仓储.
|
||||
/// </summary>
|
||||
private readonly ISqlSugarRepository<PrintLogEntity> _repository;
|
||||
|
||||
/// <summary>
|
||||
/// 用户管理.
|
||||
/// </summary>
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化一个<see cref="PrintDevService"/>类型的新实例.
|
||||
/// </summary>
|
||||
public PrintLogService(
|
||||
ISqlSugarRepository<PrintLogEntity> repository,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region Get
|
||||
/// <summary>
|
||||
/// 列表(分页).
|
||||
/// </summary>
|
||||
/// <param name="input">请求参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<dynamic> GetList(string id, [FromQuery] PrintLogQuery input)
|
||||
{
|
||||
var whereLambda = LinqExpression.And<PrintLogEntity>();
|
||||
whereLambda = whereLambda.And(x => x.PrintId == id);
|
||||
var start = new DateTime();
|
||||
var end = new DateTime();
|
||||
if (input.endTime != null && input.startTime != null)
|
||||
{
|
||||
start = Convert.ToDateTime(string.Format("{0:yyyy-MM-dd 00:00:00}", input.startTime?.TimeStampToDateTime()));
|
||||
end = Convert.ToDateTime(string.Format("{0:yyyy-MM-dd 23:59:59}", input.endTime?.TimeStampToDateTime()));
|
||||
whereLambda = whereLambda.And(x => SqlFunc.Between(x.PrintTime, start, end));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(input.keyword))
|
||||
whereLambda = whereLambda.And(m => m.PrintTitle.Contains(input.keyword));
|
||||
var list = await _repository.AsQueryable().Where(whereLambda).OrderBy(x => x.PrintTime, OrderByType.Desc)
|
||||
.Select(a => new PrintLogOutuut
|
||||
{
|
||||
id = a.Id,
|
||||
printId = a.PrintId,
|
||||
printMan = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id == a.PrintMan).Select(u => SqlFunc.MergeString(u.RealName, "/", u.Account)),
|
||||
printNum = a.PrintNum,
|
||||
printTime = a.PrintTime,
|
||||
printTitle = a.PrintTitle
|
||||
})
|
||||
.ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return PageResult<PrintLogOutuut>.SqlSugarPageResult(list);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Post
|
||||
/// <summary>
|
||||
/// 新增.
|
||||
/// </summary>
|
||||
/// <param name="input">请求参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("save")]
|
||||
public async Task Delete([FromBody] PrintLogOutuut input)
|
||||
{
|
||||
var entity = input.Adapt<PrintLogEntity>();
|
||||
entity.Id= SnowflakeIdHelper.NextId();
|
||||
entity.PrintMan = _userManager.UserId;
|
||||
entity.PrintTime = DateTime.Now;
|
||||
var isOk = await _repository.AsInsertable(entity).ExecuteCommandAsync();
|
||||
if (isOk < 1)
|
||||
throw Oops.Oh(ErrorCode.COM1000);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -178,7 +178,7 @@ public class SysCacheService : IDynamicApiController, ITransient
|
||||
/// <returns></returns>
|
||||
private async Task<bool> DelUserInfo(string tenantId, string userId)
|
||||
{
|
||||
var cacheKey = string.Format("{0}{1}_{2}", CommonConst.CACHEKEYUSER, tenantId, userId);
|
||||
var cacheKey = string.Format("{0}:{1}:{2}", tenantId, CommonConst.CACHEKEYUSER, userId);
|
||||
return await _cacheManager.DelAsync(cacheKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public class SysConfigService : ISysConfigService, IDynamicApiController, ITrans
|
||||
[UnitOfWork]
|
||||
public async Task SetAdminList([FromBody] SetAdminInput input)
|
||||
{
|
||||
await _repository.AsSugarClient().Updateable<UserEntity>().SetColumns(x => x.IsAdministrator == 0).Where(x => x.IsAdministrator == 1 && !x.Id.Equals("admin")).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Updateable<UserEntity>().SetColumns(x => x.IsAdministrator == 0).Where(x => x.IsAdministrator == 1 && !x.Account.Equals("admin")).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Updateable<UserEntity>().SetColumns(x => x.IsAdministrator == 1).Where(x => input.adminIds.Contains(x.Id)).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using JNPF.Common.Const;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Const;
|
||||
using JNPF.Common.Core.Handlers;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
@@ -70,7 +71,7 @@ public class SystemService : IDynamicApiController, ITransient
|
||||
/// <param name="input">参数.</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("")]
|
||||
public async Task<dynamic> GetList([FromQuery] KeywordInput input)
|
||||
public async Task<dynamic> GetList([FromQuery] SystemQuery input)
|
||||
{
|
||||
var authorIds = await _repository.AsSugarClient().Queryable<AuthorizeEntity>()
|
||||
.Where(x => x.ItemType.Equals("system") && x.ObjectType.Equals("Role") && _userManager.Roles.Contains(x.ObjectId)).Select(x => x.ItemId).ToListAsync();
|
||||
@@ -81,6 +82,8 @@ public class SystemService : IDynamicApiController, ITransient
|
||||
whereLambda = whereLambda.And(x => authorIds.Contains(x.Id));
|
||||
if (input.keyword.IsNotEmptyOrNull())
|
||||
whereLambda = whereLambda.And(x => x.FullName.Contains(input.keyword) || x.EnCode.Contains(input.keyword));
|
||||
if (input.enableMark.IsNotEmptyOrNull())
|
||||
whereLambda = whereLambda.And(x => x.EnabledMark == SqlFunc.ToInt32(input.enableMark));
|
||||
var output = (await _repository.AsQueryable().Where(whereLambda).OrderBy(a => a.SortCode).OrderByDescending(a => a.CreatorTime).ToListAsync()).Adapt<List<SystemListOutput>>();
|
||||
return new { list = output };
|
||||
}
|
||||
@@ -215,7 +218,7 @@ public class SystemService : IDynamicApiController, ITransient
|
||||
allUserOnlineList.RemoveAll((x) => x.connectionId == item.connectionId);
|
||||
|
||||
// 删除用户登录信息缓存.
|
||||
var mCacheKey = string.Format("{0}{1}_{2}", CommonConst.CACHEKEYUSER, tenantId, item.userId);
|
||||
var mCacheKey = string.Format("{0}:{1}:{2}", tenantId, CommonConst.CACHEKEYUSER, item.userId);
|
||||
await _cacheManager.DelAsync(mCacheKey);
|
||||
});
|
||||
await _cacheManager.SetAsync(cacheKey, allUserOnlineList);
|
||||
|
||||
Reference in New Issue
Block a user