using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using dodohold.core;
using Dataoke;


namespace molilian.core
{
    [Table("admin_logs")]
    public class OperationLog
    {
        [Key]
        public int Id { get; set; }
        public string Operator { get; set; } = string.Empty;
        public string OperatorIp { get; set; } = string.Empty;
        public string TargetObject { get; set; } = string.Empty;
        public string BeforeValue { get; set; } = string.Empty;
        public string ChangeValue { get; set; } = string.Empty;
        public DateTime OperationTime { get; set; } = DateTime.Now;
    }
    public partial class OperationLogCore
    {

        public static void LogOperation(string operatorName, string operatorIp, string targetObject,
            string beforeValue, string changeValue)
        {
            var log = new OperationLog
            {
                Operator = operatorName,
                OperatorIp = operatorIp,
                TargetObject = targetObject,
                BeforeValue = beforeValue,
                ChangeValue = changeValue,
                OperationTime = DateTime.Now
            };

            using var conn = DBContext.GetOpenConnection();
            conn.Insert(log);
        }

    }


}
