diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs new file mode 100644 index 00000000..b2919f9b --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs @@ -0,0 +1,57 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 设备附件表 +/// +[SugarTable("eqp_equip_file")] +public partial class EqpEquipFile : BaseEntity +{ + public EqpEquipFile() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 设备id + /// + public string equip_id { get; set; } = string.Empty; + + /// + /// 附件 + /// + public string attachment { get; set; } = string.Empty; + + /// + /// 文件名 + /// + public string file_name { get; set; } = string.Empty; + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 所属组织 + /// + public string? org_id { get; set; } + +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs index 61c0ae8c..076469c0 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs @@ -109,9 +109,4 @@ public partial class EqpSpotInsRecordD : BaseEntity /// public string? is_pass { get; set; } - /// - /// 所属组织 - /// - public string? org_id { get; set; } - } diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs new file mode 100644 index 00000000..258e6439 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs @@ -0,0 +1,15 @@ +using Microsoft.AspNetCore.Http; +using Tnb.EquipMgr.Entities.Dto; + +namespace Tnb.EquipMgr.Interfaces +{ + public interface IEqpEquipFileService + { + /// + /// 上传附件 + /// + /// + /// + public Task Upload(string equip_id,IFormFile file); + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs b/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs new file mode 100644 index 00000000..b664448f --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs @@ -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 +{ + /// + /// 设备保养计划执行管理 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class EqpEquipFileService : IEqpEquipFileService, IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + private readonly FileService _fileService; + + public EqpEquipFileService(ISqlSugarRepository repository, + FileService fileService, + IUserManager userManager) + { + _repository = repository; + _userManager = userManager; + _fileService = fileService; + } + + [HttpPost] + public async Task 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; + } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj b/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj index 520c0756..872b640f 100644 --- a/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj +++ b/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj @@ -10,6 +10,7 @@ +