package com.younike.system.service.impl;

import com.younike.system.domain.vo.GoodsCommentsVO;
import com.younike.system.mapper.MerchantGoodsCommentMapper;
import com.younike.system.param.GoodsCommentQueryParam;
import com.younike.system.service.IMerchantGoodsCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;


/**
 * 商品评价Service业务层处理
 *
 * @author jubs
 * @date 2022-01-11
 */
@Service
public class MerchantGoodsCommentServiceImpl implements IMerchantGoodsCommentService {
    @Autowired
    private MerchantGoodsCommentMapper goodsCommentMapper;

    /**
     * 查询商品评价
     *
     * @param commontId 商品评价主键
     * @return 商品评价
     */
    @Override
    public GoodsCommentsVO selectGoodsCommentByCommontId(Long commontId) {
        return goodsCommentMapper.selectGoodsCommentByCommontId(commontId);
    }

    /**
     * 查询商品评价列表
     *
     * @param goodsCommentsVO 商品评价
     * @return 商品评价
     */
    @Override
    public List<GoodsCommentsVO> selectGoodsCommentList(GoodsCommentsVO goodsCommentsVO) {
        return goodsCommentMapper.selectGoodsCommentList(goodsCommentsVO);
    }

    /**
     * 新增商品评价
     *
     * @param goodsComment 商品评价
     * @return 结果
     */
    @Override
    public int insertGoodsComment(GoodsCommentsVO goodsComment) {
        goodsComment.setCreateTime(LocalDateTime.now());
        return goodsCommentMapper.insertGoodsComment(goodsComment);
    }

    /**
     * 修改商品评价
     *
     * @param goodsComment 商品评价
     * @return 结果
     */
    @Override
    public int updateGoodsComment(GoodsCommentsVO goodsComment) {
        goodsComment.setUpdateTime(LocalDateTime.now());
        return goodsCommentMapper.updateGoodsComment(goodsComment);
    }

    /**
     * 批量删除商品评价
     *
     * @param commontIds 需要删除的商品评价主键
     * @return 结果
     */
    @Override
    public int deleteGoodsCommentByCommontIds(Long[] commontIds) {
        return goodsCommentMapper.deleteGoodsCommentByCommontIds(commontIds);
    }

    /**
     * 删除商品评价信息
     *
     * @param commontId 商品评价主键
     * @return 结果
     */
    @Override
    public int deleteGoodsCommentByCommontId(Long commontId)
    {
        return goodsCommentMapper.deleteGoodsCommentByCommontId(commontId);
    }

    /**
     * 根据订单类型查询订单商品评价列表
     *
     * @param commentQueryParam
     * @return
     */
    @Override
    public List<GoodsCommentsVO> listGoodsCommentByOrderType(GoodsCommentQueryParam commentQueryParam) {

        List<GoodsCommentsVO> goodsCommentsVOS = goodsCommentMapper.listGoodsCommentByOrderType(commentQueryParam);

        return goodsCommentsVOS;
    }
}
