package com.fzm.mall.server.front.goods.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fzm.mall.server.front.goods.model.CommentAppend;
import com.fzm.mall.server.front.goods.mapper.CommentAppendMapper;
import com.fzm.mall.server.front.goods.model.vo.CommentAppendVo;
import com.fzm.mall.server.front.goods.service.ICommentAppendService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fzm
 * @since 2021-04-28
 */
@Service
public class CommentAppendServiceImpl extends ServiceImpl<CommentAppendMapper, CommentAppend> implements ICommentAppendService {

    @Override
    public void addCommentAppend(CommentAppendVo commentAppendVo) {
        CommentAppend commentAppend = new CommentAppend();
        BeanUtils.copyProperties(commentAppendVo,commentAppend);
        commentAppend.setImagesJson(commentAppendVo.getImagesJson().toJSONString());
        save(commentAppend);
    }

    @Override
    public CommentAppend getByCommentId(String commentId) {
        QueryWrapper<CommentAppend> q = new QueryWrapper<>();
        q.eq("comment_id",commentId);
        return getOne(q);
    }
}
