EquipmentDocController.cs
2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using HHECS.Application.Service;
using HHECS.Infrastructure.Json;
using HHECS.Model.Entities;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.IdentityModel.Tokens.Jwt;
using System.IO;
namespace HHECS.Web.Areas.EquipmentInfo.Controllers
{
[Area("EquipmentInfo")]
public class EquipmentDocController : BaseController
{
private readonly EquipmentDocService _docService;
public EquipmentDocController(EquipmentDocService docService)
{
_docService = docService;
}
[ServiceFilter(typeof(OperLogFilter))]
public IActionResult Index()
{
return View();
}
[HttpPost]
public string Load(PageReq pageRequest, EquipmentDoc entity)
{
return _docService.GetEquipmentDoc(entity, pageRequest.page, pageRequest.limit);
}
/// <summary>
/// 修改数据
/// </summary>
/// <param name="entity">修改实例</param>
/// <returns></returns>
[HttpPost]
[XSSFilter]
[ServiceFilter(typeof(OperLogFilter))]
public string Upd(EquipmentDoc entity)
{
return _docService.Update(entity, User);
}
[HttpPost]
[XSSFilter]
[ServiceFilter(typeof(OperLogFilter))]
public string DelByIds(int[] ids)
{
return _docService.DeleteByIds(ids);
}
/// <summary>
/// 导入数据
/// </summary>
/// <returns></returns>
[HttpPost]
public string Import(EquipmentDoc equipmentDoc)
{
return _docService.AddOrUpdate(equipmentDoc, User);
}
[HttpGet, HttpPost]
public IActionResult Download(string fileName)
{
try
{
var fileStream = _docService.GetFileStreamByName(fileName,out string docName );
return File(fileStream, "application/octet-stream", $"{docName}");
}
catch (Exception ex)
{
return NotFound(ex.Message);
}
}
[HttpGet]
[ResponseCache(Duration =20)]
public string GetTreeList()
{
var data = _docService.GetTreeList();
return JsonHelper.Instance.Serialize(data);
}
}
}