using APT.BaseData.Domain.Entities.FM;
using APT.BaseData.Domain.Entities.NW;
using APT.Infrastructure.Core;
using APT.Utility;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace APT.NW.WebApi.Controllers.Api
{
    [Route("api/NW/Enterprise")]
    public partial class EnterpriseInfoController : AuthorizeApiController<T_FM_ORGANIZATION>
    {

        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        [HttpPost, Route("ReSetPwd")]
        public JsonActionResult<bool> ReSetPwd([FromBody] KeywordFilter filter)
        {
            return SafeExecute<bool>(() =>
            {
                var user = this.GetEntities<T_FM_USER>(x => x.ORG_ID == new Guid(filter.Keyword) && x.CODE == "admin",new BaseFilter()).FirstOrDefault();
                user.PASSWORD = "E10ADC3949BA59ABBE56E057F20F883E";//默认密码123456
                this.UpdateEntity(user);              
                return true;
            });
        }
    }
}
