using System.Threading.Tasks;
using GxPress.Auth;
using GxPress.Common.Page;
using GxPress.Entity;
using GxPress.Repository.Interface;
using GxPress.Request.Notice;
using GxPress.Result.Notice;
using GxPress.Service.Interface.Notice;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace GxPress.Api.AdminControllers
{
///
/// 通知
///
[Route("api/admin/notice")]
[ApiController]
[Authorize]
public class AdminNoticeController : ControllerBase
{
private readonly INoticeRepository _noticeRepository;
private readonly INoticeService _noticeServivce;
public AdminNoticeController(INoticeRepository noticeRepository,ILoginContext loginContext,INoticeService noticeService)
{
_noticeRepository = noticeRepository;
_noticeServivce=noticeService;
}
///
/// 查询
///
///
///
[HttpPost("list")]
public async Task> GetNoticeByUserId(NoticePageSearchRequest request)
{
return await _noticeRepository.GetAdminNoticeByUserIdAsync(request);
}
///
/// 管理员删除通知
///
///
///
[HttpDelete("{id}")]
public async Task AdminDelete(int id)
{
return await _noticeRepository.AdminDeleteAsync(id);
}
///
/// 获取通知详情
///
///
///
[HttpGet("detail/{id}")]
public async Task GetNoticeDetailResult(int id)
{
return await _noticeServivce.GetNoticeDetailResultAsync(id,0);
}
///
/// 修改通知
///
///
///
///
[HttpPut("{id}")]
public async Task UpdateNoticeAsync(int id,[FromBody] Notice request)
{
return await _noticeRepository.UpdateNoticeAsync(request);
}
}
}