package com.brframework.commoncms.core.layout.layout;

import com.brframework.commoncms.annatotion.layout.EditAlertLayout;
import lombok.Data;
import org.springframework.core.annotation.AnnotatedElementUtils;

import java.lang.reflect.Method;

/**
 * 弹框编辑框
 * @see com.brframework.commoncms.annatotion.layout.EditAlertLayout
 * @author xu
 * @date 2018/9/26 13:50
 */
@Data
public class PanelEditAlertLayout extends PanelEditLayout {

    /**
     * 弹框数据编辑
     */
    public static final String TYPE = "EDIT_ALERT";

    @Override
    public String getType() {
        return TYPE;
    }

    @Override
    protected String getPaddingUrl(Method method) {
        EditAlertLayout editAlertLayout = AnnotatedElementUtils.findMergedAnnotation(method, EditAlertLayout.class);

        return editAlertLayout.paddingUrl();
    }

    /**
     * 数据填充映射方法
     * @param method
     * @return
     */
    protected String getPaddingMappingMethod(Method method){
        EditAlertLayout editLayout = AnnotatedElementUtils.findMergedAnnotation(method, EditAlertLayout.class);
        return editLayout.paddingMappingMethod();
    }
}
