using Hotline.Application.Snapshot.Contracts;
using Hotline.Share.Dtos;
using Hotline.Share.Dtos.Snapshot;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel;
using Hotline.Repository.SqlSugar.Extensions;
using Hotline.Share.Tools;

namespace Hotline.Api.Controllers.Snapshot;


/// <summary>
/// 积分管理
/// </summary>
[Description("积分管理")]
public class PointsController : BaseController
{
    private readonly ISnapshotPointsApplication _pointsRecordApplication;

    public PointsController(ISnapshotPointsApplication pointsRecordApplication)
    {
        _pointsRecordApplication = pointsRecordApplication;
    }

    /// <summary>
    /// 积分集合
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    public async Task<PagedDto<PointsItemsOutDto>> GetPointsItemsAsync([FromQuery]PointsItemsInDto dto)
        => (await _pointsRecordApplication.GetPointsItems(dto).ToPagedListAsync(dto)).ToPaged();

    /// <summary>
    /// 设置用户是安全卫士
    /// </summary>
    /// <returns></returns>
    [HttpPut("securitymax")]
    public async Task UpdateIsSecurityMaxAsync([FromBody] UpdateIsSecurityMaxAsync dto)
        => await _pointsRecordApplication.UpdateIsSecurityMaxAsync(dto, HttpContext.RequestAborted);
}
