73 lines
2.3 KiB
C#
73 lines
2.3 KiB
C#
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;
|
|
}
|
|
}
|
|
} |