You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
258 lines
9.9 KiB
258 lines
9.9 KiB
using AutoMapper.Internal.Mappers;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.Application.Services;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.Identity;
|
|
using Volo.Abp;
|
|
using Shentun.Peis.Models;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using NPOI.SS.UserModel;
|
|
using System.Reflection;
|
|
using NUglify.JavaScript.Syntax;
|
|
using System.Collections;
|
|
using System.Linq.Dynamic.Core;
|
|
using SqlSugar;
|
|
using Volo.Abp.Application.Dtos;
|
|
using Volo.Abp.Users;
|
|
using Volo.Abp.ObjectMapping;
|
|
using Microsoft.Extensions.Configuration;
|
|
using System.IO;
|
|
using Shentun.Peis.HelperDto;
|
|
|
|
namespace Shentun.Peis.ColumnReferences
|
|
{
|
|
/// <summary>
|
|
/// 字段对照主表
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = "Work")]
|
|
[Authorize]
|
|
public class ColumnReferenceAppService : ApplicationService
|
|
{
|
|
private readonly IRepository<ColumnReference, Guid> _repository;
|
|
private readonly ColumnReferenceManager _manager;
|
|
private readonly CacheService _cacheService;
|
|
private readonly IRepository<IdentityUser, Guid> _userRepository;
|
|
|
|
public ColumnReferenceAppService(
|
|
IRepository<ColumnReference, Guid> repository,
|
|
ColumnReferenceManager manager,
|
|
CacheService cacheService,
|
|
IRepository<IdentityUser, Guid> userRepository
|
|
)
|
|
{
|
|
_repository = repository;
|
|
_manager = manager;
|
|
_cacheService = cacheService;
|
|
_userRepository = userRepository;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据ID查实体内容
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/ColumnReference/Get")]
|
|
public async Task<ColumnReferenceDto> GetAsync(Guid id)
|
|
{
|
|
var entity = await _repository.GetAsync(id);
|
|
var entityDto = ObjectMapper.Map<ColumnReference, ColumnReferenceDto>(entity);
|
|
entityDto.CreatorName = _cacheService.GetUserNameAsync(entityDto.CreatorId).Result;
|
|
entityDto.LastModifierName = _cacheService.GetUserNameAsync(entityDto.LastModifierId).Result;
|
|
|
|
return entityDto;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 查询列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/ColumnReference/GetList")]
|
|
public async Task<List<ColumnReferenceDto>> GetListAsync()
|
|
{
|
|
var userQueryable = await _userRepository.GetQueryableAsync();
|
|
|
|
var entlist = (from a in await _repository.GetQueryableAsync()
|
|
join b in userQueryable on a.CreatorId equals b.Id into bb
|
|
from ab in bb.DefaultIfEmpty()
|
|
join c in userQueryable on a.LastModifierId equals c.Id into cc
|
|
from ac in cc.DefaultIfEmpty()
|
|
select new
|
|
{
|
|
a,
|
|
CreatorName = ab != null ? ab.UserName : "",
|
|
LastModifierName = ac != null ? ac.UserName : ""
|
|
|
|
})
|
|
.Select(s => new ColumnReferenceDto
|
|
{
|
|
CreationTime = s.a.CreationTime,
|
|
CreatorId = s.a.CreatorId,
|
|
LastModifierId = s.a.LastModifierId,
|
|
Id = s.a.Id,
|
|
DisplayOrder = s.a.DisplayOrder,
|
|
DisplayName = s.a.DisplayName,
|
|
ParmValue = s.a.ParmValue,
|
|
LastModificationTime = s.a.LastModificationTime,
|
|
CreatorName = s.CreatorName,
|
|
LastModifierName = s.LastModifierName
|
|
}).OrderBy(o => o.DisplayOrder).ToList();
|
|
|
|
return entlist;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/ColumnReference/Create")]
|
|
public async Task<ColumnReferenceDto> CreateAsync(CreateColumnReferenceDto input)
|
|
{
|
|
var createEntity = ObjectMapper.Map<CreateColumnReferenceDto, ColumnReference>(input);
|
|
var entity = await _manager.CreateAsync(createEntity);
|
|
entity = await _repository.InsertAsync(entity);
|
|
var dto = ObjectMapper.Map<ColumnReference, ColumnReferenceDto>(entity);
|
|
return dto;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/ColumnReference/Update")]
|
|
public async Task<ColumnReferenceDto> UpdateAsync(UpdateColumnReferenceDto input)
|
|
{
|
|
var entity = await _repository.GetAsync(input.Id);
|
|
var sourceEntity = ObjectMapper.Map<UpdateColumnReferenceDto, ColumnReference>(input);
|
|
await _manager.UpdateAsync(sourceEntity, entity);
|
|
entity = await _repository.UpdateAsync(entity);
|
|
return ObjectMapper.Map<ColumnReference, ColumnReferenceDto>(entity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/ColumnReference/Delete")]
|
|
public async Task DeleteAsync(Guid id)
|
|
{
|
|
var entity = await _repository.GetAsync(id);
|
|
await _manager.CheckAndDeleteAsync(entity);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 修改排序 置顶,置底
|
|
/// </summary>
|
|
/// <param name="id">需要修改的ID</param>
|
|
/// <param name="SortType">修改方式:1 置顶 2 置底</param>
|
|
/// <returns></returns>
|
|
[HttpPut("api/app/ColumnReference/UpdateManySort")]
|
|
public async Task UpdateManySortAsync(Guid id, int SortType)
|
|
{
|
|
await _manager.UpdateManySortAsync(id, SortType);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改排序 拖拽
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPut("api/app/ColumnReference/UpdateSortMany")]
|
|
public async Task UpdateSortManyAsync(UpdateSortManyDto input)
|
|
{
|
|
await _manager.UpdateSortManyAsync(input);
|
|
}
|
|
|
|
|
|
//public async Task<List<string>> GetColumns(ColumnReferenceIdInputDto input)
|
|
//{
|
|
// var entity = await _repository.GetAsync(input.Id);
|
|
// var parmValue = entity.ParmValue;
|
|
// var configurationBuilder = new ConfigurationBuilder()
|
|
// .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue)));
|
|
// var config = configurationBuilder.Build();
|
|
// var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
|
|
// var className = config.GetSection("Interface").GetSection("ClassName").Value;
|
|
// object objectValue = Invoke(assemblyName, className, "GetColumns");
|
|
// List<string> list = new List<string>();
|
|
|
|
// if (objectValue is IEnumerable enumerableObject)
|
|
// {
|
|
// list = enumerableObject.Cast<string>().ToList();
|
|
// }
|
|
// return list;
|
|
//}
|
|
//public async Task<string> GetFilterColumnName(ColumnReferenceIdInputDto input)
|
|
//{
|
|
// return null;
|
|
//}
|
|
|
|
//public async Task<List<string>> GetInterfaceColumns(ColumnReferenceIdInputDto input)
|
|
//{
|
|
// var entity = await _repository.GetAsync(input.Id);
|
|
// var parmValue = entity.ParmValue;
|
|
// var configurationBuilder = new ConfigurationBuilder()
|
|
// .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue)));
|
|
// var config = configurationBuilder.Build();
|
|
// var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
|
|
// var className = config.GetSection("Interface").GetSection("ClassName").Value;
|
|
// object objectValue = Invoke(assemblyName, className, "GetInterfaceColumns");
|
|
// List<string> list = new List<string>();
|
|
|
|
// if (objectValue is IEnumerable enumerableObject)
|
|
// {
|
|
// list = enumerableObject.Cast<string>().ToList();
|
|
// }
|
|
// return list;
|
|
//}
|
|
|
|
//public async Task<List<ColumnReferenceCodeValue>> GetCodeValues(ColumnReferenceIdInputDto input)
|
|
//{
|
|
// return null;
|
|
//}
|
|
|
|
//public async Task<List<ColumnReferenceFilterCodeValue>> GetFilterCodeValues(ColumnReferenceIdInputDto input)
|
|
//{
|
|
// return null;
|
|
//}
|
|
|
|
//public async Task<List<ColumnReferenceCodeValue>> GetInterfaceCodeValues(ColumnReferenceIdInputDto input)
|
|
//{
|
|
// return null;
|
|
//}
|
|
|
|
//public async Task<List<ColumnReferenceCodeValue>> GetColumnReferenceInterfaceCodeValues(ColumnReferenceIdInputDto input)
|
|
//{
|
|
// return null;
|
|
//}
|
|
|
|
//public async Task CreateColumnReferenceValue(CreateColumnReferenceValue input)
|
|
//{
|
|
|
|
//}
|
|
|
|
//private object Invoke(string assemblyName, string className, string methodName, object[] args = null)
|
|
//{
|
|
// Assembly assembly = Assembly.Load(assemblyName);
|
|
// Type type = assembly.GetType(className);
|
|
// // 创建类的实例
|
|
// object instance = Activator.CreateInstance(type);
|
|
// // 获取方法信息
|
|
// MethodInfo method = type.GetMethod(methodName);
|
|
// // 调用方法,如果方法需要参数,可以传入对应的参数数组,例如: new object[] { arg1, arg2 }
|
|
// object returnValue = method.Invoke(instance, args);
|
|
// return returnValue;
|
|
//}
|
|
}
|
|
}
|