package com.apobates.forum.attention.core.decorater.posts;

import com.apobates.forum.attention.core.decorater.MultiUploadImagePathCovert;

/**
 * 解码回复内容中的上传图片
 *
 * @author xiaofanku
 * @since 20200516
 */
public final class PostsUploadImageDecodeContentDecorator extends PostsContentDecorator {
    //图片的访问域名
    //http://center.test.com
    private final String imageDomain;
    //imagestore
    private final String uploadDirectName;
    
    /**
     *
     * @param display 装饰器的基础接口
     * @param lazyLoad 内容中的图片是否懒加载; true进行懒加载,false直接加载
     * @param scale 缩放的比例
     * @param imageDomain 图片存储的域名
     * @param uploadDirectName 图片保存的目录名称
     */
    public PostsUploadImageDecodeContentDecorator(Display display, boolean lazyLoad, String scale, String imageDomain, String uploadDirectName) {
        super(display, lazyLoad, scale);
        this.imageDomain = imageDomain;
        this.uploadDirectName = uploadDirectName;
    }
    
    @Override
    public String getDecoratorContent() {
        String rawContent = super.getDisplay().getContent();
        MultiUploadImagePathCovert ipc = new MultiUploadImagePathCovert(imageDomain, uploadDirectName);
        return ipc.decode(rawContent, isLazyLoad(), getScale());
    }
}