package io.renren.modules.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.business.dao.BusinessCommentsDao;
import io.renren.modules.business.entity.BusinessCommentsEntity;
import io.renren.modules.business.service.BusinessCommentsService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("businessCommentsService")
public class BusinessCommentsServiceImpl extends ServiceImpl<BusinessCommentsDao, BusinessCommentsEntity> implements BusinessCommentsService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper qw = new QueryWrapper<BusinessCommentsEntity>();
        qw.eq("comments_total_id",params.get("commentsTotalId"));
        qw.orderByAsc("id");
        IPage<BusinessCommentsEntity> page = this.page(
                new Query<BusinessCommentsEntity>().getPage(params),
                qw
        );

        return new PageUtils(page);
    }

    /**
     * 根据立项id获取所有的评论信息
     * @param projectId
     * @return
     */
    @Override
    public List<BusinessCommentsEntity> getListByProjectId(String projectId) {
        return baseMapper.getListByProjectId(projectId);
    }

}