Compare commits
No commits in common. "515a41fa583a038550ffc37d3622f1ae7241ba21" and "2541d2036ea39b150ce8b73fb462cf9322fd18af" have entirely different histories.
515a41fa58
...
2541d2036e
@ -1,40 +0,0 @@
|
|||||||
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
|
||||||
//
|
|
||||||
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
|
||||||
//
|
|
||||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Vistar.Application.SolidWorksManageService.Dto;
|
|
||||||
public class AddRelatedFilesInput
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 对象id
|
|
||||||
/// </summary>
|
|
||||||
public long object_id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 记录 ID
|
|
||||||
/// </summary>
|
|
||||||
public long record_id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 文件结构 ID
|
|
||||||
/// </summary>
|
|
||||||
public long file_structure_id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 文件名
|
|
||||||
/// </summary>
|
|
||||||
public string file_name { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 文件
|
|
||||||
/// </summary>
|
|
||||||
public byte[] file { get; set; }
|
|
||||||
}
|
|
@ -3,12 +3,10 @@ using Admin.NET.Core.Service;
|
|||||||
using Furion.DependencyInjection;
|
using Furion.DependencyInjection;
|
||||||
using Furion.DynamicApiController;
|
using Furion.DynamicApiController;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
@ -33,8 +31,6 @@ public class SolidWorksManageService : IDynamicApiController, ITransient
|
|||||||
/// 获取 token
|
/// 获取 token
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>授权响应对象</returns>
|
/// <returns>授权响应对象</returns>
|
||||||
[ApiDescriptionSettings(Name = "Authenticate", Description = "获取 token", Order = 1000), HttpGet]
|
|
||||||
[DisplayName("获取 token")]
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<AuthorizationResponse> Authenticate()
|
public async Task<AuthorizationResponse> Authenticate()
|
||||||
{
|
{
|
||||||
@ -312,12 +308,12 @@ public class SolidWorksManageService : IDynamicApiController, ITransient
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 导出相关文件(全部)
|
/// 导出相关文件(全部)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ManageResponse> ExportRelatedFiles(CheckDataInput input)
|
public async Task<ManageResponse> ExportRelatedFiles(CheckDataInput input)
|
||||||
{
|
{
|
||||||
// 获取 SolidWorksManage 地址
|
// 获取 SolidWorksManage 地址
|
||||||
string apiUrl = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageApiUrl);
|
string apiUrl = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageApiUrl);
|
||||||
@ -357,50 +353,5 @@ public class SolidWorksManageService : IDynamicApiController, ITransient
|
|||||||
return errorResponse;
|
return errorResponse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 添加相关文件
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<ManageResponse> AddRelatedFiles(AddRelatedFilesInput input)
|
|
||||||
{
|
|
||||||
// 获取 SolidWorksManage 地址
|
|
||||||
string apiUrl = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageApiUrl);
|
|
||||||
// 拼接接口地址
|
|
||||||
string url = $"{apiUrl}/api/File/AddRelatedFileToFolder";
|
|
||||||
//获取token
|
|
||||||
var token = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageAuthorization);
|
|
||||||
// 将参数对象序列化为 JSON 字符串
|
|
||||||
string jsonParameters = JsonConvert.SerializeObject(input);
|
|
||||||
// 设置请求内容
|
|
||||||
var content = new StringContent(jsonParameters, Encoding.UTF8, "application/json");
|
|
||||||
client.DefaultRequestHeaders.Remove("Authorization");
|
|
||||||
// 添加 Authorization 到请求头
|
|
||||||
client.DefaultRequestHeaders.Add("Authorization", token);
|
|
||||||
// 发送 POST 请求
|
|
||||||
HttpResponseMessage response = await client.PostAsync(url, content);
|
|
||||||
// 处理响应
|
|
||||||
if (response.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
string responseBody = await response.Content.ReadAsStringAsync();
|
|
||||||
// 解析 JSON 数据
|
|
||||||
var result = JsonConvert.DeserializeObject<ManageResponse>(responseBody);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string responseBody = await response.Content.ReadAsStringAsync();
|
|
||||||
|
|
||||||
var errorResponse = new ManageResponse()
|
|
||||||
{
|
|
||||||
Success = false,
|
|
||||||
Message = responseBody,
|
|
||||||
Data = "",
|
|
||||||
CustomAction = "",
|
|
||||||
CustomAttributes = ""
|
|
||||||
};
|
|
||||||
return errorResponse;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user