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

import com.xindazhou.business.controller.app.community.post.vo.PostCreateReqVO;
import com.xindazhou.business.controller.app.community.post.vo.PostRespVO;
import com.xindazhou.business.controller.app.community.post.vo.PostUpdateReqVO;
import com.xindazhou.business.dal.community.dataobject.post.PostDO;
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 PostConvert {

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

    PostDO convert(PostCreateReqVO bean);

    PostDO convert(PostUpdateReqVO bean);

    @Mapping(target = "userNickname", ignore = true)
    @Mapping(target = "userAvatar", ignore = true)
    @Mapping(target = "isLiked", ignore = true)
    @Mapping(target = "isCollected", ignore = true)
    PostRespVO convert(PostDO bean);

    PageResult<PostRespVO> convertPage(PageResult<PostDO> page);

    List<PostRespVO> convertList(List<PostDO> list);

}

