using Furion.DynamicApiController;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Nirvana.Common;
using Nirvana.Common.ApiBase;
using System.Threading.Tasks;
using YBDevice.Entity;

namespace YBDevice.Application.BusinessInfo
{
    /// <summary>
    /// 客户管理
    /// </summary>
    [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
    public class BusinessAppService : IDynamicApiController
    {
        private readonly IBusinessService _Service;
        public BusinessAppService(IBusinessService Service)
        {
            _Service = Service;
        }

        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<ResultInfo> ChangePasswordAsync(BusienssPwd model)
        {
            return await _Service.ChangePasswordAsync(model);
        }
        /// <summary>
        /// 客户列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> GetListAsync(QueryParams param)
        {
            var result= await _Service.GetListAsync(param);
            return new ResultInfo(ResultState.SUCCESS, "success", result);
        }

        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="id"></param>
        /// <param name="pwd">密码</param>
        /// <returns></returns>
        [HttpGet]
        [QueryParameters]
        public async Task<ResultInfo> ResetPasswordAsync(int id, string pwd)
        {
            return await _Service.ResetPasswordAsync(id,pwd);
        }

        /// <summary>
        /// 状态变更
        /// </summary>
        /// <param name="id"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        [HttpGet]
        [QueryParameters]
        public async Task<ResultInfo> SetStatusAsync(int id, StatusType status)
        {
            return await _Service.SetStatusAsync(id, status);
        }

        /// <summary>
        /// 信息提交
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<ResultInfo> SubmitAsync(BusinessSubmitModel model)
        {
            return await _Service.SubmitAsync(model);
        }
    }
}
