Infrastructure/OpenAuth.WebApi/Controllers/ServiceControllers/FireManagement/FmFireSiteController.cs

206 lines
6.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App.Response;
using OpenAuth.App.ServiceApp.FireManagement;
using OpenAuth.App.ServiceApp.FireManagement.Request;
using OpenAuth.App.ServiceApp.FmFireSiteManage;
using OpenAuth.App.ServiceApp.FmFireSiteManage.Response;
using OpenAuth.Repository.Domain.FireManagement;
namespace OpenAuth.WebApi.Controllers.ServiceControllers.FireManagement
{
/// <summary>
/// 防火站点管理模块
/// </summary>
[Route("api/[controller]/[action]")]
[ApiController]
public class FmFireSiteController : ControllerBase
{
private readonly FmFireSiteApp _app;
public FmFireSiteController(FmFireSiteApp app)
{
_app = app;
}
#region 站点管理
/// <summary>
/// 查询所有站点
/// </summary>
/// <param name="siteName">站点名称</param>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="state">状态0-未审核1-审核通过2-未通过)</param>
/// <returns></returns>
[HttpGet]
public async Task<Response<PageInfo<List<FmSiteInfo>>>> LoadAllSite(string siteName, int pageIndex, int pageSize, int state)
{
Response<PageInfo<List<FmSiteInfo>>> response = new Response<PageInfo<List<FmSiteInfo>>>();
try
{
return await _app.LoadAllSite(siteName,pageIndex,pageSize,state);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
/// <summary>
/// 导出所有站点
/// </summary>
/// <returns></returns>
[HttpGet]
public IActionResult ExportSite(int state)
{
var ms = _app.ExportSite(state);
ms.Position = 0;
return File(ms, "application/octet-stream",
$"站点{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
}
/// <summary>
/// 站点审核
/// </summary>
/// <param name="siteId">站点id</param>
/// <param name="state">要修改的状态</param>
/// <param name="content">审核说明</param>
/// <returns></returns>
[HttpPost]
public async Task<Response<bool>> AuditSite(long siteId, int state, string content)
{
Response<bool> response = new();
try
{
return await _app.AuditSite(siteId,state,content);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
/// <summary>
/// 获取站点管理人员及消息接收人员
/// </summary>
/// <param name="siteId">站点id</param>
/// <param name="roleid">角色id站点管理人员角色的id</param>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">页面大小</param>
/// <returns></returns>
[HttpGet]
public async Task<Response<PageInfo<List<SiteUserRes>>>> LoadSiteUser(long siteId, long roleid, int pageIndex, int pageSize)
{
Response<PageInfo<List<SiteUserRes>>> response = new Response<PageInfo<List<SiteUserRes>>>();
try
{
return await _app.LoadSiteUser(siteId, roleid,pageIndex, pageSize);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
/// <summary>
/// 获取所有站点管理人员
/// </summary>
/// <param name="roleid">角色id站点管理人员角色id</param>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">页面大小</param>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public TableData LoadSiteAllUser(long roleid, int pageIndex, int pageSize)
{
return _app.LoadSiteAllUser(roleid,pageIndex, pageSize);
}
/// <summary>
/// 根据管理员获取站点列表
/// </summary>
/// <param name="userId"></param>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public TableData LoadSiteByUserId(string userId, int pageIndex, int pageSize)
{
return _app.LoadSiteByUserId(userId, pageIndex, pageSize);
}
/// <summary>
/// 注册站点信息
/// </summary>
/// <param name="fmSite">站点数据</param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public async Task<Response<bool>> AddSiteInfo(FmSiteInfo fmSite)
{
Response<bool> response = new();
try
{
return await _app.AddSite(fmSite);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
/// <summary>
/// 站点编辑
/// </summary>
/// <param name="fmSite">站点编辑</param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public async Task<Response<bool>> EditSiteInfo(FmSiteInfo fmSite)
{
Response<bool> response = new();
try
{
return await _app.EditSite(fmSite);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
/// <summary>
/// 获取站点详情
/// </summary>
/// <param name="siteId">站点id</param>
/// <returns></returns>
[HttpGet]
public async Task<Response<FmSiteRes>> GetSiteInfo(long siteId)
{
Response<FmSiteRes> response = new Response<FmSiteRes>();
try
{
return await _app.GetSiteInfo(siteId);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
#endregion
}
}