package com.xindazhou.business.convert.community.comment;

import com.xindazhou.business.controller.app.community.comment.vo.CommentCreateReqVO;
import com.xindazhou.business.controller.app.community.comment.vo.CommentRespVO;
import com.xindazhou.business.dal.community.dataobject.comment.CommentDO;
import com.xindazhou.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 评论 Convert
 *
 * @author xindazhou
 */
@Mapper
public interface CommentConvert {

    CommentConvert INSTANCE = Mappers.getMapper(CommentConvert.class);

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "userId", ignore = true)
    @Mapping(target = "likeCount", ignore = true)
    @Mapping(target = "status", ignore = true)
    CommentDO convert(CommentCreateReqVO bean);

    @Mapping(target = "userNickname", ignore = true)
    @Mapping(target = "userAvatar", ignore = true)
    @Mapping(target = "parentUserNickname", ignore = true)
    @Mapping(target = "isLiked", ignore = true)
    @Mapping(target = "replies", ignore = true)
    CommentRespVO convert(CommentDO bean);

    PageResult<CommentRespVO> convertPage(PageResult<CommentDO> page);

    List<CommentRespVO> convertList(List<CommentDO> list);

}

