package io.modules.item.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import cn.hutool.core.util.StrUtil;
import io.common.service.impl.CrudServiceImpl;
import io.modules.item.dao.CommentDao;
import io.modules.item.dto.CommentDTO;
import io.modules.item.entity.CommentEntity;
import io.modules.item.service.CommentService;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 评论表

 */
@Service
public class CommentServiceImpl extends CrudServiceImpl<CommentDao, CommentEntity, CommentDTO> implements CommentService {

    @Override
    public QueryWrapper<CommentEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        String itemId = (String)params.get("itemId");

        QueryWrapper<CommentEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
        wrapper.eq(StrUtil.isNotBlank(itemId), "item_id", itemId);
        wrapper.orderByDesc("create_time");
        return wrapper;
    }


}
