ThemeConvert.java 2.1 KB
package com.tanpu.community.controller.convert;

import com.tanpu.community.api.beans.ThemeDTO;
import com.tanpu.community.dao.entity.community.ThemeEntity;

import java.util.List;
import java.util.stream.Collectors;

public class ThemeConvert {
    public static ThemeDTO convertToDTO(ThemeEntity themeEntity){
        ThemeDTO themeDTO = new ThemeDTO();
        themeDTO.setId(themeEntity.getId());
        themeDTO.setContent(themeEntity.getContent());
        themeDTO.setThemeType(themeEntity.getThemeType());
        themeDTO.setAttachment(themeEntity.getAttachment());
        themeDTO.setAttachType(themeEntity.getAttachType());
        themeDTO.setFormerThemeId(themeEntity.getFormerThemeId());
        themeDTO.setAuthorId(themeEntity.getAuthorId());
        themeDTO.setCreateBy(themeEntity.getCreateBy());
        themeDTO.setUpdateBy(themeEntity.getUpdateBy());
        themeDTO.setCreateTime(themeEntity.getCreateTime());
        themeDTO.setUpdateBy(themeEntity.getUpdateBy());
        return themeDTO;
    }


    public static ThemeEntity convertToEntity(ThemeDTO themeDTO){
        ThemeEntity themeEntity = new ThemeEntity();
        themeEntity.setContent(themeDTO.getContent());
        themeEntity.setThemeType(themeDTO.getThemeType());
        themeEntity.setAttachment(themeDTO.getAttachment());
        themeEntity.setAttachType(themeDTO.getAttachType());
        themeEntity.setFormerThemeId(themeDTO.getFormerThemeId());
        themeEntity.setAuthorId(themeDTO.getAuthorId());
        themeEntity.setCreateBy(themeDTO.getCreateBy());
        themeEntity.setUpdateBy(themeDTO.getUpdateBy());
        themeEntity.setCreateTime(themeDTO.getCreateTime());
        themeEntity.setUpdateBy(themeDTO.getUpdateBy());
        return themeEntity;
    }

    public static List<ThemeDTO> convertToEntitys(List<ThemeEntity> topicEntities){
        return topicEntities.stream().map(ThemeConvert::convertToDTO).collect(Collectors.toList());
    }

    public static List<ThemeDTO> convertToDTOs(List<ThemeEntity> topicEntities){
        return topicEntities.stream().map(ThemeConvert::convertToDTO).collect(Collectors.toList());
    }
}