63 lines
1.6 KiB
C#
63 lines
1.6 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using MilliSim.Common.Dtos;
|
|
using MilliSim.Common.Models;
|
|
using MilliSim.Services;
|
|
|
|
namespace MilliSim.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/consultations")]
|
|
public class ConsultationsController : ControllerBase
|
|
{
|
|
private readonly IContentService _contentService;
|
|
|
|
public ConsultationsController(IContentService contentService)
|
|
{
|
|
_contentService = contentService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 咨询消息列表
|
|
/// </summary>
|
|
[HttpGet]
|
|
[Authorize(Policy = "Staff")]
|
|
public async Task<IActionResult> GetList([FromQuery] PageRequest request, [FromQuery] bool? isRead)
|
|
{
|
|
var result = await _contentService.GetConsultationsAsync(request, isRead);
|
|
return Ok(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 提交咨询(公开)
|
|
/// </summary>
|
|
[HttpPost]
|
|
public async Task<IActionResult> Create([FromBody] CreateConsultationRequest request)
|
|
{
|
|
var result = await _contentService.CreateConsultationAsync(request);
|
|
return Ok(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 标记已读
|
|
/// </summary>
|
|
[HttpPost("{id:long}/read")]
|
|
[Authorize(Policy = "Staff")]
|
|
public async Task<IActionResult> MarkAsRead(long id)
|
|
{
|
|
var result = await _contentService.MarkAsReadAsync(id);
|
|
return Ok(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除咨询消息
|
|
/// </summary>
|
|
[HttpPost("{id:long}/delete")]
|
|
[Authorize(Policy = "Staff")]
|
|
public async Task<IActionResult> Delete(long id)
|
|
{
|
|
var result = await _contentService.DeleteConsultationAsync(id);
|
|
return Ok(result);
|
|
}
|
|
}
|