using BBM.ChatGLM.Dtos;
using BBM.ChatGLM.User;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using OfficeOpenXml;
using System;
using System.IO;
using System.Text.RegularExpressions;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Identity;


namespace BBM.ChatGLM.Controllers
{
    [Route("User")]
    public class UserController : ChatGLMController, IUsersAppService
    {
        private readonly IUsersAppService _usersAppService;
        private readonly IConfiguration _configuration;
        public UserController(IUsersAppService usersAppService, IConfiguration configuration)
        {
            _usersAppService = usersAppService;
            _configuration = configuration;
        }

        [HttpPost("create")]
        public async Task<IdentityUserDto> CreateAsync([FromBody] UserCreateInput input)
        {
            return await _usersAppService.CreateAsync(input);
        }

        [HttpPost("delete")]
        public async Task<bool> DeleteAsync([FromBody] GuidIdInput input)
        {
            return await _usersAppService.DeleteAsync(input);
        }

        [HttpPost("update")]
        public async Task<IdentityUserDto> UpdateAsync([FromBody] UserUpdateInput input)
        {
            return await _usersAppService.UpdateAsync(input);
        }

        [HttpPost("reset")]
        public async Task<bool> ResetPasswordAsync([FromBody] UserResetPasswordInput input)
        {
            return await _usersAppService.ResetPasswordAsync(input);
        }

        [HttpPost("page")]
        public async Task<PagedResultDto<UserDto>> PageAsync([FromBody] UserPageInput input)
        {
            return await _usersAppService.PageAsync(input);
        }

        [HttpPost("roles")]
        public async Task<List<string>> GetRolesAsync()
        {
            return await _usersAppService.GetRolesAsync();
        }

        [HttpPost("token")]
        public async Task<string> GetTokenAsync()
        {
            return await _usersAppService.GetTokenAsync();
        }

        [HttpPost("excelFile")]
        public async Task<ImportUsersResult> CreateUsersByExcel([FromForm] IFormFile file)
        {
            return await _usersAppService.CreateUsersByExcel(file);
        }

    }
}
