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

import com.brframework.commoncms.annatotion.column.ImageColumn;
import com.brframework.commoncms.core.layout.AbstractPanelLayoutColumn;
import lombok.Data;
import org.springframework.core.annotation.AnnotationUtils;

import java.lang.reflect.Field;
import java.util.List;

/**
 * 图片
 * @author xu
 * @date 2018/9/26 14:08
 * @see ImageColumn
 */
@Data
public class LayoutImageColumn extends AbstractPanelLayoutColumn {

    private static final String TYPE_DEF = "IMAGE";
    private String key;
    private String title;
    /** 图片上传数量限制 */
    private int number;

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public String getTitle() {
        return title;
    }

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

    @Override
    public void create(Field columnField) throws Throwable {
        init(columnField);

        ImageColumn imageColumn = AnnotationUtils.findAnnotation(columnField, ImageColumn.class);
        assert imageColumn != null;
        number = imageColumn.number();
    }

    @Override
    public List<Class<?>> supportType() {
        return null;
    }
}
