using System.Collections.Generic;
using System.Threading.Tasks;
using GxPress.Auth;
using GxPress.Request.App.AdminVerify;
using GxPress.Result.App.AdminVerify;
using GxPress.Service.Interface.AdminVerify;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace GxPress.Api.AppControllers
{
    /// <summary>
    /// 验证信息
    /// </summary>
    [Route("api/app/admin-verify")]
    [ApiController]
    [Authorize]
    public class AdminVerifyController : ControllerBase
    {
        private readonly IAdminVerifyService _adminVerifyService;
        private readonly ILoginContext _loginContext;
        public AdminVerifyController(IAdminVerifyService adminVerifyService,ILoginContext loginContext)
        {
            _adminVerifyService = adminVerifyService;
            _loginContext = loginContext;
        }

        /// <summary>
        /// 清空
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete")]
        public async Task<bool> DeleteAllAsync()
        {
            return await _adminVerifyService.DeleteAllAsync(_loginContext.AccountId);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut("update")]
        public async Task<bool> UpdateAsync(AdminVerifyUpdateRequest request)
        {
            return await _adminVerifyService.UpdateAsync(request.Id, request.AdminVerifyTypeConst);
        }

        /// <summary>
        /// 根据用户查询
        /// </summary>
        /// <returns></returns>
        [HttpPost("search")]
        public async Task<IEnumerable<AdminVerifySearchResult>> GetAllAsync()
        {
            return await _adminVerifyService.GetAllAsync(_loginContext.AccountId);
        }

        /// <summary>
        /// 查询未处理条数
        /// </summary>
        /// <returns></returns>
        [HttpPost("count")]
        public async Task<int> GetUDisposeCount()
        {
            return await _adminVerifyService.GetUDisposeCount(_loginContext.AccountId);
        }
    }
}