设备附件
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user