using DataSharing.LuZhou.LZ110;
using DataSharing.Share.Dtos.LuZhou;
using NETCore.Encrypt;

namespace DataSharing.LuZhou.Encrypt
{
    public static class EncryptHandler
    {
        public static TModel AES<TModel>(TModel model) where TModel : ICanEncrypt
        {
            var infos = typeof(TModel).GetProperties();
            foreach (var info in infos)
            {
                var value = info.GetValue(model)?.ToString() ?? string.Empty;
                if (!string.IsNullOrEmpty(value))
                {
                    info.SetValue(model, EncryptProvider.AESEncrypt(value, LZ110Defaults.EncryptKey));
                }
            }
            return model;
        }
    }

}
