CaptionVo.java 816 Bytes
package com.viontech.storage.vo;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.viontech.storage.entity.Context;
import com.viontech.storage.model.Caption;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * .
 *
 * @author 谢明辉
 * @date 2021/11/8
 */

@Getter
@Setter
public class CaptionVo extends Caption {

    private List<Context> contexts;

    public static CaptionVo copy(Caption caption) {
        if (caption == null) {
            return null;
        }
        CaptionVo captionVo = new CaptionVo();
        BeanUtil.copyProperties(caption, captionVo, true);
        if (captionVo.getContext() != null) {
            captionVo.setContexts(JSONUtil.toList(captionVo.getContext(), Context.class));
        }
        return captionVo;
    }
}