Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
57
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs
Normal file
57
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 设备附件表
|
||||
/// </summary>
|
||||
[SugarTable("eqp_equip_file")]
|
||||
public partial class EqpEquipFile : BaseEntity<string>
|
||||
{
|
||||
public EqpEquipFile()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 设备id
|
||||
/// </summary>
|
||||
public string equip_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 附件
|
||||
/// </summary>
|
||||
public string attachment { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 文件名
|
||||
/// </summary>
|
||||
public string file_name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
}
|
||||
@@ -109,9 +109,4 @@ public partial class EqpSpotInsRecordD : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? is_pass { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
}
|
||||
|
||||
15
EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs
Normal file
15
EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
public interface IEqpEquipFileService
|
||||
{
|
||||
/// <summary>
|
||||
/// 上传附件
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> Upload(string equip_id,IFormFile file);
|
||||
}
|
||||
}
|
||||
73
EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs
Normal file
73
EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Common;
|
||||
using JNPF.Systems.Interfaces.Common;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保养计划执行管理
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class EqpEquipFileService : IEqpEquipFileService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<EqpEquipFile> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly FileService _fileService;
|
||||
|
||||
public EqpEquipFileService(ISqlSugarRepository<EqpEquipFile> repository,
|
||||
FileService fileService,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
_fileService = fileService;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Upload([FromForm]string equip_id,[FromForm]IFormFile file)
|
||||
{
|
||||
string msg = "";
|
||||
try
|
||||
{
|
||||
var attachment = await _fileService.Uploader("annexpic", file);
|
||||
|
||||
EqpEquipFile eqpEquipFile = new EqpEquipFile()
|
||||
{
|
||||
file_name = file.FileName,
|
||||
equip_id = equip_id,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
attachment = JsonConvert.SerializeObject(attachment)
|
||||
};
|
||||
|
||||
await _repository.InsertAsync(eqpEquipFile);
|
||||
msg = "上传成功";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
msg = "上传失败";
|
||||
Log.Error(e.Message);
|
||||
throw Oops.Oh(ErrorCode.D8001);
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\BasicData\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" />
|
||||
<ProjectReference Include="..\..\system\Tnb.Systems\Tnb.Systems.csproj" />
|
||||
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
|
||||
<ProjectReference Include="..\Tnb.EquipMgr.Interfaces\Tnb.EquipMgr.Interfaces.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user