package cn.ibizlab.core.extensions.aspect;

import cn.ibizlab.core.extensions.service.OUModelService;
import cn.ibizlab.util.annotation.DEField;
import cn.ibizlab.util.enums.DEFieldDefaultValueType;
import cn.ibizlab.util.enums.DEPredefinedFieldType;
import cn.ibizlab.util.helper.DEFieldCacheMap;
import cn.ibizlab.util.security.AuthenticationUser;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.AlternativeJdkIdGenerator;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 实体属性默认值切面，只有新建（Create）时才会填充默认值
 */
@Aspect
@Order(0)
@Component
public class OUModelRefreshAspect
{
    @Autowired
    @Lazy
    private OUModelService ouModelService;

    @After(value = "execution(* cn.ibizlab.core.ou.service.IIBZOrganizationService.creat*(..))")
    public void AfterCreateOrg(JoinPoint point) throws Exception {
        ouModelService.refreshModel();
    }
    @After(value = "execution(* cn.ibizlab.core.ou.service.IIBZOrganizationService.updat*(..))")
    public void AfterUpdateOrg(JoinPoint point) throws Exception {
        ouModelService.refreshModel();
    }
    @After(value = "execution(* cn.ibizlab.core.ou.service.IIBZOrganizationService.remov*(..))")
    public void AfterRemoveOrg(JoinPoint point) throws Exception {
        ouModelService.refreshModel();
    }
    @After(value = "execution(* cn.ibizlab.core.ou.service.IIBZOrganizationService.sav*(..))")
    public void AfterSaveOrg(JoinPoint point) throws Exception {
        ouModelService.refreshModel();
    }

    @After(value = "execution(* cn.ibizlab.core.ou.service.IIBZDepartmentService.creat*(..))")
    public void AfterCreateDept(JoinPoint point) throws Exception {
        ouModelService.refreshModel();
    }
    @After(value = "execution(* cn.ibizlab.core.ou.service.IIBZDepartmentService.updat*(..))")
    public void AfterUpdateDept(JoinPoint point) throws Exception {
        ouModelService.refreshModel();
    }
    @After(value = "execution(* cn.ibizlab.core.ou.service.IIBZDepartmentService.remov*(..))")
    public void AfterRemoveDept(JoinPoint point) throws Exception {
        ouModelService.refreshModel();
    }
    @After(value = "execution(* cn.ibizlab.core.ou.service.IIBZDepartmentService.sav*(..))")
    public void AfterSaveDept(JoinPoint point) throws Exception {
        ouModelService.refreshModel();
    }

}
